David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 1 | #include <linux/string.h> |
| 2 | #include <linux/kernel.h> |
Stephen Rothwell | f85ff30 | 2007-05-01 16:40:36 +1000 | [diff] [blame] | 3 | #include <linux/of.h> |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 4 | #include <linux/init.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/mod_devicetable.h> |
| 7 | #include <linux/slab.h> |
Stephen Rothwell | 3f23de1 | 2007-05-03 02:38:57 +1000 | [diff] [blame] | 8 | #include <linux/errno.h> |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 9 | #include <linux/irq.h> |
Stephen Rothwell | 3f23de1 | 2007-05-03 02:38:57 +1000 | [diff] [blame] | 10 | #include <linux/of_device.h> |
| 11 | #include <linux/of_platform.h> |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 12 | |
Robert Reif | c9f5b7e | 2009-06-04 02:00:02 -0700 | [diff] [blame] | 13 | #include "of_device_common.h" |
| 14 | |
David S. Miller | 3ca9fab | 2006-06-29 14:35:33 -0700 | [diff] [blame] | 15 | void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name) |
| 16 | { |
| 17 | unsigned long ret = res->start + offset; |
David S. Miller | 6bda573 | 2006-10-18 23:00:35 -0700 | [diff] [blame] | 18 | struct resource *r; |
David S. Miller | 3ca9fab | 2006-06-29 14:35:33 -0700 | [diff] [blame] | 19 | |
David S. Miller | 6bda573 | 2006-10-18 23:00:35 -0700 | [diff] [blame] | 20 | if (res->flags & IORESOURCE_MEM) |
| 21 | r = request_mem_region(ret, size, name); |
| 22 | else |
| 23 | r = request_region(ret, size, name); |
| 24 | if (!r) |
David S. Miller | 3ca9fab | 2006-06-29 14:35:33 -0700 | [diff] [blame] | 25 | ret = 0; |
| 26 | |
| 27 | return (void __iomem *) ret; |
| 28 | } |
| 29 | EXPORT_SYMBOL(of_ioremap); |
| 30 | |
David S. Miller | e3a411a3 | 2006-12-28 21:01:32 -0800 | [diff] [blame] | 31 | void of_iounmap(struct resource *res, void __iomem *base, unsigned long size) |
David S. Miller | 3ca9fab | 2006-06-29 14:35:33 -0700 | [diff] [blame] | 32 | { |
David S. Miller | e3a411a3 | 2006-12-28 21:01:32 -0800 | [diff] [blame] | 33 | if (res->flags & IORESOURCE_MEM) |
| 34 | release_mem_region((unsigned long) base, size); |
| 35 | else |
| 36 | release_region((unsigned long) base, size); |
David S. Miller | 3ca9fab | 2006-06-29 14:35:33 -0700 | [diff] [blame] | 37 | } |
| 38 | EXPORT_SYMBOL(of_iounmap); |
| 39 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 40 | /* |
| 41 | * PCI bus specific translator |
| 42 | */ |
| 43 | |
| 44 | static int of_bus_pci_match(struct device_node *np) |
| 45 | { |
David S. Miller | 7ee766d | 2008-09-20 22:00:40 -0700 | [diff] [blame] | 46 | if (!strcmp(np->name, "pci")) { |
David S. Miller | a165b42 | 2007-03-29 01:50:16 -0700 | [diff] [blame] | 47 | const char *model = of_get_property(np, "model", NULL); |
David S. Miller | 01f94c4 | 2007-03-04 12:53:19 -0800 | [diff] [blame] | 48 | |
| 49 | if (model && !strcmp(model, "SUNW,simba")) |
| 50 | return 0; |
| 51 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 52 | /* Do not do PCI specific frobbing if the |
| 53 | * PCI bridge lacks a ranges property. We |
| 54 | * want to pass it through up to the next |
| 55 | * parent as-is, not with the PCI translate |
| 56 | * method which chops off the top address cell. |
| 57 | */ |
| 58 | if (!of_find_property(np, "ranges", NULL)) |
| 59 | return 0; |
| 60 | |
| 61 | return 1; |
| 62 | } |
| 63 | |
| 64 | return 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 65 | } |
| 66 | |
David S. Miller | 01f94c4 | 2007-03-04 12:53:19 -0800 | [diff] [blame] | 67 | static int of_bus_simba_match(struct device_node *np) |
| 68 | { |
David S. Miller | a165b42 | 2007-03-29 01:50:16 -0700 | [diff] [blame] | 69 | const char *model = of_get_property(np, "model", NULL); |
David S. Miller | 01f94c4 | 2007-03-04 12:53:19 -0800 | [diff] [blame] | 70 | |
| 71 | if (model && !strcmp(model, "SUNW,simba")) |
| 72 | return 1; |
David S. Miller | 8c2786c | 2007-06-07 21:59:44 -0700 | [diff] [blame] | 73 | |
| 74 | /* Treat PCI busses lacking ranges property just like |
| 75 | * simba. |
| 76 | */ |
David S. Miller | 7ee766d | 2008-09-20 22:00:40 -0700 | [diff] [blame] | 77 | if (!strcmp(np->name, "pci")) { |
David S. Miller | 8c2786c | 2007-06-07 21:59:44 -0700 | [diff] [blame] | 78 | if (!of_find_property(np, "ranges", NULL)) |
| 79 | return 1; |
| 80 | } |
| 81 | |
David S. Miller | 01f94c4 | 2007-03-04 12:53:19 -0800 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static int of_bus_simba_map(u32 *addr, const u32 *range, |
| 86 | int na, int ns, int pna) |
| 87 | { |
| 88 | return 0; |
| 89 | } |
| 90 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 91 | static void of_bus_pci_count_cells(struct device_node *np, |
| 92 | int *addrc, int *sizec) |
| 93 | { |
| 94 | if (addrc) |
| 95 | *addrc = 3; |
| 96 | if (sizec) |
| 97 | *sizec = 2; |
| 98 | } |
| 99 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 100 | static int of_bus_pci_map(u32 *addr, const u32 *range, |
| 101 | int na, int ns, int pna) |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 102 | { |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 103 | u32 result[OF_MAX_ADDR_CELLS]; |
| 104 | int i; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 105 | |
| 106 | /* Check address type match */ |
David S. Miller | 4230fa3 | 2009-12-09 01:39:09 -0800 | [diff] [blame] | 107 | if (!((addr[0] ^ range[0]) & 0x03000000)) |
| 108 | goto type_match; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 109 | |
David S. Miller | 4230fa3 | 2009-12-09 01:39:09 -0800 | [diff] [blame] | 110 | /* Special exception, we can map a 64-bit address into |
| 111 | * a 32-bit range. |
| 112 | */ |
| 113 | if ((addr[0] & 0x03000000) == 0x03000000 && |
| 114 | (range[0] & 0x03000000) == 0x02000000) |
| 115 | goto type_match; |
| 116 | |
| 117 | return -EINVAL; |
| 118 | |
| 119 | type_match: |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 120 | if (of_out_of_range(addr + 1, range + 1, range + na + pna, |
| 121 | na - 1, ns)) |
| 122 | return -EINVAL; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 123 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 124 | /* Start with the parent range base. */ |
| 125 | memcpy(result, range + na, pna * 4); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 126 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 127 | /* Add in the child address offset, skipping high cell. */ |
| 128 | for (i = 0; i < na - 1; i++) |
| 129 | result[pna - 1 - i] += |
| 130 | (addr[na - 1 - i] - |
| 131 | range[na - 1 - i]); |
| 132 | |
| 133 | memcpy(addr, result, pna * 4); |
| 134 | |
| 135 | return 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 136 | } |
| 137 | |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 138 | static unsigned long of_bus_pci_get_flags(const u32 *addr, unsigned long flags) |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 139 | { |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 140 | u32 w = addr[0]; |
| 141 | |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 142 | /* For PCI, we override whatever child busses may have used. */ |
| 143 | flags = 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 144 | switch((w >> 24) & 0x03) { |
| 145 | case 0x01: |
| 146 | flags |= IORESOURCE_IO; |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 147 | break; |
| 148 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 149 | case 0x02: /* 32 bits */ |
| 150 | case 0x03: /* 64 bits */ |
| 151 | flags |= IORESOURCE_MEM; |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 152 | break; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 153 | } |
| 154 | if (w & 0x40000000) |
| 155 | flags |= IORESOURCE_PREFETCH; |
| 156 | return flags; |
| 157 | } |
| 158 | |
| 159 | /* |
David S. Miller | 4130a4b | 2006-10-25 22:31:06 -0700 | [diff] [blame] | 160 | * FHC/Central bus specific translator. |
| 161 | * |
| 162 | * This is just needed to hard-code the address and size cell |
| 163 | * counts. 'fhc' and 'central' nodes lack the #address-cells and |
| 164 | * #size-cells properties, and if you walk to the root on such |
| 165 | * Enterprise boxes all you'll get is a #size-cells of 2 which is |
| 166 | * not what we want to use. |
| 167 | */ |
| 168 | static int of_bus_fhc_match(struct device_node *np) |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 169 | { |
David S. Miller | 4130a4b | 2006-10-25 22:31:06 -0700 | [diff] [blame] | 170 | return !strcmp(np->name, "fhc") || |
| 171 | !strcmp(np->name, "central"); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 172 | } |
| 173 | |
David S. Miller | 4130a4b | 2006-10-25 22:31:06 -0700 | [diff] [blame] | 174 | #define of_bus_fhc_count_cells of_bus_sbus_count_cells |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * Array of bus specific translators |
| 178 | */ |
| 179 | |
| 180 | static struct of_bus of_busses[] = { |
| 181 | /* PCI */ |
| 182 | { |
| 183 | .name = "pci", |
| 184 | .addr_prop_name = "assigned-addresses", |
| 185 | .match = of_bus_pci_match, |
| 186 | .count_cells = of_bus_pci_count_cells, |
| 187 | .map = of_bus_pci_map, |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 188 | .get_flags = of_bus_pci_get_flags, |
| 189 | }, |
David S. Miller | 01f94c4 | 2007-03-04 12:53:19 -0800 | [diff] [blame] | 190 | /* SIMBA */ |
| 191 | { |
| 192 | .name = "simba", |
| 193 | .addr_prop_name = "assigned-addresses", |
| 194 | .match = of_bus_simba_match, |
| 195 | .count_cells = of_bus_pci_count_cells, |
| 196 | .map = of_bus_simba_map, |
| 197 | .get_flags = of_bus_pci_get_flags, |
| 198 | }, |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 199 | /* SBUS */ |
| 200 | { |
| 201 | .name = "sbus", |
| 202 | .addr_prop_name = "reg", |
| 203 | .match = of_bus_sbus_match, |
| 204 | .count_cells = of_bus_sbus_count_cells, |
David S. Miller | 4130a4b | 2006-10-25 22:31:06 -0700 | [diff] [blame] | 205 | .map = of_bus_default_map, |
| 206 | .get_flags = of_bus_default_get_flags, |
| 207 | }, |
| 208 | /* FHC */ |
| 209 | { |
| 210 | .name = "fhc", |
| 211 | .addr_prop_name = "reg", |
| 212 | .match = of_bus_fhc_match, |
| 213 | .count_cells = of_bus_fhc_count_cells, |
| 214 | .map = of_bus_default_map, |
| 215 | .get_flags = of_bus_default_get_flags, |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 216 | }, |
| 217 | /* Default */ |
| 218 | { |
| 219 | .name = "default", |
| 220 | .addr_prop_name = "reg", |
| 221 | .match = NULL, |
| 222 | .count_cells = of_bus_default_count_cells, |
| 223 | .map = of_bus_default_map, |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 224 | .get_flags = of_bus_default_get_flags, |
| 225 | }, |
| 226 | }; |
| 227 | |
| 228 | static struct of_bus *of_match_bus(struct device_node *np) |
| 229 | { |
| 230 | int i; |
| 231 | |
| 232 | for (i = 0; i < ARRAY_SIZE(of_busses); i ++) |
| 233 | if (!of_busses[i].match || of_busses[i].match(np)) |
| 234 | return &of_busses[i]; |
| 235 | BUG(); |
| 236 | return NULL; |
| 237 | } |
| 238 | |
| 239 | static int __init build_one_resource(struct device_node *parent, |
| 240 | struct of_bus *bus, |
| 241 | struct of_bus *pbus, |
| 242 | u32 *addr, |
| 243 | int na, int ns, int pna) |
| 244 | { |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 245 | const u32 *ranges; |
David S. Miller | 21cd883 | 2008-09-11 23:53:41 -0700 | [diff] [blame] | 246 | int rone, rlen; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 247 | |
| 248 | ranges = of_get_property(parent, "ranges", &rlen); |
| 249 | if (ranges == NULL || rlen == 0) { |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 250 | u32 result[OF_MAX_ADDR_CELLS]; |
| 251 | int i; |
| 252 | |
| 253 | memset(result, 0, pna * 4); |
| 254 | for (i = 0; i < na; i++) |
| 255 | result[pna - 1 - i] = |
| 256 | addr[na - 1 - i]; |
| 257 | |
| 258 | memcpy(addr, result, pna * 4); |
| 259 | return 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* Now walk through the ranges */ |
| 263 | rlen /= 4; |
| 264 | rone = na + pna + ns; |
| 265 | for (; rlen >= rone; rlen -= rone, ranges += rone) { |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 266 | if (!bus->map(addr, ranges, na, ns, pna)) |
| 267 | return 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 268 | } |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 269 | |
David S. Miller | 49d23cf | 2007-05-13 22:01:18 -0700 | [diff] [blame] | 270 | /* When we miss an I/O space match on PCI, just pass it up |
| 271 | * to the next PCI bridge and/or controller. |
| 272 | */ |
| 273 | if (!strcmp(bus->name, "pci") && |
| 274 | (addr[0] & 0x03000000) == 0x01000000) |
| 275 | return 0; |
| 276 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 277 | return 1; |
| 278 | } |
| 279 | |
| 280 | static int __init use_1to1_mapping(struct device_node *pp) |
| 281 | { |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 282 | /* If we have a ranges property in the parent, use it. */ |
| 283 | if (of_find_property(pp, "ranges", NULL) != NULL) |
| 284 | return 0; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 285 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 286 | /* If the parent is the dma node of an ISA bus, pass |
| 287 | * the translation up to the root. |
David S. Miller | 5280267 | 2008-09-03 02:04:41 -0700 | [diff] [blame] | 288 | * |
| 289 | * Some SBUS devices use intermediate nodes to express |
| 290 | * hierarchy within the device itself. These aren't |
| 291 | * real bus nodes, and don't have a 'ranges' property. |
| 292 | * But, we should still pass the translation work up |
| 293 | * to the SBUS itself. |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 294 | */ |
David S. Miller | 5280267 | 2008-09-03 02:04:41 -0700 | [diff] [blame] | 295 | if (!strcmp(pp->name, "dma") || |
| 296 | !strcmp(pp->name, "espdma") || |
| 297 | !strcmp(pp->name, "ledma") || |
| 298 | !strcmp(pp->name, "lebuffer")) |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 299 | return 0; |
| 300 | |
David S. Miller | 8c2786c | 2007-06-07 21:59:44 -0700 | [diff] [blame] | 301 | /* Similarly for all PCI bridges, if we get this far |
| 302 | * it lacks a ranges property, and this will include |
| 303 | * cases like Simba. |
| 304 | */ |
David S. Miller | 7ee766d | 2008-09-20 22:00:40 -0700 | [diff] [blame] | 305 | if (!strcmp(pp->name, "pci")) |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 306 | return 0; |
| 307 | |
| 308 | return 1; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 309 | } |
| 310 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 311 | static int of_resource_verbose; |
| 312 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 313 | static void __init build_device_resources(struct of_device *op, |
| 314 | struct device *parent) |
| 315 | { |
| 316 | struct of_device *p_op; |
| 317 | struct of_bus *bus; |
| 318 | int na, ns; |
| 319 | int index, num_reg; |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 320 | const void *preg; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 321 | |
| 322 | if (!parent) |
| 323 | return; |
| 324 | |
| 325 | p_op = to_of_device(parent); |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 326 | bus = of_match_bus(p_op->dev.of_node); |
| 327 | bus->count_cells(op->dev.of_node, &na, &ns); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 328 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 329 | preg = of_get_property(op->dev.of_node, bus->addr_prop_name, &num_reg); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 330 | if (!preg || num_reg == 0) |
| 331 | return; |
| 332 | |
| 333 | /* Convert to num-cells. */ |
| 334 | num_reg /= 4; |
| 335 | |
David S. Miller | 46ba6d7 | 2006-07-16 22:10:44 -0700 | [diff] [blame] | 336 | /* Convert to num-entries. */ |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 337 | num_reg /= na + ns; |
| 338 | |
Simon Arlott | e5dd42e | 2007-05-11 13:52:08 -0700 | [diff] [blame] | 339 | /* Prevent overrunning the op->resources[] array. */ |
David S. Miller | 46ba6d7 | 2006-07-16 22:10:44 -0700 | [diff] [blame] | 340 | if (num_reg > PROMREG_MAX) { |
| 341 | printk(KERN_WARNING "%s: Too many regs (%d), " |
| 342 | "limiting to %d.\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 343 | op->dev.of_node->full_name, num_reg, PROMREG_MAX); |
David S. Miller | 46ba6d7 | 2006-07-16 22:10:44 -0700 | [diff] [blame] | 344 | num_reg = PROMREG_MAX; |
| 345 | } |
| 346 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 347 | for (index = 0; index < num_reg; index++) { |
| 348 | struct resource *r = &op->resource[index]; |
| 349 | u32 addr[OF_MAX_ADDR_CELLS]; |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 350 | const u32 *reg = (preg + (index * ((na + ns) * 4))); |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 351 | struct device_node *dp = op->dev.of_node; |
| 352 | struct device_node *pp = p_op->dev.of_node; |
David S. Miller | b85cdd4 | 2007-02-28 23:20:12 -0800 | [diff] [blame] | 353 | struct of_bus *pbus, *dbus; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 354 | u64 size, result = OF_BAD_ADDR; |
| 355 | unsigned long flags; |
| 356 | int dna, dns; |
| 357 | int pna, pns; |
| 358 | |
| 359 | size = of_read_addr(reg + na, ns); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 360 | memcpy(addr, reg, na * 4); |
| 361 | |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 362 | flags = bus->get_flags(addr, 0); |
| 363 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 364 | if (use_1to1_mapping(pp)) { |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 365 | result = of_read_addr(addr, na); |
| 366 | goto build_res; |
| 367 | } |
| 368 | |
| 369 | dna = na; |
| 370 | dns = ns; |
David S. Miller | b85cdd4 | 2007-02-28 23:20:12 -0800 | [diff] [blame] | 371 | dbus = bus; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 372 | |
| 373 | while (1) { |
| 374 | dp = pp; |
| 375 | pp = dp->parent; |
| 376 | if (!pp) { |
| 377 | result = of_read_addr(addr, dna); |
| 378 | break; |
| 379 | } |
| 380 | |
| 381 | pbus = of_match_bus(pp); |
| 382 | pbus->count_cells(dp, &pna, &pns); |
| 383 | |
David S. Miller | b85cdd4 | 2007-02-28 23:20:12 -0800 | [diff] [blame] | 384 | if (build_one_resource(dp, dbus, pbus, addr, |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 385 | dna, dns, pna)) |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 386 | break; |
| 387 | |
David S. Miller | e3c71a3 | 2008-08-28 21:02:58 -0700 | [diff] [blame] | 388 | flags = pbus->get_flags(addr, flags); |
| 389 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 390 | dna = pna; |
| 391 | dns = pns; |
David S. Miller | b85cdd4 | 2007-02-28 23:20:12 -0800 | [diff] [blame] | 392 | dbus = pbus; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | build_res: |
| 396 | memset(r, 0, sizeof(*r)); |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 397 | |
| 398 | if (of_resource_verbose) |
Sam Ravnborg | 9018113 | 2009-01-06 13:19:28 -0800 | [diff] [blame] | 399 | printk("%s reg[%d] -> %llx\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 400 | op->dev.of_node->full_name, index, |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 401 | result); |
| 402 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 403 | if (result != OF_BAD_ADDR) { |
David S. Miller | 1815aed | 2006-06-29 19:58:28 -0700 | [diff] [blame] | 404 | if (tlb_type == hypervisor) |
| 405 | result &= 0x0fffffffffffffffUL; |
| 406 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 407 | r->start = result; |
| 408 | r->end = result + size - 1; |
| 409 | r->flags = flags; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 410 | } |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 411 | r->name = op->dev.of_node->name; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 415 | static struct device_node * __init |
| 416 | apply_interrupt_map(struct device_node *dp, struct device_node *pp, |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 417 | const u32 *imap, int imlen, const u32 *imask, |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 418 | unsigned int *irq_p) |
| 419 | { |
| 420 | struct device_node *cp; |
| 421 | unsigned int irq = *irq_p; |
| 422 | struct of_bus *bus; |
| 423 | phandle handle; |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 424 | const u32 *reg; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 425 | int na, num_reg, i; |
| 426 | |
| 427 | bus = of_match_bus(pp); |
| 428 | bus->count_cells(dp, &na, NULL); |
| 429 | |
| 430 | reg = of_get_property(dp, "reg", &num_reg); |
| 431 | if (!reg || !num_reg) |
| 432 | return NULL; |
| 433 | |
| 434 | imlen /= ((na + 3) * 4); |
| 435 | handle = 0; |
| 436 | for (i = 0; i < imlen; i++) { |
| 437 | int j; |
| 438 | |
| 439 | for (j = 0; j < na; j++) { |
| 440 | if ((reg[j] & imask[j]) != imap[j]) |
| 441 | goto next; |
| 442 | } |
| 443 | if (imap[na] == irq) { |
| 444 | handle = imap[na + 1]; |
| 445 | irq = imap[na + 2]; |
| 446 | break; |
| 447 | } |
| 448 | |
| 449 | next: |
| 450 | imap += (na + 3); |
| 451 | } |
David S. Miller | 46ba6d7 | 2006-07-16 22:10:44 -0700 | [diff] [blame] | 452 | if (i == imlen) { |
| 453 | /* Psycho and Sabre PCI controllers can have 'interrupt-map' |
| 454 | * properties that do not include the on-board device |
| 455 | * interrupts. Instead, the device's 'interrupts' property |
| 456 | * is already a fully specified INO value. |
| 457 | * |
| 458 | * Handle this by deciding that, if we didn't get a |
| 459 | * match in the parent's 'interrupt-map', and the |
| 460 | * parent is an IRQ translater, then use the parent as |
| 461 | * our IRQ controller. |
| 462 | */ |
| 463 | if (pp->irq_trans) |
| 464 | return pp; |
| 465 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 466 | return NULL; |
David S. Miller | 46ba6d7 | 2006-07-16 22:10:44 -0700 | [diff] [blame] | 467 | } |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 468 | |
| 469 | *irq_p = irq; |
| 470 | cp = of_find_node_by_phandle(handle); |
| 471 | |
| 472 | return cp; |
| 473 | } |
| 474 | |
| 475 | static unsigned int __init pci_irq_swizzle(struct device_node *dp, |
| 476 | struct device_node *pp, |
| 477 | unsigned int irq) |
| 478 | { |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 479 | const struct linux_prom_pci_registers *regs; |
David S. Miller | bb4c18c | 2007-02-26 14:55:06 -0800 | [diff] [blame] | 480 | unsigned int bus, devfn, slot, ret; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 481 | |
| 482 | if (irq < 1 || irq > 4) |
| 483 | return irq; |
| 484 | |
| 485 | regs = of_get_property(dp, "reg", NULL); |
| 486 | if (!regs) |
| 487 | return irq; |
| 488 | |
David S. Miller | bb4c18c | 2007-02-26 14:55:06 -0800 | [diff] [blame] | 489 | bus = (regs->phys_hi >> 16) & 0xff; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 490 | devfn = (regs->phys_hi >> 8) & 0xff; |
| 491 | slot = (devfn >> 3) & 0x1f; |
| 492 | |
David S. Miller | bb4c18c | 2007-02-26 14:55:06 -0800 | [diff] [blame] | 493 | if (pp->irq_trans) { |
| 494 | /* Derived from Table 8-3, U2P User's Manual. This branch |
| 495 | * is handling a PCI controller that lacks a proper set of |
| 496 | * interrupt-map and interrupt-map-mask properties. The |
| 497 | * Ultra-E450 is one example. |
| 498 | * |
| 499 | * The bit layout is BSSLL, where: |
| 500 | * B: 0 on bus A, 1 on bus B |
| 501 | * D: 2-bit slot number, derived from PCI device number as |
| 502 | * (dev - 1) for bus A, or (dev - 2) for bus B |
| 503 | * L: 2-bit line number |
David S. Miller | bb4c18c | 2007-02-26 14:55:06 -0800 | [diff] [blame] | 504 | */ |
| 505 | if (bus & 0x80) { |
| 506 | /* PBM-A */ |
| 507 | bus = 0x00; |
| 508 | slot = (slot - 1) << 2; |
| 509 | } else { |
| 510 | /* PBM-B */ |
| 511 | bus = 0x10; |
| 512 | slot = (slot - 2) << 2; |
| 513 | } |
| 514 | irq -= 1; |
| 515 | |
| 516 | ret = (bus | slot | irq); |
| 517 | } else { |
| 518 | /* Going through a PCI-PCI bridge that lacks a set of |
| 519 | * interrupt-map and interrupt-map-mask properties. |
| 520 | */ |
| 521 | ret = ((irq - 1 + (slot & 3)) & 3) + 1; |
| 522 | } |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 523 | |
| 524 | return ret; |
| 525 | } |
| 526 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 527 | static int of_irq_verbose; |
| 528 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 529 | static unsigned int __init build_one_device_irq(struct of_device *op, |
| 530 | struct device *parent, |
| 531 | unsigned int irq) |
| 532 | { |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 533 | struct device_node *dp = op->dev.of_node; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 534 | struct device_node *pp, *ip; |
| 535 | unsigned int orig_irq = irq; |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 536 | int nid; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 537 | |
| 538 | if (irq == 0xffffffff) |
| 539 | return irq; |
| 540 | |
| 541 | if (dp->irq_trans) { |
| 542 | irq = dp->irq_trans->irq_build(dp, irq, |
| 543 | dp->irq_trans->data); |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 544 | |
| 545 | if (of_irq_verbose) |
| 546 | printk("%s: direct translate %x --> %x\n", |
| 547 | dp->full_name, orig_irq, irq); |
| 548 | |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 549 | goto out; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /* Something more complicated. Walk up to the root, applying |
| 553 | * interrupt-map or bus specific translations, until we hit |
| 554 | * an IRQ translator. |
| 555 | * |
| 556 | * If we hit a bus type or situation we cannot handle, we |
| 557 | * stop and assume that the original IRQ number was in a |
| 558 | * format which has special meaning to it's immediate parent. |
| 559 | */ |
| 560 | pp = dp->parent; |
| 561 | ip = NULL; |
| 562 | while (pp) { |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 563 | const void *imap, *imsk; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 564 | int imlen; |
| 565 | |
| 566 | imap = of_get_property(pp, "interrupt-map", &imlen); |
| 567 | imsk = of_get_property(pp, "interrupt-map-mask", NULL); |
| 568 | if (imap && imsk) { |
| 569 | struct device_node *iret; |
| 570 | int this_orig_irq = irq; |
| 571 | |
| 572 | iret = apply_interrupt_map(dp, pp, |
| 573 | imap, imlen, imsk, |
| 574 | &irq); |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 575 | |
| 576 | if (of_irq_verbose) |
| 577 | printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 578 | op->dev.of_node->full_name, |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 579 | pp->full_name, this_orig_irq, |
| 580 | (iret ? iret->full_name : "NULL"), irq); |
| 581 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 582 | if (!iret) |
| 583 | break; |
| 584 | |
| 585 | if (iret->irq_trans) { |
| 586 | ip = iret; |
| 587 | break; |
| 588 | } |
| 589 | } else { |
David S. Miller | 7ee766d | 2008-09-20 22:00:40 -0700 | [diff] [blame] | 590 | if (!strcmp(pp->name, "pci")) { |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 591 | unsigned int this_orig_irq = irq; |
| 592 | |
| 593 | irq = pci_irq_swizzle(dp, pp, irq); |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 594 | if (of_irq_verbose) |
| 595 | printk("%s: PCI swizzle [%s] " |
| 596 | "%x --> %x\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 597 | op->dev.of_node->full_name, |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 598 | pp->full_name, this_orig_irq, |
| 599 | irq); |
| 600 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | if (pp->irq_trans) { |
| 604 | ip = pp; |
| 605 | break; |
| 606 | } |
| 607 | } |
| 608 | dp = pp; |
| 609 | pp = pp->parent; |
| 610 | } |
| 611 | if (!ip) |
| 612 | return orig_irq; |
| 613 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 614 | irq = ip->irq_trans->irq_build(op->dev.of_node, irq, |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 615 | ip->irq_trans->data); |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 616 | if (of_irq_verbose) |
| 617 | printk("%s: Apply IRQ trans [%s] %x --> %x\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame^] | 618 | op->dev.of_node->full_name, ip->full_name, orig_irq, irq); |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 619 | |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 620 | out: |
| 621 | nid = of_node_to_nid(dp); |
| 622 | if (nid != -1) { |
Rusty Russell | 96d76a7 | 2008-12-26 22:23:38 +1030 | [diff] [blame] | 623 | cpumask_t numa_mask = *cpumask_of_node(nid); |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 624 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 625 | irq_set_affinity(irq, &numa_mask); |
David S. Miller | c1b1a5f1 | 2008-03-19 04:52:48 -0700 | [diff] [blame] | 626 | } |
| 627 | |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 628 | return irq; |
| 629 | } |
| 630 | |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 631 | static struct of_device * __init scan_one_device(struct device_node *dp, |
| 632 | struct device *parent) |
| 633 | { |
| 634 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); |
Stephen Rothwell | 6a23acf | 2007-04-23 15:53:27 -0700 | [diff] [blame] | 635 | const unsigned int *irq; |
David S. Miller | 3d6e470 | 2007-07-18 22:03:25 -0700 | [diff] [blame] | 636 | struct dev_archdata *sd; |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 637 | int len, i; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 638 | |
| 639 | if (!op) |
| 640 | return NULL; |
| 641 | |
David S. Miller | 3d6e470 | 2007-07-18 22:03:25 -0700 | [diff] [blame] | 642 | sd = &op->dev.archdata; |
| 643 | sd->prom_node = dp; |
| 644 | sd->op = op; |
| 645 | |
Grant Likely | d706c1b | 2010-04-13 16:12:28 -0700 | [diff] [blame] | 646 | op->dev.of_node = dp; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 647 | op->node = dp; |
| 648 | |
| 649 | op->clock_freq = of_getintprop_default(dp, "clock-frequency", |
| 650 | (25*1000*1000)); |
| 651 | op->portid = of_getintprop_default(dp, "upa-portid", -1); |
| 652 | if (op->portid == -1) |
| 653 | op->portid = of_getintprop_default(dp, "portid", -1); |
| 654 | |
| 655 | irq = of_get_property(dp, "interrupts", &len); |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 656 | if (irq) { |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 657 | op->num_irqs = len / 4; |
Robert Reif | 92d9091 | 2008-12-26 15:39:11 -0800 | [diff] [blame] | 658 | |
| 659 | /* Prevent overrunning the op->irqs[] array. */ |
| 660 | if (op->num_irqs > PROMINTR_MAX) { |
| 661 | printk(KERN_WARNING "%s: Too many irqs (%d), " |
| 662 | "limiting to %d.\n", |
| 663 | dp->full_name, op->num_irqs, PROMINTR_MAX); |
| 664 | op->num_irqs = PROMINTR_MAX; |
| 665 | } |
| 666 | memcpy(op->irqs, irq, op->num_irqs * 4); |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 667 | } else { |
| 668 | op->num_irqs = 0; |
| 669 | } |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 670 | |
| 671 | build_device_resources(op, parent); |
David S. Miller | 2b1e597 | 2006-06-29 15:07:37 -0700 | [diff] [blame] | 672 | for (i = 0; i < op->num_irqs; i++) |
| 673 | op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 674 | |
| 675 | op->dev.parent = parent; |
Stephen Rothwell | 37b7754 | 2007-04-30 17:43:56 +1000 | [diff] [blame] | 676 | op->dev.bus = &of_platform_bus_type; |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 677 | if (!parent) |
Greg Kroah-Hartman | 2222c31 | 2008-05-02 06:02:41 +0200 | [diff] [blame] | 678 | dev_set_name(&op->dev, "root"); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 679 | else |
Grant Likely | 6016a36 | 2010-01-28 14:06:53 -0700 | [diff] [blame] | 680 | dev_set_name(&op->dev, "%08x", dp->phandle); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 681 | |
| 682 | if (of_device_register(op)) { |
| 683 | printk("%s: Could not register of device.\n", |
| 684 | dp->full_name); |
| 685 | kfree(op); |
| 686 | op = NULL; |
| 687 | } |
| 688 | |
| 689 | return op; |
| 690 | } |
| 691 | |
| 692 | static void __init scan_tree(struct device_node *dp, struct device *parent) |
| 693 | { |
| 694 | while (dp) { |
| 695 | struct of_device *op = scan_one_device(dp, parent); |
| 696 | |
| 697 | if (op) |
| 698 | scan_tree(dp->child, &op->dev); |
| 699 | |
| 700 | dp = dp->sibling; |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | static void __init scan_of_devices(void) |
| 705 | { |
| 706 | struct device_node *root = of_find_node_by_path("/"); |
| 707 | struct of_device *parent; |
| 708 | |
| 709 | parent = scan_one_device(root, NULL); |
| 710 | if (!parent) |
| 711 | return; |
| 712 | |
| 713 | scan_tree(root->child, &parent->dev); |
| 714 | } |
| 715 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 716 | static int __init of_bus_driver_init(void) |
| 717 | { |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 718 | int err; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 719 | |
Stephen Rothwell | 3f23de1 | 2007-05-03 02:38:57 +1000 | [diff] [blame] | 720 | err = of_bus_type_init(&of_platform_bus_type, "of"); |
David S. Miller | cf44bbc | 2006-06-29 14:34:50 -0700 | [diff] [blame] | 721 | if (!err) |
| 722 | scan_of_devices(); |
| 723 | |
| 724 | return err; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | postcore_initcall(of_bus_driver_init); |
| 728 | |
David S. Miller | a83f982 | 2006-07-12 23:19:31 -0700 | [diff] [blame] | 729 | static int __init of_debug(char *str) |
| 730 | { |
| 731 | int val = 0; |
| 732 | |
| 733 | get_option(&str, &val); |
| 734 | if (val & 1) |
| 735 | of_resource_verbose = 1; |
| 736 | if (val & 2) |
| 737 | of_irq_verbose = 1; |
| 738 | return 1; |
| 739 | } |
| 740 | |
| 741 | __setup("of_debug=", of_debug); |