diff options
author | njl <njl@FreeBSD.org> | 2005-03-20 01:27:27 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2005-03-20 01:27:27 +0000 |
commit | f9994cc85ed8ce53813bc660ba299c16c348127c (patch) | |
tree | 10482fc7cd3521ae4dbd2c7a632f5955acec167d | |
parent | 4dff4a6c79c8a039628cdca11bb3c6839b6a7644 (diff) | |
download | FreeBSD-src-f9994cc85ed8ce53813bc660ba299c16c348127c.zip FreeBSD-src-f9994cc85ed8ce53813bc660ba299c16c348127c.tar.gz |
Add the acpi_ec_read and write methods. This allows an external driver
(like an EC/SMbus controller) to access the EC address space. Access
is synchronized by the EcLock/Unlock routines in EcSpaceHandler().
Tested by: Hans Petter Selasky
-rw-r--r-- | sys/dev/acpica/acpi_ec.c | 35 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_if.m | 30 |
2 files changed, 65 insertions, 0 deletions
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index ae318c3..9dfb05b 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -336,6 +336,10 @@ static ACPI_STATUS EcWrite(struct acpi_ec_softc *sc, UINT8 Address, static int acpi_ec_probe(device_t dev); static int acpi_ec_attach(device_t dev); static int acpi_ec_shutdown(device_t dev); +static int acpi_ec_read_method(device_t dev, u_int addr, + ACPI_INTEGER *val, int width); +static int acpi_ec_write_method(device_t dev, u_int addr, + ACPI_INTEGER val, int width); static device_method_t acpi_ec_methods[] = { /* Device interface */ @@ -343,6 +347,10 @@ static device_method_t acpi_ec_methods[] = { DEVMETHOD(device_attach, acpi_ec_attach), DEVMETHOD(device_shutdown, acpi_ec_shutdown), + /* Embedded controller interface */ + DEVMETHOD(acpi_ec_read, acpi_ec_read_method), + DEVMETHOD(acpi_ec_write, acpi_ec_write_method), + {0, 0} }; @@ -646,6 +654,33 @@ acpi_ec_shutdown(device_t dev) return (0); } +/* Methods to allow other devices (e.g., smbat) to read/write EC space. */ +static int +acpi_ec_read_method(device_t dev, u_int addr, ACPI_INTEGER *val, int width) +{ + struct acpi_ec_softc *sc; + ACPI_STATUS status; + + sc = device_get_softc(dev); + status = EcSpaceHandler(ACPI_READ, addr, width * 8, val, sc, NULL); + if (ACPI_FAILURE(status)) + return (ENXIO); + return (0); +} + +static int +acpi_ec_write_method(device_t dev, u_int addr, ACPI_INTEGER val, int width) +{ + struct acpi_ec_softc *sc; + ACPI_STATUS status; + + sc = device_get_softc(dev); + status = EcSpaceHandler(ACPI_WRITE, addr, width * 8, &val, sc, NULL); + if (ACPI_FAILURE(status)) + return (ENXIO); + return (0); +} + static void EcGpeQueryHandler(void *Context) { diff --git a/sys/dev/acpica/acpi_if.m b/sys/dev/acpica/acpi_if.m index 9c63b3e..a93171d 100644 --- a/sys/dev/acpica/acpi_if.m +++ b/sys/dev/acpica/acpi_if.m @@ -154,3 +154,33 @@ METHOD ACPI_STATUS scan_children { acpi_scan_cb_t user_fn; void *arg; }; + +# +# Read embedded controller (EC) address space +# +# device_t dev: EC device +# u_int addr: Address to read from in EC space +# ACPI_INTEGER *val: Location to store read value +# int width: Size of area to read in bytes +# +METHOD int ec_read { + device_t dev; + u_int addr; + ACPI_INTEGER *val; + int width; +}; + +# +# Write embedded controller (EC) address space +# +# device_t dev: EC device +# u_int addr: Address to write to in EC space +# ACPI_INTEGER val: Value to write +# int width: Size of value to write in bytes +# +METHOD int ec_write { + device_t dev; + u_int addr; + ACPI_INTEGER val; + int width; +}; |