diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-03-09 00:55:49 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 04:55:11 -0400 |
commit | 9fd8b64761d3fe7e4ef567161be57e4234af5c1c (patch) | |
tree | 39eb4744d6f36c003bb4e9fea77c7c9921bbef2b /arch/sparc64/kernel/pci_schizo.c | |
parent | 01f94c4a6ced476ce69b895426fc29bfc48c69bd (diff) |
[SPARC64]: Consolidate PCI mem/io resource determination.
It can be done for every PCI configuration using OF properties.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_schizo.c')
-rw-r--r-- | arch/sparc64/kernel/pci_schizo.c | 81 |
1 files changed, 3 insertions, 78 deletions
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index 332cfd9736b7..79ad2688317b 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* $Id: pci_schizo.c,v 1.24 2002/01/23 11:27:32 davem Exp $ | 1 | /* pci_schizo.c: SCHIZO/TOMATILLO specific PCI controller support. |
2 | * pci_schizo.c: SCHIZO/TOMATILLO specific PCI controller support. | ||
3 | * | 2 | * |
4 | * Copyright (C) 2001, 2002, 2003 David S. Miller (davem@redhat.com) | 3 | * Copyright (C) 2001, 2002, 2003, 2007 David S. Miller (davem@davemloft.net) |
5 | */ | 4 | */ |
6 | 5 | ||
7 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
@@ -1304,79 +1303,6 @@ static void schizo_resource_adjust(struct pci_dev *pdev, | |||
1304 | res->end += root->start; | 1303 | res->end += root->start; |
1305 | } | 1304 | } |
1306 | 1305 | ||
1307 | /* Use ranges property to determine where PCI MEM, I/O, and Config | ||
1308 | * space are for this PCI bus module. | ||
1309 | */ | ||
1310 | static void schizo_determine_mem_io_space(struct pci_pbm_info *pbm) | ||
1311 | { | ||
1312 | int i, saw_cfg, saw_mem, saw_io; | ||
1313 | |||
1314 | saw_cfg = saw_mem = saw_io = 0; | ||
1315 | for (i = 0; i < pbm->num_pbm_ranges; i++) { | ||
1316 | struct linux_prom_pci_ranges *pr = &pbm->pbm_ranges[i]; | ||
1317 | unsigned long a; | ||
1318 | int type; | ||
1319 | |||
1320 | type = (pr->child_phys_hi >> 24) & 0x3; | ||
1321 | a = (((unsigned long)pr->parent_phys_hi << 32UL) | | ||
1322 | ((unsigned long)pr->parent_phys_lo << 0UL)); | ||
1323 | |||
1324 | switch (type) { | ||
1325 | case 0: | ||
1326 | /* PCI config space, 16MB */ | ||
1327 | pbm->config_space = a; | ||
1328 | saw_cfg = 1; | ||
1329 | break; | ||
1330 | |||
1331 | case 1: | ||
1332 | /* 16-bit IO space, 16MB */ | ||
1333 | pbm->io_space.start = a; | ||
1334 | pbm->io_space.end = a + ((16UL*1024UL*1024UL) - 1UL); | ||
1335 | pbm->io_space.flags = IORESOURCE_IO; | ||
1336 | saw_io = 1; | ||
1337 | break; | ||
1338 | |||
1339 | case 2: | ||
1340 | /* 32-bit MEM space, 2GB */ | ||
1341 | pbm->mem_space.start = a; | ||
1342 | pbm->mem_space.end = a + (0x80000000UL - 1UL); | ||
1343 | pbm->mem_space.flags = IORESOURCE_MEM; | ||
1344 | saw_mem = 1; | ||
1345 | break; | ||
1346 | |||
1347 | default: | ||
1348 | break; | ||
1349 | }; | ||
1350 | } | ||
1351 | |||
1352 | if (!saw_cfg || !saw_io || !saw_mem) { | ||
1353 | prom_printf("%s: Fatal error, missing %s PBM range.\n", | ||
1354 | pbm->name, | ||
1355 | ((!saw_cfg ? | ||
1356 | "CFG" : | ||
1357 | (!saw_io ? | ||
1358 | "IO" : "MEM")))); | ||
1359 | prom_halt(); | ||
1360 | } | ||
1361 | |||
1362 | printk("%s: PCI CFG[%lx] IO[%lx] MEM[%lx]\n", | ||
1363 | pbm->name, | ||
1364 | pbm->config_space, | ||
1365 | pbm->io_space.start, | ||
1366 | pbm->mem_space.start); | ||
1367 | } | ||
1368 | |||
1369 | static void pbm_register_toplevel_resources(struct pci_controller_info *p, | ||
1370 | struct pci_pbm_info *pbm) | ||
1371 | { | ||
1372 | pbm->io_space.name = pbm->mem_space.name = pbm->name; | ||
1373 | |||
1374 | request_resource(&ioport_resource, &pbm->io_space); | ||
1375 | request_resource(&iomem_resource, &pbm->mem_space); | ||
1376 | pci_register_legacy_regions(&pbm->io_space, | ||
1377 | &pbm->mem_space); | ||
1378 | } | ||
1379 | |||
1380 | #define SCHIZO_STRBUF_CONTROL (0x02800UL) | 1306 | #define SCHIZO_STRBUF_CONTROL (0x02800UL) |
1381 | #define SCHIZO_STRBUF_FLUSH (0x02808UL) | 1307 | #define SCHIZO_STRBUF_FLUSH (0x02808UL) |
1382 | #define SCHIZO_STRBUF_FSYNC (0x02810UL) | 1308 | #define SCHIZO_STRBUF_FSYNC (0x02810UL) |
@@ -1679,8 +1605,7 @@ static void schizo_pbm_init(struct pci_controller_info *p, | |||
1679 | pbm->num_pbm_ranges = | 1605 | pbm->num_pbm_ranges = |
1680 | (len / sizeof(struct linux_prom_pci_ranges)); | 1606 | (len / sizeof(struct linux_prom_pci_ranges)); |
1681 | 1607 | ||
1682 | schizo_determine_mem_io_space(pbm); | 1608 | pci_determine_mem_io_space(pbm); |
1683 | pbm_register_toplevel_resources(p, pbm); | ||
1684 | 1609 | ||
1685 | pbm->pbm_intmap = of_get_property(dp, "interrupt-map", &len); | 1610 | pbm->pbm_intmap = of_get_property(dp, "interrupt-map", &len); |
1686 | if (pbm->pbm_intmap) { | 1611 | if (pbm->pbm_intmap) { |