Skip to contentSkip to conversation

powerpc/fsl-pci: Keep PCI SoC controller registers in

RFC PATCH Applied Kumar Gala 6 participants 15 messages Mar 13, 2013 – Apr 30, 2013

Subsystems (2)
lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

RFC PATCH 1/2 powerpc/fsl-pci: Keep PCI SoC controller registers in

Move to keeping the SoC registers that control and config the PCI controllers on FSL SoCs in the pci_controller struct. This allows us to not need to ioremap() the registers in multiple different places that use them.

---
 arch/powerpc/include/asm/pci-bridge.h |    5 ++-
 arch/powerpc/sysdev/fsl_pci.c         |   69 ++++++++++++++-------------------
 2 files changed, 34 insertions(+), 40 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +4 -1
index 025a130..c0278f0 100644
@@ -70,6 +70,8 @@ struct pci_controller {
 	 *  BIG_ENDIAN - cfg_addr is a big endian register
 	 *  BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs on
 	 *   the PLB4.  Effectively disable MRM commands by setting this.
+	 *  FSL_CFG_REG_LINK - Freescale controller version in which the PCIe
+	 *   link status is in a RC PCIe cfg register (vs being a SoC register)
 	 */
 #define PPC_INDIRECT_TYPE_SET_CFG_TYPE		0x00000001
 #define PPC_INDIRECT_TYPE_EXT_REG		0x00000002
@@ -77,6 +79,7 @@ struct pci_controller {
 #define PPC_INDIRECT_TYPE_NO_PCIE_LINK		0x00000008
 #define PPC_INDIRECT_TYPE_BIG_ENDIAN		0x00000010
 #define PPC_INDIRECT_TYPE_BROKEN_MRM		0x00000020
+#define PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK	0x00000040
 	u32 indirect_type;
 	/* Currently, we limit ourselves to 1 IO range and 3 mem
 	 * ranges since the common pci_bus structure can't handle more
@@ -90,9 +93,9 @@ struct pci_controller {
 
 #ifdef CONFIG_PPC64
 	unsigned long buid;
+#endif	/* CONFIG_PPC64 */
 
 	void *private_data;
-#endif	/* CONFIG_PPC64 */
 };
 
 /* These are used for config access before all the PCI probing
arch/powerpc/sysdev/fsl_pci.c +30 -39

133 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author
#1 lore raw

RFC PATCH 2/2 powerpc/fsl-pci Make PCIe hotplug work with Freescale

From: Rojhalat Ibrahim <[email protected]>

---
 arch/powerpc/include/asm/pci-bridge.h |    6 ++++++
 arch/powerpc/sysdev/fsl_pci.c         |   37 +++++++++++++++++++++++++++++----
 arch/powerpc/sysdev/indirect_pci.c    |   10 ++++-----
 3 files changed, 43 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +6 -0
index c0278f0..ffbc5fd 100644
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct pci_controller* hose,
 			       resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);
 
+extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+				 int offset, int len, u32 val);
+
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
 	return bus->sysdata;
arch/powerpc/sysdev/fsl_pci.c +33 -4
index 41bbcc4..b18c377 100644
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct pci_controller *hose)
 	return 0;
 }
 
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				    int offset, int len, u32 *val)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+	
+	/* check the link status */
+	if ((bus->number == hose->first_busno) && (devfn == 0)) {
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+		else
+			hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	}
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+
+static struct pci_ops fsl_indirect_pci_ops =
+{
+	.read = fsl_indirect_read_config,
+	.write = indirect_write_config,
+};
+
+static void __init fsl_setup_indirect_pci(struct pci_controller* hose,
+					  resource_size_t cfg_addr,
+					  resource_size_t cfg_data, u32 flags)
+{
+	setup_indirect_pci(hose, cfg_addr, cfg_data, flags);
+	hose->ops = &fsl_indirect_pci_ops;
+}
+
 #if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
 
 #define MAX_PHYS_ADDR_BITS	40
@@ -469,8 +498,8 @@ int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
 	if (!hose->private_data)
 		goto no_bridge;
 
-	setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
-		PPC_INDIRECT_TYPE_BIG_ENDIAN);
+	fsl_setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
+			       PPC_INDIRECT_TYPE_BIG_ENDIAN);
 
 	if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
 		hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
@@ -779,8 +808,8 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
 		if (ret)
 			goto err0;
 	} else {
-		setup_indirect_pci(hose, rsrc_cfg.start,
-				   rsrc_cfg.start + 4, 0);
+		fsl_setup_indirect_pci(hose, rsrc_cfg.start,
+				       rsrc_cfg.start + 4, 0);
 	}
 
 	printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
arch/powerpc/sysdev/indirect_pci.c +4 -6
index 82fdad8..c6c8b52 100644
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
Signature · 1 line
1.7.9.7
#2 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Quoted 13 lines · On Wednesday 13 March 2013 14:07:16 Kumar Gala wrote:
arch/powerpc/sysdev/fsl_pci.c +4 -0
index 41bbcc4..b18c377 100644
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }
 
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int
 devfn, +				    int offset, int len, u32 *val)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct · line 91

Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +10 -0
+	/* check the link status */
+	if ((bus->number == hose->first_busno) && (devfn == 0)) {
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+		else
+			hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	}
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+

This does not work because fsl_indirect_read_config calls fsl_pcie_check_link which calls early_read_config_dword which eventually calls fsl_indirect_read_config, so the kernel hangs in a recursion loop. Below is a modified patch that does work.

---
 arch/powerpc/include/asm/pci-bridge.h |    6 ++++
 arch/powerpc/sysdev/fsl_pci.c         |   51 ++++++++++++++++++++++++++++++----
 arch/powerpc/sysdev/indirect_pci.c    |   10 ++----
 3 files changed, 55 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +6 -0
index c0278f0..ffbc5fd 100644
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct pci_controller* hose,
 			       resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);
 
+extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+				 int offset, int len, u32 val);
+
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
 	return bus->sysdata;
arch/powerpc/sysdev/fsl_pci.c +45 -6

79 lines not on this page · raw message

arch/powerpc/sysdev/indirect_pci.c +4 -6
index 82fdad8..c6c8b52 100644
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
author
#3 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Quoted 2 lines · Rojhalat Ibrahim

=

Quoted 1 line · On Wednesday 13 March 2013 14:07:16 Kumar Gala wrote:
= renamed from arch/powerpc/sysdev/fsl_pci.c +0 -0

b/arch/powerpc/sysdev/fsl_pci.c

Quoted 8 lines
Quoted 8 lines

index 41bbcc4..b18c377 100644

arch/powerpc/sysdev/fsl_pci.c +0 -0
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }

=20
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned =

int

Quoted 1 line
Quoted 1 line

devfn, + int offset, int len, u32 =

*val)

Quoted 5 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct pci_controller *hose)

Quoted 5 lines
arch/powerpc/sysdev/fsl_pci.c +5 -0
+{
+	struct pci_controller *hose =3D pci_bus_to_host(bus);
+
+	/* check the link status */
+	if ((bus->number =3D=3D hose->first_busno) && (devfn =3D=3D 0)) =

{

Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |=3D =

PPC_INDIRECT_TYPE_NO_PCIE_LINK;

Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+		else
+			hose->indirect_type &=3D =

~PPC_INDIRECT_TYPE_NO_PCIE_LINK;

Quoted 6 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct pci_controller *hose) · line 101

Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4 -0
+	}
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+

=20
This does not work because fsl_indirect_read_config calls =

fsl_pcie_check_link which calls early_read_config_dword which eventually = calls fsl_indirect_read_config, so the kernel hangs in a recursion loop. = Below is a modified patch that does work.

ok, that makes sense, but I guess now its making me question the = following statement:

Quoted 1 line

if ((bus->number =3D=3D hose->first_busno) && (devfn =3D=3D 0)) {

Why do we have this conditional?

- k=

#4 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Quoted 31 lines · On Thursday 14 March 2013 15:35:40 Kumar Gala wrote:
Quoted 22 lines · Rojhalat Ibrahim
Quoted 21 lines · On Wednesday 13 March 2013 14:07:16 Kumar Gala wrote:
arch/powerpc/sysdev/fsl_pci.c +11 -0
index 41bbcc4..b18c377 100644
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }
 
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int
 devfn, +				    int offset, int len, u32 *val)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+
+	/* check the link status */
+	if ((bus->number == hose->first_busno) && (devfn == 0)) {
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+		else
+			hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	}
Quoted 8 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct · line 91

Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +3 -0
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+

This does not work because fsl_indirect_read_config calls fsl_pcie_check_link which calls early_read_config_dword which eventually calls fsl_indirect_read_config, so the kernel hangs in a recursion loop. Below is a modified patch that does work.

Quoted 6 lines

ok, that makes sense, but I guess now its making me question the following statement:

Quoted 1 line

if ((bus->number == hose->first_busno) && (devfn == 0)) {

Why do we have this conditional?

- k

Right. This is not necessary anymore. I modified the patch accordingly.

---
 arch/powerpc/include/asm/pci-bridge.h |    6 ++++
 arch/powerpc/sysdev/fsl_pci.c         |   51 +++++++++++++++++++++++++++++-----
 arch/powerpc/sysdev/indirect_pci.c    |   10 ++----
 3 files changed, 54 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +6 -0
index c0278f0..ffbc5fd 100644
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct pci_controller* hose,
 			       resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);
 
+extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+				 int offset, int len, u32 val);
+
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
 	return bus->sysdata;
arch/powerpc/sysdev/fsl_pci.c +44 -7

78 lines not on this page · raw message

arch/powerpc/sysdev/indirect_pci.c +4 -6
index 82fdad8..c6c8b52 100644
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
#5 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Hi Kumar,

what about this patch? Any reasons not to apply?

Rojhalat

Quoted 33 lines · On Monday 18 March 2013 10:22:40 Rojhalat Ibrahim wrote:
Quoted 32 lines · On Thursday 14 March 2013 15:35:40 Kumar Gala wrote:
Quoted 30 lines · Rojhalat Ibrahim
Quoted 14 lines · On Wednesday 13 March 2013 14:07:16 Kumar Gala wrote:
arch/powerpc/sysdev/fsl_pci.c +4 -0
index 41bbcc4..b18c377 100644
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }
 
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int
 devfn, +				    int offset, int len, u32 *val)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct · line 91

Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +10 -0
+	/* check the link status */
+	if ((bus->number == hose->first_busno) && (devfn == 0)) {
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+		else
+			hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	}
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+

This does not work because fsl_indirect_read_config calls fsl_pcie_check_link which calls early_read_config_dword which eventually calls fsl_indirect_read_config, so the kernel hangs in a recursion loop. Below is a modified patch that does work.

Quoted 1 line
Quoted 1 line

ok, that makes sense, but I guess now its making me question the following

statement:

Quoted 154 lines
Quoted 5 lines
Quoted 1 line

if ((bus->number == hose->first_busno) && (devfn == 0)) {

Why do we have this conditional?

- k

Right. This is not necessary anymore. I modified the patch accordingly.

---
 arch/powerpc/include/asm/pci-bridge.h |    6 ++++
 arch/powerpc/sysdev/fsl_pci.c         |   51
+++++++++++++++++++++++++++++----- arch/powerpc/sysdev/indirect_pci.c    | 
 10 ++----
 3 files changed, 54 insertions(+), 13 deletions(-)
(quoted diff) +0 -0

b/arch/powerpc/include/asm/pci-bridge.h index c0278f0..ffbc5fd 100644

arch/powerpc/include/asm/pci-bridge.h +6 -0
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct pci_controller*
 hose, resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);
 
+extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+				 int offset, int len, u32 val);
+
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus
 *bus) {
 	return bus->sysdata;
arch/powerpc/sysdev/fsl_pci.c +43 -7
index 41bbcc4..9c0fcc9 100644
@@ -54,12 +54,22 @@ static void quirk_fsl_pcie_header(struct pci_dev *dev)
 	return;
 }
 
-static int __init fsl_pcie_check_link(struct pci_controller *hose)
+static int fsl_indirect_read_config(struct pci_bus *, unsigned int,
+				    int, int, u32 *);
+
+static int fsl_pcie_check_link(struct pci_controller *hose)
 {
-	u32 val;
+	u32 val = 0;
 
 	if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
-		early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
+		if (hose->ops->read == fsl_indirect_read_config) {
+			struct pci_bus bus;
+			bus.number = 0;
+			bus.sysdata = hose;
+			bus.ops = hose->ops;
+			indirect_read_config(&bus, 0, PCIE_LTSSM, 4, &val);
+		} else
+			early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
 		if (val < PCIE_LTSSM_L0)
 			return 1;
 	} else {
@@ -74,6 +84,33 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }
 
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int
 devfn, +				    int offset, int len, u32 *val)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+
+	if (fsl_pcie_check_link(hose))
+		hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	else
+		hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+
+static struct pci_ops fsl_indirect_pci_ops =
+{
+	.read = fsl_indirect_read_config,
+	.write = indirect_write_config,
+};
+
+static void __init fsl_setup_indirect_pci(struct pci_controller* hose,
+					  resource_size_t cfg_addr,
+					  resource_size_t cfg_data, u32 flags)
+{
+	setup_indirect_pci(hose, cfg_addr, cfg_data, flags);
+	hose->ops = &fsl_indirect_pci_ops;
+}
+
 #if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
 
 #define MAX_PHYS_ADDR_BITS	40
@@ -469,8 +506,8 @@ int __init fsl_add_bridge(struct platform_device *pdev,
 int is_primary) if (!hose->private_data)
 		goto no_bridge;
 
-	setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
-		PPC_INDIRECT_TYPE_BIG_ENDIAN);
+	fsl_setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
+			       PPC_INDIRECT_TYPE_BIG_ENDIAN);
 
 	if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
 		hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
@@ -779,8 +816,8 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
 		if (ret)
 			goto err0;
 	} else {
-		setup_indirect_pci(hose, rsrc_cfg.start,
-				   rsrc_cfg.start + 4, 0);
+		fsl_setup_indirect_pci(hose, rsrc_cfg.start,
+				       rsrc_cfg.start + 4, 0);
 	}
 
 	printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
(quoted diff) +0 -0

b/arch/powerpc/sysdev/indirect_pci.c index 82fdad8..c6c8b52 100644

arch/powerpc/sysdev/indirect_pci.c +4 -6
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int
 devfn, int offset, return PCIBIOS_SUCCESSFUL;
 }
 
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

author
#6 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Quoted 5 lines · Rojhalat Ibrahim

Hi Kumar,
=20
what about this patch? Any reasons not to apply?
=20
Rojhalat

Was on vacation, getting back to it now. Do send a proper patch = w/commit message & signed-off-by.

- k

Quoted 6 lines

=20
=20

Quoted 3 lines · On Monday 18 March 2013 10:22:40 Rojhalat Ibrahim wrote:
Quoted 2 lines · On Thursday 14 March 2013 15:35:40 Kumar Gala wrote:
Quoted 1 line · Rojhalat Ibrahim

On Wednesday 13 March 2013 14:07:16 Kumar Gala wrote:

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +0 -0
index 41bbcc4..b18c377 100644
@@ -74,6 +74,35 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }

=20
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned =

int

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

devfn, + int offset, int len, u32 =

*val)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 5 lines
arch/powerpc/sysdev/fsl_pci.c +5 -0
+{
+	struct pci_controller *hose =3D pci_bus_to_host(bus);
+
+	/* check the link status */
+	if ((bus->number =3D=3D hose->first_busno) && (devfn =3D=3D 0)) =

{

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+		if (fsl_pcie_check_link(hose))
+			hose->indirect_type |=3D =

PPC_INDIRECT_TYPE_NO_PCIE_LINK;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+		else
+			hose->indirect_type &=3D =

~PPC_INDIRECT_TYPE_NO_PCIE_LINK;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct pci_controller *hose) · line 99

Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4 -0
+	}
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+

=20
This does not work because fsl_indirect_read_config calls fsl_pcie_check_link which calls early_read_config_dword which =

eventually

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

calls fsl_indirect_read_config, so the kernel hangs in a recursion =

loop.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Below is a modified patch that does work.

=20
ok, that makes sense, but I guess now its making me question the =

following=20

Quoted 8 lines

statement:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

if ((bus->number =3D=3D hose->first_busno) && (devfn =3D=3D 0)) {

=20
Why do we have this conditional?
=20
- k

=20
Right. This is not necessary anymore. I modified the patch =

accordingly.

Quoted 7 lines
Quoted 7 lines

=20
=20

---
arch/powerpc/include/asm/pci-bridge.h | 6 ++++
arch/powerpc/sysdev/fsl_pci.c | 51
+++++++++++++++++++++++++++++----- arch/powerpc/sysdev/indirect_pci.c =

|=20

Quoted 8 lines

arch/powerpc/include/asm/pci-bridge.h extern void setup_indirect_pci(struct =

Quoted 8 lines

10 ++----

3 files changed, 54 insertions(+), 13 deletions(-)

=20

(quoted diff) +0 -0

b/arch/powerpc/include/asm/pci-bridge.h index c0278f0..ffbc5fd 100644

arch/powerpc/include/asm/pci-bridge.h +0 -0
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct =

pci_controller*

Quoted 4 lines
Quoted 4 lines
arch/powerpc/include/asm/pci-bridge.h +0 -0
 hose, resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);

=20
+extern int indirect_read_config(struct pci_bus *bus, unsigned int =

devfn,

Quoted 3 lines

arch/powerpc/include/asm/pci-bridge.h extern void setup_indirect_pci(struct pci_controller* hose,

Quoted 3 lines
arch/powerpc/include/asm/pci-bridge.h +3 -0
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int =

devfn,

Quoted 3 lines
Quoted 3 lines
arch/powerpc/include/asm/pci-bridge.h +2 -0
+				 int offset, int len, u32 val);
+

static inline struct pci_controller *pci_bus_to_host(const struct =

pci_bus

Quoted 3 lines

=

Quoted 3 lines
*bus) {
	return bus->sysdata;
= renamed from arch/powerpc/sysdev/fsl_pci.c +0 -0

b/arch/powerpc/sysdev/fsl_pci.c

Quoted 4 lines

arch/powerpc/sysdev/fsl_pci.c static void quirk_fsl_pcie_header(struct pci_dev =

Quoted 4 lines

index 41bbcc4..9c0fcc9 100644

arch/powerpc/sysdev/fsl_pci.c +0 -0
@@ -54,12 +54,22 @@ static void quirk_fsl_pcie_header(struct pci_dev =

*dev)

Quoted 12 lines
Quoted 12 lines
arch/powerpc/sysdev/fsl_pci.c +0 -0
 	return;
 }

=20

arch/powerpc/sysdev/fsl_pci.c +4 -1
-static int __init fsl_pcie_check_link(struct pci_controller *hose)
+static int fsl_indirect_read_config(struct pci_bus *, unsigned int,
+				    int, int, u32 *);
+
+static int fsl_pcie_check_link(struct pci_controller *hose)

{

arch/powerpc/sysdev/fsl_pci.c +1 -1
-	u32 val;
+	u32 val =3D 0;

=20

Quoted 8 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 8 lines
	if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
arch/powerpc/sysdev/fsl_pci.c +6 -1
-		early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
+		if (hose->ops->read =3D=3D fsl_indirect_read_config) {
+			struct pci_bus bus;
+			bus.number =3D 0;
+			bus.sysdata =3D hose;
+			bus.ops =3D hose->ops;
+			indirect_read_config(&bus, 0, PCIE_LTSSM, 4, =

&val);

Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+		} else
+			early_read_config_dword(hose, 0, 0, PCIE_LTSSM, =

&val);

Quoted 8 lines
Quoted 8 lines
		if (val < PCIE_LTSSM_L0)
			return 1;
	} else {
arch/powerpc/sysdev/fsl_pci.c +0 -0
@@ -74,6 +84,33 @@ static int __init fsl_pcie_check_link(struct
 pci_controller *hose) return 0;
 }

=20
+static int fsl_indirect_read_config(struct pci_bus *bus, unsigned =

int

Quoted 1 line
Quoted 1 line

devfn, + int offset, int len, u32 =

*val)

Quoted 7 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct pci_controller *hose)

Quoted 7 lines
arch/powerpc/sysdev/fsl_pci.c +7 -0
+{
+	struct pci_controller *hose =3D pci_bus_to_host(bus);
+
+	if (fsl_pcie_check_link(hose))
+		hose->indirect_type |=3D PPC_INDIRECT_TYPE_NO_PCIE_LINK;
+	else
+		hose->indirect_type &=3D =

~PPC_INDIRECT_TYPE_NO_PCIE_LINK;

Quoted 11 lines

arch/powerpc/sysdev/fsl_pci.c static int __init fsl_pcie_check_link(struct pci_controller *hose)

Quoted 11 lines
arch/powerpc/sysdev/fsl_pci.c +11 -0
+
+	return indirect_read_config(bus, devfn, offset, len, val);
+}
+
+static struct pci_ops fsl_indirect_pci_ops =3D
+{
+	.read =3D fsl_indirect_read_config,
+	.write =3D indirect_write_config,
+};
+
+static void __init fsl_setup_indirect_pci(struct pci_controller* =

hose,

Quoted 2 lines

arch/powerpc/sysdev/fsl_pci.c

Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2 -0
+					  resource_size_t cfg_addr,
+					  resource_size_t cfg_data, u32 =

flags)

Quoted 9 lines

arch/powerpc/sysdev/fsl_pci.c int __init fsl_add_bridge(struct platform_device =

Quoted 9 lines
arch/powerpc/sysdev/fsl_pci.c +5 -0
+{
+	setup_indirect_pci(hose, cfg_addr, cfg_data, flags);
+	hose->ops =3D &fsl_indirect_pci_ops;
+}
+

#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx) =20
#define MAX_PHYS_ADDR_BITS 40

arch/powerpc/sysdev/fsl_pci.c +0 -0
@@ -469,8 +506,8 @@ int __init fsl_add_bridge(struct platform_device =

*pdev,

Quoted 10 lines
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +0 -0
 int is_primary) if (!hose->private_data)
 		goto no_bridge;

=20

arch/powerpc/sysdev/fsl_pci.c +2 -2
-	setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
-		PPC_INDIRECT_TYPE_BIG_ENDIAN);
+	fsl_setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
+			       PPC_INDIRECT_TYPE_BIG_ENDIAN);

=20

	if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
		hose->indirect_type |=3D =

PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;

Quoted 1 line

arch/powerpc/sysdev/fsl_pci.c int __init mpc83xx_add_bridge(struct device_node =

Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +0 -0
@@ -779,8 +816,8 @@ int __init mpc83xx_add_bridge(struct device_node =

*dev)

Quoted 12 lines
Quoted 12 lines
arch/powerpc/sysdev/fsl_pci.c +2 -2
 		if (ret)
 			goto err0;
 	} else {
-		setup_indirect_pci(hose, rsrc_cfg.start,
-				   rsrc_cfg.start + 4, 0);
+		fsl_setup_indirect_pci(hose, rsrc_cfg.start,
+				       rsrc_cfg.start + 4, 0);
 	}

=20

	printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
(quoted diff) +0 -0

b/arch/powerpc/sysdev/indirect_pci.c index 82fdad8..c6c8b52 100644

Quoted 8 lines

arch/powerpc/sysdev/indirect_pci.c

Quoted 8 lines
arch/powerpc/sysdev/indirect_pci.c +0 -0
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>

=20

arch/powerpc/sysdev/indirect_pci.c +0 -2
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int =

offset,

Quoted 7 lines

arch/powerpc/sysdev/indirect_pci.c indirect_read_config(struct pci_bus *bus, unsigned =

Quoted 7 lines
arch/powerpc/sysdev/indirect_pci.c +2 -1
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
{
	struct pci_controller *hose =3D pci_bus_to_host(bus);
	volatile void __iomem *cfg_data;
arch/powerpc/sysdev/indirect_pci.c +0 -0
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned =

int

Quoted 5 lines

arch/powerpc/sysdev/indirect_pci.c

Quoted 5 lines
arch/powerpc/sysdev/indirect_pci.c +0 -0
 devfn, int offset, return PCIBIOS_SUCCESSFUL;
 }

=20

arch/powerpc/sysdev/indirect_pci.c +0 -2
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int =

offset,

Quoted 12 lines
Quoted 12 lines
arch/powerpc/sysdev/indirect_pci.c +2 -1
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
{
	struct pci_controller *hose =3D pci_bus_to_host(bus);
	volatile void __iomem *cfg_data;

=20
=20
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#7 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Up to now the PCIe link status on Freescale PCIe controllers was only checked once at boot time. So hotplug did not work. With this patch the link status is checked on every config read. PCIe devices not present at boot time are found after doing 'echo 1 >/sys/bus/pci/rescan'.

---
 arch/powerpc/include/asm/pci-bridge.h |    6 ++++
 arch/powerpc/sysdev/fsl_pci.c         |   51 +++++++++++++++++++++++++++++-----
 arch/powerpc/sysdev/indirect_pci.c    |   10 ++----
 3 files changed, 54 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +6 -0
index c0278f0..ffbc5fd 100644
@@ -120,6 +120,12 @@ extern void setup_indirect_pci(struct pci_controller* hose,
 			       resource_size_t cfg_addr,
 			       resource_size_t cfg_data, u32 flags);
 
+extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+				int offset, int len, u32 *val);
+
+extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+				 int offset, int len, u32 val);
+
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
 	return bus->sysdata;
arch/powerpc/sysdev/fsl_pci.c +44 -7

78 lines not on this page · raw message

arch/powerpc/sysdev/indirect_pci.c +4 -6
index 82fdad8..c6c8b52 100644
@@ -20,9 +20,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-static int
-indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		     int len, u32 *val)
+int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
+			 int offset, int len, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int
-indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
-		      int len, u32 val)
+int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
+			  int offset, int len, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
 	volatile void __iomem *cfg_data;

---
1.8.1.5

author Applied
#8 lore raw

Re: [RFC][PATCH 2/2] powerpc/fsl-pci Make PCIe hotplug work with Freescale

Quoted 2 lines · Rojhalat Ibrahim

Up to now the PCIe link status on Freescale PCIe controllers was only checked once at boot time. So hotplug did not work. With this patch =

the

Quoted 1 line

link status is checked on every config read. PCIe devices not present =

at

Quoted 6 lines

boot time are found after doing 'echo 1 >/sys/bus/pci/rescan'. =20

---
arch/powerpc/include/asm/pci-bridge.h | 6 ++++
arch/powerpc/sysdev/fsl_pci.c | 51 =

+++++++++++++++++++++++++++++-----

arch/pow

Quoted 4 lines

arch/powerpc/sysdev/indirect_pci.c | 10 ++----

3 files changed, 54 insertions(+), 13 deletions(-)

=20

arch/pow renamed from arch/powerpc/include/asm/pci-bridge.h +0 -0

applied to next

- k=

Acked-by on v1 1/2
#9 lore raw
In reply to Kumar Gala
Quoted 6 lines · On Wednesday 13 March 2013 14:07:15 Kumar Gala wrote:

Move to keeping the SoC registers that control and config the PCI controllers on FSL SoCs in the pci_controller struct. This allows us to not need to ioremap() the registers in multiple different places that use them.

Quoted 183 lines
---
 arch/powerpc/include/asm/pci-bridge.h |    5 ++-
 arch/powerpc/sysdev/fsl_pci.c         |   69

++++++++++++++------------------- 2 files changed, 34 insertions(+), 40 deletions(-)

(quoted diff) +0 -0

b/arch/powerpc/include/asm/pci-bridge.h index 025a130..c0278f0 100644

arch/powerpc/include/asm/pci-bridge.h +4 -1
@@ -70,6 +70,8 @@ struct pci_controller {
 	 *  BIG_ENDIAN - cfg_addr is a big endian register
 	 *  BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs on
 	 *   the PLB4.  Effectively disable MRM commands by setting this.
+	 *  FSL_CFG_REG_LINK - Freescale controller version in which the PCIe
+	 *   link status is in a RC PCIe cfg register (vs being a SoC register)
 	 */
 #define PPC_INDIRECT_TYPE_SET_CFG_TYPE		0x00000001
 #define PPC_INDIRECT_TYPE_EXT_REG		0x00000002
@@ -77,6 +79,7 @@ struct pci_controller {
 #define PPC_INDIRECT_TYPE_NO_PCIE_LINK		0x00000008
 #define PPC_INDIRECT_TYPE_BIG_ENDIAN		0x00000010
 #define PPC_INDIRECT_TYPE_BROKEN_MRM		0x00000020
+#define PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK	0x00000040
 	u32 indirect_type;
 	/* Currently, we limit ourselves to 1 IO range and 3 mem
 	 * ranges since the common pci_bus structure can't handle more
@@ -90,9 +93,9 @@ struct pci_controller {
 
 #ifdef CONFIG_PPC64
 	unsigned long buid;
+#endif	/* CONFIG_PPC64 */
 
 	void *private_data;
-#endif	/* CONFIG_PPC64 */
 };
 
 /* These are used for config access before all the PCI probing
arch/powerpc/sysdev/fsl_pci.c +30 -39
index 3271177..41bbcc4 100644
@@ -54,34 +54,22 @@ static void quirk_fsl_pcie_header(struct pci_dev *dev)
 	return;
 }
 
-static int __init fsl_pcie_check_link(struct pci_controller *hose,
-				  struct resource *rsrc)
+static int __init fsl_pcie_check_link(struct pci_controller *hose)
 {
-	struct ccsr_pci __iomem *pci = NULL;
 	u32 val;
 
-	/* for PCIe IP rev 3.0 or greater use CSR0 for link state */
-	if (rsrc) {
-		pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
-		    (u64)rsrc->start, (u64)rsrc->end - (u64)rsrc->start + 1);
-		pci = ioremap(rsrc->start, rsrc->end - rsrc->start + 1);
-		if (!pci) {
-			dev_err(hose->parent, "Unable to map PCIe registers\n");
-			return -ENOMEM;
-		}
-		if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_3_0) {
-			val = (in_be32(&pci->pex_csr0) & PEX_CSR0_LTSSM_MASK)
-					>> PEX_CSR0_LTSSM_SHIFT;
-			if (val != PEX_CSR0_LTSSM_L0)
-				return 1;
-			iounmap(pci);
-			return 0;
-		}
-		iounmap(pci);
+	if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
+		early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
+		if (val < PCIE_LTSSM_L0)
+			return 1;
+	} else {
+		struct ccsr_pci __iomem *pci = hose->private_data;
+		/* for PCIe IP rev 3.0 or greater use CSR0 for link state */
+		val = (in_be32(&pci->pex_csr0) & PEX_CSR0_LTSSM_MASK)
+				>> PEX_CSR0_LTSSM_SHIFT;
+		if (val != PEX_CSR0_LTSSM_L0)
+			return 1;
 	}
-	early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
-	if (val < PCIE_LTSSM_L0)
-		return 1;
 
 	return 0;
 }
@@ -148,10 +136,9 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
 }
 
 /* atmu setup for fsl pci/pcie controller */
-static void setup_pci_atmu(struct pci_controller *hose,
-				  struct resource *rsrc)
+static void setup_pci_atmu(struct pci_controller *hose)
 {
-	struct ccsr_pci __iomem *pci;
+	struct ccsr_pci __iomem *pci = hose->private_data;
 	int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4;
 	u64 mem, sz, paddr_hi = 0;
 	u64 paddr_lo = ULLONG_MAX;
@@ -162,15 +149,6 @@ static void setup_pci_atmu(struct pci_controller *hose,
 const u64 *reg;
 	int len;
 
-	pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
-		 (u64)rsrc->start, (u64)resource_size(rsrc));
-
-	pci = ioremap(rsrc->start, resource_size(rsrc));
-	if (!pci) {
-	    dev_err(hose->parent, "Unable to map ATMU registers\n");
-	    return;
-	}
-
 	if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
 		if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_2_2) {
 			win_idx = 2;
@@ -451,6 +429,7 @@ int __init fsl_add_bridge(struct platform_device *pdev,
 int is_primary) const int *bus_range;
 	u8 hdr_type, progif;
 	struct device_node *dev;
+	struct ccsr_pci __iomem *pci;
 
 	dev = pdev->dev.of_node;
 
@@ -483,9 +462,19 @@ int __init fsl_add_bridge(struct platform_device *pdev,
 int is_primary) hose->first_busno = bus_range ? bus_range[0] : 0x0;
 	hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
+	pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
+		 (u64)rsrc.start, (u64)resource_size(&rsrc));
+
+	pci = hose->private_data = ioremap(rsrc.start, resource_size(&rsrc));
+	if (!hose->private_data)
+		goto no_bridge;
+
 	setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
 		PPC_INDIRECT_TYPE_BIG_ENDIAN);
 
+	if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
+		hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
+
 	if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
 		/* For PCIE read HEADER_TYPE to identify controler mode */
 		early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type);
@@ -505,7 +494,7 @@ int __init fsl_add_bridge(struct platform_device *pdev,
 int is_primary) if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
 		hose->indirect_type |= PPC_INDIRECT_TYPE_EXT_REG |
 			PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
-		if (fsl_pcie_check_link(hose, &rsrc))
+		if (fsl_pcie_check_link(hose))
 			hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
 	}
 
@@ -522,11 +511,12 @@ int __init fsl_add_bridge(struct platform_device
 *pdev, int is_primary) pci_process_bridge_OF_ranges(hose, dev, is_primary);
 
 	/* Setup PEX window registers */
-	setup_pci_atmu(hose, &rsrc);
+	setup_pci_atmu(hose);
 
 	return 0;
 
 no_bridge:
+	iounmap(hose->private_data);
 	/* unmap cfg_data & cfg_addr separately if not on same page */
 	if (((unsigned long)hose->cfg_data & PAGE_MASK) !=
 	    ((unsigned long)hose->cfg_addr & PAGE_MASK))
@@ -703,11 +693,12 @@ static int __init mpc83xx_pcie_setup(struct
 pci_controller *hose, WARN_ON(hose->dn->data);
 	hose->dn->data = pcie;
 	hose->ops = &mpc83xx_pcie_ops;
+	hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
 
 	out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAH, 0);
 	out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, 0);
 
-	if (fsl_pcie_check_link(hose, NULL))
+	if (fsl_pcie_check_link(hose))
 		hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
 
 	return 0;
author Applied
#10 lore raw
In reply to Kumar Gala
Quoted 2 lines · Kumar Gala

Move to keeping the SoC registers that control and config the PCI controllers on FSL SoCs in the pci_controller struct. This allows us =

to

Quoted 7 lines

not need to ioremap() the registers in multiple different places that use them.
=20

---
arch/powerpc/include/asm/pci-bridge.h | 5 ++-
arch/powerpc/sysdev/fsl_pci.c | 69 =

++++++++++++++-------------------

Quoted 1 line
2 files changed, 34 insertions(+), 40 deletions(-)

applied to next

- k=

#11 lore raw

PATCH 1/1 powerpc: fix usage of setup_pci_atmu()

In reply to Kumar Gala

Linux next is currently failing to compile mpc85xx_defconfig with:
arch/powerpc/sysdev/fsl_pci.c:944:2: error: too many arguments to function 'setup_pci_atmu'

This is caused by (from Kumar's next branch):
commit 34642bbb3d12121333efcf4ea7dfe66685e403a1
Author: Kumar Gala <[email protected]> powerpc/fsl-pci: Keep PCI SoC controller registers in pci_controller

Which changed definition of setup_pci_atmu() but didn't update one of the callers. Below fixes this.

---
Kumar: this is for your next tree

arch/powerpc/sysdev/fsl_pci.c +1 -1
index 83918c3..a10a036 100644
@@ -941,7 +941,7 @@ static int fsl_pci_resume(struct device *dev)
 		return -ENODEV;
 	}
 
-	setup_pci_atmu(hose, &pci_rsrc);
+	setup_pci_atmu(hose);
 
 	return 0;
 }
Reviewed-by on v1 1/1
#12 lore raw

Re: [PATCH] powerpc: fix usage of setup_pci_atmu()

Quoted 8 lines · On Mon, 15 Apr 2013 15:42:01 +1000 Michael Neuling <[email protected]> wrote:

Linux next is currently failing to compile mpc85xx_defconfig with:
arch/powerpc/sysdev/fsl_pci.c:944:2: error: too many arguments to function 'setup_pci_atmu'

This is caused by (from Kumar's next branch):
commit 34642bbb3d12121333efcf4ea7dfe66685e403a1
Author: Kumar Gala <[email protected]> powerpc/fsl-pci: Keep PCI SoC controller registers in pci_controller

Quoted 6 lines

Which changed definition of setup_pci_atmu() but didn't update one of the callers. Below fixes this.

---
Kumar: this is for your next tree

Thanks,

Kim

#13 lore raw

Re: [PATCH] powerpc: fix usage of setup_pci_atmu()

In reply to Michael Neuling

Hi Kumar,

Quoted 22 lines · On Mon, 15 Apr 2013 15:42:01 +1000 Michael Neuling <[email protected]> wrote:

Linux next is currently failing to compile mpc85xx_defconfig with:
arch/powerpc/sysdev/fsl_pci.c:944:2: error: too many arguments to function 'setup_pci_atmu'

This is caused by (from Kumar's next branch):
commit 34642bbb3d12121333efcf4ea7dfe66685e403a1
Author: Kumar Gala <[email protected]> powerpc/fsl-pci: Keep PCI SoC controller registers in pci_controller

Which changed definition of setup_pci_atmu() but didn't update one of the callers. Below fixes this.

---
Kumar: this is for your next tree

arch/powerpc/sysdev/fsl_pci.c +0 -0
index 83918c3..a10a036 100644

arch/powerpc/sysdev/fsl_pci.c static int fsl_pci_resume(struct device *dev) · line 947

Quoted 8 lines
arch/powerpc/sysdev/fsl_pci.c +1 -1
@@ -941,7 +941,7 @@ static int fsl_pci_resume(struct device *dev)
 		return -ENODEV;
 	}
 
-	setup_pci_atmu(hose, &pci_rsrc);
+	setup_pci_atmu(hose);
 
 	return 0;
 }

This is still not in your tree ...

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
#14 lore raw

Re: [PATCH] powerpc: fix usage of setup_pci_atmu()

Quoted 2 lines · Stephen Rothwell

This is still not in your tree ...

I'll apply it after I merge kumar stuff.

Cheers,
Ben.