aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-26 02:36:55 -0400
committerPaul Mackerras <paulus@samba.org>2005-10-26 02:36:55 -0400
commit25635c71e44111a6bd48f342e144e2fc02d0a314 (patch)
tree794b0428a72fefa53a0d9d709247a60a5b4527da
parentd9953105ce000abcfa988d0c160b2662186f5879 (diff)
ppc: Use the indirect_pci.c from arch/powerpc/sysdev
This defines a CONFIG_INDIRECT_PCI symbol to control whether it gets used or not, and fixes the Kconfig to select that symbol for platforms that need it. Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/Kconfig10
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig8
-rw-r--r--arch/powerpc/sysdev/Makefile3
-rw-r--r--arch/ppc/Kconfig18
-rw-r--r--arch/ppc/Makefile3
-rw-r--r--arch/ppc/syslib/Makefile38
-rw-r--r--arch/ppc/syslib/indirect_pci.c134
7 files changed, 58 insertions, 156 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 27f122e1f849..a3451d5bb788 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -280,11 +280,13 @@ config PPC_PSERIES
280config PPC_CHRP 280config PPC_CHRP
281 bool " Common Hardware Reference Platform (CHRP) based machines" 281 bool " Common Hardware Reference Platform (CHRP) based machines"
282 depends on PPC_MULTIPLATFORM && PPC32 282 depends on PPC_MULTIPLATFORM && PPC32
283 select PPC_INDIRECT_PCI
283 default y 284 default y
284 285
285config PPC_PMAC 286config PPC_PMAC
286 bool " Apple PowerMac based machines" 287 bool " Apple PowerMac based machines"
287 depends on PPC_MULTIPLATFORM 288 depends on PPC_MULTIPLATFORM
289 select PPC_INDIRECT_PCI if PPC32
288 default y 290 default y
289 291
290config PPC_PMAC64 292config PPC_PMAC64
@@ -296,6 +298,7 @@ config PPC_PMAC64
296config PPC_PREP 298config PPC_PREP
297 bool " PowerPC Reference Platform (PReP) based machines" 299 bool " PowerPC Reference Platform (PReP) based machines"
298 depends on PPC_MULTIPLATFORM && PPC32 300 depends on PPC_MULTIPLATFORM && PPC32
301 select PPC_INDIRECT_PCI
299 default y 302 default y
300 303
301config PPC_MAPLE 304config PPC_MAPLE
@@ -637,6 +640,12 @@ config GENERIC_ISA_DMA
637 depends on PPC64 || POWER4 || 6xx && !CPM2 640 depends on PPC64 || POWER4 || 6xx && !CPM2
638 default y 641 default y
639 642
643config PPC_INDIRECT_PCI
644 bool
645 depends on PCI
646 default y if 40x || 44x || 85xx || 83xx
647 default n
648
640config EISA 649config EISA
641 bool 650 bool
642 651
@@ -677,6 +686,7 @@ config PCI_QSPAN
677config PCI_8260 686config PCI_8260
678 bool 687 bool
679 depends on PCI && 8260 688 depends on PCI && 8260
689 select PPC_INDIRECT_PCI
680 default y 690 default y
681 691
682config 8260_PCI9 692config 8260_PCI9
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 2d755b79d51f..784b41e19465 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -27,6 +27,7 @@ config CHESTNUT
27 27
28config SPRUCE 28config SPRUCE
29 bool "IBM-Spruce" 29 bool "IBM-Spruce"
30 select PPC_INDIRECT_PCI
30 31
31config HDPU 32config HDPU
32 bool "Sky-HDPU" 33 bool "Sky-HDPU"
@@ -50,15 +51,19 @@ config LOPEC
50 51
51config MVME5100 52config MVME5100
52 bool "Motorola-MVME5100" 53 bool "Motorola-MVME5100"
54 select PPC_INDIRECT_PCI
53 55
54config PPLUS 56config PPLUS
55 bool "Motorola-PowerPlus" 57 bool "Motorola-PowerPlus"
58 select PPC_INDIRECT_PCI
56 59
57config PRPMC750 60config PRPMC750
58 bool "Motorola-PrPMC750" 61 bool "Motorola-PrPMC750"
62 select PPC_INDIRECT_PCI
59 63
60config PRPMC800 64config PRPMC800
61 bool "Motorola-PrPMC800" 65 bool "Motorola-PrPMC800"
66 select PPC_INDIRECT_PCI
62 67
63config SANDPOINT 68config SANDPOINT
64 bool "Motorola-Sandpoint" 69 bool "Motorola-Sandpoint"
@@ -74,6 +79,7 @@ config PAL4
74 79
75config GEMINI 80config GEMINI
76 bool "Synergy-Gemini" 81 bool "Synergy-Gemini"
82 select PPC_INDIRECT_PCI
77 depends on BROKEN 83 depends on BROKEN
78 help 84 help
79 Select Gemini if configuring for a Synergy Microsystems' Gemini 85 Select Gemini if configuring for a Synergy Microsystems' Gemini
@@ -226,6 +232,7 @@ config MV64360 # Really MV64360 & MV64460
226config MV64X60 232config MV64X60
227 bool 233 bool
228 depends on (GT64260 || MV64360) 234 depends on (GT64260 || MV64360)
235 select PPC_INDIRECT_PCI
229 default y 236 default y
230 237
231menu "Set bridge options" 238menu "Set bridge options"
@@ -274,6 +281,7 @@ config EPIC_SERIAL_MODE
274config MPC10X_BRIDGE 281config MPC10X_BRIDGE
275 bool 282 bool
276 depends on POWERPMC250 || LOPEC || SANDPOINT 283 depends on POWERPMC250 || LOPEC || SANDPOINT
284 select PPC_INDIRECT_PCI
277 default y 285 default y
278 286
279config MPC10X_OPENPIC 287config MPC10X_OPENPIC
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index c649f03acf68..e66fef652fac 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -1,3 +1,2 @@
1obj-$(CONFIG_MPIC) += mpic.o 1obj-$(CONFIG_MPIC) += mpic.o
2indirectpci-$(CONFIG_PPC_PMAC) = indirect_pci.o 2obj-$(CONFIG_PPC_INDIRECT_PCI) += indirect_pci.o
3obj-$(CONFIG_PPC32) += $(indirectpci-y)
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index ed9c9727d75f..e3efaf47d083 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -568,6 +568,7 @@ config CHESTNUT
568 568
569config SPRUCE 569config SPRUCE
570 bool "IBM-Spruce" 570 bool "IBM-Spruce"
571 select PPC_INDIRECT_PCI
571 572
572config HDPU 573config HDPU
573 bool "Sky-HDPU" 574 bool "Sky-HDPU"
@@ -591,15 +592,19 @@ config LOPEC
591 592
592config MVME5100 593config MVME5100
593 bool "Motorola-MVME5100" 594 bool "Motorola-MVME5100"
595 select PPC_INDIRECT_PCI
594 596
595config PPLUS 597config PPLUS
596 bool "Motorola-PowerPlus" 598 bool "Motorola-PowerPlus"
599 select PPC_INDIRECT_PCI
597 600
598config PRPMC750 601config PRPMC750
599 bool "Motorola-PrPMC750" 602 bool "Motorola-PrPMC750"
603 select PPC_INDIRECT_PCI
600 604
601config PRPMC800 605config PRPMC800
602 bool "Motorola-PrPMC800" 606 bool "Motorola-PrPMC800"
607 select PPC_INDIRECT_PCI
603 608
604config SANDPOINT 609config SANDPOINT
605 bool "Motorola-Sandpoint" 610 bool "Motorola-Sandpoint"
@@ -616,6 +621,7 @@ config PAL4
616config GEMINI 621config GEMINI
617 bool "Synergy-Gemini" 622 bool "Synergy-Gemini"
618 depends on BROKEN 623 depends on BROKEN
624 select PPC_INDIRECT_PCI
619 help 625 help
620 Select Gemini if configuring for a Synergy Microsystems' Gemini 626 Select Gemini if configuring for a Synergy Microsystems' Gemini
621 series Single Board Computer. More information is available at: 627 series Single Board Computer. More information is available at:
@@ -749,11 +755,13 @@ config CPM2
749config PPC_CHRP 755config PPC_CHRP
750 bool " Common Hardware Reference Platform (CHRP) based machines" 756 bool " Common Hardware Reference Platform (CHRP) based machines"
751 depends on PPC_MULTIPLATFORM 757 depends on PPC_MULTIPLATFORM
758 select PPC_INDIRECT_PCI
752 default y 759 default y
753 760
754config PPC_PMAC 761config PPC_PMAC
755 bool " Apple PowerMac based machines" 762 bool " Apple PowerMac based machines"
756 depends on PPC_MULTIPLATFORM 763 depends on PPC_MULTIPLATFORM
764 select PPC_INDIRECT_PCI
757 default y 765 default y
758 766
759config PPC_PMAC64 767config PPC_PMAC64
@@ -764,6 +772,7 @@ config PPC_PMAC64
764config PPC_PREP 772config PPC_PREP
765 bool " PowerPC Reference Platform (PReP) based machines" 773 bool " PowerPC Reference Platform (PReP) based machines"
766 depends on PPC_MULTIPLATFORM 774 depends on PPC_MULTIPLATFORM
775 select PPC_INDIRECT_PCI
767 default y 776 default y
768 777
769config PPC_OF 778config PPC_OF
@@ -797,6 +806,7 @@ config MV64360 # Really MV64360 & MV64460
797config MV64X60 806config MV64X60
798 bool 807 bool
799 depends on (GT64260 || MV64360) 808 depends on (GT64260 || MV64360)
809 select PPC_INDIRECT_PCI
800 default y 810 default y
801 811
802menu "Set bridge options" 812menu "Set bridge options"
@@ -845,6 +855,7 @@ config EPIC_SERIAL_MODE
845config MPC10X_BRIDGE 855config MPC10X_BRIDGE
846 bool 856 bool
847 depends on POWERPMC250 || LOPEC || SANDPOINT 857 depends on POWERPMC250 || LOPEC || SANDPOINT
858 select PPC_INDIRECT_PCI
848 default y 859 default y
849 860
850config MPC10X_OPENPIC 861config MPC10X_OPENPIC
@@ -1139,6 +1150,12 @@ config GENERIC_ISA_DMA
1139 depends on POWER3 || POWER4 || 6xx && !CPM2 1150 depends on POWER3 || POWER4 || 6xx && !CPM2
1140 default y 1151 default y
1141 1152
1153config PPC_INDIRECT_PCI
1154 bool
1155 depends on PCI
1156 default y if 40x || 44x || 85xx || 83xx
1157 default n
1158
1142config EISA 1159config EISA
1143 bool 1160 bool
1144 help 1161 help
@@ -1182,6 +1199,7 @@ config PCI_QSPAN
1182config PCI_8260 1199config PCI_8260
1183 bool 1200 bool
1184 depends on PCI && 8260 1201 depends on PCI && 8260
1202 select PPC_INDIRECT_PCI
1185 default y 1203 default y
1186 1204
1187config 8260_PCI9 1205config 8260_PCI9
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index aedc9ae13b2a..121d2347b89f 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -61,7 +61,8 @@ head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
61 61
62core-y += arch/ppc/kernel/ arch/powerpc/kernel/ \ 62core-y += arch/ppc/kernel/ arch/powerpc/kernel/ \
63 arch/ppc/platforms/ \ 63 arch/ppc/platforms/ \
64 arch/ppc/mm/ arch/ppc/lib/ arch/ppc/syslib/ 64 arch/ppc/mm/ arch/ppc/lib/ \
65 arch/ppc/syslib/ arch/powerpc/sysdev/
65core-$(CONFIG_4xx) += arch/ppc/platforms/4xx/ 66core-$(CONFIG_4xx) += arch/ppc/platforms/4xx/
66core-$(CONFIG_83xx) += arch/ppc/platforms/83xx/ 67core-$(CONFIG_83xx) += arch/ppc/platforms/83xx/
67core-$(CONFIG_85xx) += arch/ppc/platforms/85xx/ 68core-$(CONFIG_85xx) += arch/ppc/platforms/85xx/
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index f6a2f1938bfa..5739a19b9ed9 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -31,7 +31,7 @@ obj-$(CONFIG_GEN_RTC) += todc_time.o
31obj-$(CONFIG_PPC4xx_DMA) += ppc4xx_dma.o 31obj-$(CONFIG_PPC4xx_DMA) += ppc4xx_dma.o
32obj-$(CONFIG_PPC4xx_EDMA) += ppc4xx_sgdma.o 32obj-$(CONFIG_PPC4xx_EDMA) += ppc4xx_sgdma.o
33ifeq ($(CONFIG_40x),y) 33ifeq ($(CONFIG_40x),y)
34obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o ppc405_pci.o 34obj-$(CONFIG_PCI) += pci_auto.o ppc405_pci.o
35endif 35endif
36endif 36endif
37obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \ 37obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \
@@ -40,43 +40,43 @@ ifeq ($(CONFIG_8xx),y)
40obj-$(CONFIG_PCI) += qspan_pci.o i8259.o 40obj-$(CONFIG_PCI) += qspan_pci.o i8259.o
41endif 41endif
42obj-$(CONFIG_PPC_OF) += prom_init.o prom.o 42obj-$(CONFIG_PPC_OF) += prom_init.o prom.o
43obj-$(CONFIG_PPC_PMAC) += open_pic.o indirect_pci.o 43obj-$(CONFIG_PPC_PMAC) += open_pic.o
44obj-$(CONFIG_POWER4) += open_pic2.o 44obj-$(CONFIG_POWER4) += open_pic2.o
45obj-$(CONFIG_PPC_CHRP) += open_pic.o indirect_pci.o i8259.o 45obj-$(CONFIG_PPC_CHRP) += open_pic.o i8259.o
46obj-$(CONFIG_PPC_PREP) += open_pic.o indirect_pci.o i8259.o todc_time.o 46obj-$(CONFIG_PPC_PREP) += open_pic.o i8259.o todc_time.o
47obj-$(CONFIG_BAMBOO) += indirect_pci.o pci_auto.o todc_time.o 47obj-$(CONFIG_BAMBOO) += pci_auto.o todc_time.o
48obj-$(CONFIG_CPCI690) += todc_time.o pci_auto.o 48obj-$(CONFIG_CPCI690) += todc_time.o pci_auto.o
49obj-$(CONFIG_EBONY) += indirect_pci.o pci_auto.o todc_time.o 49obj-$(CONFIG_EBONY) += pci_auto.o todc_time.o
50obj-$(CONFIG_EV64260) += todc_time.o pci_auto.o 50obj-$(CONFIG_EV64260) += todc_time.o pci_auto.o
51obj-$(CONFIG_CHESTNUT) += mv64360_pic.o pci_auto.o 51obj-$(CONFIG_CHESTNUT) += mv64360_pic.o pci_auto.o
52obj-$(CONFIG_GEMINI) += open_pic.o indirect_pci.o 52obj-$(CONFIG_GEMINI) += open_pic.o
53obj-$(CONFIG_GT64260) += gt64260_pic.o 53obj-$(CONFIG_GT64260) += gt64260_pic.o
54obj-$(CONFIG_LOPEC) += i8259.o pci_auto.o todc_time.o 54obj-$(CONFIG_LOPEC) += i8259.o pci_auto.o todc_time.o
55obj-$(CONFIG_HDPU) += pci_auto.o 55obj-$(CONFIG_HDPU) += pci_auto.o
56obj-$(CONFIG_LUAN) += indirect_pci.o pci_auto.o todc_time.o 56obj-$(CONFIG_LUAN) += pci_auto.o todc_time.o
57obj-$(CONFIG_KATANA) += pci_auto.o 57obj-$(CONFIG_KATANA) += pci_auto.o
58obj-$(CONFIG_MV64360) += mv64360_pic.o 58obj-$(CONFIG_MV64360) += mv64360_pic.o
59obj-$(CONFIG_MV64X60) += mv64x60.o mv64x60_win.o indirect_pci.o 59obj-$(CONFIG_MV64X60) += mv64x60.o mv64x60_win.o
60obj-$(CONFIG_MVME5100) += open_pic.o todc_time.o indirect_pci.o \ 60obj-$(CONFIG_MVME5100) += open_pic.o todc_time.o \
61 pci_auto.o hawk_common.o 61 pci_auto.o hawk_common.o
62obj-$(CONFIG_MVME5100_IPMC761_PRESENT) += i8259.o 62obj-$(CONFIG_MVME5100_IPMC761_PRESENT) += i8259.o
63obj-$(CONFIG_OCOTEA) += indirect_pci.o pci_auto.o todc_time.o 63obj-$(CONFIG_OCOTEA) += pci_auto.o todc_time.o
64obj-$(CONFIG_PAL4) += cpc700_pic.o 64obj-$(CONFIG_PAL4) += cpc700_pic.o
65obj-$(CONFIG_POWERPMC250) += pci_auto.o 65obj-$(CONFIG_POWERPMC250) += pci_auto.o
66obj-$(CONFIG_PPLUS) += hawk_common.o open_pic.o i8259.o \ 66obj-$(CONFIG_PPLUS) += hawk_common.o open_pic.o i8259.o \
67 indirect_pci.o todc_time.o pci_auto.o 67 todc_time.o pci_auto.o
68obj-$(CONFIG_PRPMC750) += open_pic.o indirect_pci.o pci_auto.o \ 68obj-$(CONFIG_PRPMC750) += open_pic.o pci_auto.o \
69 hawk_common.o 69 hawk_common.o
70obj-$(CONFIG_HARRIER) += harrier.o 70obj-$(CONFIG_HARRIER) += harrier.o
71obj-$(CONFIG_PRPMC800) += open_pic.o indirect_pci.o pci_auto.o 71obj-$(CONFIG_PRPMC800) += open_pic.o pci_auto.o
72obj-$(CONFIG_RADSTONE_PPC7D) += i8259.o pci_auto.o 72obj-$(CONFIG_RADSTONE_PPC7D) += i8259.o pci_auto.o
73obj-$(CONFIG_SANDPOINT) += i8259.o pci_auto.o todc_time.o 73obj-$(CONFIG_SANDPOINT) += i8259.o pci_auto.o todc_time.o
74obj-$(CONFIG_SBC82xx) += todc_time.o 74obj-$(CONFIG_SBC82xx) += todc_time.o
75obj-$(CONFIG_SPRUCE) += cpc700_pic.o indirect_pci.o pci_auto.o \ 75obj-$(CONFIG_SPRUCE) += cpc700_pic.o pci_auto.o \
76 todc_time.o 76 todc_time.o
77obj-$(CONFIG_8260) += m8260_setup.o pq2_devices.o pq2_sys.o \ 77obj-$(CONFIG_8260) += m8260_setup.o pq2_devices.o pq2_sys.o \
78 ppc_sys.o 78 ppc_sys.o
79obj-$(CONFIG_PCI_8260) += m82xx_pci.o indirect_pci.o pci_auto.o 79obj-$(CONFIG_PCI_8260) += m82xx_pci.o pci_auto.o
80obj-$(CONFIG_8260_PCI9) += m8260_pci_erratum9.o 80obj-$(CONFIG_8260_PCI9) += m8260_pci_erratum9.o
81obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o 81obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o
82ifeq ($(CONFIG_PPC_GEN550),y) 82ifeq ($(CONFIG_PPC_GEN550),y)
@@ -87,7 +87,7 @@ ifeq ($(CONFIG_SERIAL_MPSC_CONSOLE),y)
87obj-$(CONFIG_SERIAL_TEXT_DEBUG) += mv64x60_dbg.o 87obj-$(CONFIG_SERIAL_TEXT_DEBUG) += mv64x60_dbg.o
88endif 88endif
89obj-$(CONFIG_BOOTX_TEXT) += btext.o 89obj-$(CONFIG_BOOTX_TEXT) += btext.o
90obj-$(CONFIG_MPC10X_BRIDGE) += mpc10x_common.o indirect_pci.o ppc_sys.o 90obj-$(CONFIG_MPC10X_BRIDGE) += mpc10x_common.o ppc_sys.o
91obj-$(CONFIG_MPC10X_OPENPIC) += open_pic.o 91obj-$(CONFIG_MPC10X_OPENPIC) += open_pic.o
92obj-$(CONFIG_40x) += dcr.o 92obj-$(CONFIG_40x) += dcr.o
93obj-$(CONFIG_BOOKE) += dcr.o 93obj-$(CONFIG_BOOKE) += dcr.o
@@ -95,12 +95,12 @@ obj-$(CONFIG_85xx) += open_pic.o ppc85xx_common.o ppc85xx_setup.o \
95 ppc_sys.o i8259.o mpc85xx_sys.o \ 95 ppc_sys.o i8259.o mpc85xx_sys.o \
96 mpc85xx_devices.o 96 mpc85xx_devices.o
97ifeq ($(CONFIG_85xx),y) 97ifeq ($(CONFIG_85xx),y)
98obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o 98obj-$(CONFIG_PCI) += pci_auto.o
99endif 99endif
100obj-$(CONFIG_83xx) += ipic.o ppc83xx_setup.o ppc_sys.o \ 100obj-$(CONFIG_83xx) += ipic.o ppc83xx_setup.o ppc_sys.o \
101 mpc83xx_sys.o mpc83xx_devices.o 101 mpc83xx_sys.o mpc83xx_devices.o
102ifeq ($(CONFIG_83xx),y) 102ifeq ($(CONFIG_83xx),y)
103obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o 103obj-$(CONFIG_PCI) += pci_auto.o
104endif 104endif
105obj-$(CONFIG_MPC8548_CDS) += todc_time.o 105obj-$(CONFIG_MPC8548_CDS) += todc_time.o
106obj-$(CONFIG_MPC8555_CDS) += todc_time.o 106obj-$(CONFIG_MPC8555_CDS) += todc_time.o
diff --git a/arch/ppc/syslib/indirect_pci.c b/arch/ppc/syslib/indirect_pci.c
deleted file mode 100644
index e71488469704..000000000000
--- a/arch/ppc/syslib/indirect_pci.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Support for indirect PCI bridges.
3 *
4 * Copyright (C) 1998 Gabriel Paubert.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/pci.h>
14#include <linux/delay.h>
15#include <linux/string.h>
16#include <linux/init.h>
17
18#include <asm/io.h>
19#include <asm/prom.h>
20#include <asm/pci-bridge.h>
21#include <asm/machdep.h>
22
23#ifdef CONFIG_PPC_INDIRECT_PCI_BE
24#define PCI_CFG_OUT out_be32
25#else
26#define PCI_CFG_OUT out_le32
27#endif
28
29static int
30indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
31 int len, u32 *val)
32{
33 struct pci_controller *hose = bus->sysdata;
34 volatile void __iomem *cfg_data;
35 u8 cfg_type = 0;
36
37 if (ppc_md.pci_exclude_device)
38 if (ppc_md.pci_exclude_device(bus->number, devfn))
39 return PCIBIOS_DEVICE_NOT_FOUND;
40
41 if (hose->set_cfg_type)
42 if (bus->number != hose->first_busno)
43 cfg_type = 1;
44
45 PCI_CFG_OUT(hose->cfg_addr,
46 (0x80000000 | ((bus->number - hose->bus_offset) << 16)
47 | (devfn << 8) | ((offset & 0xfc) | cfg_type)));
48
49 /*
50 * Note: the caller has already checked that offset is
51 * suitably aligned and that len is 1, 2 or 4.
52 */
53 cfg_data = hose->cfg_data + (offset & 3);
54 switch (len) {
55 case 1:
56 *val = in_8(cfg_data);
57 break;
58 case 2:
59 *val = in_le16(cfg_data);
60 break;
61 default:
62 *val = in_le32(cfg_data);
63 break;
64 }
65 return PCIBIOS_SUCCESSFUL;
66}
67
68static int
69indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
70 int len, u32 val)
71{
72 struct pci_controller *hose = bus->sysdata;
73 volatile void __iomem *cfg_data;
74 u8 cfg_type = 0;
75
76 if (ppc_md.pci_exclude_device)
77 if (ppc_md.pci_exclude_device(bus->number, devfn))
78 return PCIBIOS_DEVICE_NOT_FOUND;
79
80 if (hose->set_cfg_type)
81 if (bus->number != hose->first_busno)
82 cfg_type = 1;
83
84 PCI_CFG_OUT(hose->cfg_addr,
85 (0x80000000 | ((bus->number - hose->bus_offset) << 16)
86 | (devfn << 8) | ((offset & 0xfc) | cfg_type)));
87
88 /*
89 * Note: the caller has already checked that offset is
90 * suitably aligned and that len is 1, 2 or 4.
91 */
92 cfg_data = hose->cfg_data + (offset & 3);
93 switch (len) {
94 case 1:
95 out_8(cfg_data, val);
96 break;
97 case 2:
98 out_le16(cfg_data, val);
99 break;
100 default:
101 out_le32(cfg_data, val);
102 break;
103 }
104 return PCIBIOS_SUCCESSFUL;
105}
106
107static struct pci_ops indirect_pci_ops =
108{
109 indirect_read_config,
110 indirect_write_config
111};
112
113void __init
114setup_indirect_pci_nomap(struct pci_controller* hose, void __iomem * cfg_addr,
115 void __iomem * cfg_data)
116{
117 hose->cfg_addr = cfg_addr;
118 hose->cfg_data = cfg_data;
119 hose->ops = &indirect_pci_ops;
120}
121
122void __init
123setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
124{
125 unsigned long base = cfg_addr & PAGE_MASK;
126 void __iomem *mbase, *addr, *data;
127
128 mbase = ioremap(base, PAGE_SIZE);
129 addr = mbase + (cfg_addr & ~PAGE_MASK);
130 if ((cfg_data & PAGE_MASK) != base)
131 mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE);
132 data = mbase + (cfg_data & ~PAGE_MASK);
133 setup_indirect_pci_nomap(hose, addr, data);
134}