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>
27 void pmh7_register_set_bit(int reg, int bit)
31 outb(reg, EC_LENOVO_PMH7_ADDR);
32 val = inb(EC_LENOVO_PMH7_DATA);
33 outb(reg, EC_LENOVO_PMH7_ADDR);
34 outb(val | (1 << bit), EC_LENOVO_PMH7_DATA);
37 void pmh7_register_clear_bit(int reg, int bit)
41 outb(reg, EC_LENOVO_PMH7_ADDR);
42 val = inb(EC_LENOVO_PMH7_DATA);
43 outb(reg, EC_LENOVO_PMH7_ADDR);
44 outb(val &= ~(1 << bit), EC_LENOVO_PMH7_DATA);
47 char pmh7_register_read(int reg)
49 outb(reg, EC_LENOVO_PMH7_ADDR);
50 return inb(EC_LENOVO_PMH7_DATA);
53 void pmh7_register_write(int reg, int val)
55 outb(reg, EC_LENOVO_PMH7_ADDR);
56 outb(val, EC_LENOVO_PMH7_DATA);
59 static void enable_dev(device_t dev)
61 struct resource *resource;
63 resource = new_resource(dev, EC_LENOVO_PMH7_INDEX);
64 resource->flags = IORESOURCE_IO | IORESOURCE_FIXED;
65 resource->base = EC_LENOVO_PMH7_BASE;
71 struct chip_operations ec_lenovo_pmh7_ops = {
72 CHIP_NAME("Lenovo Power Management Hardware Hub 7")
73 .enable_dev = enable_dev,