"no warnings day"
[coreboot.git] / src / southbridge / via / vt8235 / vt8235.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 #include <pc80/keyboard.h>
7 #include <pc80/i8259.h>
8 #include "chip.h"
9
10 /*
11  * Base VT8235.
12  */
13
14 void hard_reset(void) 
15 {
16         printk(BIOS_ERR, "NO HARD RESET ON VT8235! FIX ME!\n");
17 }
18
19 static void keyboard_on(struct device *dev)
20 {
21         unsigned char regval;
22
23         regval = pci_read_config8(dev, 0x51);
24         regval |= 0x05; 
25         regval &= 0xfd;
26         pci_write_config8(dev, 0x51, regval);
27
28         pc_keyboard_init(0);
29 }
30
31 void dump_south(device_t dev0)
32 {
33         int i,j;
34         
35         for(i = 0; i < 256; i += 16) {
36                 printk(BIOS_DEBUG, "0x%x: ", i);
37                 for(j = 0; j < 16; j++) {
38                         printk(BIOS_DEBUG, "%02x ", pci_read_config8(dev0, i+j));
39                 }
40                 printk(BIOS_DEBUG, "\n");
41         }
42 }
43
44 void set_led()
45 {
46         // set power led to steady now that lxbios has virtually done its job
47         device_t dev;
48         dev = dev_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, 0);
49         pci_write_config8(dev, 0x94, 0xb0);
50 }
51
52
53 static void vt8235_enable(struct device *dev)
54 {
55         unsigned char regval;
56         unsigned short vendor,model;
57
58         vendor = pci_read_config16(dev,0);
59         model = pci_read_config16(dev,0x2);
60
61         printk(BIOS_DEBUG, "In vt8235_enable %04x %04x.\n",vendor,model);
62         
63         /* if this is not the southbridge itself just return */
64         /* this is necessary because USB devices are slot 10, whereas this device is slot 11 
65           therefore usb devices get called first during the bus scan */
66
67         if( (vendor != PCI_VENDOR_ID_VIA) || (model != PCI_DEVICE_ID_VIA_8235))
68                 return;
69
70         printk(BIOS_DEBUG, "Initialising Devices\n");
71
72         setup_i8259();   // make sure interupt controller is configured before keyboard init 
73
74         /* enable RTC and ethernet */
75         regval = pci_read_config8(dev, 0x51);
76         regval |= 0x18; 
77         pci_write_config8(dev, 0x51, regval);
78
79         /* turn on keyboard */
80         keyboard_on(dev);
81
82         /* enable USB 1.1 & USB 2.0 -redundant really since we've already been there - see note above*/
83         regval = pci_read_config8(dev, 0x50);
84         regval &= ~(0x36);
85         pci_write_config8(dev, 0x50, regval);
86 }
87
88 struct chip_operations southbridge_via_vt8235_ops = {
89         CHIP_NAME("VIA VT8235 Southbridge")
90         .enable_dev = vt8235_enable,
91 };