blob: e12a8db85ab9b2c272834b3d205d26e326188122 [file] [log] [blame]
arch import user (historical)80e3d962005-07-06 18:17:33 +00001
2static 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);
Stefan Reinauer14e22772010-04-27 06:56:47 +000012
arch import user (historical)80e3d962005-07-06 18:17:33 +000013 /* 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 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000023
arch import user (historical)80e3d962005-07-06 18:17:33 +000024 if(dev0) {
25 regval = pci_read_config8(dev0, 0x50);
Stefan Reinauer14e22772010-04-27 06:56:47 +000026 if (enable)
27 regval &= ~(0x10);
arch import user (historical)80e3d962005-07-06 18:17:33 +000028 else
Stefan Reinauer14e22772010-04-27 06:56:47 +000029 regval |= 0x10;
arch import user (historical)80e3d962005-07-06 18:17:33 +000030 pci_write_config8(dev0, 0x50, regval);
31 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000032
arch import user (historical)80e3d962005-07-06 18:17:33 +000033 /* 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 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000043
arch import user (historical)80e3d962005-07-06 18:17:33 +000044 if(dev0) {
45 regval = pci_read_config8(dev0, 0x50);
Stefan Reinauer14e22772010-04-27 06:56:47 +000046 if (enable)
47 regval &= ~(0x20);
arch import user (historical)80e3d962005-07-06 18:17:33 +000048 else
Stefan Reinauer14e22772010-04-27 06:56:47 +000049 regval |= 0x20;
arch import user (historical)80e3d962005-07-06 18:17:33 +000050 pci_write_config8(dev0, 0x50, regval);
51 }
52}