2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/pnp.h>
28 void pmh7_backlight_enable(int onoff)
31 pmh7_register_set_bit(0x50, 5);
33 pmh7_register_clear_bit(0x50, 5);
36 void pmh7_register_set_bit(int reg, int bit)
40 outb(reg, EC_LENOVO_PMH7_ADDR);
41 val = inb(EC_LENOVO_PMH7_DATA);
42 outb(reg, EC_LENOVO_PMH7_ADDR);
43 outb(val | (1 << bit), EC_LENOVO_PMH7_DATA);
46 void pmh7_register_clear_bit(int reg, int bit)
50 outb(reg, EC_LENOVO_PMH7_ADDR);
51 val = inb(EC_LENOVO_PMH7_DATA);
52 outb(reg, EC_LENOVO_PMH7_ADDR);
53 outb(val &= ~(1 << bit), EC_LENOVO_PMH7_DATA);
56 char pmh7_register_read(int reg)
58 outb(reg, EC_LENOVO_PMH7_ADDR);
59 return inb(EC_LENOVO_PMH7_DATA);
62 void pmh7_register_write(int reg, int val)
64 outb(reg, EC_LENOVO_PMH7_ADDR);
65 outb(val, EC_LENOVO_PMH7_DATA);
68 static void enable_dev(device_t dev)
70 struct ec_lenovo_pmh7_config *conf = dev->chip_info;
71 struct resource *resource;
73 resource = new_resource(dev, EC_LENOVO_PMH7_INDEX);
74 resource->flags = IORESOURCE_IO | IORESOURCE_FIXED;
75 resource->base = EC_LENOVO_PMH7_BASE;
80 pmh7_backlight_enable(conf->backlight_enable);
83 struct chip_operations ec_lenovo_pmh7_ops = {
84 CHIP_NAME("Lenovo Power Management Hardware Hub 7")
85 .enable_dev = enable_dev,