[PATCH] ocfs2: zero_user_page conversion
[wrt350n-kernel.git] / arch / sparc64 / kernel / isa.c
blob6a6882e57ff22ff3c5f1aee779b761d20b493ab6
1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/pci.h>
4 #include <linux/slab.h>
5 #include <asm/oplib.h>
6 #include <asm/prom.h>
7 #include <asm/of_device.h>
8 #include <asm/isa.h>
10 struct sparc_isa_bridge *isa_chain;
12 static void __init fatal_err(const char *reason)
14 prom_printf("ISA: fatal error, %s.\n", reason);
17 static void __init report_dev(struct sparc_isa_device *isa_dev, int child)
19 if (child)
20 printk(" (%s)", isa_dev->prom_node->name);
21 else
22 printk(" [%s", isa_dev->prom_node->name);
25 static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev)
27 struct of_device *op = of_find_device_by_node(isa_dev->prom_node);
29 memcpy(&isa_dev->resource, &op->resource[0], sizeof(struct resource));
32 static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev)
34 struct of_device *op = of_find_device_by_node(isa_dev->prom_node);
36 if (!op || !op->num_irqs) {
37 isa_dev->irq = PCI_IRQ_NONE;
38 } else {
39 isa_dev->irq = op->irqs[0];
43 static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
45 struct device_node *dp = parent_isa_dev->prom_node->child;
47 if (!dp)
48 return;
50 printk(" ->");
51 while (dp) {
52 struct sparc_isa_device *isa_dev;
54 isa_dev = kzalloc(sizeof(*isa_dev), GFP_KERNEL);
55 if (!isa_dev) {
56 fatal_err("cannot allocate child isa_dev");
57 prom_halt();
60 /* Link it in to parent. */
61 isa_dev->next = parent_isa_dev->child;
62 parent_isa_dev->child = isa_dev;
64 isa_dev->bus = parent_isa_dev->bus;
65 isa_dev->prom_node = dp;
67 isa_dev_get_resource(isa_dev);
68 isa_dev_get_irq(isa_dev);
70 report_dev(isa_dev, 1);
72 dp = dp->sibling;
76 static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
78 struct device_node *dp = isa_br->prom_node->child;
80 while (dp) {
81 struct sparc_isa_device *isa_dev;
83 isa_dev = kzalloc(sizeof(*isa_dev), GFP_KERNEL);
84 if (!isa_dev) {
85 printk(KERN_DEBUG "ISA: cannot allocate isa_dev");
86 return;
89 isa_dev->ofdev.node = dp;
90 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
91 isa_dev->ofdev.dev.bus = &isa_bus_type;
92 sprintf(isa_dev->ofdev.dev.bus_id, "isa[%08x]", dp->node);
94 /* Register with core */
95 if (of_device_register(&isa_dev->ofdev) != 0) {
96 printk(KERN_DEBUG "isa: device registration error for %s!\n",
97 dp->path_component_name);
98 kfree(isa_dev);
99 goto next_sibling;
102 /* Link it in. */
103 isa_dev->next = NULL;
104 if (isa_br->devices == NULL) {
105 isa_br->devices = isa_dev;
106 } else {
107 struct sparc_isa_device *tmp = isa_br->devices;
109 while (tmp->next)
110 tmp = tmp->next;
112 tmp->next = isa_dev;
115 isa_dev->bus = isa_br;
116 isa_dev->prom_node = dp;
118 isa_dev_get_resource(isa_dev);
119 isa_dev_get_irq(isa_dev);
121 report_dev(isa_dev, 0);
123 isa_fill_children(isa_dev);
125 printk("]");
127 next_sibling:
128 dp = dp->sibling;
132 void __init isa_init(void)
134 struct pci_dev *pdev;
135 unsigned short vendor, device;
136 int index = 0;
138 vendor = PCI_VENDOR_ID_AL;
139 device = PCI_DEVICE_ID_AL_M1533;
141 pdev = NULL;
142 while ((pdev = pci_get_device(vendor, device, pdev)) != NULL) {
143 struct sparc_isa_bridge *isa_br;
144 struct device_node *dp;
146 dp = pci_device_to_OF_node(pdev);
148 isa_br = kzalloc(sizeof(*isa_br), GFP_KERNEL);
149 if (!isa_br) {
150 printk(KERN_DEBUG "isa: cannot allocate sparc_isa_bridge");
151 return;
154 isa_br->ofdev.node = dp;
155 isa_br->ofdev.dev.parent = &pdev->dev;
156 isa_br->ofdev.dev.bus = &isa_bus_type;
157 sprintf(isa_br->ofdev.dev.bus_id, "isa%d", index);
159 /* Register with core */
160 if (of_device_register(&isa_br->ofdev) != 0) {
161 printk(KERN_DEBUG "isa: device registration error for %s!\n",
162 dp->path_component_name);
163 kfree(isa_br);
164 return;
167 /* Link it in. */
168 isa_br->next = isa_chain;
169 isa_chain = isa_br;
171 isa_br->self = pdev;
172 isa_br->index = index++;
173 isa_br->prom_node = dp;
175 printk("isa%d:", isa_br->index);
177 isa_fill_devices(isa_br);
179 printk("\n");