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