Skip to content

Commit 2e56ff2

Browse files
committed
[POWERPC] Make endianess of cfg_addr for indirect pci ops runtime
Make it so we do a runtime check to know if we need to write cfg_addr as big or little endian. This is needed if we want to allow 86xx support to co-exist in the same kernel as other 6xx PPCs. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
1 parent d526996 commit 2e56ff2

12 files changed

Lines changed: 29 additions & 31 deletions

File tree

‎arch/powerpc/Kconfig‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,6 @@ config PPC_INDIRECT_PCI
411411
default y if 40x || 44x
412412
default n
413413

414-
config PPC_INDIRECT_PCI_BE
415-
bool
416-
depends PPC_INDIRECT_PCI
417-
default n
418-
419414
config EISA
420415
bool
421416

‎arch/powerpc/platforms/82xx/mpc82xx_ads.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ static void __init mpc82xx_add_bridge(struct device_node *np)
553553

554554
setup_indirect_pci(hose,
555555
r.start + offsetof(pci_cpm2_t, pci_cfg_addr),
556-
r.start + offsetof(pci_cpm2_t, pci_cfg_data));
556+
r.start + offsetof(pci_cpm2_t, pci_cfg_data),
557+
0);
557558

558559
pci_process_bridge_OF_ranges(hose, np, 1);
559560
}

‎arch/powerpc/platforms/83xx/pci.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
7474
*/
7575
/* PCI 1 */
7676
if ((rsrc.start & 0xfffff) == 0x8500) {
77-
setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304);
77+
setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304, 0);
7878
}
7979
/* PCI 2 */
8080
if ((rsrc.start & 0xfffff) == 0x8600) {
81-
setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384);
81+
setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384, 0);
8282
primary = 0;
8383
}
8484

‎arch/powerpc/platforms/85xx/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ config MPC85xx
5151
bool
5252
select PPC_UDBG_16550
5353
select PPC_INDIRECT_PCI if PCI
54-
select PPC_INDIRECT_PCI_BE if PCI
5554
select MPIC
5655
select FSL_PCI if PCI
5756
select SERIAL_8250_SHARE_IRQ if SERIAL_8250

‎arch/powerpc/platforms/86xx/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ endchoice
1414

1515
config MPC8641
1616
bool
17-
select PPC_INDIRECT_PCI_BE if PCI
1817
select FSL_PCI if PCI
1918
select PPC_UDBG_16550
2019
select MPIC

‎arch/powerpc/platforms/chrp/pci.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ setup_python(struct pci_controller *hose, struct device_node *dev)
181181
}
182182
iounmap(reg);
183183

184-
setup_indirect_pci(hose, r.start + 0xf8000, r.start + 0xf8010);
184+
setup_indirect_pci(hose, r.start + 0xf8000, r.start + 0xf8010, 0);
185185
}
186186

187187
/* Marvell Discovery II based Pegasos 2 */
@@ -277,13 +277,14 @@ chrp_find_bridges(void)
277277
hose->cfg_data = p;
278278
gg2_pci_config_base = p;
279279
} else if (is_pegasos == 1) {
280-
setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc);
280+
setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc, 0);
281281
} else if (is_pegasos == 2) {
282282
setup_peg2(hose, dev);
283283
} else if (!strncmp(model, "IBM,CPC710", 10)) {
284284
setup_indirect_pci(hose,
285285
r.start + 0x000f8000,
286-
r.start + 0x000f8010);
286+
r.start + 0x000f8010,
287+
0);
287288
if (index == 0) {
288289
dma = of_get_property(dev, "system-dma-base",
289290
&len);

‎arch/powerpc/platforms/embedded6xx/linkstation.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static int __init linkstation_add_bridge(struct device_node *dev)
7373
return -ENOMEM;
7474
hose->first_busno = bus_range ? bus_range[0] : 0;
7575
hose->last_busno = bus_range ? bus_range[1] : 0xff;
76-
setup_indirect_pci(hose, 0xfec00000, 0xfee00000);
76+
setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
7777

7878
/* Interpret the "ranges" property */
7979
/* This also maps the I/O region and sets isa_io/mem_base */

‎arch/powerpc/sysdev/fsl_pci.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
185185
hose->first_busno = bus_range ? bus_range[0] : 0x0;
186186
hose->last_busno = bus_range ? bus_range[1] : 0xff;
187187

188-
setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4);
188+
setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
189+
PPC_INDIRECT_TYPE_BIG_ENDIAN);
189190
setup_pci_cmd(hose);
190191

191192
/* check PCI express link status */

‎arch/powerpc/sysdev/grackle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
5555

5656
void __init setup_grackle(struct pci_controller *hose)
5757
{
58-
setup_indirect_pci(hose, 0xfec00000, 0xfee00000);
58+
setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
5959
if (machine_is_compatible("PowerMac1,1"))
6060
pci_assign_all_buses = 1;
6161
if (machine_is_compatible("AAPL,PowerBook1998"))

‎arch/powerpc/sysdev/indirect_pci.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
#include <asm/pci-bridge.h>
2121
#include <asm/machdep.h>
2222

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-
2923
static int
3024
indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
3125
int len, u32 *val)
@@ -58,9 +52,12 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
5852
else
5953
reg = offset & 0xfc;
6054

61-
PCI_CFG_OUT(hose->cfg_addr,
62-
(0x80000000 | (bus_no << 16)
63-
| (devfn << 8) | reg | cfg_type));
55+
if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
56+
out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
57+
(devfn << 8) | reg | cfg_type));
58+
else
59+
out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
60+
(devfn << 8) | reg | cfg_type));
6461

6562
/*
6663
* Note: the caller has already checked that offset is
@@ -113,9 +110,12 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
113110
else
114111
reg = offset & 0xfc;
115112

116-
PCI_CFG_OUT(hose->cfg_addr,
117-
(0x80000000 | (bus_no << 16)
118-
| (devfn << 8) | reg | cfg_type));
113+
if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
114+
out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
115+
(devfn << 8) | reg | cfg_type));
116+
else
117+
out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
118+
(devfn << 8) | reg | cfg_type));
119119

120120
/* surpress setting of PCI_PRIMARY_BUS */
121121
if (hose->indirect_type & PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS)
@@ -149,7 +149,7 @@ static struct pci_ops indirect_pci_ops =
149149
};
150150

151151
void __init
152-
setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
152+
setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data, u32 flags)
153153
{
154154
unsigned long base = cfg_addr & PAGE_MASK;
155155
void __iomem *mbase;

0 commit comments

Comments
 (0)