summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica/acpi_ec.c
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2005-03-20 01:27:27 +0000
committernjl <njl@FreeBSD.org>2005-03-20 01:27:27 +0000
commitf9994cc85ed8ce53813bc660ba299c16c348127c (patch)
tree10482fc7cd3521ae4dbd2c7a632f5955acec167d /sys/dev/acpica/acpi_ec.c
parent4dff4a6c79c8a039628cdca11bb3c6839b6a7644 (diff)
downloadFreeBSD-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
Diffstat (limited to 'sys/dev/acpica/acpi_ec.c')
-rw-r--r--sys/dev/acpica/acpi_ec.c35
1 files changed, 35 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)
{
OpenPOWER on IntegriCloud