Add support for Intel Panther Point PCH
[coreboot.git] / src / southbridge / intel / bd82x6x / gpio.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
5  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <stdint.h>
21 #include <string.h>
22 #include <arch/io.h>
23 #include <arch/romcc_io.h>
24
25 #include "pch.h"
26 #include "gpio.h"
27
28 void setup_pch_gpios(const struct pch_gpio_map *gpio)
29 {
30         u16 gpiobase = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
31
32         /* GPIO Set 1 */
33         if (gpio->set1.level)
34                 outl(*((u32*)gpio->set1.level), gpiobase + GP_LVL);
35         if (gpio->set1.mode)
36                 outl(*((u32*)gpio->set1.mode), gpiobase + GPIO_USE_SEL);
37         if (gpio->set1.direction)
38                 outl(*((u32*)gpio->set1.direction), gpiobase + GP_IO_SEL);
39         if (gpio->set1.reset)
40                 outl(*((u32*)gpio->set1.reset), gpiobase + GP_RST_SEL1);
41         if (gpio->set1.invert)
42                 outl(*((u32*)gpio->set1.invert), gpiobase + GPI_INV);
43         if (gpio->set1.blink)
44                 outl(*((u32*)gpio->set1.blink), gpiobase + GPO_BLINK);
45
46         /* GPIO Set 2 */
47         if (gpio->set2.level)
48                 outl(*((u32*)gpio->set2.level), gpiobase + GP_LVL2);
49         if (gpio->set2.mode)
50                 outl(*((u32*)gpio->set2.mode), gpiobase + GPIO_USE_SEL2);
51         if (gpio->set2.direction)
52                 outl(*((u32*)gpio->set2.direction), gpiobase + GP_IO_SEL2);
53         if (gpio->set2.reset)
54                 outl(*((u32*)gpio->set2.reset), gpiobase + GP_RST_SEL2);
55
56         /* GPIO Set 3 */
57         if (gpio->set3.level)
58                 outl(*((u32*)gpio->set3.level), gpiobase + GP_LVL3);
59         if (gpio->set3.mode)
60                 outl(*((u32*)gpio->set3.mode), gpiobase + GPIO_USE_SEL3);
61         if (gpio->set3.direction)
62                 outl(*((u32*)gpio->set3.direction), gpiobase + GP_IO_SEL3);
63         if (gpio->set3.reset)
64                 outl(*((u32*)gpio->set3.reset), gpiobase + GP_RST_SEL3);
65 }