1 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
12 static void pci_domain_read_resources(device_t dev)
14 struct resource *resource;
16 /* Initialize the system wide io space constraints */
17 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
19 resource->limit = 0xffffUL;
20 resource->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | IORESOURCE_ASSIGNED;
22 /* Initialize the system wide memory resources constraints */
23 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
24 resource->base = 0x80000000ULL;
25 resource->limit = 0xfeffffffULL; /* We can put pci resources in the system controll area */
26 resource->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | IORESOURCE_ASSIGNED;
29 static void pci_domain_set_resources(device_t dev)
33 /* Get the memory controller device */
34 mc_dev = dev->link[0].children;
36 /* Figure out which areas occupied by ram. */
38 uint32_t memstart1, memstart2, extmemstart1, extmemstart2;
39 uint32_t memend1, memend2, extmemend1, extmemend2;
41 unsigned long start, end, size;
43 /* Find the memory setup */
44 memstart1 = pci_read_config32(dev, 0x80);
45 memstart2 = pci_read_config32(dev, 0x84);
46 extmemstart1 = pci_read_config32(dev, 0x88);
47 extmemstart1 = pci_read_config32(dev, 0x8c);
48 memend1 = pci_read_config32(dev, 0x90);
49 memend2 = pci_read_config32(dev, 0x94);
50 extmemend1 = pci_read_config32(dev, 0x98);
51 extmemend2 = pci_read_config32(dev, 0x9c);
52 bank_enable = pci_read_config32(dev, 0xa0);
54 /* Report the memory regions */
56 for(i = 0; i < 8; i++) {
58 /* Ignore banks that are not enabled */
59 if (!(bank_enable & (1 << i))) {
62 /* Find the start and end of each bank */
65 start = ((memstart1 >> shift) & 0xff) << 20;
66 start |= ((extmemstart1 >> shift) & 0xff) << 28;
67 end = ((memend1 >> shift) & 0xff) << 20;
68 end |= ((extmemend1 >> shift) & 0xff) << 28;
70 int shift = (8*(i - 4));
71 start = ((memstart2 >> shift) & 0xff) << 20;
72 start |= ((extmemstart2 >> shift) & 0xff) << 28;
73 end = ((memend2 >> shift) & 0xff) << 20;
74 end |= ((extmemend2 >> shift) & 0xff) << 28;
76 /* Comput the size of the bank */
77 size = (end + (1 << 20)) - start;
79 /* And now report the memory region */
80 res = new_resource(dev, idx++);
83 res->flags = IORESOURCE_MEM | IORESOURCE_CACHEABLE | \
84 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
87 /* And assign the resources */
88 assign_resources(&dev->link[0]);
92 static unsigned int pci_domain_scan_bus(device_t dev, unsigned int max)
94 max = pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, max);
98 static struct device_operations pci_domain_ops = {
99 .read_resources = pci_domain_read_resources,
100 .set_resources = pci_domain_set_resources,
101 .enable_resources = enable_childrens_resources,
103 .scan_bus = pci_domain_scan_bus,
104 .ops_pci_bus = &pci_ppc_conf1,
107 static void cpu_bus_init(device_t dev)
109 initialize_cpus(&dev->link[0]);
112 static void cpu_bus_noop(device_t dev)
116 static struct device_operations cpu_bus_ops = {
117 .read_resources = cpu_bus_noop,
118 .set_resources = cpu_bus_noop,
119 .enable_resources = cpu_bus_noop,
120 .init = cpu_bus_init,
124 static void enable_dev(struct device *dev)
126 /* Set the operations if it is a special bus type */
127 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
128 dev->ops = &pci_domain_ops;
130 else if (dev->path.type == DEVICE_PATH_CPU_BUS) {
131 dev->ops = &cpu_bus_ops;
135 struct chip_operations northbridge_motorola_mpc107_ops = {
137 .enable_dev = enable_dev,