Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / southbridge / via / vt8231 / vt8231_usb.c
1
2 static void usb_on(int enable)
3 {
4         unsigned char regval;
5
6         /* Base 8231 controller */
7         device_t dev0 = dev_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, 0);
8         /* USB controller 1 */
9         device_t dev2 = dev_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, 0);
10         /* USB controller 2 */
11         device_t dev3 = dev_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, dev2);
12
13         /* enable USB1 */
14         if(dev2) {
15                 if (enable) {
16                         pci_write_config8(dev2, 0x3c, 0x05);
17                         pci_write_config8(dev2, 0x04, 0x07);
18                 } else {
19                         pci_write_config8(dev2, 0x3c, 0x00);
20                         pci_write_config8(dev2, 0x04, 0x00);
21                 }
22         }
23
24         if(dev0) {
25                 regval = pci_read_config8(dev0, 0x50);
26                 if (enable)
27                         regval &= ~(0x10);
28                 else
29                         regval |= 0x10;
30                 pci_write_config8(dev0, 0x50, regval);
31         }
32
33         /* enable USB2 */
34         if(dev3) {
35                 if (enable) {
36                         pci_write_config8(dev3, 0x3c, 0x05);
37                         pci_write_config8(dev3, 0x04, 0x07);
38                 } else {
39                         pci_write_config8(dev3, 0x3c, 0x00);
40                         pci_write_config8(dev3, 0x04, 0x00);
41                 }
42         }
43
44         if(dev0) {
45                 regval = pci_read_config8(dev0, 0x50);
46                 if (enable)
47                         regval &= ~(0x20);
48                 else
49                         regval |= 0x20;
50                 pci_write_config8(dev0, 0x50, regval);
51         }
52 }