3 * by yinghai.lu@amd.com
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pnp.h>
10 #include <device/pci_ids.h>
11 #include <device/pci_ops.h>
12 #include <pc80/mc146818rtc.h>
13 #include <pc80/isa-dma.h>
18 static void lpc_init(device_t dev)
21 /* Initialize the real time clock */
24 /* Initialize isa dma */
29 static void bcm5785_lpc_read_resources(device_t dev)
33 /* Get the normal pci resources of this device */
34 pci_dev_read_resources(dev);
36 /* Add an extra subtractive resource for both memory and I/O. */
37 res = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
40 res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE |
41 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
43 res = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
44 res->base = 0xff800000;
45 res->size = 0x00800000; /* 8 MB for flash */
46 res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE |
47 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
49 res = new_resource(dev, 3); /* IOAPIC */
50 res->base = 0xfec00000;
51 res->size = 0x00001000;
52 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
56 * @brief Enable resources for children devices
58 * @param dev the device whos children's resources are to be enabled
60 * This function is call by the global enable_resources() indirectly via the
61 * device_operation::enable_resources() method of devices.
63 * Indirect mutual recursion:
64 * enable_childrens_resources() -> enable_resources()
65 * enable_resources() -> device_operation::enable_resources()
66 * device_operation::enable_resources() -> enable_children_resources()
68 static void bcm5785_lpc_enable_childrens_resources(device_t dev)
74 reg = pci_read_config8(dev, 0x44);
76 for (link = 0; link < dev->links; link++) {
78 for (child = dev->link[link].children; child; child = child->sibling) {
79 enable_resources(child);
80 if(child->enabled && (child->path.type == DEVICE_PATH_PNP)) {
81 for(i=0;i<child->resources;i++) {
83 unsigned long base, end; // don't need long long
84 res = &child->resource[i];
85 if(!(res->flags & IORESOURCE_IO)) continue;
87 end = resource_end(res);
88 printk(BIOS_DEBUG, "bcm5785lpc decode:%s, base=0x%08lx, end=0x%08lx\n",dev_path(child),base, end);
97 case 0x378: // Parallal 1
100 reg |= (1<<26); break;
101 case 0x220: // Aduio 0
102 reg |= (1<<14); break;
103 case 0x300: // Midi 0
104 reg |= (1<<18); break;
110 pci_write_config32(dev, 0x44, reg);
115 static void bcm5785_lpc_enable_resources(device_t dev)
117 pci_dev_enable_resources(dev);
118 bcm5785_lpc_enable_childrens_resources(dev);
121 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
123 pci_write_config32(dev, 0x40,
124 ((device & 0xffff) << 16) | (vendor & 0xffff));
127 static struct pci_operations lops_pci = {
128 .set_subsystem = lpci_set_subsystem,
131 static struct device_operations lpc_ops = {
132 .read_resources = bcm5785_lpc_read_resources,
133 .set_resources = pci_dev_set_resources,
134 .enable_resources = bcm5785_lpc_enable_resources,
136 .scan_bus = scan_static_bus,
137 // .enable = bcm5785_enable,
138 .ops_pci = &lops_pci,
140 static const struct pci_driver lpc_driver __pci_driver = {
142 .vendor = PCI_VENDOR_ID_SERVERWORKS,
143 .device = PCI_DEVICE_ID_SERVERWORKS_BCM5785_LPC,