acpica_ec.c revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Solaris x86 ACPI CA Embedded Controller operation region handler
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Internal prototypes
*/
static int ec_wait_ibf_clear(int sc_addr);
static int ec_wait_obf_set(int sc_addr);
/*
* EC status bits
*/
#define EC_IBF (0x02)
#define EC_OBF (0x01)
#define EC_SMI (0x40)
#define EC_SCI (0x20)
/*
* EC commands
*/
#define EC_RD (0x80)
#define EC_WR (0x81)
#define EC_BE (0x82)
#define EC_BD (0x83)
#define EC_QR (0x84)
#define IO_PORT_DES (0x47)
/*
* EC softstate
*/
struct ec_softstate {
} ec;
/* I/O port range descriptor */
typedef struct io_port_des {
/*
* ACPI CA address space handler interface functions
*/
/*ARGSUSED*/
static ACPI_STATUS
{
return (AE_OK);
}
static int
{
#ifdef DEBUG
}
}
#endif
"for IBF to clear");
return (-1);
}
"for IBF to clear");
return (-1);
}
"for OBF to set");
return (-1);
}
return (rv);
}
static int
{
int cnt;
#ifdef DEBUG
}
}
#endif
"for IBF to clear");
return (-1);
}
"for IBF to clear");
return (-1);
}
"for IBF to clear");
return (-1);
}
return (0);
}
static int
ec_query(void)
{
"for IBF to clear");
return (-1);
}
"for OBF to set");
return (-1);
}
return (rv);
}
static ACPI_STATUS
{
int tmp;
/*
* Add safety checks for BIOSes not strictly compliant
* with ACPI spec
*/
if ((width % 8) != 0) {
width);
return (AE_ERROR);
}
if (width > 8) {
return (AE_ERROR);
}
switch (func) {
case ACPI_READ:
if (tmp < 0)
return (AE_ERROR);
break;
case ACPI_WRITE:
return (AE_ERROR);
break;
default:
return (AE_ERROR);
}
return (AE_OK);
}
static void
ec_gpe_callback(void *ctx)
{
char query_str[5];
int query;
return;
if (query >= 0) {
}
}
static UINT32
ec_gpe_handler(void *ctx)
{
return (0);
}
/*
* Busy-wait for IBF to clear
* return < 0 for time out, 0 for no error
*/
static int
ec_wait_ibf_clear(int sc_addr)
{
int cnt;
cnt = 0;
cnt += 1;
drv_usecwait(10);
if (cnt > 10000) {
return (-1);
}
}
return (0);
}
/*
* Busy-wait for OBF to set
* return < 0 for time out, 0 for no error
*/
static int
ec_wait_obf_set(int sc_addr)
{
int cnt;
cnt = 0;
cnt += 1;
drv_usecwait(10);
if (cnt > 10000) {
return (-1);
}
}
return (0);
}
/*
* Called from AcpiWalkDevices() when an EC device is found
*/
static ACPI_STATUS
{
int status, i;
int io_port_cnt;
/*
* Save the one EC object we have
*/
/*
* Find ec_base and ec_sc addresses
*/
if (ACPI_FAILURE(res)) {
"failed");
return (AE_OK);
}
return (AE_OK);
}
if (*tmp != IO_PORT_DES)
continue;
/*
* Assuming first port is ec_base and second is ec_sc
*/
if (io_port_cnt)
else
io_port_cnt++;
/*
* Increment ahead to next struct.
*/
i += 7;
}
/*
* Drain the EC data register if something is left over from
* legacy mode
*/
#ifndef DEBUG
#else
#endif
}
/*
* Get GPE
*/
/*
* grab contents of GPE object
*/
"failed");
return (AE_OK);
}
return (AE_OK);
}
/*
* Initialize EC mutex here
*/
return (AE_ERROR);
}
/*
* Enable EC GPE
*/
" = %d", status);
/*
* don't return an error here - GPE won't work but the EC
* handler may be OK
*/
}
return (AE_OK);
}
#ifdef DEBUG
/*ARGSUSED*/
static ACPI_STATUS
{
return (AE_OK);
}
/*ARGSUSED*/
static ACPI_STATUS
{
return (AE_OK);
}
#endif /* DEBUG */
#ifdef NOTYET
static void
{
}
static void
{
return;
}
}
#endif /* NOTYET */
void
acpica_ec_init(void)
{
#ifdef NOTYET
/*
* Search the ACPI tables for an ECDT; if
* found, use it to install an EC handler
*/
#endif /* NOTYET */
/*
* General model is: use GetDevices callback to install
* handler(s) when device is present.
*/
#ifdef DEBUG
#endif /* DEBUG */
}