diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2005-11-30 00:57:28 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-01-08 22:51:26 -0500 |
commit | d2dd482bc17c3bc240045f80a7c4b4d5cea5e29c (patch) | |
tree | 9c40a9ab9a04839f2d578f9d47985b399074ce58 | |
parent | bb6b9b28d6847bc71f910e2e82c9040ff4b97ec0 (diff) |
[PATCH] powerpc: Update OF address parsers
This updates the OF address parsers to return the IO flags
indicating the type of address obtained. It also adds a PCI
call for converting physical addresses that hit IO space into
into IO tokens, and add routines that return the translated
addresses into struct resource
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/kernel/legacy_serial.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 14 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 165 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/feature.c | 2 | ||||
-rw-r--r-- | arch/ppc/kernel/pci.c | 15 | ||||
-rw-r--r-- | drivers/macintosh/macio_asic.c | 12 | ||||
-rw-r--r-- | include/asm-powerpc/pci-bridge.h | 9 | ||||
-rw-r--r-- | include/asm-powerpc/prom.h | 28 | ||||
-rw-r--r-- | include/asm-ppc/pci-bridge.h | 9 | ||||
-rw-r--r-- | include/asm-ppc/prom.h | 28 |
10 files changed, 251 insertions, 36 deletions
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c index 83023bb59ad9..d179ec502292 100644 --- a/arch/powerpc/kernel/legacy_serial.c +++ b/arch/powerpc/kernel/legacy_serial.c | |||
@@ -146,6 +146,7 @@ static int __init add_legacy_pci_port(struct device_node *np, | |||
146 | { | 146 | { |
147 | phys_addr_t addr, base; | 147 | phys_addr_t addr, base; |
148 | u32 *addrp; | 148 | u32 *addrp; |
149 | unsigned int flags; | ||
149 | int iotype, index = -1, lindex = 0; | 150 | int iotype, index = -1, lindex = 0; |
150 | 151 | ||
151 | /* We only support ports that have a clock frequency properly | 152 | /* We only support ports that have a clock frequency properly |
@@ -159,12 +160,12 @@ static int __init add_legacy_pci_port(struct device_node *np, | |||
159 | return -1; | 160 | return -1; |
160 | 161 | ||
161 | /* Get the PCI address. Assume BAR 0 */ | 162 | /* Get the PCI address. Assume BAR 0 */ |
162 | addrp = of_get_pci_address(pci_dev, 0, NULL); | 163 | addrp = of_get_pci_address(pci_dev, 0, NULL, &flags); |
163 | if (addrp == NULL) | 164 | if (addrp == NULL) |
164 | return -1; | 165 | return -1; |
165 | 166 | ||
166 | /* We only support BAR 0 for now */ | 167 | /* We only support BAR 0 for now */ |
167 | iotype = (addrp[0] & 0x02000000) ? UPIO_MEM : UPIO_PORT; | 168 | iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT; |
168 | addr = of_translate_address(pci_dev, addrp); | 169 | addr = of_translate_address(pci_dev, addrp); |
169 | 170 | ||
170 | /* Set the IO base to the same as the translated address for MMIO, | 171 | /* Set the IO base to the same as the translated address for MMIO, |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 5f241fcd88e8..0988222741f0 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -1181,6 +1181,20 @@ void phbs_remap_io(void) | |||
1181 | remap_bus_range(hose->bus); | 1181 | remap_bus_range(hose->bus); |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | unsigned int pci_address_to_pio(phys_addr_t address) | ||
1185 | { | ||
1186 | struct pci_controller *hose, *tmp; | ||
1187 | |||
1188 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | ||
1189 | if (address >= hose->io_base_phys && | ||
1190 | address < (hose->io_base_phys + hose->pci_io_size)) | ||
1191 | return (unsigned int)hose->io_base_virt + | ||
1192 | (address - hose->io_base_phys); | ||
1193 | } | ||
1194 | return (unsigned int)-1; | ||
1195 | } | ||
1196 | EXPORT_SYMBOL_GPL(pci_address_to_pio); | ||
1197 | |||
1184 | static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) | 1198 | static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) |
1185 | { | 1199 | { |
1186 | struct pci_controller *hose = pci_bus_to_host(dev->bus); | 1200 | struct pci_controller *hose = pci_bus_to_host(dev->bus); |
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index 23c85af53d47..5b764277f470 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
@@ -4,7 +4,9 @@ | |||
4 | #include <linux/string.h> | 4 | #include <linux/string.h> |
5 | #include <linux/pci_regs.h> | 5 | #include <linux/pci_regs.h> |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/ioport.h> | ||
7 | #include <asm/prom.h> | 8 | #include <asm/prom.h> |
9 | #include <asm/pci-bridge.h> | ||
8 | 10 | ||
9 | #ifdef DEBUG | 11 | #ifdef DEBUG |
10 | #define DBG(fmt...) do { printk(fmt); } while(0) | 12 | #define DBG(fmt...) do { printk(fmt); } while(0) |
@@ -54,6 +56,7 @@ struct of_bus { | |||
54 | int *addrc, int *sizec); | 56 | int *addrc, int *sizec); |
55 | u64 (*map)(u32 *addr, u32 *range, int na, int ns, int pna); | 57 | u64 (*map)(u32 *addr, u32 *range, int na, int ns, int pna); |
56 | int (*translate)(u32 *addr, u64 offset, int na); | 58 | int (*translate)(u32 *addr, u64 offset, int na); |
59 | unsigned int (*get_flags)(u32 *addr); | ||
57 | }; | 60 | }; |
58 | 61 | ||
59 | 62 | ||
@@ -61,8 +64,8 @@ struct of_bus { | |||
61 | * Default translator (generic bus) | 64 | * Default translator (generic bus) |
62 | */ | 65 | */ |
63 | 66 | ||
64 | static void of_default_count_cells(struct device_node *dev, | 67 | static void of_bus_default_count_cells(struct device_node *dev, |
65 | int *addrc, int *sizec) | 68 | int *addrc, int *sizec) |
66 | { | 69 | { |
67 | if (addrc) | 70 | if (addrc) |
68 | *addrc = prom_n_addr_cells(dev); | 71 | *addrc = prom_n_addr_cells(dev); |
@@ -70,7 +73,7 @@ static void of_default_count_cells(struct device_node *dev, | |||
70 | *sizec = prom_n_size_cells(dev); | 73 | *sizec = prom_n_size_cells(dev); |
71 | } | 74 | } |
72 | 75 | ||
73 | static u64 of_default_map(u32 *addr, u32 *range, int na, int ns, int pna) | 76 | static u64 of_bus_default_map(u32 *addr, u32 *range, int na, int ns, int pna) |
74 | { | 77 | { |
75 | u64 cp, s, da; | 78 | u64 cp, s, da; |
76 | 79 | ||
@@ -86,7 +89,7 @@ static u64 of_default_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
86 | return da - cp; | 89 | return da - cp; |
87 | } | 90 | } |
88 | 91 | ||
89 | static int of_default_translate(u32 *addr, u64 offset, int na) | 92 | static int of_bus_default_translate(u32 *addr, u64 offset, int na) |
90 | { | 93 | { |
91 | u64 a = of_read_addr(addr, na); | 94 | u64 a = of_read_addr(addr, na); |
92 | memset(addr, 0, na * 4); | 95 | memset(addr, 0, na * 4); |
@@ -98,6 +101,11 @@ static int of_default_translate(u32 *addr, u64 offset, int na) | |||
98 | return 0; | 101 | return 0; |
99 | } | 102 | } |
100 | 103 | ||
104 | static unsigned int of_bus_default_get_flags(u32 *addr) | ||
105 | { | ||
106 | return IORESOURCE_MEM; | ||
107 | } | ||
108 | |||
101 | 109 | ||
102 | /* | 110 | /* |
103 | * PCI bus specific translator | 111 | * PCI bus specific translator |
@@ -139,7 +147,24 @@ static u64 of_bus_pci_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
139 | 147 | ||
140 | static int of_bus_pci_translate(u32 *addr, u64 offset, int na) | 148 | static int of_bus_pci_translate(u32 *addr, u64 offset, int na) |
141 | { | 149 | { |
142 | return of_default_translate(addr + 1, offset, na - 1); | 150 | return of_bus_default_translate(addr + 1, offset, na - 1); |
151 | } | ||
152 | |||
153 | static unsigned int of_bus_pci_get_flags(u32 *addr) | ||
154 | { | ||
155 | unsigned int flags = 0; | ||
156 | u32 w = addr[0]; | ||
157 | |||
158 | switch((w >> 24) & 0x03) { | ||
159 | case 0x01: | ||
160 | flags |= IORESOURCE_IO; | ||
161 | case 0x02: /* 32 bits */ | ||
162 | case 0x03: /* 64 bits */ | ||
163 | flags |= IORESOURCE_MEM; | ||
164 | } | ||
165 | if (w & 0x40000000) | ||
166 | flags |= IORESOURCE_PREFETCH; | ||
167 | return flags; | ||
143 | } | 168 | } |
144 | 169 | ||
145 | /* | 170 | /* |
@@ -182,9 +207,22 @@ static u64 of_bus_isa_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
182 | 207 | ||
183 | static int of_bus_isa_translate(u32 *addr, u64 offset, int na) | 208 | static int of_bus_isa_translate(u32 *addr, u64 offset, int na) |
184 | { | 209 | { |
185 | return of_default_translate(addr + 1, offset, na - 1); | 210 | return of_bus_default_translate(addr + 1, offset, na - 1); |
211 | } | ||
212 | |||
213 | static unsigned int of_bus_isa_get_flags(u32 *addr) | ||
214 | { | ||
215 | unsigned int flags = 0; | ||
216 | u32 w = addr[0]; | ||
217 | |||
218 | if (w & 1) | ||
219 | flags |= IORESOURCE_IO; | ||
220 | else | ||
221 | flags |= IORESOURCE_MEM; | ||
222 | return flags; | ||
186 | } | 223 | } |
187 | 224 | ||
225 | |||
188 | /* | 226 | /* |
189 | * Array of bus specific translators | 227 | * Array of bus specific translators |
190 | */ | 228 | */ |
@@ -198,6 +236,7 @@ static struct of_bus of_busses[] = { | |||
198 | .count_cells = of_bus_pci_count_cells, | 236 | .count_cells = of_bus_pci_count_cells, |
199 | .map = of_bus_pci_map, | 237 | .map = of_bus_pci_map, |
200 | .translate = of_bus_pci_translate, | 238 | .translate = of_bus_pci_translate, |
239 | .get_flags = of_bus_pci_get_flags, | ||
201 | }, | 240 | }, |
202 | /* ISA */ | 241 | /* ISA */ |
203 | { | 242 | { |
@@ -207,15 +246,17 @@ static struct of_bus of_busses[] = { | |||
207 | .count_cells = of_bus_isa_count_cells, | 246 | .count_cells = of_bus_isa_count_cells, |
208 | .map = of_bus_isa_map, | 247 | .map = of_bus_isa_map, |
209 | .translate = of_bus_isa_translate, | 248 | .translate = of_bus_isa_translate, |
249 | .get_flags = of_bus_isa_get_flags, | ||
210 | }, | 250 | }, |
211 | /* Default */ | 251 | /* Default */ |
212 | { | 252 | { |
213 | .name = "default", | 253 | .name = "default", |
214 | .addresses = "reg", | 254 | .addresses = "reg", |
215 | .match = NULL, | 255 | .match = NULL, |
216 | .count_cells = of_default_count_cells, | 256 | .count_cells = of_bus_default_count_cells, |
217 | .map = of_default_map, | 257 | .map = of_bus_default_map, |
218 | .translate = of_default_translate, | 258 | .translate = of_bus_default_translate, |
259 | .get_flags = of_bus_default_get_flags, | ||
219 | }, | 260 | }, |
220 | }; | 261 | }; |
221 | 262 | ||
@@ -254,7 +295,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, | |||
254 | ranges = (u32 *)get_property(parent, "ranges", &rlen); | 295 | ranges = (u32 *)get_property(parent, "ranges", &rlen); |
255 | if (ranges == NULL || rlen == 0) { | 296 | if (ranges == NULL || rlen == 0) { |
256 | offset = of_read_addr(addr, na); | 297 | offset = of_read_addr(addr, na); |
257 | memset(addr, 0, pna); | 298 | memset(addr, 0, pna * 4); |
299 | DBG("OF: no ranges, 1:1 translation\n"); | ||
258 | goto finish; | 300 | goto finish; |
259 | } | 301 | } |
260 | 302 | ||
@@ -370,7 +412,8 @@ u64 of_translate_address(struct device_node *dev, u32 *in_addr) | |||
370 | } | 412 | } |
371 | EXPORT_SYMBOL(of_translate_address); | 413 | EXPORT_SYMBOL(of_translate_address); |
372 | 414 | ||
373 | u32 *of_get_address(struct device_node *dev, int index, u64 *size) | 415 | u32 *of_get_address(struct device_node *dev, int index, u64 *size, |
416 | unsigned int *flags) | ||
374 | { | 417 | { |
375 | u32 *prop; | 418 | u32 *prop; |
376 | unsigned int psize; | 419 | unsigned int psize; |
@@ -399,22 +442,106 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size) | |||
399 | if (i == index) { | 442 | if (i == index) { |
400 | if (size) | 443 | if (size) |
401 | *size = of_read_addr(prop + na, ns); | 444 | *size = of_read_addr(prop + na, ns); |
445 | if (flags) | ||
446 | *flags = bus->get_flags(prop); | ||
402 | return prop; | 447 | return prop; |
403 | } | 448 | } |
404 | return NULL; | 449 | return NULL; |
405 | } | 450 | } |
406 | EXPORT_SYMBOL(of_get_address); | 451 | EXPORT_SYMBOL(of_get_address); |
407 | 452 | ||
408 | u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size) | 453 | u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, |
454 | unsigned int *flags) | ||
409 | { | 455 | { |
410 | u32 *addr; | 456 | u32 *prop; |
411 | int index; | 457 | unsigned int psize; |
458 | struct device_node *parent; | ||
459 | struct of_bus *bus; | ||
460 | int onesize, i, na, ns; | ||
412 | 461 | ||
413 | for (index = 0; (addr = of_get_address(dev, index, size)) != NULL; | 462 | /* Get parent & match bus type */ |
414 | index++) { | 463 | parent = of_get_parent(dev); |
415 | if ((addr[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) | 464 | if (parent == NULL) |
416 | return addr; | 465 | return NULL; |
417 | } | 466 | bus = of_match_bus(parent); |
467 | if (strcmp(bus->name, "pci")) | ||
468 | return NULL; | ||
469 | bus->count_cells(dev, &na, &ns); | ||
470 | of_node_put(parent); | ||
471 | if (!OF_CHECK_COUNTS(na, ns)) | ||
472 | return NULL; | ||
473 | |||
474 | /* Get "reg" or "assigned-addresses" property */ | ||
475 | prop = (u32 *)get_property(dev, bus->addresses, &psize); | ||
476 | if (prop == NULL) | ||
477 | return NULL; | ||
478 | psize /= 4; | ||
479 | |||
480 | onesize = na + ns; | ||
481 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | ||
482 | if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { | ||
483 | if (size) | ||
484 | *size = of_read_addr(prop + na, ns); | ||
485 | if (flags) | ||
486 | *flags = bus->get_flags(prop); | ||
487 | return prop; | ||
488 | } | ||
418 | return NULL; | 489 | return NULL; |
419 | } | 490 | } |
420 | EXPORT_SYMBOL(of_get_pci_address); | 491 | EXPORT_SYMBOL(of_get_pci_address); |
492 | |||
493 | static int __of_address_to_resource(struct device_node *dev, u32 *addrp, | ||
494 | u64 size, unsigned int flags, | ||
495 | struct resource *r) | ||
496 | { | ||
497 | u64 taddr; | ||
498 | |||
499 | if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) | ||
500 | return -EINVAL; | ||
501 | taddr = of_translate_address(dev, addrp); | ||
502 | if (taddr == OF_BAD_ADDR) | ||
503 | return -EINVAL; | ||
504 | memset(r, 0, sizeof(struct resource)); | ||
505 | if (flags & IORESOURCE_IO) { | ||
506 | unsigned int port; | ||
507 | port = pci_address_to_pio(taddr); | ||
508 | if (port == (unsigned int)-1) | ||
509 | return -EINVAL; | ||
510 | r->start = port; | ||
511 | r->end = port + size - 1; | ||
512 | } else { | ||
513 | r->start = taddr; | ||
514 | r->end = taddr + size - 1; | ||
515 | } | ||
516 | r->flags = flags; | ||
517 | r->name = dev->name; | ||
518 | return 0; | ||
519 | } | ||
520 | |||
521 | int of_address_to_resource(struct device_node *dev, int index, | ||
522 | struct resource *r) | ||
523 | { | ||
524 | u32 *addrp; | ||
525 | u64 size; | ||
526 | unsigned int flags; | ||
527 | |||
528 | addrp = of_get_address(dev, index, &size, &flags); | ||
529 | if (addrp == NULL) | ||
530 | return -EINVAL; | ||
531 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
532 | } | ||
533 | EXPORT_SYMBOL_GPL(of_address_to_resource); | ||
534 | |||
535 | int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
536 | struct resource *r) | ||
537 | { | ||
538 | u32 *addrp; | ||
539 | u64 size; | ||
540 | unsigned int flags; | ||
541 | |||
542 | addrp = of_get_pci_address(dev, bar, &size, &flags); | ||
543 | if (addrp == NULL) | ||
544 | return -EINVAL; | ||
545 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
546 | } | ||
547 | EXPORT_SYMBOL_GPL(of_pci_address_to_resource); | ||
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 52a9d0c1b8b8..b2928bbe9227 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c | |||
@@ -2683,7 +2683,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ | |||
2683 | printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name); | 2683 | printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name); |
2684 | return; | 2684 | return; |
2685 | } | 2685 | } |
2686 | addrp = of_get_pci_address(node, 0, &size); | 2686 | addrp = of_get_pci_address(node, 0, &size, NULL); |
2687 | if (addrp == NULL) { | 2687 | if (addrp == NULL) { |
2688 | printk(KERN_ERR "pmac_feature: %s: can't find base !\n", | 2688 | printk(KERN_ERR "pmac_feature: %s: can't find base !\n", |
2689 | node->full_name); | 2689 | node->full_name); |
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 0aa184112fb1..af364003880b 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c | |||
@@ -1805,6 +1805,21 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *addr) | |||
1805 | EXPORT_SYMBOL(pci_iomap); | 1805 | EXPORT_SYMBOL(pci_iomap); |
1806 | EXPORT_SYMBOL(pci_iounmap); | 1806 | EXPORT_SYMBOL(pci_iounmap); |
1807 | 1807 | ||
1808 | unsigned int pci_address_to_pio(phys_addr_t address) | ||
1809 | { | ||
1810 | struct pci_controller* hose = hose_head; | ||
1811 | |||
1812 | for (; hose; hose = hose->next) { | ||
1813 | unsigned int size = hose->io_resource.end - | ||
1814 | hose->io_resource.start + 1; | ||
1815 | if (address >= hose->io_base_phys && | ||
1816 | address < (hose->io_base_phys + size)) | ||
1817 | return (unsigned int)hose->io_base_virt + | ||
1818 | (address - hose->io_base_phys); | ||
1819 | } | ||
1820 | return (unsigned int)-1; | ||
1821 | } | ||
1822 | EXPORT_SYMBOL(pci_address_to_pio); | ||
1808 | 1823 | ||
1809 | /* | 1824 | /* |
1810 | * Null PCI config access functions, for the case when we can't | 1825 | * Null PCI config access functions, for the case when we can't |
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index f14c744a94ef..0137ff239f13 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
@@ -332,18 +332,14 @@ static void macio_setup_resources(struct macio_dev *dev, | |||
332 | struct resource *parent_res) | 332 | struct resource *parent_res) |
333 | { | 333 | { |
334 | struct device_node *np = dev->ofdev.node; | 334 | struct device_node *np = dev->ofdev.node; |
335 | u32 *addr; | 335 | struct resource r; |
336 | u64 size; | ||
337 | int index; | 336 | int index; |
338 | 337 | ||
339 | for (index = 0; (addr = of_get_address(np, index, &size)) != NULL; | 338 | for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) { |
340 | index++) { | ||
341 | struct resource *res = &dev->resource[index]; | 339 | struct resource *res = &dev->resource[index]; |
342 | if (index >= MACIO_DEV_COUNT_RESOURCES) | 340 | if (index >= MACIO_DEV_COUNT_RESOURCES) |
343 | break; | 341 | break; |
344 | res->start = of_translate_address(np, addr); | 342 | *res = r; |
345 | res->end = res->start + (unsigned long)size - 1; | ||
346 | res->flags = IORESOURCE_MEM; | ||
347 | res->name = dev->ofdev.dev.bus_id; | 343 | res->name = dev->ofdev.dev.bus_id; |
348 | 344 | ||
349 | if (macio_resource_quirks(np, res, index)) { | 345 | if (macio_resource_quirks(np, res, index)) { |
@@ -353,7 +349,7 @@ static void macio_setup_resources(struct macio_dev *dev, | |||
353 | /* Currently, we consider failure as harmless, this may | 349 | /* Currently, we consider failure as harmless, this may |
354 | * change in the future, once I've found all the device | 350 | * change in the future, once I've found all the device |
355 | * tree bugs in older machines & worked around them | 351 | * tree bugs in older machines & worked around them |
356 | */ | 352 | l */ |
357 | if (insert_resource(parent_res, res)) { | 353 | if (insert_resource(parent_res, res)) { |
358 | printk(KERN_WARNING "Can't request resource " | 354 | printk(KERN_WARNING "Can't request resource " |
359 | "%d for MacIO device %s\n", | 355 | "%d for MacIO device %s\n", |
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h index 00d21513d009..01132bb602e3 100644 --- a/include/asm-powerpc/pci-bridge.h +++ b/include/asm-powerpc/pci-bridge.h | |||
@@ -156,6 +156,15 @@ extern struct pci_controller * | |||
156 | pcibios_alloc_controller(struct device_node *dev); | 156 | pcibios_alloc_controller(struct device_node *dev); |
157 | extern void pcibios_free_controller(struct pci_controller *phb); | 157 | extern void pcibios_free_controller(struct pci_controller *phb); |
158 | 158 | ||
159 | #ifdef CONFIG_PCI | ||
160 | extern unsigned int pci_address_to_pio(phys_addr_t address); | ||
161 | #else | ||
162 | static inline unsigned int pci_address_to_pio(phys_addr_t address) | ||
163 | { | ||
164 | return (unsigned int)-1; | ||
165 | } | ||
166 | #endif | ||
167 | |||
159 | /* Return values for ppc_md.pci_probe_mode function */ | 168 | /* Return values for ppc_md.pci_probe_mode function */ |
160 | #define PCI_PROBE_NONE -1 /* Don't look at this bus at all */ | 169 | #define PCI_PROBE_NONE -1 /* Don't look at this bus at all */ |
161 | #define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */ | 170 | #define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */ |
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index fb732c992bd2..73d27bad55fa 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h | |||
@@ -223,14 +223,36 @@ extern struct resource *request_OF_resource(struct device_node* node, | |||
223 | int index, const char* name_postfix); | 223 | int index, const char* name_postfix); |
224 | extern int release_OF_resource(struct device_node* node, int index); | 224 | extern int release_OF_resource(struct device_node* node, int index); |
225 | 225 | ||
226 | |||
226 | /* | 227 | /* |
227 | * Address translation function(s) | 228 | * OF address retreival & translation |
229 | */ | ||
230 | |||
231 | |||
232 | /* Translate an OF address block into a CPU physical address | ||
228 | */ | 233 | */ |
229 | #define OF_BAD_ADDR ((u64)-1) | 234 | #define OF_BAD_ADDR ((u64)-1) |
230 | extern u64 of_translate_address(struct device_node *np, u32 *addr); | 235 | extern u64 of_translate_address(struct device_node *np, u32 *addr); |
231 | extern u32 *of_get_address(struct device_node *dev, int index, u64 *size); | ||
232 | extern u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size); | ||
233 | 236 | ||
237 | /* Extract an address from a device, returns the region size and | ||
238 | * the address space flags too. The PCI version uses a BAR number | ||
239 | * instead of an absolute index | ||
240 | */ | ||
241 | extern u32 *of_get_address(struct device_node *dev, int index, | ||
242 | u64 *size, unsigned int *flags); | ||
243 | extern u32 *of_get_pci_address(struct device_node *dev, int bar_no, | ||
244 | u64 *size, unsigned int *flags); | ||
245 | |||
246 | /* Get an address as a resource. Note that if your address is | ||
247 | * a PIO address, the conversion will fail if the physical address | ||
248 | * can't be internally converted to an IO token with | ||
249 | * pci_address_to_pio(), that is because it's either called to early | ||
250 | * or it can't be matched to any host bridge IO space | ||
251 | */ | ||
252 | extern int of_address_to_resource(struct device_node *dev, int index, | ||
253 | struct resource *r); | ||
254 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
255 | struct resource *r); | ||
234 | 256 | ||
235 | #endif /* __KERNEL__ */ | 257 | #endif /* __KERNEL__ */ |
236 | #endif /* _POWERPC_PROM_H */ | 258 | #endif /* _POWERPC_PROM_H */ |
diff --git a/include/asm-ppc/pci-bridge.h b/include/asm-ppc/pci-bridge.h index e58c78f90a5a..95672ddfe528 100644 --- a/include/asm-ppc/pci-bridge.h +++ b/include/asm-ppc/pci-bridge.h | |||
@@ -137,5 +137,14 @@ static inline unsigned char bridge_swizzle(unsigned char pin, | |||
137 | */ | 137 | */ |
138 | extern int pciauto_bus_scan(struct pci_controller *, int); | 138 | extern int pciauto_bus_scan(struct pci_controller *, int); |
139 | 139 | ||
140 | #ifdef CONFIG_PCI | ||
141 | extern unsigned int pci_address_to_pio(phys_addr_t address); | ||
142 | #else | ||
143 | static inline unsigned int pci_address_to_pio(phys_addr_t address) | ||
144 | { | ||
145 | return (unsigned int)-1; | ||
146 | } | ||
147 | #endif | ||
148 | |||
140 | #endif | 149 | #endif |
141 | #endif /* __KERNEL__ */ | 150 | #endif /* __KERNEL__ */ |
diff --git a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h index a10a2d64b300..eb317a0806e4 100644 --- a/include/asm-ppc/prom.h +++ b/include/asm-ppc/prom.h | |||
@@ -138,12 +138,34 @@ extern unsigned long sub_reloc_offset(unsigned long); | |||
138 | 138 | ||
139 | 139 | ||
140 | /* | 140 | /* |
141 | * Address translation function(s) | 141 | * OF address retreival & translation |
142 | */ | ||
143 | |||
144 | |||
145 | /* Translate an OF address block into a CPU physical address | ||
142 | */ | 146 | */ |
143 | #define OF_BAD_ADDR ((u64)-1) | 147 | #define OF_BAD_ADDR ((u64)-1) |
144 | extern u64 of_translate_address(struct device_node *np, u32 *addr); | 148 | extern u64 of_translate_address(struct device_node *np, u32 *addr); |
145 | extern u32 *of_get_address(struct device_node *dev, int index, u64 *size); | 149 | |
146 | extern u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size); | 150 | /* Extract an address from a device, returns the region size and |
151 | * the address space flags too. The PCI version uses a BAR number | ||
152 | * instead of an absolute index | ||
153 | */ | ||
154 | extern u32 *of_get_address(struct device_node *dev, int index, | ||
155 | u64 *size, unsigned int *flags); | ||
156 | extern u32 *of_get_pci_address(struct device_node *dev, int bar_no, | ||
157 | u64 *size, unsigned int *flags); | ||
158 | |||
159 | /* Get an address as a resource. Note that if your address is | ||
160 | * a PIO address, the conversion will fail if the physical address | ||
161 | * can't be internally converted to an IO token with | ||
162 | * pci_address_to_pio(), that is because it's either called to early | ||
163 | * or it can't be matched to any host bridge IO space | ||
164 | */ | ||
165 | extern int of_address_to_resource(struct device_node *dev, int index, | ||
166 | struct resource *r); | ||
167 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
168 | struct resource *r); | ||
147 | 169 | ||
148 | 170 | ||
149 | #endif /* _PPC_PROM_H */ | 171 | #endif /* _PPC_PROM_H */ |