ad72f5dc023d1076f552d1af78011296120b82c5
[coreboot.git] / src / mainboard / lippert / roadrunner-lx / mainboard.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 LiPPERT Embedded Computers GmbH
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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 /* Based on mainboard.c from AMD's DB800 mainboard. */
22
23 #include <stdlib.h>
24 #include <stdint.h>
25 #include <console/console.h>
26 #include <device/device.h>
27 #include <arch/io.h>
28 #include <device/pci.h>
29 #include <device/pci_ids.h>
30 #include "chip.h"
31
32 static const u16 ec_init_table[] = {    /* hi=data, lo=index */
33         0x1900,         /* Enable monitoring */
34         0x0351,         /* TMPIN1,2 diode mode, TMPIN3 off */
35         0x805C,         /* Unlock zero adjust */
36         0x7056, 0x3C57, /* Zero adjust TMPIN1,2 */
37         0x005C,         /* Lock zero adjust */
38         0xD014          /* Also set FAN_CTL polarity to Active High */
39 };
40
41 static void init(struct device *dev)
42 {
43         struct mainboard_config *mb = dev->chip_info;
44         unsigned int gpio_base, i;
45         printk_debug("LiPPERT RoadRunner-LX ENTER %s\n", __func__);
46
47         /* Init CS5536 GPIOs. */
48         gpio_base = pci_read_config32(dev_find_device(PCI_VENDOR_ID_AMD,
49                     PCI_DEVICE_ID_AMD_CS5536_ISA, 0), PCI_BASE_ADDRESS_1) - 1;
50
51         outl(0x00000040, gpio_base + 0x00); // GPIO6  value      1 - LAN_PD#
52         outl(0x00000040, gpio_base + 0x04); // GPIO6  output     1 - LAN_PD#
53         outl(0x00000400, gpio_base + 0x34); // GPIO10 in aux1    1 - THRM_ALRM#
54         outl(0x00000400, gpio_base + 0x20); // GPIO10 input      1 - THRM_ALRM#
55         outl(0x08000000, gpio_base + 0x98); // GPIO27 pull up    0 - PM-LED
56
57         /* Init Environment Controller. */
58         for (i = 0; i < ARRAY_SIZE(ec_init_table); i++) {
59                 u16 val = ec_init_table[i];
60                 outb((u8)val, 0x0295);
61                 outb(val >> 8, 0x0296);
62         }
63
64         outb(mb->sio_gp1x_config, 0x1220); /* Simple-I/O GP17-10 */
65         printk_debug("LiPPERT RoadRunner-LX EXIT %s\n", __func__);
66 }
67
68 static void enable_dev(struct device *dev)
69 {
70         dev->ops->init = init;
71 }
72
73 struct chip_operations mainboard_ops = {
74         CHIP_NAME("LiPPERT RoadRunner-LX Mainboard")
75         .enable_dev = enable_dev,
76 };