Sven Schnelle | 4a6c9d1 | 2011-02-01 10:44:26 +0000 | [diff] [blame] | 1 | #include <arch/io.h> |
| 2 | #include <console/console.h> |
| 3 | #include <device/device.h> |
| 4 | #include <device/pnp.h> |
| 5 | #include <stdlib.h> |
| 6 | |
| 7 | #include "pmh7.h" |
| 8 | |
| 9 | void pmh7_register_set_bit(int reg, int bit) |
| 10 | { |
| 11 | char val; |
| 12 | |
| 13 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 14 | val = inb(EC_LENOVO_PMH7_DATA); |
| 15 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 16 | outb(val | (1 << bit), EC_LENOVO_PMH7_DATA); |
| 17 | } |
| 18 | |
| 19 | void pmh7_register_clear_bit(int reg, int bit) |
| 20 | { |
| 21 | char val; |
| 22 | |
| 23 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 24 | val = inb(EC_LENOVO_PMH7_DATA); |
| 25 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 26 | outb(val &= ~(1 << bit), EC_LENOVO_PMH7_DATA); |
| 27 | } |
| 28 | |
| 29 | char pmh7_register_read(int reg) |
| 30 | { |
| 31 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 32 | return inb(EC_LENOVO_PMH7_DATA); |
| 33 | } |
| 34 | |
| 35 | void pmh7_register_write(int reg, int val) |
| 36 | { |
| 37 | outb(reg, EC_LENOVO_PMH7_ADDR); |
| 38 | outb(val, EC_LENOVO_PMH7_DATA); |
| 39 | } |
| 40 | |
| 41 | static void enable_dev(device_t dev) |
| 42 | { |
| 43 | struct resource *resource; |
| 44 | resource = new_resource(dev, EC_LENOVO_PMH7_INDEX); |
| 45 | resource->flags = IORESOURCE_IO | IORESOURCE_FIXED; |
| 46 | resource->base = EC_LENOVO_PMH7_BASE; |
| 47 | resource->size = 16; |
| 48 | resource->align = 5; |
| 49 | resource->gran = 5; |
| 50 | |
| 51 | } |
| 52 | |
| 53 | struct chip_operations ec_lenovo_pmh7_ops = { |
| 54 | CHIP_NAME("Lenovo Power Management Hardware Hub 7") |
| 55 | .enable_dev = enable_dev, |
| 56 | }; |