Author: oxygene Date: Tue Feb 1 11:44:26 2011 New Revision: 6325 URL: https://tracker.coreboot.org/trac/coreboot/changeset/6325
Log: 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
Added: trunk/src/ec/lenovo/ trunk/src/ec/lenovo/Kconfig trunk/src/ec/lenovo/Makefile.inc trunk/src/ec/lenovo/pmh7/ trunk/src/ec/lenovo/pmh7/Kconfig trunk/src/ec/lenovo/pmh7/Makefile.inc trunk/src/ec/lenovo/pmh7/pmh7.c trunk/src/ec/lenovo/pmh7/pmh7.h Modified: trunk/src/ec/Kconfig
Modified: trunk/src/ec/Kconfig ============================================================================== --- trunk/src/ec/Kconfig Tue Feb 1 11:42:52 2011 (r6324) +++ trunk/src/ec/Kconfig Tue Feb 1 11:44:26 2011 (r6325) @@ -1 +1,2 @@ source src/ec/acpi/Kconfig +source src/ec/lenovo/Kconfig
Added: trunk/src/ec/lenovo/Kconfig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/Kconfig Tue Feb 1 11:44:26 2011 (r6325) @@ -0,0 +1 @@ +source src/ec/lenovo/pmh7/Kconfig
Added: trunk/src/ec/lenovo/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/Makefile.inc Tue Feb 1 11:44:26 2011 (r6325) @@ -0,0 +1 @@ +subdirs-$(CONFIG_EC_LENOVO_PMH7) += pmh7
Added: trunk/src/ec/lenovo/pmh7/Kconfig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/pmh7/Kconfig Tue Feb 1 11:44:26 2011 (r6325) @@ -0,0 +1,2 @@ +config EC_LENOVO_PMH7 + bool
Added: trunk/src/ec/lenovo/pmh7/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/pmh7/Makefile.inc Tue Feb 1 11:44:26 2011 (r6325) @@ -0,0 +1 @@ +driver-y += pmh7.c
Added: trunk/src/ec/lenovo/pmh7/pmh7.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/pmh7/pmh7.c Tue Feb 1 11:44:26 2011 (r6325) @@ -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, +};
Added: trunk/src/ec/lenovo/pmh7/pmh7.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/ec/lenovo/pmh7/pmh7.h Tue Feb 1 11:44:26 2011 (r6325) @@ -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