1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "nvidia.h"␊ |
6 | #include "ati.h"␊ |
7 | ␊ |
8 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
9 | extern int ehci_acquire(pci_dt_t *pci_dev);␊ |
10 | extern int legacy_off(pci_dt_t *pci_dev);␊ |
11 | extern int uhci_reset(pci_dt_t *pci_dev);␊ |
12 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
13 | ␊ |
14 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
15 | {␊ |
16 | ␉char *devicepath;␊ |
17 | ␉bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_legoff, fix_uhci, fix_usb, do_enable_hpet;␊ |
18 | ␉pci_dt_t *current = pci_dt;␊ |
19 | ␊ |
20 | ␉do_eth_devprop = do_gfx_devprop = fix_ehci = fix_legoff = fix_uhci = fix_usb = do_enable_hpet = false;␊ |
21 | ␊ |
22 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);␊ |
23 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig);␊ |
24 | ␉if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig) && fix_usb) {␊ |
25 | ␉␉fix_ehci = fix_uhci = true;␊ |
26 | ␉} else {␊ |
27 | ␉␉getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig);␊ |
28 | ␉␉getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig);␊ |
29 | ␉}␊ |
30 | ␉getBoolForKey(kUSBLegacyOff, &fix_legoff, &bootInfo->bootConfig);␊ |
31 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig);␊ |
32 | ␊ |
33 | ␉while (current)␊ |
34 | ␉{␊ |
35 | ␉␉devicepath = get_pci_dev_path(current);␊ |
36 | ␊ |
37 | ␉␉switch (current->class_id)␊ |
38 | ␉␉{␊ |
39 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
40 | ␉␉␉␉if (do_eth_devprop)␊ |
41 | ␉␉␉␉␉set_eth_builtin(current);␊ |
42 | ␉␉␉␉break;␊ |
43 | ␉␉␉␉␊ |
44 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
45 | ␉␉␉␉if (do_gfx_devprop)␊ |
46 | ␉␉␉␉␉switch (current->vendor_id)␊ |
47 | ␉␉␉␉␉{␊ |
48 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
49 | ␉␉␉␉␉␉␉verbose("ATI VGA Controller [%04x:%04x] :: %s \n", ␊ |
50 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
51 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
52 | ␉␉␉␉␉␉␉break;␊ |
53 | ␉␉␉␉␉␊ |
54 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL: ␊ |
55 | ␉␉␉␉␉␉␉/* message to be removed once support for these cards is added */␊ |
56 | ␉␉␉␉␉␉␉verbose("Intel VGA Controller [%04x:%04x] :: %s (currently NOT SUPPORTED)\n", ␊ |
57 | ␉␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
58 | ␉␉␉␉␉␉␉break;␊ |
59 | ␉␉␉␉␉␊ |
60 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
61 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
62 | ␉␉␉␉␉␉␉break;␊ |
63 | ␉␉␉␉␉}␊ |
64 | ␉␉␉␉break;␊ |
65 | ␊ |
66 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
67 | ␉␉␉␉switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))␊ |
68 | ␉␉␉␉{␊ |
69 | ␉␉␉␉␉/* EHCI */␊ |
70 | ␉␉␉␉␉case 0x20:␊ |
71 | ␉␉␉␉ ␉if (fix_ehci)␊ |
72 | ␉␉␉␉␉␉␉ehci_acquire(current);␊ |
73 | ␉␉␉␉␉␉if (fix_legoff)␊ |
74 | ␉␉␉␉␉␉␉legacy_off(current);␊ |
75 | ␉␉␉␉␉␉break;␊ |
76 | ␊ |
77 | ␉␉␉␉␉/* UHCI */␊ |
78 | ␉␉␉␉␉case 0x00:␊ |
79 | ␉␉␉␉ ␉if (fix_uhci)␊ |
80 | ␉␉␉␉␉␉␉uhci_reset(current);␊ |
81 | ␉␉␉␉␉␉break;␊ |
82 | ␉␉␉␉}␊ |
83 | ␉␉␉␉break;␊ |
84 | ␊ |
85 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
86 | ␉␉␉␉if (do_enable_hpet)␊ |
87 | ␉␉␉␉␉force_enable_hpet(current);␊ |
88 | ␉␉␉␉break;␊ |
89 | ␉␉}␊ |
90 | ␉␉␊ |
91 | ␉␉setup_pci_devs(current->children);␊ |
92 | ␉␉current = current->next;␊ |
93 | ␉}␊ |
94 | }␊ |
95 | |