summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSven Schnelle <svens@stackframe.org>2011-02-01 10:44:26 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2011-02-01 10:44:26 +0000
commit4a6c9d159c38ed52397fa7b98b57d48e8c53c427 (patch)
treeb60e99ec6f252e3177f22639a695c3f5da7b8278 /src
parent478b77d3884f8c1ca54144380a417ba7a73162ea (diff)
downloadcoreboot-4a6c9d159c38ed52397fa7b98b57d48e8c53c427.tar.xz
Add support for the Lenovo PMH7 embedded controller
Lenovo PMH7 (Power Management Hardware Hub) is found in most recent (starting with X60/T60 AFAIK) Lenovo/IBM Laptops. Signed-off-by: Sven Schnelle <svens@stackframe.org> Acked-by: Patrick Georgi <patrick.georgi@secunet.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6325 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src')
-rw-r--r--src/ec/Kconfig1
-rw-r--r--src/ec/lenovo/Kconfig1
-rw-r--r--src/ec/lenovo/Makefile.inc1
-rw-r--r--src/ec/lenovo/pmh7/Kconfig2
-rw-r--r--src/ec/lenovo/pmh7/Makefile.inc1
-rw-r--r--src/ec/lenovo/pmh7/pmh7.c56
-rw-r--r--src/ec/lenovo/pmh7/pmh7.h15
7 files changed, 77 insertions, 0 deletions
diff --git a/src/ec/Kconfig b/src/ec/Kconfig
index 9408f6bd9e..2a36a328e0 100644
--- a/src/ec/Kconfig
+++ b/src/ec/Kconfig
@@ -1 +1,2 @@
source src/ec/acpi/Kconfig
+source src/ec/lenovo/Kconfig
diff --git a/src/ec/lenovo/Kconfig b/src/ec/lenovo/Kconfig
new file mode 100644
index 0000000000..b564b62b0b
--- /dev/null
+++ b/src/ec/lenovo/Kconfig
@@ -0,0 +1 @@
+source src/ec/lenovo/pmh7/Kconfig
diff --git a/src/ec/lenovo/Makefile.inc b/src/ec/lenovo/Makefile.inc
new file mode 100644
index 0000000000..f9a3feb4a1
--- /dev/null
+++ b/src/ec/lenovo/Makefile.inc
@@ -0,0 +1 @@
+subdirs-$(CONFIG_EC_LENOVO_PMH7) += pmh7
diff --git a/src/ec/lenovo/pmh7/Kconfig b/src/ec/lenovo/pmh7/Kconfig
new file mode 100644
index 0000000000..27815bc017
--- /dev/null
+++ b/src/ec/lenovo/pmh7/Kconfig
@@ -0,0 +1,2 @@
+config EC_LENOVO_PMH7
+ bool
diff --git a/src/ec/lenovo/pmh7/Makefile.inc b/src/ec/lenovo/pmh7/Makefile.inc
new file mode 100644
index 0000000000..4c891b25ab
--- /dev/null
+++ b/src/ec/lenovo/pmh7/Makefile.inc
@@ -0,0 +1 @@
+driver-y += pmh7.c
diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c
new file mode 100644
index 0000000000..c9cf1925cf
--- /dev/null
+++ b/src/ec/lenovo/pmh7/pmh7.c
@@ -0,0 +1,56 @@
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <stdlib.h>
+
+#include "pmh7.h"
+
+void pmh7_register_set_bit(int reg, int bit)
+{
+ char val;
+
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ val = inb(EC_LENOVO_PMH7_DATA);
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ outb(val | (1 << bit), EC_LENOVO_PMH7_DATA);
+}
+
+void pmh7_register_clear_bit(int reg, int bit)
+{
+ char val;
+
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ val = inb(EC_LENOVO_PMH7_DATA);
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ outb(val &= ~(1 << bit), EC_LENOVO_PMH7_DATA);
+}
+
+char pmh7_register_read(int reg)
+{
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ return inb(EC_LENOVO_PMH7_DATA);
+}
+
+void pmh7_register_write(int reg, int val)
+{
+ outb(reg, EC_LENOVO_PMH7_ADDR);
+ outb(val, EC_LENOVO_PMH7_DATA);
+}
+
+static void enable_dev(device_t dev)
+{
+ struct resource *resource;
+ resource = new_resource(dev, EC_LENOVO_PMH7_INDEX);
+ resource->flags = IORESOURCE_IO | IORESOURCE_FIXED;
+ resource->base = EC_LENOVO_PMH7_BASE;
+ resource->size = 16;
+ resource->align = 5;
+ resource->gran = 5;
+
+}
+
+struct chip_operations ec_lenovo_pmh7_ops = {
+ CHIP_NAME("Lenovo Power Management Hardware Hub 7")
+ .enable_dev = enable_dev,
+};
diff --git a/src/ec/lenovo/pmh7/pmh7.h b/src/ec/lenovo/pmh7/pmh7.h
new file mode 100644
index 0000000000..2999ef6197
--- /dev/null
+++ b/src/ec/lenovo/pmh7/pmh7.h
@@ -0,0 +1,15 @@
+#ifndef EC_LENOVO_PMH7_H
+#define EC_LENOVO_PMH7_H
+
+#define EC_LENOVO_PMH7_INDEX 0x77
+
+#define EC_LENOVO_PMH7_BASE 0x15e0
+#define EC_LENOVO_PMH7_ADDR (EC_LENOVO_PMH7_BASE + 0x0c)
+#define EC_LENOVO_PMH7_DATA (EC_LENOVO_PMH7_BASE + 0x0e)
+
+void pmh7_register_set_bit(int reg, int bit);
+void pmh7_register_clear_bit(int reg, int bit);
+char pmh7_register_read(int reg);
+void pmh7_register_write(int reg, int val);
+
+#endif