Move the v3 resource allocator to v2.
[coreboot.git] / src / northbridge / ibm / cpc925 / cpc925_northbridge.c
1 #include <console/console.h>
2 #include <arch/io.h>
3 #include <stdint.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <bitops.h>
9 #include <cpu/cpu.h>
10 #include "chip.h"
11
12 static void ram_resource(device_t dev, unsigned long index,
13         unsigned long basek, unsigned long sizek)
14 {
15         struct resource *resource;
16
17         if (!sizek) {
18                 return;
19         }
20         resource = new_resource(dev, index);
21         resource->base  = ((resource_t)basek) << 10;
22         resource->size  = ((resource_t)sizek) << 10;
23         resource->flags =  IORESOURCE_MEM | IORESOURCE_CACHEABLE | \
24                 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
25 }
26
27 static void pci_domain_set_resources(device_t dev)
28 {
29         int idx;
30
31         /* Report the memory regions */
32         idx = 10;
33         ram_resource(dev, idx++, 0, 1024*1024); /* FIXME */
34
35         /* And assign the resources */
36         assign_resources(&dev->link[0]);
37 }
38
39 static struct device_operations pci_domain_ops = {
40         .read_resources   = pci_domain_read_resources,
41         .set_resources    = pci_domain_set_resources,
42         .enable_resources = enable_childrens_resources,
43         .init             = 0,
44         .scan_bus         = pci_domain_scan_bus,
45         .ops_pci_bus      = &pci_ppc_conf1,
46 };  
47
48 static void cpu_bus_init(device_t dev)
49 {
50         initialize_cpus(&dev->link[0]);
51 }
52
53 static void cpu_bus_noop(device_t dev)
54 {
55 }
56
57 static struct device_operations cpu_bus_ops = {
58         .read_resources   = cpu_bus_noop,
59         .set_resources    = cpu_bus_noop,
60         .enable_resources = cpu_bus_noop,
61         .init             = cpu_bus_init,
62         .scan_bus         = 0,
63 };
64
65 static void enable_dev(struct device *dev)
66 {
67         /* Set the operations if it is a special bus type */
68         if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
69                 dev->ops = &pci_domain_ops;
70         }
71         else if (dev->path.type == DEVICE_PATH_CPU_BUS) {
72                 dev->ops = &cpu_bus_ops;
73         }
74 }
75
76 struct chip_operations northbridge_ibm_cpc925_ops = {
77         CHIP_NAME("IBM CPC925 Northbridge")
78         .enable_dev = enable_dev,
79 };