Skip to contentSkip to conversation

PCIe support for DRA7xx

RFC PATCH In review Kishon Vijay Abraham I 5 participants 20 messages Mar 26, 2014 – Mar 27, 2014

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover PCIe support for DRA7xx

This patch series adds support for PCIe in DRA7xx including drivers and dt data. PCIe in DRA7xx uses desingware IP and hence this re-uses the pcie desingware driver (pcie-designware.c) by Jingoo.

This patch series depends on a few patches that is already in -next.

Tested broadcom PCIe card and XIO2000 bridge along with DGE530T ethernet card.

Keerthy (2):
ARM: dts: DRA7: Add divider table to optfclk_pciephy_div clock
ARM: dts: DRA7: Change the parent of apll_pcie_in_clk_mux to
dpll_pcie_ref_m2ldo_ck

Kishon Vijay Abraham I (10):
phy: phy-omap-pipe3: Add support for PCIe PHY
pci: host: pcie-dra7xx: add support for pcie-dra7xx controller
pci: host: pcie-designware: Use *base-mask* for configuring the iATU
arm: dra7xx: Add hwmod data for pcie1 phy and pcie2 phy
arm: dra7xx: Add hwmod data for pcie1 and pcie2 subsystems
ARM: dts: dra7xx-clocks: Add missing 32khz clocks used for PHY
ARM: dts: dra7: Add dt data for PCIe PHY control module
ARM: dts: dra7: Add dt data for PCIe PHY
ARM: dts: dra7: Add dt data for PCIe controller
ARM: OMAP: Enable PCI for DRA7

 .../devicetree/bindings/pci/designware-pcie.txt    |    1 +
 Documentation/devicetree/bindings/pci/ti-pci.txt   |   35 ++
 Documentation/devicetree/bindings/phy/ti-phy.txt   |    8 +-
 arch/arm/boot/dts/dra7.dtsi                        |   48 +++
 arch/arm/boot/dts/dra7xx-clocks.dtsi               |   11 +-
 arch/arm/mach-omap2/Kconfig                        |    2 +
 arch/arm/mach-omap2/cm2_7xx.h                      |    4 +
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c          |  112 ++++++
 arch/arm/mach-omap2/prm7xx.h                       |    4 +
 drivers/pci/host/Kconfig                           |   10 +
 drivers/pci/host/Makefile                          |    1 +
 drivers/pci/host/pcie-designware.c                 |   39 +-
 drivers/pci/host/pcie-designware.h                 |    1 +
 drivers/pci/host/pcie-dra7xx.c                     |  411 ++++++++++++++++++++
 drivers/phy/phy-ti-pipe3.c                         |   99 ++++-
 15 files changed, 750 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c
Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/12 phy: phy-omap-pipe3: Add support for PCIe PHY

PCIe PHY uses an external pll instead of the internal pll used by SATA and USB3. So added support in pipe3 PHY to use external pll

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    8 +-
 drivers/phy/phy-ti-pipe3.c                       |   99 +++++++++++++++++-----
 2 files changed, 84 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +6 -2
index 788fb0f..e628a23 100644
@@ -49,8 +49,8 @@ usb2phy at 4a0ad080 {
 TI PIPE3 PHY
 
 Required properties:
- - compatible: Should be "ti,phy-usb3" or "ti,phy-pipe3-sata".
-   "ti,omap-usb3" is deprecated.
+ - compatible: Should be "ti,phy-usb3", "ti,phy-pipe3-sata" or
+   "ti,phy-pipe3-pcie. "ti,omap-usb3" is deprecated.
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the registers
    filled in "reg".
@@ -62,6 +62,10 @@ Required properties:
    * "wkupclk" - wakeup clock.
    * "sysclk" - system clock.
    * "refclk" - reference clock.
+   * "dpll_ref" - external dpll ref clk
+   * "dpll_ref_m2" - external dpll ref clk
+   * "phy-div" - divider for apll
+   * "div-clk" - apll clock
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +78 -21

160 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

RFC PATCH 2/12 pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Kishon Vijay Abraham I

Added support for pcie controller in dra7xx. This driver re-uses the designware core code that is already present in kernel.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   35 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pcie-dra7xx.c                   |  411 ++++++++++++++++++++++
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c
Documentation/devicetree/bindings/pci/ti-pci.txt new file +35 -0
new file mode 100644
index 0000000..0528c47
@@ -0,0 +1,35 @@
+TI PCI Controllers
+
+PCIe Designware Controller
+This node should have the properties described in "designware-pcie.txt".
+ - compatible: Should be "ti,dra7xx-pcie""
+ - reg : Address and length of the register set for the device.
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
+ - resets: phandle used if reset is handled be soc
+ - reset-names: name given to the phandle
+ - ti,device-type: Should be 1 - EP TYPE, 2 - LEG EP TYPE OR 3 - RC TYPE
+
+Example:
+pcie at 51000000 {
+	compatible = "ti,dra7xx-pcie";
+	reg = <0x51002000 0x14c>, <0x51000000 0x2000>, <0x4A002540 0x1f>, <0x4A003c24 0x4>, <0x4AE07310 0x4>;
+	interrupts = <0 129 0x4>, <0 134 0x4>;
+	#address-cells = <3>;
+	#size-cells = <2>;
+	device_type = "pci";
+	ti,device_type = <3>;
+	ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000  /* Configuration Space */
+		  0x81000000 0 0          0x20003000 0 0x00010000  /* IO Space */
+		  0x82000000 0 0x20013000 0x20013000 0 0xffed000>; /* MEM Space */
+	#interrupt-cells = <1>;
+	num-lanes = <1>;
+	interrupt-map-mask = <0 0 0 0>;
+	interrupt-map = <0x0 0 &gic 134>;
+	ti,hwmods = "pcie1";
+	phys = <&pcie1_phy>;
+	phy-names = "pcie-phy";
+	resets = <&prm_resets &device_reset>;
+	reset-names = "reset";
+};
drivers/pci/host/Kconfig +10 -0
index 47d46c6..5066a3c 100644
@@ -1,6 +1,16 @@
 menu "PCI host controller drivers"
 	depends on PCI
 
+config PCIE_DRA7XX
+	bool "TI DRA7xx PCIe controller"
+	select PCIE_DW
+	depends on OF || HAS_IOMEM || TI_PIPE3
+	help
+	 Enables support for the PCIE controller present in DRA7xx SoC. There
+	 are two instances of PCIE controller in DRA7xx. This controller can
+	 act both as EP and RC. This reuses the same Designware core as used
+	 by other SoCs.
+
 config PCI_MVEBU
 	bool "Marvell EBU PCIe controller"
 	depends on ARCH_MVEBU || ARCH_DOVE || ARCH_KIRKWOOD
drivers/pci/host/Makefile +1 -0
index 13fb333..90a275d 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o
+obj-$(CONFIG_PCIE_DRA7XX) += pcie-dra7xx.o
 obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
 obj-$(CONFIG_PCI_IMX6) += pci-imx6.o
 obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
drivers/pci/host/pcie-dra7xx.c new file +411 -0

411 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#7 lore raw

RFC PATCH 3/12 pci: host: pcie-designware: Use *base-mask* for configuring the iATU

In reply to Kishon Vijay Abraham I

In DRA7, the cpu sees 32bit address, but the pcie controller can see only 28bit address. So whenever the cpu issues a read/write request, the 4 most significant bits are used by L3 to determine the target controller. For example, the cpu reserves 0x2000_0000 - 0x2FFF_FFFF for PCIe controller but the PCIe controller will see only (0x000_0000 - 0xFFF_FFF). So for programming the outbound translation window the *base* should be programmed as 0x000_0000. Whenever we try to write to say 0x2000_0000, it will be translated to whatever we have programmed in the translation window with base as 0x000_0000.

---
 .../devicetree/bindings/pci/designware-pcie.txt    |    1 +
 drivers/pci/host/pcie-designware.c                 |   39 ++++++++++++++------
 drivers/pci/host/pcie-designware.h                 |    1 +
 3 files changed, 29 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/pci/designware-pcie.txt +1 -0
index d6fae13..c574dd3 100644
@@ -27,6 +27,7 @@ Optional properties for fsl,imx6q-pcie
 - power-on-gpio: gpio pin number of power-enable signal
 - wake-up-gpio: gpio pin number of incoming wakeup signal
 - disable-gpio: gpio pin number of outgoing rfkill/endpoint disable signal
+- base-mask: address mask for the PCIe controller target port
 
 Example:
 
drivers/pci/host/pcie-designware.c +27 -12
index 17ce88f..98b661c 100644
@@ -464,6 +464,9 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 		return -EINVAL;
 	}
 
+	if (of_property_read_u64(np, "base-mask", &pp->base_mask))
+		pp->base_mask = ~(0x0ULL);
+
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
 		pp->irq_domain = irq_domain_add_linear(pp->dev->of_node,
 					MAX_MSI_IRQS, &msi_domain_ops,
@@ -503,12 +506,15 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 
 static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)
 {
+	u64 cfg0_base;
+
+	cfg0_base = pp->cfg0_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : CFG0 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
 			  PCIE_ATU_VIEWPORT);
-	dw_pcie_writel_rc(pp, pp->cfg0_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->cfg0_base + pp->config.cfg0_size - 1,
+	dw_pcie_writel_rc(pp, cfg0_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg0_base + pp->config.cfg0_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
@@ -518,14 +524,17 @@ static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)
 
 static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
 {
+	u64 cfg1_base;
+
+	cfg1_base = pp->cfg1_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : CFG1 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
+	dw_pcie_writel_rc(pp, cfg1_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg1_base + pp->config.cfg1_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
@@ -533,14 +542,17 @@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
 
 static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
 {
+	u64 mem_base;
+
+	mem_base = pp->mem_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : MEM */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
+	dw_pcie_writel_rc(pp, mem_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (mem_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, mem_base + pp->config.mem_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
@@ -549,14 +561,17 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
 
 static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
 {
+	u64 io_base;
+
+	io_base = pp->io_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : IO */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
+	dw_pcie_writel_rc(pp, io_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (io_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, io_base + pp->config.io_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
drivers/pci/host/pcie-designware.h +1 -0
index 3063b35..3fa12a6 100644
@@ -35,6 +35,7 @@ struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
 	void __iomem		*dbi_base;
+	u64			base_mask;
 	u64			cfg0_base;
 	void __iomem		*va_cfg0_base;
 	u64			cfg1_base;
Signature · 1 line
1.7.9.5
#11 lore raw

RFC PATCH 4/12 ARM: dts: DRA7: Add divider table to optfclk_pciephy_div clock

In reply to Kishon Vijay Abraham I

From: Keerthy <[email protected]>

Add divider table to optfclk_pciephy_div clock.

---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +1 -0
index e96da9a..d909484 100644
@@ -1170,6 +1170,7 @@
 		clocks = <&apll_pcie_ck>;
 		#clock-cells = <0>;
 		reg = <0x021c>;
+		ti,dividers = <2>, <1>;
 		ti,bit-shift = <8>;
 		ti,max-div = <2>;
 	};
Signature · 1 line
1.7.9.5
#12 lore raw

RFC PATCH 5/12 ARM: dts: DRA7: Change the parent of apll_pcie_in_clk_mux to dpll_pcie_ref_m2ldo_ck

In reply to Kishon Vijay Abraham I

From: Keerthy <[email protected]>

Change the parent of apll_pcie_in_clk_mux to dpll_pcie_ref_m2ldo_ck from dpll_pcie_ref_ck.

---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7xx-clocks.dtsi +1 -1
index d909484..9e0bb09 100644
@@ -1152,7 +1152,7 @@
 
 	apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
 		compatible = "ti,mux-clock";
-		clocks = <&dpll_pcie_ref_ck>, <&pciesref_acs_clk_ck>;
+		clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
 		#clock-cells = <0>;
 		reg = <0x021c 0x4>;
 		ti,bit-shift = <7>;
Signature · 1 line
1.7.9.5
#13 lore raw

RFC PATCH 6/12 arm: dra7xx: Add hwmod data for pcie1 phy and pcie2 phy

In reply to Kishon Vijay Abraham I

Added hwmod data for pcie1 and pcie2 phy present in DRA7xx SOC. Also added the missing CLKCTRL OFFSET macro and CONTEXT OFFSET macro for pcie1 phy and pcie2 phy.

---
 arch/arm/mach-omap2/cm2_7xx.h             |    4 ++
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c |   57 +++++++++++++++++++++++++++++
 arch/arm/mach-omap2/prm7xx.h              |    4 ++
 3 files changed, 65 insertions(+)
arch/arm/mach-omap2/cm2_7xx.h +4 -0
index 9ad7594..e966e3a 100644
@@ -357,6 +357,10 @@
 #define DRA7XX_CM_L3INIT_SATA_CLKCTRL				DRA7XX_CM_CORE_REGADDR(DRA7XX_CM_CORE_L3INIT_INST, 0x0088)
 #define DRA7XX_CM_PCIE_CLKSTCTRL_OFFSET				0x00a0
 #define DRA7XX_CM_PCIE_STATICDEP_OFFSET				0x00a4
+#define DRA7XX_CM_L3INIT_PCIESS1_CLKCTRL_OFFSET			0x00b0
+#define DRA7XX_CM_L3INIT_PCIESS1_CLKCTRL			DRA7XX_CM_CORE_REGADDR(DRA7XX_CM_CORE_L3INIT_INST, 0x00b0)
+#define DRA7XX_CM_L3INIT_PCIESS2_CLKCTRL_OFFSET			0x00b8
+#define DRA7XX_CM_L3INIT_PCIESS2_CLKCTRL			DRA7XX_CM_CORE_REGADDR(DRA7XX_CM_CORE_L3INIT_INST, 0x00b8)
 #define DRA7XX_CM_GMAC_CLKSTCTRL_OFFSET				0x00c0
 #define DRA7XX_CM_GMAC_STATICDEP_OFFSET				0x00c4
 #define DRA7XX_CM_GMAC_DYNAMICDEP_OFFSET			0x00c8
arch/arm/mach-omap2/omap_hwmod_7xx_data.c +57 -0

75 lines not on this page · raw message

arch/arm/mach-omap2/prm7xx.h +4 -0
index d92a840..4bb50fbf 100644
@@ -374,6 +374,10 @@
 #define DRA7XX_RM_L3INIT_IEEE1500_2_OCP_CONTEXT_OFFSET		0x007c
 #define DRA7XX_PM_L3INIT_SATA_WKDEP_OFFSET			0x0088
 #define DRA7XX_RM_L3INIT_SATA_CONTEXT_OFFSET			0x008c
+#define DRA7XX_PM_L3INIT_PCIESS1_WKDEP_OFFSET			0x00b0
+#define DRA7XX_RM_L3INIT_PCIESS1_CONTEXT_OFFSET		0x00b4
+#define DRA7XX_PM_L3INIT_PCIESS2_WKDEP_OFFSET			0x00b8
+#define DRA7XX_RM_L3INIT_PCIESS2_CONTEXT_OFFSET		0x00bc
 #define DRA7XX_RM_GMAC_GMAC_CONTEXT_OFFSET			0x00d4
 #define DRA7XX_RM_L3INIT_OCP2SCP1_CONTEXT_OFFSET		0x00e4
 #define DRA7XX_RM_L3INIT_OCP2SCP3_CONTEXT_OFFSET		0x00ec
Signature · 1 line
1.7.9.5
#14 lore raw

RFC PATCH 7/12 arm: dra7xx: Add hwmod data for pcie1 and pcie2 subsystems

In reply to Kishon Vijay Abraham I

Added hwmod data for pcie1 and pcie2 subsystem present in DRA7xx SOC.

---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c |   55 +++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/arm/mach-omap2/omap_hwmod_7xx_data.c +55 -0
index 9397265..c789b00 100644
@@ -1290,6 +1290,43 @@ static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
 };
 
 /*
+ * 'PCIE' class
+ *
+ */
+
+static struct omap_hwmod_class dra7xx_pcie_hwmod_class = {
+	.name	= "pcie",
+};
+
+/* pcie1 */
+static struct omap_hwmod dra7xx_pcie1_hwmod = {
+	.name		= "pcie1",
+	.class		= &dra7xx_pcie_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.main_clk	= "l4_root_clk_div",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs	= DRA7XX_CM_PCIE_CLKSTCTRL_OFFSET,
+			.modulemode	= MODULEMODE_SWCTRL,
+		},
+	},
+};
+
+/* pcie2 */
+static struct omap_hwmod dra7xx_pcie2_hwmod = {
+	.name		= "pcie2",
+	.class		= &dra7xx_pcie_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.main_clk	= "l4_root_clk_div",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs = DRA7XX_CM_PCIE_CLKSTCTRL_OFFSET,
+			.modulemode   = MODULEMODE_SWCTRL,
+		},
+	},
+};
+
+/*
  * 'PCIE PHY' class
  *
  */
@@ -2459,6 +2496,22 @@ static struct omap_hwmod_ocp_if dra7xx_l4_cfg__ocp2scp1 = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* l4_cfg -> pcie1 */
+static struct omap_hwmod_ocp_if dra7xx_l4_cfg__pcie1 = {
+	.master		= &dra7xx_l4_cfg_hwmod,
+	.slave		= &dra7xx_pcie1_hwmod,
+	.clk		= "l4_root_clk_div",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+/* l4_cfg -> pcie2 */
+static struct omap_hwmod_ocp_if dra7xx_l4_cfg__pcie2 = {
+	.master		= &dra7xx_l4_cfg_hwmod,
+	.slave		= &dra7xx_pcie2_hwmod,
+	.clk		= "l4_root_clk_div",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l4_cfg -> pcie1 phy */
 static struct omap_hwmod_ocp_if dra7xx_l4_cfg__pcie1_phy = {
 	.master		= &dra7xx_l4_cfg_hwmod,
@@ -2824,6 +2877,8 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = {
 	&dra7xx_l4_cfg__mpu,
 	&dra7xx_l4_cfg__ocp2scp1,
 	&dra7xx_l4_cfg__ocp2scp3,
+	&dra7xx_l4_cfg__pcie1,
+	&dra7xx_l4_cfg__pcie2,
 	&dra7xx_l4_cfg__pcie1_phy,
 	&dra7xx_l4_cfg__pcie2_phy,
 	&dra7xx_l3_main_1__qspi,
Signature · 1 line
1.7.9.5
#15 lore raw

RFC PATCH 8/12 ARM: dts: dra7xx-clocks: Add missing 32khz clocks used for PHY

In reply to Kishon Vijay Abraham I

Added missing 32khz clock used by PCIe PHY.
The documention for this node can be found @ ../bindings/clock/ti/gate.txt.

---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +8 -0
index 9e0bb09..5f13189 100644
@@ -1165,6 +1165,14 @@
 		reg = <0x021c>, <0x0220>;
 	};
 
+	optfclk_pciephy_32khz: optfclk_pciephy_32khz at 4a0093b0 {
+		compatible = "ti,gate-clock";
+		clocks = <&sys_32k_ck>;
+		#clock-cells = <0>;
+		reg = <0x13b0>;
+		ti,bit-shift = <8>;
+	};
+
 	optfclk_pciephy_div: optfclk_pciephy_div at 4a00821c {
 		compatible = "ti,divider-clock";
 		clocks = <&apll_pcie_ck>;
Signature · 1 line
1.7.9.5
#16 lore raw

RFC PATCH 9/12 ARM: dts: dra7: Add dt data for PCIe PHY control module

In reply to Kishon Vijay Abraham I

Added dt data for PCIe PHY control module used by PCIe PHY. The documention for this node can be found @ ../bindings/phy/ti-phy.txt

---
 arch/arm/boot/dts/dra7.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7.dtsi +8 -0
index f3565ac..73c61d0 100644
@@ -656,6 +656,14 @@
 			clock-names = "sysclk";
 		};
 
+		omap_control_pcie1phy: omap-control-pciephy at 0x4a003c40 {
+			compatible = "ti,control-phy-pipe3";
+			reg = <0x4a003c40 0x4>;
+			reg-names = "power";
+			clocks = <&sys_clkin1>;
+			clock-names = "sysclk";
+		};
+
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
Signature · 1 line
1.7.9.5
#17 lore raw

RFC PATCH 10/12 ARM: dts: dra7: Add dt data for PCIe PHY

In reply to Kishon Vijay Abraham I

Added dt data for PCIe PHY as a child node of ocp2scp3.
The documention for this node can be found @ ../bindings/phy/ti-phy.txt.

---
 arch/arm/boot/dts/dra7.dtsi |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/boot/dts/dra7.dtsi +16 -0
index 73c61d0..7ac372b 100644
@@ -683,6 +683,22 @@
 				clock-names = "sysclk";
 				#phy-cells = <0>;
 			};
+
+			pcie1_phy: pciephy at 4a094000 {
+				compatible = "ti,phy-pipe3-pcie";
+				ctrl-module = <&omap_control_pcie1phy>;
+				clocks = <&dpll_pcie_ref_ck>,
+					 <&dpll_pcie_ref_m2ldo_ck>,
+					 <&optfclk_pciephy_32khz>,
+					 <&optfclk_pciephy_clk>,
+					 <&optfclk_pciephy_div_clk>,
+					 <&optfclk_pciephy_div>;
+				clock-names = "dpll_ref", "dpll_ref_m2",
+					      "wkupclk", "refclk",
+					      "div-clk", "phy-div";
+				#phy-cells = <0>;
+				ti,hwmods = "pcie1-phy";
+			};
 		};
 
 		sata: sata at 4a141100 {
Signature · 1 line
1.7.9.5
#18 lore raw

RFC PATCH 11/12 ARM: dts: dra7: Add dt data for PCIe controller

In reply to Kishon Vijay Abraham I

Added dt data for PCIe controller. This node contains dt data for both the DRA7 part of designware controller and for the designware core. The documention for this node can be found @ ../bindings/pci/ti-pci.txt.

---
 arch/arm/boot/dts/dra7.dtsi |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/boot/dts/dra7.dtsi +24 -0
index 7ac372b..10def39 100644
@@ -701,6 +701,30 @@
 			};
 		};
 
+		pcie at 51000000 {
+			compatible = "ti,dra7xx-pcie";
+			reg = <0x51002000 0x14c>, <0x51000000 0x2000>, <0x4A002540 0x1f>;
+			reg-names = "ti_conf", "rc_dbics", "mmr_unlock";
+			interrupts = <0 232 0x4>, <0 233 0x4>;
+			#address-cells = <3>;
+			#size-cells = <2>;
+			device_type = "pci";
+			ti,device_type = <3>;
+			ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000
+				  0x81000000 0 0          0x20003000 0 0x00010000
+				  0x82000000 0 0x20013000 0x20013000 0 0xffed000>;
+			#interrupt-cells = <1>;
+			base-mask = <0x00000000 0x0fffffff>;
+			num-lanes = <1>;
+			interrupt-map-mask = <0 0 0 0>;
+			interrupt-map = <0x0 0 &gic 233>;
+			ti,hwmods = "pcie1";
+			phys = <&pcie1_phy>;
+			phy-names = "pcie-phy";
+			resets = <&prm_resets &device_reset>;
+			reset-names = "reset";
+		};
+
 		sata: sata at 4a141100 {
 			compatible = "snps,dwc-ahci";
 			reg = <0x4a140000 0x1100>, <0x4a141100 0x7>;
Signature · 1 line
1.7.9.5
#19 lore raw

RFC PATCH 12/12 ARM: OMAP: Enable PCI for DRA7

In reply to Kishon Vijay Abraham I

Now that we have added PCIe driver for DRA7 SOCs, enable PCI on DRA7 SOCs.

---
 arch/arm/mach-omap2/Kconfig |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-omap2/Kconfig +2 -0
index 46f8c53..352f252 100644
@@ -86,6 +86,8 @@ config SOC_DRA7XX
 	select HAVE_SMP
 	select HAVE_ARM_ARCH_TIMER
 	select IRQ_CROSSBAR
+	select MIGHT_HAVE_PCI
+	select ARCH_SUPPORTS_MSI
 
 config ARCH_OMAP2PLUS
 	bool
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [RFC PATCH 02/12] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Kishon Vijay Abraham I
Quoted 19 lines · Kishon Vijay Abraham I

Added support for pcie controller in dra7xx. This driver re-uses the designware core code that is already present in kernel.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   35 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pcie-dra7xx.c                   |  411 ++++++++++++++++++++++
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c
Documentation/devicetree/bindings/pci/ti-pci.txt new file +0 -0
new file mode 100644
index 0000000..0528c47

Documentation/devicetree/bindings/pci/ti-pci.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +10 -0
@@ -0,0 +1,35 @@
+TI PCI Controllers
+
+PCIe Designware Controller
+This node should have the properties described in "designware-pcie.txt".
+ - compatible: Should be "ti,dra7xx-pcie""
+ - reg : Address and length of the register set for the device.
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
+ - resets: phandle used if reset is handled be soc

s/be/by/ ?

Documentation/devicetree/bindings/pci/ti-pci.txt line 12

Quoted 2 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +2 -0
+ - reset-names: name given to the phandle
+ - ti,device-type: Should be 1 - EP TYPE, 2 - LEG EP TYPE OR 3 - RC TYPE

I don't think this makes sense. I'd imagine we'd need the binding to look quite a bit different if endpoint mode was actually supported. I think I would start defining endpoint mode with a different compatible string and go from there.

Documentation/devicetree/bindings/pci/ti-pci.txt line 17

Quoted 5 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +5 -0
+
+Example:
+pcie at 51000000 {
+       compatible = "ti,dra7xx-pcie";
+       reg = <0x51002000 0x14c>, <0x51000000 0x2000>, <0x4A002540 0x1f>, <0x4A003c24 0x4>, <0x4AE07310 0x4>;

This is different number of entries from your actual dts. You need to define how many reg entries, what they are, and the order.

Rob

#4 lore raw

Re: [RFC PATCH 02/12] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 33 lines · Rob Herring
Quoted 19 lines · Kishon Vijay Abraham I

Added support for pcie controller in dra7xx. This driver re-uses the designware core code that is already present in kernel.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   35 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pcie-dra7xx.c                   |  411 ++++++++++++++++++++++
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c
Documentation/devicetree/bindings/pci/ti-pci.txt new file +0 -0
new file mode 100644
index 0000000..0528c47

Documentation/devicetree/bindings/pci/ti-pci.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +10 -0
@@ -0,0 +1,35 @@
+TI PCI Controllers
+
+PCIe Designware Controller
+This node should have the properties described in "designware-pcie.txt".
+ - compatible: Should be "ti,dra7xx-pcie""
+ - reg : Address and length of the register set for the device.
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
+ - resets: phandle used if reset is handled be soc

s/be/by/ ?

Quoted 5 lines

Documentation/devicetree/bindings/pci/ti-pci.txt line 12

Quoted 2 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +2 -0
+ - reset-names: name given to the phandle
+ - ti,device-type: Should be 1 - EP TYPE, 2 - LEG EP TYPE OR 3 - RC TYPE

I don't think this makes sense. I'd imagine we'd need the binding to look quite a bit different if endpoint mode was actually supported. I

right, it makes sense to remove the ti,device-type altogether as this driver only supports RC.

Quoted 11 lines

think I would start defining endpoint mode with a different compatible string and go from there.

Documentation/devicetree/bindings/pci/ti-pci.txt line 17

Quoted 5 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +5 -0
+
+Example:
+pcie at 51000000 {
+       compatible = "ti,dra7xx-pcie";
+       reg = <0x51002000 0x14c>, <0x51000000 0x2000>, <0x4A002540 0x1f>, <0x4A003c24 0x4>, <0x4AE07310 0x4>;

This is different number of entries from your actual dts. You need to define how many reg entries, what they are, and the order.

Ok. Will fix it.

Thanks
Kishon

#5 lore raw

Re: [RFC PATCH 02/12] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Kishon Vijay Abraham I
Quoted 5 lines · Kishon Vijay Abraham I

Added support for pcie controller in dra7xx. This driver re-uses the designware core code that is already present in kernel.

Hi Kishon,
Long time no see! I added trivial comments.

Quoted 5 lines
---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   35 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pcie-dra7xx.c                   |  411 ++++++++++++++++++++++

How about using 'pci-' prefix?
As it was discussed earlier, 'pci-' prefix is more proper.

Quoted 3 lines
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c

[.....]

Quoted 2 lines
drivers/pci/host/pcie-dra7xx.c new file +0 -0

[.....]

drivers/pci/host/pcie-dra7xx.c line 31

Quoted 2 lines
drivers/pci/host/pcie-dra7xx.c new file +2 -0
+#define	PCIECTRL_TI_CONF_IRQSTATUS_MAIN		0x0024
+#define	PCIECTRL_TI_CONF_IRQENABLE_SET_MAIN	0x0028

I don't think that it's good to add vendor names such as TI to SFR names.

How about adding 'DRA7XX' or just removing 'TI'?

1. PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN

2. PCIECTRL_CONF_IRQSTATUS_MAIN

[.....]

drivers/pci/host/pcie-dra7xx.c line 83

Quoted 6 lines
drivers/pci/host/pcie-dra7xx.c new file +6 -0
+enum dra7xx_pcie_device_type {
+	DRA7XX_PCIE_UNKNOWN_TYPE,
+	DRA7XX_PCIE_EP_TYPE,
+	DRA7XX_PCIE_LEG_EP_TYPE,
+	DRA7XX_PCIE_RC_TYPE,
+};

This driver can support only RC mode, so, these enum can be removed.

[.....]

Quoted 7 lines
drivers/pci/host/pcie-dra7xx.c new file +7 -0
+	of_property_read_u32(node, "ti,device-type", &device_type);
+	switch (device_type) {
+	case DRA7XX_PCIE_RC_TYPE:
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_RC);
+		break;
+	case DRA7XX_PCIE_EP_TYPE:

drivers/pci/host/pcie-dra7xx.c line 366

Quoted 10 lines
drivers/pci/host/pcie-dra7xx.c new file +10 -0
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_EP);
+		break;
+	case DRA7XX_PCIE_LEG_EP_TYPE:
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_LEG_EP);
+		break;
+	default:
+		dev_dbg(dev, "UNKNOWN device type %d\n", device_type);
+	}

Thus, this switch can be removed.
Others look good.

Best regards,
Jingoo Han

#6 lore raw

Re: [RFC PATCH 02/12] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 9 lines · Jingoo Han
Quoted 5 lines · Kishon Vijay Abraham I

Added support for pcie controller in dra7xx. This driver re-uses the designware core code that is already present in kernel.

Hi Kishon,
Long time no see! I added trivial comments.

yeah, these were in my TODO for a long time. Sorry for it though.

Quoted 27 lines
Quoted 6 lines
---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   35 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pcie-dra7xx.c                   |  411 ++++++++++++++++++++++

How about using 'pci-' prefix?
As it was discussed earlier, 'pci-' prefix is more proper.

Quoted 3 lines
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pcie-dra7xx.c

[.....]

Quoted 2 lines
drivers/pci/host/pcie-dra7xx.c new file +0 -0

[.....]

drivers/pci/host/pcie-dra7xx.c line 31

Quoted 2 lines
drivers/pci/host/pcie-dra7xx.c new file +2 -0
+#define	PCIECTRL_TI_CONF_IRQSTATUS_MAIN		0x0024
+#define	PCIECTRL_TI_CONF_IRQENABLE_SET_MAIN	0x0028

I don't think that it's good to add vendor names such as TI to SFR names.

Quoted 3 lines

How about adding 'DRA7XX' or just removing 'TI'?

1. PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN

ok.

Quoted 27 lines

2. PCIECTRL_CONF_IRQSTATUS_MAIN

[.....]

drivers/pci/host/pcie-dra7xx.c line 83

Quoted 6 lines
drivers/pci/host/pcie-dra7xx.c new file +6 -0
+enum dra7xx_pcie_device_type {
+	DRA7XX_PCIE_UNKNOWN_TYPE,
+	DRA7XX_PCIE_EP_TYPE,
+	DRA7XX_PCIE_LEG_EP_TYPE,
+	DRA7XX_PCIE_RC_TYPE,
+};

This driver can support only RC mode, so, these enum can be removed.

[.....]

Quoted 11 lines
drivers/pci/host/pcie-dra7xx.c new file +11 -0
+	of_property_read_u32(node, "ti,device-type", &device_type);
+	switch (device_type) {
+	case DRA7XX_PCIE_RC_TYPE:
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_RC);
+		break;
+	case DRA7XX_PCIE_EP_TYPE:
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_EP);
+		break;
+	case DRA7XX_PCIE_LEG_EP_TYPE:
Quoted 8 lines

drivers/pci/host/pcie-dra7xx.c line 366

Quoted 6 lines
drivers/pci/host/pcie-dra7xx.c new file +6 -0
+		dra7xx_pcie_writel(dra7xx->base,
+			PCIECTRL_TI_CONF_DEVICE_TYPE, DEVICE_TYPE_LEG_EP);
+		break;
+	default:
+		dev_dbg(dev, "UNKNOWN device type %d\n", device_type);
+	}

Thus, this switch can be removed.

sure.

Thanks
Kishon

Acked-by on v1 3/12
#8 lore raw

Re: [RFC PATCH 03/12] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

In reply to Kishon Vijay Abraham I
Quoted 11 lines · Kishon Vijay Abraham I

In DRA7, the cpu sees 32bit address, but the pcie controller can see only 28bit address. So whenever the cpu issues a read/write request, the 4 most significant bits are used by L3 to determine the target controller. For example, the cpu reserves 0x2000_0000 - 0x2FFF_FFFF for PCIe controller but the PCIe controller will see only (0x000_0000 - 0xFFF_FFF). So for programming the outbound translation window the *base* should be programmed as 0x000_0000. Whenever we try to write to say 0x2000_0000, it will be translated to whatever we have programmed in the translation window with base as 0x000_0000.

(+cc Pratyush Anand, Marek Vasut, Richard Zhu)

Mohit Kumar, Pratyush Anand,
If you have other opinions, please let us know. :-) Thank you.

Best regards,
Jingoo Han

Quoted 129 lines
---
 .../devicetree/bindings/pci/designware-pcie.txt    |    1 +
 drivers/pci/host/pcie-designware.c                 |   39 ++++++++++++++------
 drivers/pci/host/pcie-designware.h                 |    1 +
 3 files changed, 29 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/pci/designware-pcie.txt +1 -0
index d6fae13..c574dd3 100644
@@ -27,6 +27,7 @@ Optional properties for fsl,imx6q-pcie
 - power-on-gpio: gpio pin number of power-enable signal
 - wake-up-gpio: gpio pin number of incoming wakeup signal
 - disable-gpio: gpio pin number of outgoing rfkill/endpoint disable signal
+- base-mask: address mask for the PCIe controller target port
 
 Example:
 
drivers/pci/host/pcie-designware.c +27 -12
index 17ce88f..98b661c 100644
@@ -464,6 +464,9 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 		return -EINVAL;
 	}
 
+	if (of_property_read_u64(np, "base-mask", &pp->base_mask))
+		pp->base_mask = ~(0x0ULL);
+
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
 		pp->irq_domain = irq_domain_add_linear(pp->dev->of_node,
 					MAX_MSI_IRQS, &msi_domain_ops,
@@ -503,12 +506,15 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 
 static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)
 {
+	u64 cfg0_base;
+
+	cfg0_base = pp->cfg0_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : CFG0 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
 			  PCIE_ATU_VIEWPORT);
-	dw_pcie_writel_rc(pp, pp->cfg0_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->cfg0_base + pp->config.cfg0_size - 1,
+	dw_pcie_writel_rc(pp, cfg0_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg0_base + pp->config.cfg0_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
@@ -518,14 +524,17 @@ static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)
 
 static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
 {
+	u64 cfg1_base;
+
+	cfg1_base = pp->cfg1_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : CFG1 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
+	dw_pcie_writel_rc(pp, cfg1_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg1_base + pp->config.cfg1_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
@@ -533,14 +542,17 @@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
 
 static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
 {
+	u64 mem_base;
+
+	mem_base = pp->mem_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : MEM */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
+	dw_pcie_writel_rc(pp, mem_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (mem_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, mem_base + pp->config.mem_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
@@ -549,14 +561,17 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
 
 static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
 {
+	u64 io_base;
+
+	io_base = pp->io_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : IO */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
-	dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
+	dw_pcie_writel_rc(pp, io_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (io_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, io_base + pp->config.io_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
drivers/pci/host/pcie-designware.h +1 -1
index 3063b35..3fa12a6 100644
@@ -35,6 +35,7 @@ struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
 	void __iomem		*dbi_base;
+	u64			base_mask;
 	u64			cfg0_base;
 	void __iomem		*va_cfg0_base;
 	u64			cfg1_base;
--

1.7.9.5

#9 lore raw

RE: [RFC PATCH 03/12] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Hello Kishon,

Quoted 27 lines

-----Original Message-----
From: Jingoo Han [mailto:jg1.han at samsung.com]
Sent: Thursday, March 27, 2014 5:15 PM
To: 'Kishon Vijay Abraham I'; Mohit KUMAR DCG; Pratyush ANAND
Cc: devicetree at vger.kernel.org; linux-doc at vger.kernel.org; linux- kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux- omap at vger.kernel.org; linux-pci at vger.kernel.org; bhelgaas at google.com; robh+dt at kernel.org; pawel.moll at arm.com; mark.rutland at arm.com; ijc+devicetree at hellion.org.uk; galak at codeaurora.org; rob at landley.net; linux at arm.linux.org.uk; tony at atomide.com; rnayak at ti.com; paul at pwsan.com; 'Marek Vasut'; 'Richard Zhu'
Subject: Re: [RFC PATCH 03/12] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 7 lines · Kishon Vijay Abraham I

In DRA7, the cpu sees 32bit address, but the pcie controller can see only 28bit address. So whenever the cpu issues a read/write request, the 4 most significant bits are used by L3 to determine the target controller. For example, the cpu reserves 0x2000_0000 - 0x2FFF_FFFF for PCIe controller but the PCIe controller will see only (0x000_0000 - 0xFFF_FFF). So for programming the outbound translation window the

*base* should be programmed as 0x000_0000.

Quoted 2 lines

Whenever we try to write to say 0x2000_0000, it will be translated to whatever we have programmed in the translation window with base as

0x000_0000.

Quoted 1 line
Quoted 9 lines
Quoted 1 line

(+cc Pratyush Anand, Marek Vasut, Richard Zhu)

Mohit Kumar, Pratyush Anand,
If you have other opinions, please let us know. :-) Thank you.

- Yes, looks more clean now.

Regards,
Mohit

Quoted 153 lines

Best regards,
Jingoo Han

Quoted 37 lines
---
 .../devicetree/bindings/pci/designware-pcie.txt    |    1 +
 drivers/pci/host/pcie-designware.c                 |   39 ++++++++++++++------
 drivers/pci/host/pcie-designware.h                 |    1 +
 3 files changed, 29 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/pci/designware-pcie.txt +0 -0
index d6fae13..c574dd3 100644
@@ -27,6 +27,7 @@ Optional properties for fsl,imx6q-pcie
 - power-on-gpio: gpio pin number of power-enable signal
 - wake-up-gpio: gpio pin number of incoming wakeup signal
 - disable-gpio: gpio pin number of outgoing rfkill/endpoint disable

signal
+- base-mask: address mask for the PCIe controller target port

Example:

drivers/pci/host/pcie-designware.c +3 -0
index 17ce88f..98b661c 100644
@@ -464,6 +464,9 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 		return -EINVAL;
 	}
 
+	if (of_property_read_u64(np, "base-mask", &pp->base_mask))
+		pp->base_mask = ~(0x0ULL);
+
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
 		pp->irq_domain = irq_domain_add_linear(pp->dev-
 of_node,
drivers/pci/host/pcie-designware.c +0 -0
 					MAX_MSI_IRQS, &msi_domain_ops,

drivers/pci/host/pcie-designware.c int __init dw_pcie_host_init(struct pcie_port · line 514

Quoted 9 lines
drivers/pci/host/pcie-designware.c +3 -0
@@ -503,12 +506,15 @@ int __init dw_pcie_host_init(struct pcie_port
 *pp)
 
 static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32
 busdev)  {
+	u64 cfg0_base;
+
+	cfg0_base = pp->cfg0_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : CFG0 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND |

PCIE_ATU_REGION_INDEX0,

drivers/pci/host/pcie-designware.c int __init dw_pcie_host_init(struct pcie_port *pp)

Quoted 3 lines
drivers/pci/host/pcie-designware.c +0 -2
 			  PCIE_ATU_VIEWPORT);
-	dw_pcie_writel_rc(pp, pp->cfg0_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg0_base >> 32),

PCIE_ATU_UPPER_BASE);

Quoted 7 lines
drivers/pci/host/pcie-designware.c +3 -1
-	dw_pcie_writel_rc(pp, pp->cfg0_base + pp->config.cfg0_size - 1,
+	dw_pcie_writel_rc(pp, cfg0_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg0_base + pp->config.cfg0_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);

dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET); @@ -518,14

+524,17

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)

Quoted 10 lines

@@ static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)

static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32
busdev) {

drivers/pci/host/pcie-designware.c +3 -0
+	u64 cfg1_base;
+
+	cfg1_base = pp->cfg1_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : CFG1 */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND |

PCIE_ATU_REGION_INDEX1,

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)

Quoted 5 lines
drivers/pci/host/pcie-designware.c +0 -2
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32),

PCIE_ATU_UPPER_BASE);

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)

Quoted 7 lines
drivers/pci/host/pcie-designware.c +3 -1
-	dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
+	dw_pcie_writel_rc(pp, cfg1_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, cfg1_base + pp->config.cfg1_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
 	dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET); @@ -533,14

+542,17

Quoted 4 lines

@@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)

static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port

*pp)

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)

Quoted 6 lines

{

drivers/pci/host/pcie-designware.c +3 -0
+	u64 mem_base;
+
+	mem_base = pp->mem_base & pp->base_mask;
 	/* Program viewport 0 : OUTBOUND : MEM */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND |

PCIE_ATU_REGION_INDEX0,

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)

Quoted 5 lines
drivers/pci/host/pcie-designware.c +0 -2
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->mem_base >> 32),

PCIE_ATU_UPPER_BASE);

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)

Quoted 6 lines
drivers/pci/host/pcie-designware.c +3 -1
-	dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
+	dw_pcie_writel_rc(pp, mem_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (mem_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, mem_base + pp->config.mem_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.mem_bus_addr,

PCIE_ATU_LOWER_TARGET);

drivers/pci/host/pcie-designware.c static void · line 569

Quoted 11 lines
drivers/pci/host/pcie-designware.c +3 -0
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
@@ -549,14 +561,17 @@ static void
 dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
 
 static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
 {
+	u64 io_base;
+
+	io_base = pp->io_base & pp->base_mask;
 	/* Program viewport 1 : OUTBOUND : IO */
 	dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND |

PCIE_ATU_REGION_INDEX1,

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)

Quoted 5 lines
drivers/pci/host/pcie-designware.c +0 -2
 			  PCIE_ATU_VIEWPORT);
 	dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
 	dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
-	dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
-	dw_pcie_writel_rc(pp, (pp->io_base >> 32),

PCIE_ATU_UPPER_BASE);

drivers/pci/host/pcie-designware.c static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)

Quoted 6 lines
drivers/pci/host/pcie-designware.c +3 -1
-	dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
+	dw_pcie_writel_rc(pp, io_base, PCIE_ATU_LOWER_BASE);
+	dw_pcie_writel_rc(pp, (io_base >> 32), PCIE_ATU_UPPER_BASE);
+	dw_pcie_writel_rc(pp, io_base + pp->config.io_size - 1,
 			  PCIE_ATU_LIMIT);
 	dw_pcie_writel_rc(pp, pp->config.io_bus_addr,

PCIE_ATU_LOWER_TARGET);

Quoted 16 lines
drivers/pci/host/pcie-designware.c +0 -0
 	dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
drivers/pci/host/pcie-designware.h +1 -1
index 3063b35..3fa12a6 100644
@@ -35,6 +35,7 @@ struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
 	void __iomem		*dbi_base;
+	u64			base_mask;
 	u64			cfg0_base;
 	void __iomem		*va_cfg0_base;
 	u64			cfg1_base;
--

1.7.9.5

#10 lore raw

Re: [RFC PATCH 03/12] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

In reply to Jingoo Han
Quoted 11 lines · Jingoo Han
Quoted 10 lines · Kishon Vijay Abraham I

In DRA7, the cpu sees 32bit address, but the pcie controller can see only 28bit address. So whenever the cpu issues a read/write request, the 4 most significant bits are used by L3 to determine the target controller. For example, the cpu reserves 0x2000_0000 - 0x2FFF_FFFF for PCIe controller but the PCIe controller will see only (0x000_0000 - 0xFFF_FFF). So for programming the outbound translation window the *base* should be programmed as 0x000_0000. Whenever we try to write to say 0x2000_0000, it will be translated to whatever we have programmed in the translation window with base as 0x000_0000.

Quoted 3 lines
Quoted 1 line

(+cc Pratyush Anand, Marek Vasut, Richard Zhu)

Thanks.

Quoted 1 line

This patch has no impact on MX6, the mask on MX6 is ~0 . A few comments below
...
[...]

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -0

b/drivers/pci/host/pcie-designware.c index 17ce88f..98b661c 100644

drivers/pci/host/pcie-designware.c +0 -0
@@ -464,6 +464,9 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 
Quoted 6 lines

drivers/pci/host/pcie-designware.c int __init dw_pcie_host_init(struct pcie_port *pp) · line 468

Quoted 6 lines
drivers/pci/host/pcie-designware.c +2 -0
 		return -EINVAL;
 
 	}
 
+	if (of_property_read_u64(np, "base-mask", &pp->base_mask))
+		pp->base_mask = ~(0x0ULL);

You can just use ~0x0ULL without the () I believe.

[...]

Quoted 10 lines
Quoted 10 lines
(quoted diff) +0 -0

b/drivers/pci/host/pcie-designware.h index 3063b35..3fa12a6 100644

drivers/pci/host/pcie-designware.h +0 -0
@@ -35,6 +35,7 @@ struct pcie_port {
 
 	struct device		*dev;
 	u8			root_bus_nr;
 	void __iomem		*dbi_base;
 
Quoted 5 lines

drivers/pci/host/pcie-designware.h struct pcie_port { · line 41

Quoted 5 lines
drivers/pci/host/pcie-designware.h +1 -0
+	u64			base_mask;
 
drivers/pci/host/pcie-designware.h +0 -0
 	u64			cfg0_base;
 	void __iomem		*va_cfg0_base;
 	u64			cfg1_base;

This structure contains a lot of slop, check [1] please. We really should be more careful about the structures. I think a separate patch to clean this up would be fine though.

[1] http://www.catb.org/esr/structure-packing/