5f8ab4500902368b45b10d59061fedf2f986f326
[coreboot.git] / src / southbridge / via / vt8231 / vt8231.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ops.h>
5 #include <device/pci_ids.h>
6
7 #include <pc80/mc146818rtc.h>
8 #include <pc80/keyboard.h>
9
10 #include "chip.h"
11
12 /* Base 8231 controller */
13 static device_t lpc_dev;
14
15 void hard_reset(void)
16 {
17         printk_err("NO HARD RESET ON VT8231! FIX ME!\n");
18 }
19
20 static void keyboard_on(void)
21 {
22         unsigned char regval;
23
24         if (lpc_dev) {
25                 regval = pci_read_config8(lpc_dev, 0x51);
26                 regval |= 0x0f; 
27                 pci_write_config8(lpc_dev, 0x51, regval);
28         }
29         pc_keyboard_init(0);
30 }
31
32 static void com_port_on(void)
33 {
34 #if 0
35         // enable com1 and com2. 
36         enables = pci_read_config8(dev, 0x6e);
37         
38         /* 0x80 is enable com port b, 0x10 is to make it com2, 0x8
39          * is enable com port a as com1 kevinh/Ispiri - Old code
40          * thought 0x01 would make it com1, that was wrong enables =
41          * 0x80 | 0x10 | 0x8 ; pci_write_config8(dev, 0x6e,
42          * enables); // note: this is also a redo of some port of
43          * assembly, but we want everything up.
44          */
45
46         /* set com1 to 115 kbaud not clear how to do this yet.
47          * forget it; done in assembly.
48          */
49 #endif
50 }
51
52 /* FixME: to be removed ? */
53 static void vt8231_enable(struct device *dev)
54 {
55         struct southbridge_via_vt8231_config *conf = dev->chip_info;
56
57         if (!lpc_dev) {
58                 /* the first time called, enable devices not on PCI bus
59                  * FIXME: is that device struct there yet? */
60                 lpc_dev = dev_find_device(PCI_VENDOR_ID_VIA,
61                                           PCI_DEVICE_ID_VIA_8231, 0);
62                 if (conf->enable_keyboard)
63                         keyboard_on();
64                 if (conf->enable_com_ports)
65                         com_port_on();
66         }
67 }
68
69 struct chip_operations southbridge_via_vt8231_ops = {
70         CHIP_NAME("VIA VT8231 Southbridge")
71         .enable_dev     = vt8231_enable,
72 };