Skip to contentSkip to conversation

PCIe support for DRA7xx

PATCH Superseded Kishon Vijay Abraham I 10 participants 66 messages May 6, 2014 – May 28, 2014

Subsystems (10)

v1 of 2 Superseded Latest is v2 →

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.

The last couple of patches are marked as *TEMP* since the TI reset driver [1] is not yet merged and is in RFC.

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

Changes from RFC:
* Added external clock support for PCIE APLL
* Miscellaneous cleanups in Documentation, macro naming etc..

[1] -> http://www.spinics.net/lists/linux-omap/msg106411.html

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 (15):
phy: phy-omap-pipe3: Add support for PCIe PHY
phy: omap-control: add external clock support for PCIe PHY
phy: ti-pipe3: add external clock support for PCIe PHY
phy: pipe3: insert delay to enumerate in GEN2 mode
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
pci: host: pcie-dra7xx: use reset framework APIs to reset PCIe
ARM: dts: dra7: Add *resets* property for PCIe dt node

 .../devicetree/bindings/pci/designware-pcie.txt    |    1 +
 Documentation/devicetree/bindings/pci/ti-pci.txt   |   35 ++
 Documentation/devicetree/bindings/phy/ti-phy.txt   |   21 +-
 arch/arm/boot/dts/dra7.dtsi                        |   55 +++
 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/pci-dra7xx.c                      |  395 ++++++++++++++++++++
 drivers/pci/host/pcie-designware.c                 |   39 +-
 drivers/pci/host/pcie-designware.h                 |    1 +
 drivers/phy/phy-omap-control.c                     |   92 ++++-
 drivers/phy/phy-ti-pipe3.c                         |  142 +++++--
 include/linux/phy/omap_control_phy.h               |   23 ++
 17 files changed, 898 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pci-dra7xx.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/17 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 9ce458f..cf3de7e 100644
@@ -56,8 +56,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".
@@ -69,6 +69,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
#3 lore raw

PATCH 2/17 phy: omap-control: add external clock support for PCIe PHY

In reply to Kishon Vijay Abraham I

Export an API to be called by PIPE3 PHY to enable external clock for PCIE PHY. Added a new compatible for PCIE in omap-control in order to enable it.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    9 ++--
 drivers/phy/phy-omap-control.c                   |   51 +++++++++++++++++++++-
 include/linux/phy/omap_control_phy.h             |   14 ++++++
 3 files changed, 70 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +6 -3
index cf3de7e..bc9afb5 100644
@@ -9,15 +9,18 @@ Required properties:
                         e.g. USB2_PHY on OMAP5.
  "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control
                         e.g. USB3 PHY and SATA PHY on OMAP5.
+ "ti,control-phy-pcie" - for pcie to support external clock for pcie and to
+			set PCS delay value.
+			e.g. PCIE PHY in DRA7x
  "ti,control-phy-usb2-dra7" - if it has power down register like USB2 PHY on
                         DRA7 platform.
  "ti,control-phy-usb2-am437" - if it has power down register like USB2 PHY on
                         AM437 platform.
  - reg : Address and length of the register set for the device. It contains
    the address of "otghs_control" for control-phy-otghs or "power" register
-   for other types.
- - reg-names: should be "otghs_control" control-phy-otghs and "power" for
-   other types.
+   for other types and "control_sma" for control-phy-pcie
+ - reg-names: should be "otghs_control" for control-phy-otghs,
+  "control_sma" for control-phy-pcie and "power" for other types.
 
 omap_control_usb: omap-control-usb at 4a002300 {
         compatible = "ti,control-phy-otghs";
drivers/phy/phy-omap-control.c +50 -1

87 lines not on this page · raw message

include/linux/phy/omap_control_phy.h +14 -0
index 5450403..15cfbfe 100644
@@ -23,6 +23,7 @@ enum omap_control_phy_type {
 	OMAP_CTRL_TYPE_OTGHS = 1,	/* Mailbox OTGHS_CONTROL */
 	OMAP_CTRL_TYPE_USB2,	/* USB2_PHY, power down in CONTROL_DEV_CONF */
 	OMAP_CTRL_TYPE_PIPE3,	/* PIPE3 PHY, DPLL & seperate Rx/Tx power */
+	OMAP_CTRL_TYPE_PCIE,	/* RX TX control of ACSPCIE */
 	OMAP_CTRL_TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
 	OMAP_CTRL_TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
 };
@@ -33,6 +34,7 @@ struct omap_control_phy {
 	u32 __iomem *otghs_control;
 	u32 __iomem *power;
 	u32 __iomem *power_aux;
+	u32 __iomem *ctrl_sma;
 
 	struct clk *sys_clk;
 
@@ -63,6 +65,13 @@ enum omap_control_usb_mode {
 #define	OMAP_CTRL_PIPE3_PHY_TX_RX_POWERON	0x3
 #define	OMAP_CTRL_PIPE3_PHY_TX_RX_POWEROFF	0x0
 
+#define	OMAP_CTRL_PCIE_TX_RX_CONTROL_SHIFT	0x10
+#define	OMAP_CTRL_PCIE_TX_RX_CONTROL_MASK	0x3
+
+#define	OMAP_CTRL_PCIE_PHY_TX_ACSPCIE		0x1
+#define	OMAP_CTRL_PCIE_PHY_RX_ACSPCIE		0x2
+#define	OMAP_CTRL_PCIE_PHY_TX_RX_ACSPCIE	0x3
+
 #define OMAP_CTRL_USB2_PHY_PD		BIT(28)
 
 #define AM437X_CTRL_USB2_PHY_PD		BIT(0)
@@ -74,6 +83,7 @@ enum omap_control_usb_mode {
 void omap_control_phy_power(struct device *dev, int on);
 void omap_control_usb_set_mode(struct device *dev,
 			       enum omap_control_usb_mode mode);
+void omap_control_pcie_tx_rx_control(struct device *dev, u8 ctrl);
 #else
 
 static inline void omap_control_phy_power(struct device *dev, int on)
@@ -84,6 +94,10 @@ static inline void omap_control_usb_set_mode(struct device *dev,
 	enum omap_control_usb_mode mode)
 {
 }
+
+static inline void omap_control_pcie_tx_rx_control(struct device *dev, u8 ctrl)
+{
+}
 #endif
 
 #endif	/* __OMAP_CONTROL_PHY_H__ */
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 3/17 phy: ti-pipe3: add external clock support for PCIe PHY

In reply to Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
index bc9afb5..d50f8ee 100644
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +48 -27

100 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 24 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +5 -1
index d43019d..5513aa0 100644
@@ -293,7 +293,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
 	const struct of_device_id *match;
-	struct clk *clk;
+	struct clk *clk, *pclk;
 
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
@@ -302,6 +302,20 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	}
 	phy->dev		= &pdev->dev;
 
+	control_node = of_parse_phandle(node, "ctrl-module", 0);
+	if (!control_node) {
+		dev_err(&pdev->dev, "Failed to get control device phandle\n");
+		return -EINVAL;

drivers/phy/phy-ti-pipe3.c static int ti_pipe3_probe(struct platform_device *pdev) · line 318

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +10 -0
+	}
+
+	control_pdev = of_find_device_by_node(control_node);
+	if (!control_pdev) {
+		dev_err(&pdev->dev, "Failed to get control device\n");
+		return -EINVAL;
+	}
+
+	phy->control_dev = &control_pdev->dev;
+

Why this code was moved move is not part of patch description/subject.

Quoted 68 lines
drivers/phy/phy-ti-pipe3.c +33 -19
 	if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
 		match = of_match_device(of_match_ptr(ti_pipe3_id_table),
 					&pdev->dev);
@@ -345,19 +359,40 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	}
 
 	if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
-		clk = devm_clk_get(phy->dev, "dpll_ref");
-		if (IS_ERR(clk)) {
-			dev_err(&pdev->dev, "unable to get dpll ref clk\n");
-			return PTR_ERR(clk);
+		if (!of_property_read_bool(node, "ti,ext-clk")) {
+			clk = devm_clk_get(phy->dev, "dpll_ref");
+			if (IS_ERR(clk)) {
+				dev_err(&pdev->dev,
+					"unable to get dpll ref clk\n");
+				return PTR_ERR(clk);
+			}
+			clk_set_rate(clk, 1500000000);
+
+			clk = devm_clk_get(phy->dev, "dpll_ref_m2");
+			if (IS_ERR(clk)) {
+				dev_err(&pdev->dev,
+					"unable to get dpll ref m2 clk\n");
+				return PTR_ERR(clk);
+			}
+			clk_set_rate(clk, 100000000);
+		} else {
+			omap_control_pcie_tx_rx_control(phy->control_dev,
+						OMAP_CTRL_PCIE_PHY_RX_ACSPCIE);
+
+			clk = clk_get(phy->dev, "apll_mux");
+			if (IS_ERR(clk)) {
+				dev_err(&pdev->dev, "unable to get apll mux clk\n");
+				return PTR_ERR(clk);
+			}
+
+			pclk = clk_get(phy->dev, "refclk_ext");
+			if (IS_ERR(pclk)) {
+				dev_err(&pdev->dev, "unable to get ext ref clk for apll\n");
+				return PTR_ERR(pclk);
+			}
+
+			clk_set_parent(clk, pclk);
 		}
-		clk_set_rate(clk, 1500000000);
-
-		clk = devm_clk_get(phy->dev, "dpll_ref_m2");
-		if (IS_ERR(clk)) {
-			dev_err(&pdev->dev, "unable to get dpll ref m2 clk\n");
-			return PTR_ERR(clk);
-		}
-		clk_set_rate(clk, 100000000);
 
 		clk = devm_clk_get(phy->dev, "phy-div");
 		if (IS_ERR(clk)) {
@@ -375,20 +410,6 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 		phy->div_clk = ERR_PTR(-ENODEV);
 	}
 
-	control_node = of_parse_phandle(node, "ctrl-module", 0);
-	if (!control_node) {
-		dev_err(&pdev->dev, "Failed to get control device phandle\n");
-		return -EINVAL;
-	}
-
-	control_pdev = of_find_device_by_node(control_node);

drivers/phy/phy-ti-pipe3.c static int ti_pipe3_probe(struct platform_device *pdev) · line 415

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +0 -7
-	if (!control_pdev) {
-		dev_err(&pdev->dev, "Failed to get control device\n");
-		return -EINVAL;
-	}
-
-	phy->control_dev = &control_pdev->dev;
-
 	omap_control_phy_power(phy->control_dev, 0);
 
 	platform_set_drvdata(pdev, phy);

--
cheers,
-roger

#7 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi Roger,

Quoted 15 lines · Roger Quadros

Hi Kishon,

Quoted 12 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Quoted 14 lines

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 12 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
index bc9afb5..d50f8ee 100644
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +1 -1
index d43019d..5513aa0 100644
@@ -293,7 +293,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
 	const struct of_device_id *match;
-	struct clk *clk;
+	struct clk *clk, *pclk;
 
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
@@ -302,6 +302,20 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	}
 	phy->dev		= &pdev->dev;
 
Quoted 16 lines
Quoted 4 lines
drivers/phy/phy-ti-pipe3.c +4 -0
+	control_node = of_parse_phandle(node, "ctrl-module", 0);
+	if (!control_node) {
+		dev_err(&pdev->dev, "Failed to get control device phandle\n");
+		return -EINVAL;

drivers/phy/phy-ti-pipe3.c static int ti_pipe3_probe(struct platform_device *pdev) · line 318

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +10 -0
+	}
+
+	control_pdev = of_find_device_by_node(control_node);
+	if (!control_pdev) {
+		dev_err(&pdev->dev, "Failed to get control device\n");
+		return -EINVAL;
+	}
+
+	phy->control_dev = &control_pdev->dev;
+

Why this code was moved move is not part of patch description/subject.

external clock support needs 'control_dev', so had to move the get control device part before configuring the clocks.

Quoted 23 lines
Quoted 23 lines
drivers/phy/phy-ti-pipe3.c +11 -4
 	if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
 		match = of_match_device(of_match_ptr(ti_pipe3_id_table),
 					&pdev->dev);
@@ -345,19 +359,40 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	}
 
 	if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
-		clk = devm_clk_get(phy->dev, "dpll_ref");
-		if (IS_ERR(clk)) {
-			dev_err(&pdev->dev, "unable to get dpll ref clk\n");
-			return PTR_ERR(clk);
+		if (!of_property_read_bool(node, "ti,ext-clk")) {
+			clk = devm_clk_get(phy->dev, "dpll_ref");
+			if (IS_ERR(clk)) {
+				dev_err(&pdev->dev,
+					"unable to get dpll ref clk\n");
+				return PTR_ERR(clk);
+			}
+			clk_set_rate(clk, 1500000000);
+
+			clk = devm_clk_get(phy->dev, "dpll_ref_m2");
+			if (IS_ERR(clk)) {
Quoted 8 lines

drivers/phy/phy-ti-pipe3.c static int ti_pipe3_probe(struct platform_device *pdev) · line 380

Quoted 8 lines
drivers/phy/phy-ti-pipe3.c +8 -0
+				dev_err(&pdev->dev,
+					"unable to get dpll ref m2 clk\n");
+				return PTR_ERR(clk);
+			}
+			clk_set_rate(clk, 100000000);
+		} else {
+			omap_control_pcie_tx_rx_control(phy->control_dev,
+						OMAP_CTRL_PCIE_PHY_RX_ACSPCIE);
                        ^^here

Thanks
Kishon

#8 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 15 lines · Roger Quadros

Hi Kishon,

Quoted 12 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Quoted 14 lines

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 12 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
index bc9afb5..d50f8ee 100644
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

#9 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

Thanks
Kishon

#10 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 46 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

Quoted 7 lines

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

cheers,
-roger

#11 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Regards,
Nishanth Menon

#12 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi Nishant,

Quoted 56 lines · Nishanth Menon
Quoted 55 lines · Roger Quadros
Quoted 53 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

Quoted 5 lines
Quoted 2 lines

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Thanks
Kishon

#13 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 62 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 59 lines · Nishanth Menon
Quoted 57 lines · Roger Quadros
Quoted 46 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

Quoted 7 lines

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

Quoted 6 lines
Quoted 2 lines

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

Regards,
Nishanth Menon

#14 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

Thanks
Kishon

#15 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 88 lines · Kishon Vijay Abraham I

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};
Quoted 4 lines

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

So, How about this: if refclk_ext is not defined, dont do setparent, if it is defined, do setparent.
in short:
Optional Properties:
* "refclk_ext" - external reference clock for pcie apll - if defined, used as the parent to "apll_mux"

That said, my problem in general with this approach(which many folks have taken of describing parent of clock X in hardware block binding for Y) is the following:

The binding now has dependency on clock tree hierarchy. What if towmorrow, we have a tree where refclk_ext parent of muxZ parent of apll_mux? the binding breaks down. Lets not forget that we consider DT as an ABI - we dont want to change the binding in the future.

I had always preferred describing parent-child relationship of clocks by the approach Tero posted: https://patchwork.kernel.org/patch/3871551/

Maybe Mike and Tero could help here?

Signature · 2 lines
Regards,
Nishanth Menon
#16 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Hi,

Quoted 94 lines · Nishanth Menon
Quoted 88 lines · Kishon Vijay Abraham I

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};
Quoted 4 lines

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

Quoted 6 lines

So, How about this: if refclk_ext is not defined, dont do setparent, if it is defined, do setparent.
in short:
Optional Properties:
* "refclk_ext" - external reference clock for pcie apll - if defined, used as the parent to "apll_mux"

Ok, will remove "ti,ext-clk".

Thanks
Kishon

Quoted 15 lines

That said, my problem in general with this approach(which many folks have taken of describing parent of clock X in hardware block binding for Y) is the following:

The binding now has dependency on clock tree hierarchy. What if towmorrow, we have a tree where refclk_ext parent of muxZ parent of apll_mux? the binding breaks down. Lets not forget that we consider DT as an ABI - we dont want to change the binding in the future.

I had always preferred describing parent-child relationship of clocks by the approach Tero posted: https://patchwork.kernel.org/patch/3871551/

Maybe Mike and Tero could help here?

#17 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

In reply to Nishanth Menon

Hi,

Quoted 94 lines · Nishanth Menon
Quoted 88 lines · Kishon Vijay Abraham I

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};
Quoted 4 lines

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

Quoted 6 lines

So, How about this: if refclk_ext is not defined, dont do setparent, if it is defined, do setparent.
in short:
Optional Properties:
* "refclk_ext" - external reference clock for pcie apll - if defined, used as the parent to "apll_mux"

just realized, refclk_ext is not a property by itself but just one of the phandle for clocks/clock-names. Since we want to indicate if we are using external clock from *board* dts file, I'm not sure if there is a way to *append* a property.

Thanks
Kishon

#18 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

In reply to Nishanth Menon

Quoting Nishanth Menon (2014-05-15 05:33:13)

Quoted 110 lines · Kishon Vijay Abraham I
Quoted 88 lines

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};
Quoted 4 lines

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

So, How about this: if refclk_ext is not defined, dont do setparent, if it is defined, do setparent.
in short:
Optional Properties:
* "refclk_ext" - external reference clock for pcie apll - if defined, used as the parent to "apll_mux"

That said, my problem in general with this approach(which many folks have taken of describing parent of clock X in hardware block binding for Y) is the following:

The binding now has dependency on clock tree hierarchy. What if towmorrow, we have a tree where refclk_ext parent of muxZ parent of apll_mux? the binding breaks down. Lets not forget that we consider DT as an ABI - we dont want to change the binding in the future.

Quoted 4 lines

I had always preferred describing parent-child relationship of clocks by the approach Tero posted: https://patchwork.kernel.org/patch/3871551/

Maybe Mike and Tero could help here?

Hi all,

I didn't read all of this context, but it seems like
https://lkml.org/lkml/2014/5/19/539

might be a good fit here. Assuming that the PIPE3 PHY consumes the APLL clock, then it reasonable for the dts phy node to specify assigned-clock-parent.

Regards,
Mike

Quoted 4 lines
Signature · 3 lines
-- 
Regards,
Nishanth Menon
#19 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: add external clock support for PCIe PHY

Quoted 116 lines · Mike Turquette

Quoting Nishanth Menon (2014-05-15 05:33:13)

Quoted 110 lines · Kishon Vijay Abraham I
Quoted 88 lines

Hi,

Quoted 66 lines · Nishanth Menon
Quoted 65 lines · Kishon Vijay Abraham I

Hi Nishant,

Quoted 61 lines · Nishanth Menon
Quoted 50 lines · Roger Quadros
Quoted 49 lines · Kishon Vijay Abraham I

Hi Nishanth,

Quoted 34 lines · Nishanth Menon
Quoted 33 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 29 lines · Roger Quadros

Hi Kishon,

Quoted 17 lines · Kishon Vijay Abraham I

APLL used by PCIE phy can either use external clock as input or the clock from DPLL. Added support for the APLL to use external clock as input here.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 ++
 drivers/phy/phy-ti-pipe3.c                       |   75 ++++++++++++++--------
 2 files changed, 52 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index bc9afb5..d50f8ee 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Required properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +4 -0
@@ -76,6 +76,10 @@ Required properties:
    * "dpll_ref_m2" - external dpll ref clk
    * "phy-div" - divider for apll
    * "div-clk" - apll clock
+   * "apll_mux" - mux for pcie apll
+   * "refclk_ext" - external reference clock for pcie apll
+ - ti,ext-clk: To specifiy if PCIE apll should use external clock. Applicable
+   only to PCIE PHY.

Instead of specifying both clock sources "dpll_ref_clock", "refclk_ext" and then specifying a 3rd control option "ti,ext-clk" to select one of the 2 sources, why can't the DT just supply one clock source, i.e. the one that is being used in the board instance? The driver should then just configure the clock rate that is needed at that node. Shouldn't the clock framework automatically take care of muxing and parent rates?

Quoted 8 lines
Quoted 5 lines

Want the dt to have all the clocks used by the controller. "ti,ext-clk" should go in the board dt file (suggested by Nishanth).
The point is at some point later if some one wants to change the clock source, it should be a simple enabling "ti,ext-clk" flag instead of finding the clock phandle etc..

Wonder if that is implicit by the presence of "refclk_ext" in the clocks provided?

IMO the presence of "refclk_ext" is useless unless the board indicates it provides the clock source.

Quoted 7 lines
Quoted 4 lines

refclk_ext holds phandle for *fixed-clock*, so irrespective of whether the board provides a clock or not, it can have that handle for configuring in PRCM. However if the board does not provide the clock source, configuring refclk_ext in PRCM is useless.

I think what Nishant meant is that if "refclk_ext" is provided it means that the driver should use that over "dpll_ref_clock" so no need of a separate "ti,ext-clk" flag.

yes, thank you for clarifying - it does indeed redundant to have "ti,ext-clk". and apologies on being a little obscure in the comment.

Quoted 8 lines
Quoted 3 lines

Irrespective of whether external reference clock is used or not, all DRA7 (apll) has an input for external reference clock (and also a PRCM register for programming it) and it has to be specified in dt no?

Why is that a binding for ti-phy? that is a problem for the APLL clock driver (selecting it's own source). PHY properties should describe itself -> let the bindings of the APLL describe itself. please dont mix the two up.

The apll clock node is like this

apll_pcie_in_clk_mux: apll_pcie_in_clk_mux at 4ae06118 {
        compatible = "mux-clock";
        clocks = <&dpll_pcie_ref_m2ldo_ck>, <&pciesref_acs_clk_ck>;
        #clock-cells = <0>;
        reg = <0x4a00821c 0x4>;
        bit-mask = <0x80>;
};
Quoted 4 lines

The external reference clock is denoted by *pciesref_acs_clk_ck*.

refclk_ext holds the phandle to *pciesref_acs_clk_ck* and is used in "clk_set_parent" to set the parent of apll mux.

So, How about this: if refclk_ext is not defined, dont do setparent, if it is defined, do setparent.
in short:
Optional Properties:
* "refclk_ext" - external reference clock for pcie apll - if defined, used as the parent to "apll_mux"

That said, my problem in general with this approach(which many folks have taken of describing parent of clock X in hardware block binding for Y) is the following:

The binding now has dependency on clock tree hierarchy. What if towmorrow, we have a tree where refclk_ext parent of muxZ parent of apll_mux? the binding breaks down. Lets not forget that we consider DT as an ABI - we dont want to change the binding in the future.

Quoted 4 lines

I had always preferred describing parent-child relationship of clocks by the approach Tero posted: https://patchwork.kernel.org/patch/3871551/

Maybe Mike and Tero could help here?

Quoted 8 lines

Hi all,

I didn't read all of this context, but it seems like
https://lkml.org/lkml/2014/5/19/539

might be a good fit here. Assuming that the PIPE3 PHY consumes the APLL clock, then it reasonable for the dts phy node to specify assigned-clock-parent.

Yes indeed. Seems like the need to describe some sort of parent description in dt makes sense for other users as well. I wonder if we will see some alignment soonish enough for us to start using them.

Regards,
Nishanth Menon

#20 lore raw

PATCH 4/17 phy: pipe3: insert delay to enumerate in GEN2 mode

In reply to Kishon Vijay Abraham I

8-bit delay value (0xF1) is required for GEN2 devices to be enumerated consistently. Added an API to be called from PHY drivers to set this delay value and called it from PIPE3 driver to set the delay value.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    4 +--
 drivers/phy/phy-omap-control.c                   |   41 ++++++++++++++++++++++
 drivers/phy/phy-ti-pipe3.c                       |    4 ++-
 include/linux/phy/omap_control_phy.h             |    9 +++++
 4 files changed, 55 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -2
index d50f8ee..5653dc4 100644
@@ -18,9 +18,9 @@ Required properties:
                         AM437 platform.
  - reg : Address and length of the register set for the device. It contains
    the address of "otghs_control" for control-phy-otghs or "power" register
-   for other types and "control_sma" for control-phy-pcie
+   for other types and "control_sma", "pcie_pcs" for control-phy-pcie
  - reg-names: should be "otghs_control" for control-phy-otghs,
-  "control_sma" for control-phy-pcie and "power" for other types.
+  "control_sma", "pcie_pcs" for control-phy-pcie and "power" for other types.
 
 omap_control_usb: omap-control-usb at 4a002300 {
         compatible = "ti,control-phy-otghs";
drivers/phy/phy-omap-control.c +41 -0

53 lines not on this page · raw message

drivers/phy/phy-ti-pipe3.c +3 -1
index 5513aa0..a1a0e35 100644
@@ -216,8 +216,10 @@ static int ti_pipe3_init(struct phy *x)
 	u32 val;
 	int ret = 0;
 
-	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie"))
+	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
+		omap_control_pcie_pcs(phy->control_dev, 0x1, 0xF1);
 		return 0;
+	}
 
 	/* Bring it out of IDLE if it is IDLE */
 	val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
include/linux/phy/omap_control_phy.h +9 -0
index 15cfbfe..6127c04 100644
@@ -35,6 +35,7 @@ struct omap_control_phy {
 	u32 __iomem *power;
 	u32 __iomem *power_aux;
 	u32 __iomem *ctrl_sma;
+	u32 __iomem *pcie_pcs;
 
 	struct clk *sys_clk;
 
@@ -68,6 +69,9 @@ enum omap_control_usb_mode {
 #define	OMAP_CTRL_PCIE_TX_RX_CONTROL_SHIFT	0x10
 #define	OMAP_CTRL_PCIE_TX_RX_CONTROL_MASK	0x3
 
+#define	OMAP_CTRL_PCIE_PCS_MASK			0xff
+#define	OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT	0x8
+
 #define	OMAP_CTRL_PCIE_PHY_TX_ACSPCIE		0x1
 #define	OMAP_CTRL_PCIE_PHY_RX_ACSPCIE		0x2
 #define	OMAP_CTRL_PCIE_PHY_TX_RX_ACSPCIE	0x3
@@ -84,6 +88,7 @@ void omap_control_phy_power(struct device *dev, int on);
 void omap_control_usb_set_mode(struct device *dev,
 			       enum omap_control_usb_mode mode);
 void omap_control_pcie_tx_rx_control(struct device *dev, u8 ctrl);
+void omap_control_pcie_pcs(struct device *dev, u8 id, u8 delay);
 #else
 
 static inline void omap_control_phy_power(struct device *dev, int on)
@@ -98,6 +103,10 @@ static inline void omap_control_usb_set_mode(struct device *dev,
 static inline void omap_control_pcie_tx_rx_control(struct device *dev, u8 ctrl)
 {
 }
+
+static inline void omap_control_pcie_pcs(struct device *dev, u8 id, u8 delay)
+{
+}
 #endif
 
 #endif	/* __OMAP_CONTROL_PHY_H__ */
Signature · 1 line
1.7.9.5
Reviewed-by on v1 4/17
#21 lore raw

Re: [PATCH 04/17] phy: pipe3: insert delay to enumerate in GEN2 mode

Quoted 5 lines · Kishon Vijay Abraham I

8-bit delay value (0xF1) is required for GEN2 devices to be enumerated consistently. Added an API to be called from PHY drivers to set this delay value and called it from PIPE3 driver to set the delay value.

--
cheers,
-roger

#22 lore raw

PATCH 5/17 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.

Cc Bjorn Helgaas <[email protected]>
Cc Mohit Kumar <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Marek Vasut <[email protected]>
---
 Documentation/devicetree/bindings/pci/ti-pci.txt |   33 ++
 drivers/pci/host/Kconfig                         |   10 +
 drivers/pci/host/Makefile                        |    1 +
 drivers/pci/host/pci-dra7xx.c                    |  385 ++++++++++++++++++++++
 4 files changed, 429 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/ti-pci.txt
 create mode 100644 drivers/pci/host/pci-dra7xx.c
Documentation/devicetree/bindings/pci/ti-pci.txt new file +33 -0
new file mode 100644
index 0000000..6cb6f09
@@ -0,0 +1,33 @@
+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.
+ - reg-names : "ti_conf" for the TI specific registers and rc_dbics for the
+   "designware" registers.
+ - 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.
+
+Example:
+pcie at 51000000 {
+	compatible = "ti,dra7xx-pcie";
+	reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+	reg-names = "ti_conf", "rc_dbics";
+	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  /* 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";
+};
drivers/pci/host/Kconfig +10 -0
index a6f67ec..7be6393 100644
@@ -1,6 +1,16 @@
 menu "PCI host controller drivers"
 	depends on PCI
 
+config PCI_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..5216f55 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o
+obj-$(CONFIG_PCI_DRA7XX) += pci-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/pci-dra7xx.c new file +385 -0

385 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#23 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 2 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.

[...]

drivers/pci/host/pci-dra7xx.c line 72

Quoted 3 lines
drivers/pci/host/pci-dra7xx.c new file +3 -0
+#define to_dra7xx_pcie(x)	container_of((x), struct dra7xx_pcie, pp)
+
+static inline u32 dra7xx_pcie_readl(void __iomem *base, u32 offset)

Just pass struct dra7xx_pcie * instead of *base here , it will make the code below shorter.

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +5 -0
+{
+	return readl(base + offset);
+}
+
+static inline void dra7xx_pcie_writel(void __iomem *base, u32 offset, u32

value) +{

DTTO.

drivers/pci/host/pci-dra7xx.c line 89

Quoted 11 lines
drivers/pci/host/pci-dra7xx.c new file +11 -0
+	writel(value, base + offset);
+}
+
+static int dra7xx_pcie_link_up(struct pcie_port *pp)
+{
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	u32 reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_PHY_CS);
+
+	if (reg & LINK_UP)
+		return true;
+	return false;

return reg & LINK_UP;

drivers/pci/host/pci-dra7xx.c line 99

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+}
+
+static int dra7xx_pcie_establish_link(struct pcie_port *pp)
+{
+	u32 reg;
+	int retries = 1000;
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+	if (dw_pcie_link_up(pp)) {
+		dev_err(pp->dev, "link is already up\n");

This will spew, since the .link_up (and thus this function) can be called repeatedly. The subsystem will query if the link is up via this function.

drivers/pci/host/pci-dra7xx.c line 107

Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+		return 0;
+	}
+
+	reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
+	reg |= LTSSM_EN;
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
+
+	while (--retries) {

Use retries--

drivers/pci/host/pci-dra7xx.c line 115

Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+		reg = dra7xx_pcie_readl(dra7xx->base,
+					PCIECTRL_DRA7XX_CONF_PHY_CS);
+		if (reg & LINK_UP)
+			break;
+		usleep_range(10, 20);
+	}
+
+	if (retries <= 0) {

Then check if retries == 0 and retries can be unsigned int.

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +6 -0
+		dev_err(pp->dev, "link is not up\n");
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}

[...]

Quoted 49 lines
drivers/pci/host/pci-dra7xx.c new file +49 -0
+static int __init dra7xx_pcie_probe(struct platform_device *pdev)
+{
+	u32 reg;
+	int ret;
+	int irq;
+	struct phy *phy;
+	void __iomem *base;
+	struct resource *res;
+	struct dra7xx_pcie *dra7xx;
+	struct device *dev = &pdev->dev;
+
+	dra7xx = devm_kzalloc(&pdev->dev, sizeof(*dra7xx), GFP_KERNEL);
+	if (!dra7xx)
+		return -ENOMEM;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}
+
+	ret = devm_request_irq(&pdev->dev, irq, dra7xx_pcie_irq_handler,
+			       IRQF_SHARED, "dra7xx-pcie-main", dra7xx);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to request irq\n");
+		return ret;
+	}
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
+	base = devm_ioremap_nocache(dev, res->start, resource_size(res));
+	if (!base)
+		return -ENOMEM;
+
+	phy = devm_phy_get(dev, "pcie-phy");
+	if (IS_ERR(phy))
+		return PTR_ERR(phy);
+
+	ret = phy_init(phy);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_power_on(phy);
+	if (ret < 0)
+		goto err_power_on;
+
+	dra7xx->base = base;
+	dra7xx->phy = phy;
+	dra7xx->dev = dev;
+

drivers/pci/host/pci-dra7xx.c line 332

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (IS_ERR_VALUE(ret)) {
+		dev_err(dev, "pm_runtime_get_sync failed\n");
+		goto err_runtime_get;
+	}
+
+	reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
+	reg &= ~LTSSM_EN;
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);

platform_set_drvdata() should be here, before you add the port.

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +6 -0
+	ret = add_pcie_port(dra7xx, pdev);
+	if (ret < 0)
+		goto err_add_port;
+
+	platform_set_drvdata(pdev, dra7xx);
+	return 0;

[...]

#24 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Hi,

Quoted 36 lines · Marek Vasut
Quoted 2 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.

[...]

drivers/pci/host/pci-dra7xx.c line 72

Quoted 3 lines
drivers/pci/host/pci-dra7xx.c new file +3 -0
+#define to_dra7xx_pcie(x)	container_of((x), struct dra7xx_pcie, pp)
+
+static inline u32 dra7xx_pcie_readl(void __iomem *base, u32 offset)

Just pass struct dra7xx_pcie * instead of *base here , it will make the code below shorter.

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +5 -0
+{
+	return readl(base + offset);
+}
+
+static inline void dra7xx_pcie_writel(void __iomem *base, u32 offset, u32

value) +{

DTTO.

drivers/pci/host/pci-dra7xx.c line 89

Quoted 11 lines
drivers/pci/host/pci-dra7xx.c new file +11 -0
+	writel(value, base + offset);
+}
+
+static int dra7xx_pcie_link_up(struct pcie_port *pp)
+{
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	u32 reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_PHY_CS);
+
+	if (reg & LINK_UP)
+		return true;
+	return false;

return reg & LINK_UP;

Quoted 13 lines

drivers/pci/host/pci-dra7xx.c line 99

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+}
+
+static int dra7xx_pcie_establish_link(struct pcie_port *pp)
+{
+	u32 reg;
+	int retries = 1000;
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+	if (dw_pcie_link_up(pp)) {
+		dev_err(pp->dev, "link is already up\n");

This will spew, since the .link_up (and thus this function) can be called repeatedly. The subsystem will query if the link is up via this function.

*dra7xx_pcie_establish_link* is not the callback for link_up function, so it's actually called only once.

Quoted 92 lines

drivers/pci/host/pci-dra7xx.c line 107

Quoted 9 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+		return 0;
+	}
+
+	reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
+	reg |= LTSSM_EN;
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
+
+	while (--retries) {

Use retries--

drivers/pci/host/pci-dra7xx.c line 115

Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+		reg = dra7xx_pcie_readl(dra7xx->base,
+					PCIECTRL_DRA7XX_CONF_PHY_CS);
+		if (reg & LINK_UP)
+			break;
+		usleep_range(10, 20);
+	}
+
+	if (retries <= 0) {

Then check if retries == 0 and retries can be unsigned int.

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +6 -0
+		dev_err(pp->dev, "link is not up\n");
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}

[...]

Quoted 49 lines
drivers/pci/host/pci-dra7xx.c new file +49 -0
+static int __init dra7xx_pcie_probe(struct platform_device *pdev)
+{
+	u32 reg;
+	int ret;
+	int irq;
+	struct phy *phy;
+	void __iomem *base;
+	struct resource *res;
+	struct dra7xx_pcie *dra7xx;
+	struct device *dev = &pdev->dev;
+
+	dra7xx = devm_kzalloc(&pdev->dev, sizeof(*dra7xx), GFP_KERNEL);
+	if (!dra7xx)
+		return -ENOMEM;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}
+
+	ret = devm_request_irq(&pdev->dev, irq, dra7xx_pcie_irq_handler,
+			       IRQF_SHARED, "dra7xx-pcie-main", dra7xx);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to request irq\n");
+		return ret;
+	}
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
+	base = devm_ioremap_nocache(dev, res->start, resource_size(res));
+	if (!base)
+		return -ENOMEM;
+
+	phy = devm_phy_get(dev, "pcie-phy");
+	if (IS_ERR(phy))
+		return PTR_ERR(phy);
+
+	ret = phy_init(phy);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_power_on(phy);
+	if (ret < 0)
+		goto err_power_on;
+
+	dra7xx->base = base;
+	dra7xx->phy = phy;
+	dra7xx->dev = dev;
+

drivers/pci/host/pci-dra7xx.c line 332

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_get_sync(&pdev->dev);
+	if (IS_ERR_VALUE(ret)) {
+		dev_err(dev, "pm_runtime_get_sync failed\n");
+		goto err_runtime_get;
+	}
+
+	reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
+	reg &= ~LTSSM_EN;
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);

platform_set_drvdata() should be here, before you add the port.

Quoted 5 lines

drivers/pci/host/pci-dra7xx.c line 338

Quoted 5 lines
drivers/pci/host/pci-dra7xx.c new file +5 -0
+	ret = add_pcie_port(dra7xx, pdev);
+	if (ret < 0)
+		goto err_add_port;
+
+	platform_set_drvdata(pdev, dra7xx);

Al-right. Will fix this and all your other comments.

Thanks
Kishon

#25 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Marek Vasut
Quoted 5 lines
Quoted 5 lines
drivers/pci/host/pci-dra7xx.c new file +5 -0
+	writel(value, base + offset);
+}
+
+static int dra7xx_pcie_link_up(struct pcie_port *pp)
+{
Quoted 8 lines

drivers/pci/host/pci-dra7xx.c line 89

Quoted 6 lines
drivers/pci/host/pci-dra7xx.c new file +6 -0
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	u32 reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_PHY_CS);
+
+	if (reg & LINK_UP)
+		return true;
+	return false;

return reg & LINK_UP;

Function int returning true. I'd change the prototype and would return !!(reg & ...);

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#26 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Kishon Vijay Abraham I
Quoted 8 lines · On Tuesday 06 May 2014 19:03:51 Kishon Vijay Abraham I wrote:

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

Cc Bjorn Helgaas <[email protected]>
Cc Mohit Kumar <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Marek Vasut <[email protected]>

Looks pretty good overall, just a few details I noticed:

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

Quoted 11 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +5 -0
new file mode 100644
index 0000000..6cb6f09
@@ -0,0 +1,33 @@
+TI PCI Controllers
+
+PCIe Designware Controller
+This node should have the properties described in "designware-pcie.txt".
+ - compatible: Should be "ti,dra7xx-pcie""

No "xx" in compatible strings please. Just make name this after the first chip to use this particular interface.

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

Quoted 3 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +3 -0
+ - reg : Address and length of the register set for the device.
+ - reg-names : "ti_conf" for the TI specific registers and rc_dbics for the
+   "designware" registers.

The description uses inconsistent quotation marks. You should also have a fixed order in the binding, such as

- reg : Two register ranges as listed in the reg-names property
- reg-names : The first entry must be "ti-conf" for the TI specific registers The second entry must be "rc-dbics" for the designware pcie registers.

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

Quoted 3 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +3 -0
+ - 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.

It's not just a phandle, it can be any phy specifier including additional argument cells.

The second line should just read

- phy-names : must be "pcie-phy"

drivers/pci/host/Kconfig line 7

Quoted 12 lines
drivers/pci/host/Kconfig +4 -0
index a6f67ec..7be6393 100644
@@ -1,6 +1,16 @@
 menu "PCI host controller drivers"
 	depends on PCI
 
+config PCI_DRA7XX
+	bool "TI DRA7xx PCIe controller"
+	select PCIE_DW
+	depends on OF || HAS_IOMEM || TI_PIPE3

I think you mean &&, not || here.

drivers/pci/host/Kconfig line 16

Quoted 9 lines
drivers/pci/host/Kconfig +9 -0
+static inline u32 x(void __iomem *base, u32 offset)
+{
+	return readl(base + offset);
+}
+
+static inline void dra7xx_pcie_writel(void __iomem *base, u32 offset, u32 value)
+{
+	writel(value, base + offset);
+}

These don't actually seem to add any value, you need more characters to call the inline function than to open-code it.

Quoted 8 lines
drivers/pci/host/Kconfig +8 -0
+static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
+{
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
+			   ~INTERRUPTS);
+	dra7xx_pcie_writel(dra7xx->base,
+			   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN, INTERRUPTS);

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI,
+			   ~LEG_EP_INTERRUPTS & ~MSI);
+
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		dra7xx_pcie_writel(dra7xx->base,
+				   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI, MSI);
+	else
+		dra7xx_pcie_writel(dra7xx->base,
+				   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI,
+				   LEG_EP_INTERRUPTS);

Doesn't this just enable one or the other? In general I'd assume you need both INTx and MSI, at least if MSI is available.

It probably doesn't hurt to always turn them all on.

Quoted 10 lines
drivers/pci/host/Kconfig +9 -0
+static int add_pcie_port(struct dra7xx_pcie *dra7xx,
+			  struct platform_device *pdev)
+{
+	int ret;
+	struct pcie_port *pp;
+	struct resource *res;
+	struct device *dev = &pdev->dev;
+
+	pp = &dra7xx->pp;

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+	pp->dev = dev;
+	pp->ops = &dra7xx_pcie_host_ops;
+
+	spin_lock_init(&pp->conf_lock);
+
+	pp->irq = platform_get_irq(pdev, 1);
+	if (pp->irq < 0) {
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}

The binding does not list a mandatory "interrupts" property, so this should not be treated as an error.

Quoted 4 lines
drivers/pci/host/Kconfig +4 -0
+static int __init dra7xx_pcie_probe(struct platform_device *pdev)
+{
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}
+
+	ret = devm_request_irq(&pdev->dev, irq, dra7xx_pcie_irq_handler,
+			       IRQF_SHARED, "dra7xx-pcie-main", dra7xx);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to request irq\n");
+		return ret;
+	}

Same here.

drivers/pci/host/Kconfig

Quoted 3 lines
drivers/pci/host/Kconfig +3 -0
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
+	base = devm_ioremap_nocache(dev, res->start, resource_size(res));

Just use devm_ioremap() instead of devm_ioremap_nocache(). The second one is just there for historic reasons, and they always do the same thing.

Arnd

#27 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Hi,

Quoted 12 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 06 May 2014 19:03:51 Kishon Vijay Abraham I wrote:

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

Cc Bjorn Helgaas <[email protected]>
Cc Mohit Kumar <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Marek Vasut <[email protected]>

Looks pretty good overall, just a few details I noticed:

Quoted 14 lines

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

Quoted 11 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +5 -0
new file mode 100644
index 0000000..6cb6f09
@@ -0,0 +1,33 @@
+TI PCI Controllers
+
+PCIe Designware Controller
+This node should have the properties described in "designware-pcie.txt".
+ - compatible: Should be "ti,dra7xx-pcie""

No "xx" in compatible strings please. Just make name this after the first chip to use this particular interface.

ok.

Quoted 11 lines

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

Quoted 4 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +3 -0
+ - reg : Address and length of the register set for the device.
+ - reg-names : "ti_conf" for the TI specific registers and rc_dbics for the
+   "designware" registers.

The description uses inconsistent quotation marks. You should also have a fixed order in the binding, such as

- reg : Two register ranges as listed in the reg-names property
- reg-names : The first entry must be "ti-conf" for the TI specific registers The second entry must be "rc-dbics" for the designware pcie registers.

ok, looks better.

Quoted 11 lines

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

Quoted 4 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +3 -0
+ - 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.

It's not just a phandle, it can be any phy specifier including additional argument cells.

The second line should just read

- phy-names : must be "pcie-phy"

will fix this.

Quoted 9 lines
Quoted 9 lines
drivers/pci/host/Kconfig +0 -0
index a6f67ec..7be6393 100644
@@ -1,6 +1,16 @@
 menu "PCI host controller drivers"
 	depends on PCI
 
Quoted 6 lines

drivers/pci/host/Kconfig line 7

Quoted 4 lines
drivers/pci/host/Kconfig +4 -0
+config PCI_DRA7XX
+	bool "TI DRA7xx PCIe controller"
+	select PCIE_DW
+	depends on OF || HAS_IOMEM || TI_PIPE3

I think you mean &&, not || here.

ah.. indeed.

Quoted 27 lines

drivers/pci/host/Kconfig line 16

Quoted 10 lines
drivers/pci/host/Kconfig +9 -0
+static inline u32 x(void __iomem *base, u32 offset)
+{
+	return readl(base + offset);
+}
+
+static inline void dra7xx_pcie_writel(void __iomem *base, u32 offset, u32 value)
+{
+	writel(value, base + offset);
+}

These don't actually seem to add any value, you need more characters to call the inline function than to open-code it.

Quoted 13 lines
drivers/pci/host/Kconfig +13 -0
+static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
+{
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
+			   ~INTERRUPTS);
+	dra7xx_pcie_writel(dra7xx->base,
+			   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN, INTERRUPTS);
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI,
+			   ~LEG_EP_INTERRUPTS & ~MSI);
+
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		dra7xx_pcie_writel(dra7xx->base,
Quoted 8 lines

drivers/pci/host/Kconfig

Quoted 5 lines
drivers/pci/host/Kconfig +5 -0
+				   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI, MSI);
+	else
+		dra7xx_pcie_writel(dra7xx->base,
+				   PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI,
+				   LEG_EP_INTERRUPTS);

Doesn't this just enable one or the other? In general I'd assume you need both INTx and MSI, at least if MSI is available.

Not sure since the programming sequence in the TRM explicitly states either legacy interrupts or MSI interrupts should be enabled but not both.

Quoted 18 lines

It probably doesn't hurt to always turn them all on.

Quoted 15 lines
drivers/pci/host/Kconfig +15 -0
+static int add_pcie_port(struct dra7xx_pcie *dra7xx,
+			  struct platform_device *pdev)
+{
+	int ret;
+	struct pcie_port *pp;
+	struct resource *res;
+	struct device *dev = &pdev->dev;
+
+	pp = &dra7xx->pp;
+	pp->dev = dev;
+	pp->ops = &dra7xx_pcie_host_ops;
+
+	spin_lock_init(&pp->conf_lock);
+
+	pp->irq = platform_get_irq(pdev, 1);
Quoted 8 lines

drivers/pci/host/Kconfig

Quoted 5 lines
drivers/pci/host/Kconfig +4 -0
+	if (pp->irq < 0) {
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}

The binding does not list a mandatory "interrupts" property, so this should not be treated as an error.

actually the 'interrupts' property is documented in pci/designware-pcie.txt.

Quoted 18 lines
Quoted 5 lines
drivers/pci/host/Kconfig +4 -0
+static int __init dra7xx_pcie_probe(struct platform_device *pdev)
+{
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+		dev_err(dev, "missing IRQ resource\n");
+		return -EINVAL;
+	}
+
+	ret = devm_request_irq(&pdev->dev, irq, dra7xx_pcie_irq_handler,
+			       IRQF_SHARED, "dra7xx-pcie-main", dra7xx);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to request irq\n");
+		return ret;
+	}

Same here.

Quoted 7 lines

drivers/pci/host/Kconfig

Quoted 3 lines
drivers/pci/host/Kconfig +3 -0
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
+	base = devm_ioremap_nocache(dev, res->start, resource_size(res));

Just use devm_ioremap() instead of devm_ioremap_nocache(). The second one is just there for historic reasons, and they always do the same thing.

Ok.

Thanks
Kishon

#28 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 22 lines · On Wednesday 07 May 2014 14:14:55 Kishon Vijay Abraham I wrote:
Quoted 13 lines
Quoted 13 lines
drivers/pci/host/pci-dra7xx.c new file +13 -0
+static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
+{
+    struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+    dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
+                       ~INTERRUPTS);
+    dra7xx_pcie_writel(dra7xx->base,
+                       PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN, INTERRUPTS);
+    dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI,
+                       ~LEG_EP_INTERRUPTS & ~MSI);
+
+    if (IS_ENABLED(CONFIG_PCI_MSI))
+            dra7xx_pcie_writel(dra7xx->base,
Quoted 8 lines

drivers/pci/host/pci-dra7xx.c line 140

Quoted 5 lines
drivers/pci/host/pci-dra7xx.c new file +5 -0
+                               PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI, MSI);
+    else
+            dra7xx_pcie_writel(dra7xx->base,
+                               PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI,
+                               LEG_EP_INTERRUPTS);

Doesn't this just enable one or the other? In general I'd assume you need both INTx and MSI, at least if MSI is available.

Quoted 2 lines

Not sure since the programming sequence in the TRM explicitly states either legacy interrupts or MSI interrupts should be enabled but not both.

Hmm, I think that means you can't have MSI at all. You have to support legacy PCI devices that can't do MSI.

Do you know if you have a modern GIC implementation with MSI support in these SoCs? It would be better anyway to use the GIC for doing MSI, so you can just ignore the internal MSI controller here.

Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
drivers/pci/host/pci-dra7xx.c new file +15 -0
+static int add_pcie_port(struct dra7xx_pcie *dra7xx,
+                      struct platform_device *pdev)
+{
+    int ret;
+    struct pcie_port *pp;
+    struct resource *res;
+    struct device *dev = &pdev->dev;
+
+    pp = &dra7xx->pp;
+    pp->dev = dev;
+    pp->ops = &dra7xx_pcie_host_ops;
+
+    spin_lock_init(&pp->conf_lock);
+
+    pp->irq = platform_get_irq(pdev, 1);
Quoted 8 lines

drivers/pci/host/pci-dra7xx.c line 247

Quoted 5 lines
drivers/pci/host/pci-dra7xx.c new file +4 -0
+    if (pp->irq < 0) {
+            dev_err(dev, "missing IRQ resource\n");
+            return -EINVAL;
+    }

The binding does not list a mandatory "interrupts" property, so this should not be treated as an error.

Quoted 1 line

actually the 'interrupts' property is documented in pci/designware-pcie.txt.

Hmm, but you don't seem to use it the same way as documented there. I'm not sure what 'level interrupt, pulse interrupt, special interrupt' in the parent binding are, but they don't seem to be the ones you use here.

Arnd

#29 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Hi Arnd,

Quoted 23 lines · Arnd Bergmann
Quoted 22 lines · On Wednesday 07 May 2014 14:14:55 Kishon Vijay Abraham I wrote:
Quoted 21 lines
Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
+{
+    struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+    dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
+                       ~INTERRUPTS);
+    dra7xx_pcie_writel(dra7xx->base,
+                       PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN, INTERRUPTS);

drivers/pci/host/pci-dra7xx.c line 140

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+    dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI,
+                       ~LEG_EP_INTERRUPTS & ~MSI);
+
+    if (IS_ENABLED(CONFIG_PCI_MSI))
+            dra7xx_pcie_writel(dra7xx->base,
+                               PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI, MSI);
+    else
+            dra7xx_pcie_writel(dra7xx->base,
+                               PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI,
+                               LEG_EP_INTERRUPTS);

Doesn't this just enable one or the other? In general I'd assume you need both INTx and MSI, at least if MSI is available.

Quoted 8 lines
Quoted 2 lines

Not sure since the programming sequence in the TRM explicitly states either legacy interrupts or MSI interrupts should be enabled but not both.

Hmm, I think that means you can't have MSI at all. You have to support legacy PCI devices that can't do MSI.

Do you know if you have a modern GIC implementation with MSI support in these SoCs? It would be better anyway to use the GIC for doing

In DRA7 it is not there. I'm not sure in other platforms.

Quoted 26 lines

MSI, so you can just ignore the internal MSI controller here.

Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +9 -0
+static int add_pcie_port(struct dra7xx_pcie *dra7xx,
+                      struct platform_device *pdev)
+{
+    int ret;
+    struct pcie_port *pp;
+    struct resource *res;
+    struct device *dev = &pdev->dev;
+
+    pp = &dra7xx->pp;

drivers/pci/host/pci-dra7xx.c line 247

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+    pp->dev = dev;
+    pp->ops = &dra7xx_pcie_host_ops;
+
+    spin_lock_init(&pp->conf_lock);
+
+    pp->irq = platform_get_irq(pdev, 1);
+    if (pp->irq < 0) {
+            dev_err(dev, "missing IRQ resource\n");
+            return -EINVAL;
+    }

The binding does not list a mandatory "interrupts" property, so this should not be treated as an error.

Quoted 6 lines
Quoted 1 line

actually the 'interrupts' property is documented in pci/designware-pcie.txt.

Hmm, but you don't seem to use it the same way as documented there. I'm not sure what 'level interrupt, pulse interrupt, special interrupt' in the parent binding are, but they don't seem to be the ones you use here.

Yeah. I'll update my Documentation. Thanks for pointing this out.

Thanks
Kishon

#30 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

In reply to Kishon Vijay Abraham I

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

Quoted 11 lines · Kishon Vijay Abraham I
Documentation/devicetree/bindings/pci/ti-pci.txt new file +11 -0
+Example:
+pcie at 51000000 {
+	compatible = "ti,dra7xx-pcie";
+	reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+	reg-names = "ti_conf", "rc_dbics";
+	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  /* Configuration Space */

Configuration space should not show up in the ranges, please don't copy that mistake from other drivers, put it in reg.

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

Quoted 2 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +2 -0
+	interrupt-map-mask = <0 0 0 0>;
+	interrupt-map = <0x0 0 &gic 134>;

The HW cannot decode INTA/B/C/D?

drivers/pci/host/pci-dra7xx.c line 55

Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+#define	PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI		0x0034
+#define	PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI		0x0038
+#define	INTA						BIT(0)
+#define	INTB						BIT(1)
+#define	INTC						BIT(2)
+#define	INTD						BIT(3)
+#define	MSI						BIT(4)
+#define	LEG_EP_INTERRUPTS (INTA | INTB | INTC | INTD)

Oh, it can, it would be wise to export this from the driver. Look at the latest patches from Srikanth Thokala for the Xilinx PCI driver to see how this should look

Quoted 20 lines
drivers/pci/host/pci-dra7xx.c new file +20 -0
+static int dra7xx_pcie_establish_link(struct pcie_port *pp)
+{
+	u32 reg;
+	int retries = 1000;
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
+	if (dw_pcie_link_up(pp)) {
+		dev_err(pp->dev, "link is already up\n");
+		return 0;
+	}
+
+	reg = dra7xx_pcie_readl(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
+	reg |= LTSSM_EN;
+	dra7xx_pcie_writel(dra7xx->base, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
+
+	while (--retries) {
+		reg = dra7xx_pcie_readl(dra7xx->base,
+					PCIECTRL_DRA7XX_CONF_PHY_CS);
+		if (reg & LINK_UP)
+			break;

drivers/pci/host/pci-dra7xx.c line 121

Quoted 10 lines
drivers/pci/host/pci-dra7xx.c new file +10 -0
+		usleep_range(10, 20);
+	}
+
+	if (retries <= 0) {
+		dev_err(pp->dev, "link is not up\n");
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}

It would be really nice to see the link bring up process live in the PCI core, every driver seems to have its own take on this.

The PCI-E spec requires a 100ms delay after link bring up (aka hot reset) before sending any configuration TLPs.

Jason

#31 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Hi,

Quoted 15 lines · Jason Gunthorpe

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

Quoted 11 lines · Kishon Vijay Abraham I
Documentation/devicetree/bindings/pci/ti-pci.txt new file +11 -0
+Example:
+pcie at 51000000 {
+	compatible = "ti,dra7xx-pcie";
+	reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+	reg-names = "ti_conf", "rc_dbics";
+	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  /* Configuration Space */

Configuration space should not show up in the ranges, please don't copy that mistake from other drivers, put it in reg.

But then it needs pcie-designware.c to be modified and it will be breaking other platforms no?

Quoted 6 lines

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

Quoted 3 lines
Documentation/devicetree/bindings/pci/ti-pci.txt new file +2 -0
+	interrupt-map-mask = <0 0 0 0>;
+	interrupt-map = <0x0 0 &gic 134>;

The HW cannot decode INTA/B/C/D?

Quoted 12 lines

drivers/pci/host/pci-dra7xx.c line 55

Quoted 8 lines
drivers/pci/host/pci-dra7xx.c new file +8 -0
+#define	PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI		0x0034
+#define	PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI		0x0038
+#define	INTA						BIT(0)
+#define	INTB						BIT(1)
+#define	INTC						BIT(2)
+#define	INTD						BIT(3)
+#define	MSI						BIT(4)
+#define	LEG_EP_INTERRUPTS (INTA | INTB | INTC | INTD)

Oh, it can, it would be wise to export this from the driver. Look at the latest patches from Srikanth Thokala for the Xilinx PCI driver to see how this should look

ok.. will have a look at it.

Thanks
Kishon

#32 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 17 lines · On Wednesday 07 May 2014 14:52:47 Kishon Vijay Abraham I wrote:
Quoted 15 lines · Jason Gunthorpe

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

Quoted 11 lines · Kishon Vijay Abraham I
Documentation/devicetree/bindings/pci/ti-pci.txt new file +11 -0
+Example:
+pcie at 51000000 {
+    compatible = "ti,dra7xx-pcie";
+    reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+    reg-names = "ti_conf", "rc_dbics";
+    interrupts = <0 232 0x4>, <0 233 0x4>;
+    #address-cells = >;
+    #size-cells = <2>;
+    device_type = "pci";
+    ti,device_type = >;
+    ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000  /* Configuration Space */

Configuration space should not show up in the ranges, please don't copy that mistake from other drivers, put it in reg.

Quoted 2 lines

But then it needs pcie-designware.c to be modified and it will be breaking other platforms no?

I think the pcie-designware driver should be changed to allow either way. Ideally we would deprecate the existing method in a way that for new front-ends it doesn't work, but the old front-ends can still deal with it but also work if you put it into the reg property.

Arnd

#33 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 18 lines · Arnd Bergmann
Quoted 17 lines · On Wednesday 07 May 2014 14:52:47 Kishon Vijay Abraham I wrote:
Quoted 15 lines · Jason Gunthorpe

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

Quoted 11 lines · Kishon Vijay Abraham I
Documentation/devicetree/bindings/pci/ti-pci.txt new file +11 -0
+Example:
+pcie at 51000000 {
+    compatible = "ti,dra7xx-pcie";
+    reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+    reg-names = "ti_conf", "rc_dbics";
+    interrupts = <0 232 0x4>, <0 233 0x4>;
+    #address-cells = >;
+    #size-cells = <2>;
+    device_type = "pci";
+    ti,device_type = >;
+    ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000  /* Configuration Space */

Configuration space should not show up in the ranges, please don't copy that mistake from other drivers, put it in reg.

Quoted 7 lines
Quoted 2 lines

But then it needs pcie-designware.c to be modified and it will be breaking other platforms no?

I think the pcie-designware driver should be changed to allow either way. Ideally we would deprecate the existing method in a way that for new front-ends it doesn't work, but the old front-ends can still deal with it but also work if you put it into the reg property.

(+cc Pratyush Anand, Thierry Reding)

Hi Arnd,

Thank you for your comment.
Do you mean the case of Tegra PCIe as below?

./arch/arm/boot/dts/tegra20.dts

	pcie-controller at 80003000 {
		...
		reg = <0x80003000 0x00000800   /* PADS registers */
			 0x80003800 0x00000200   /* AFI registers */
			 0x90000000 0x10000000>; /* configuration space */
		...
		ranges = <0x82000000 0 0x80000000 0x80000000 0 0x00001000   /* port 0 registers */
			0x82000000 0 0x80001000 0x80001000 0 0x00001000   /* port 1 registers */
			0x81000000 0 0          0x82000000 0 0x00010000   /* downstream I/O */
			0x82000000 0 0xa0000000 0xa0000000 0 0x08000000   /* non-prefetchable memory */
			0xc2000000 0 0xa8000000 0xa8000000 0 0x18000000>; /* prefetchable memory */
		...

./drivers/pci/host/pci-tegra.c

	/* request configuration space, but remap later, on demand */
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
	...
	pcie->cs = devm_request_mem_region(pcie->dev, res->start,
						resource_size(res), res->name);

Best regards,
Jingoo Han

#34 lore raw

Re: [PATCH 05/17] pci: host: pcie-dra7xx: add support for pcie-dra7xx controller

Quoted 48 lines · On Thursday 08 May 2014 17:56:38 Jingoo Han wrote:
Quoted 18 lines · Arnd Bergmann
Quoted 17 lines · On Wednesday 07 May 2014 14:52:47 Kishon Vijay Abraham I wrote:
Quoted 15 lines · Jason Gunthorpe

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

Quoted 11 lines · Kishon Vijay Abraham I
Documentation/devicetree/bindings/pci/ti-pci.txt new file +11 -0
+Example:
+pcie at 51000000 {
+    compatible = "ti,dra7xx-pcie";
+    reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+    reg-names = "ti_conf", "rc_dbics";
+    interrupts = <0 232 0x4>, <0 233 0x4>;
+    #address-cells = >;
+    #size-cells = <2>;
+    device_type = "pci";
+    ti,device_type = >;
+    ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000  /* Configuration Space */

Configuration space should not show up in the ranges, please don't copy that mistake from other drivers, put it in reg.

Quoted 7 lines
Quoted 2 lines

But then it needs pcie-designware.c to be modified and it will be breaking other platforms no?

I think the pcie-designware driver should be changed to allow either way. Ideally we would deprecate the existing method in a way that for new front-ends it doesn't work, but the old front-ends can still deal with it but also work if you put it into the reg property.

(+cc Pratyush Anand, Thierry Reding)

Hi Arnd,

Thank you for your comment.
Do you mean the case of Tegra PCIe as below?

./arch/arm/boot/dts/tegra20.dts

        pcie-controller at 80003000 {
                ...
                reg = <0x80003000 0x00000800   /* PADS registers */
                         0x80003800 0x00000200   /* AFI registers */
                         0x90000000 0x10000000>; /* configuration space */
                ...
                ranges = <0x82000000 0 0x80000000 0x80000000 0 0x00001000   /* port 0 registers */
                        0x82000000 0 0x80001000 0x80001000 0 0x00001000   /* port 1 registers */
                        0x81000000 0 0          0x82000000 0 0x00010000   /* downstream I/O */
                        0x82000000 0 0xa0000000 0xa0000000 0 0x08000000   /* non-prefetchable memory */
                        0xc2000000 0 0xa8000000 0xa8000000 0 0x18000000>; /* prefetchable memory */
                ...
Quoted 6 lines

./drivers/pci/host/pci-tegra.c

        /* request configuration space, but remap later, on demand */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
        ...
        pcie->cs = devm_request_mem_region(pcie->dev, res->start,
                                                resource_size(res), res->name);

Yes, that is how the config space should be handled normally.

Arnd

#35 lore raw

PATCH 6/17 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 c4e3732..243f148 100644
@@ -463,6 +463,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,
@@ -502,12 +505,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);
@@ -517,13 +523,16 @@ 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, 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);
@@ -532,13 +541,16 @@ 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, 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),
@@ -548,13 +560,16 @@ 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, 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
#36 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

I also suspect you will have to implement swiotlb support to make generic PCI devices work behind this bridge. Otherwise you end up with random physical addresses passed into DMA registers.

Arnd

#37 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

Thank you.

Best regards,
Jingoo Han

Quoted 4 lines

I also suspect you will have to implement swiotlb support to make generic PCI devices work behind this bridge. Otherwise you end up with random physical addresses passed into DMA registers.

#38 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 21 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 20 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

Quoted 9 lines
Quoted 3 lines

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

Arnd

#39 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Hi,

Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Quoted 7 lines
Quoted 3 lines

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

For some reason lkml is not showing any contents. Do you have a different link?

Thanks
Kishon

#40 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 33 lines · Kishon Vijay Abraham I
Quoted 32 lines · Arnd Bergmann
Quoted 30 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

Quoted 5 lines
Quoted 3 lines

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

For some reason lkml is not showing any contents. Do you have a different link?

Hi Kishon,

Please refer to the following link. :-)
http://www.spinics.net/lists/linux-pci/msg29855.html

Best regards,
Jingoo Han

#41 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

In reply to Arnd Bergmann

Hi Arnd,

Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Quoted 7 lines
Quoted 3 lines

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

Do you think it can be used for *outbound* window setup too? The problem is the *ranges* property defines both the pci address and cpu address which should have been enough to program the ob translation window, but the hw is designed so that the controller sees only the 28 bits. (The most significant 4 bits is for the l3 to address the controller).

Thanks
Kishon

#42 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 37 lines · On Tuesday 13 May 2014 18:01:59 Kishon Vijay Abraham I wrote:
Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Quoted 7 lines
Quoted 3 lines

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

Quoted 5 lines

Do you think it can be used for *outbound* window setup too? The problem is the *ranges* property defines both the pci address and cpu address which should have been enough to program the ob translation window, but the hw is designed so that the controller sees only the 28 bits. (The most significant 4 bits is for the l3 to address the controller).

I'm not following what the problem is. You should always be able to describe in the inbound window (that is from the CPU perspective) using dma-ranges and the outbound window using ranges.

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

	ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

	ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Arnd

#43 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Hi Arnd,

Quoted 53 lines · Arnd Bergmann
Quoted 37 lines · On Tuesday 13 May 2014 18:01:59 Kishon Vijay Abraham I wrote:
Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Thursday 08 May 2014 18:05:11 Jingoo Han wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 May 2014 19:03:52 Kishon Vijay Abraham I wrote:

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 5 lines
Quoted 7 lines

Sorry, but NAK.

We have a standard 'dma-ranges' property to handle this, so use it.

See the x-gene PCIe driver patches for an example. Please also talk to Santosh about it, as he is implementing generic support for parsing dma-ranges in platform devices at the moment.

Hi Arnd,

Quoted 7 lines
Quoted 3 lines

Do you mean the following patch?
http://www.spinics.net/lists/kernel/msg1737725.html

That is the patch Santosh did for platform devices, which is related but not what I meant here. For the PCI inbound window setup, please have a look at https://lkml.org/lkml/2014/3/19/607

Quoted 5 lines

Do you think it can be used for *outbound* window setup too? The problem is the *ranges* property defines both the pci address and cpu address which should have been enough to program the ob translation window, but the hw is designed so that the controller sees only the 28 bits. (The most significant 4 bits is for the l3 to address the controller).

I'm not following what the problem is. You should always be able to describe in the inbound window (that is from the CPU perspective) using dma-ranges and the outbound window using ranges.

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

	ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;
Quoted 7 lines

or

	ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Thanks
Kishon

#44 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 7 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 7 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

Quoted 9 lines
Quoted 5 lines
      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

Arnd

#45 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 14 lines · On Tuesday 13 May 2014 15:27:46 Arnd Bergmann wrote:
Quoted 13 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 12 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Quoted 6 lines
Quoted 3 lines

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

To clarify: using <0x82000000 0 0 0xb0000000 0 0x10000000> will give you a mem_offset of 0xb0000000, which should work just fine for this case.

What I don't understand is why the ATU cares about whether the outbound address is 0x0000000 or 0xb0000000 if it just decodes the lower 28 bit anyway. Did you mean that we have to program the BARs using low addresses regardless of what is programmed in the ATU? That would make more sense, and it also matches what I suggested.

Arnd

#46 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

hi Arnd,

Quoted 22 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 13 May 2014 15:27:46 Arnd Bergmann wrote:
Quoted 13 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 12 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Quoted 6 lines
Quoted 3 lines

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

Quoted 8 lines

To clarify: using <0x82000000 0 0 0xb0000000 0 0x10000000> will give you a mem_offset of 0xb0000000, which should work just fine for this case.

What I don't understand is why the ATU cares about whether the outbound address is 0x0000000 or 0xb0000000 if it just decodes the lower 28 bit anyway. Did you mean that we have to program the BARs using low addresses regardless of what is programmed in the ATU? That would make more sense, and it also matches what I suggested.

No, It's not like it decodes only the lower 28bits. The BARs is programmed with 32 bit value.

My pcie dt node has
ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000 /* CONFIG */

           0x81000000 0 0          0x20003000 0 0x00010000  /* IO */
           0x82000000 0 0x20013000 0x20013000 0 0xffed000>; /* MEM */

Consider MEM address space..

Here both PCI address and CPU address is 0x20013000. So when there is a write to cpu addr 0x20013000 [writel(virt_addr(0x20013000)], we want it to be translated to PCI addr 0x20013000. So in 'ATU', we would expect *base* to be programmed to *0x20013000* and target to be programmed to *0x20013000*. But that's not the case for DRA7xx. For DRA7xx *base* should be programmed to *0x0013000* and target should be programmed to *0x20013000*.

Thanks
Kishon

#47 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 42 lines · On Wednesday 14 May 2014 11:14:45 Kishon Vijay Abraham I wrote:

hi Arnd,

Quoted 22 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 13 May 2014 15:27:46 Arnd Bergmann wrote:
Quoted 13 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 12 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Quoted 6 lines
Quoted 3 lines

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

Quoted 8 lines

To clarify: using <0x82000000 0 0 0xb0000000 0 0x10000000> will give you a mem_offset of 0xb0000000, which should work just fine for this case.

What I don't understand is why the ATU cares about whether the outbound address is 0x0000000 or 0xb0000000 if it just decodes the lower 28 bit anyway. Did you mean that we have to program the BARs using low addresses regardless of what is programmed in the ATU? That would make more sense, and it also matches what I suggested.

No, It's not like it decodes only the lower 28bits. The BARs is programmed with 32 bit value.

My pcie dt node has
ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000 /* CONFIG */

           0x81000000 0 0          0x20003000 0 0x00010000  /* IO */
           0x82000000 0 0x20013000 0x20013000 0 0xffed000>; /* MEM */
Quoted 8 lines

Consider MEM address space..

Here both PCI address and CPU address is 0x20013000. So when there is a write to cpu addr 0x20013000 [writel(virt_addr(0x20013000)], we want it to be translated to PCI addr 0x20013000. So in 'ATU', we would expect *base* to be programmed to *0x20013000* and target to be programmed to *0x20013000*. But that's not the case for DRA7xx. For DRA7xx *base* should be programmed to *0x0013000* and target should be programmed to *0x20013000*.

Ok, got it, thanks for your patience.

I think this would best be modeled as a separate bus node that contains the restriction, like this:

/ {
	#address-cells = <1>; // or <2> if you support > 4GB address space
	#size-cells = <1>;

	soc {
		#address-cells <1>;
		#size-cells = <1>;
		ranges;
		dma-ranges;

		... // all normal devices

		axi at 20000000 {
			#size-cells = <1>;
			#address-cells = <1>;
			dma-ranges; // can access all 4GB outbound
			ranges = <0 0x20000000 0x10000000>; // 28-bit bus

			pci at 0 {
				reg = <0x0    0x1000>, // internal regs
				      <0x1000 0x2000>; // config space
				dma-ranges; // 32-bit outbound
				ranges = <0x81000000 0 0           0x3000 0 0x00010000  /* IO */
					  0x82000000 0 0x20013000 0x13000 0 0xffed000>; /* MEM */
			};
		};
	};
};

Arnd

#48 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Hi Arnd,

Quoted 77 lines · Arnd Bergmann
Quoted 42 lines · On Wednesday 14 May 2014 11:14:45 Kishon Vijay Abraham I wrote:

hi Arnd,

Quoted 22 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 13 May 2014 15:27:46 Arnd Bergmann wrote:
Quoted 13 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 12 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Quoted 6 lines
Quoted 3 lines

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

Quoted 8 lines

To clarify: using <0x82000000 0 0 0xb0000000 0 0x10000000> will give you a mem_offset of 0xb0000000, which should work just fine for this case.

What I don't understand is why the ATU cares about whether the outbound address is 0x0000000 or 0xb0000000 if it just decodes the lower 28 bit anyway. Did you mean that we have to program the BARs using low addresses regardless of what is programmed in the ATU? That would make more sense, and it also matches what I suggested.

No, It's not like it decodes only the lower 28bits. The BARs is programmed with 32 bit value.

My pcie dt node has
ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000 /* CONFIG */

           0x81000000 0 0          0x20003000 0 0x00010000  /* IO */
           0x82000000 0 0x20013000 0x20013000 0 0xffed000>; /* MEM */
Quoted 8 lines

Consider MEM address space..

Here both PCI address and CPU address is 0x20013000. So when there is a write to cpu addr 0x20013000 [writel(virt_addr(0x20013000)], we want it to be translated to PCI addr 0x20013000. So in 'ATU', we would expect *base* to be programmed to *0x20013000* and target to be programmed to *0x20013000*. But that's not the case for DRA7xx. For DRA7xx *base* should be programmed to *0x0013000* and target should be programmed to *0x20013000*.

Ok, got it, thanks for your patience.

I think this would best be modeled as a separate bus node that contains the restriction, like this:

/ {
	#address-cells = <1>; // or <2> if you support > 4GB address space
	#size-cells = <1>;

	soc {
		#address-cells <1>;
		#size-cells = <1>;
		ranges;
		dma-ranges;

		... // all normal devices

		axi at 20000000 {
			#size-cells = <1>;
			#address-cells = <1>;
			dma-ranges; // can access all 4GB outbound
			ranges = <0 0x20000000 0x10000000>; // 28-bit bus

			pci at 0 {
				reg = <0x0    0x1000>, // internal regs
Quoted 8 lines
				      <0x1000 0x2000>; // config space
				dma-ranges; // 32-bit outbound
				ranges = <0x81000000 0 0           0x3000 0 0x00010000  /* IO */
					  0x82000000 0 0x20013000 0x13000 0 0xffed000>; /* MEM */
			};
		};
	};
};

Nice :-)

Thanks
Kishon

#49 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

In reply to Arnd Bergmann

Hi Arnd,

Quoted 70 lines · Arnd Bergmann
Quoted 42 lines · On Wednesday 14 May 2014 11:14:45 Kishon Vijay Abraham I wrote:

hi Arnd,

Quoted 22 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 13 May 2014 15:27:46 Arnd Bergmann wrote:
Quoted 13 lines · On Tuesday 13 May 2014 18:56:23 Kishon Vijay Abraham I wrote:
Quoted 12 lines

If you have a case where the outbound translation is a 256MB (i.e. 28bit) section of the CPU address space, that could be represented as

      ranges = <0x82000000 0 0  0xb0000000  0 0x10000000>;

or

      ranges = <0x82000000 0 0xb0000000  0xb0000000  0 0x10000000>;

depending on whether you want the BARs to be programmed using a low address 0x0-0x0fffffff or an address matching the window 0xb0000000-0xbfffffff.

Quoted 6 lines
Quoted 3 lines

The problem is, for configuring the window starting at 0xb0000000, the ATU should be programmed 0x0000000 (the cpu address for it will be 0xb0000000 though).

Then use the first of the two?

Quoted 8 lines

To clarify: using <0x82000000 0 0 0xb0000000 0 0x10000000> will give you a mem_offset of 0xb0000000, which should work just fine for this case.

What I don't understand is why the ATU cares about whether the outbound address is 0x0000000 or 0xb0000000 if it just decodes the lower 28 bit anyway. Did you mean that we have to program the BARs using low addresses regardless of what is programmed in the ATU? That would make more sense, and it also matches what I suggested.

No, It's not like it decodes only the lower 28bits. The BARs is programmed with 32 bit value.

My pcie dt node has
ranges = <0x00000800 0 0x20001000 0x20001000 0 0x00002000 /* CONFIG */

           0x81000000 0 0          0x20003000 0 0x00010000  /* IO */
           0x82000000 0 0x20013000 0x20013000 0 0xffed000>; /* MEM */
Quoted 8 lines

Consider MEM address space..

Here both PCI address and CPU address is 0x20013000. So when there is a write to cpu addr 0x20013000 [writel(virt_addr(0x20013000)], we want it to be translated to PCI addr 0x20013000. So in 'ATU', we would expect *base* to be programmed to *0x20013000* and target to be programmed to *0x20013000*. But that's not the case for DRA7xx. For DRA7xx *base* should be programmed to *0x0013000* and target should be programmed to *0x20013000*.

Ok, got it, thanks for your patience.

I think this would best be modeled as a separate bus node that contains the restriction, like this:

/ {
	#address-cells = <1>; // or <2> if you support > 4GB address space
	#size-cells = <1>;

	soc {
		#address-cells <1>;
		#size-cells = <1>;
		ranges;
		dma-ranges;

		... // all normal devices

		axi at 20000000 {
Quoted 8 lines
			#size-cells = <1>;
			#address-cells = <1>;
			dma-ranges; // can access all 4GB outbound
			ranges = <0 0x20000000 0x10000000>; // 28-bit bus

			pci at 0 {
				reg = <0x0    0x1000>, // internal regs
				      <0x1000 0x2000>; // config space

The internal reg address space starts at 0x51000000. By Using this <0 0x20000000 0x10000000>; as ranges, we are not able to get the memory resource properly. Can we use multiple ranges? how do we specify which ranges the *reg* property to use?

Btw I was using *simple-bus* as compatible to *axi*. Or should I create a new *axi* driver to create the pcie memory resources myself?

Thanks
Kishon

#50 lore raw

Re: [PATCH 06/17] pci: host: pcie-designware: Use *base-mask* for configuring the iATU

Quoted 20 lines · On Friday 16 May 2014 14:30:56 Kishon Vijay Abraham I wrote:
Quoted 19 lines · Arnd Bergmann

On Wednesday 14 May 2014 11:14:45 Kishon Vijay Abraham I wrote:

/ {
      #address-cells = <1>; // or <2> if you support > 4GB address space
      #size-cells = <1>;

      soc {
              #address-cells <1>;
              #size-cells = <1>;
              ranges;
              dma-ranges;

              ... // all normal devices

              axi at 20000000 {
                      #size-cells = <1>;
                      #address-cells = <1>;
                      dma-ranges; // can access all 4GB outbound
                      ranges = <0 0x20000000 0x10000000>; // 28-bit bus
Quoted 8 lines
Quoted 3 lines
                      pci at 0 {
                              reg = <0x0    0x1000>, // internal regs
                                    <0x1000 0x2000>; // config space

The internal reg address space starts at 0x51000000. By Using this <0 0x20000000 0x10000000>; as ranges, we are not able to get the memory resource properly. Can we use multiple ranges? how do we specify which ranges the *reg* property to use?

Yes, multiple ranges will work fine. You can make up a representation yourself if you don't know what the hardware really does.

Two possible ways of doing this would be

a)

	/* two separate physical connections represented as one logical bus */
	axi at 20000000 {
		#address-cells = <2>;
		#size-cells = <1>;
		ranges = <0 0 0x20000000 0x10000000>, /* configurable registers */
			 <1 0 0x51000000 0x01000000>; /* PCI host registers */

		pci at 1.0 {
			reg = <1 0 0x01000000>, /* host registers */
				<0 0x1000 0x2000>; /* config space */
		}

	};

b)

	/* one physical bus, with some address munging */
	axi at 20000000 {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges = <0 0x20000000 0x10000000>, /* configurable registers */
			 <0x51000000 0x51000000 0x01000000>; /* PCI host registers */

		pci at 1.0 {
			reg = <0x51000000 0x01000000>, /* host registers */
				<0x1000 0x2000>; /* config space */
		}

	};
Quoted 2 lines

Btw I was using *simple-bus* as compatible to *axi*. Or should I create a new *axi* driver to create the pcie memory resources myself?

simple-bus is best here, since you don't have a complex bus that needs to be set up using register accesses or that generates interrupts.

Arnd

#51 lore raw

PATCH 7/17 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. The Documentation for divider clock can be found at ../clock/ti/divider.txt

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +1 -0
index c767687..55e95c5 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
#52 lore raw

PATCH 8/17 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.

Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 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 55e95c5..44993ec 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
#53 lore raw

PATCH 9/17 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
#54 lore raw

PATCH 10/17 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 1282a42..a51fa7f 100644
@@ -1231,6 +1231,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
  *
  */
@@ -2388,6 +2425,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,
@@ -2751,6 +2804,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
#55 lore raw

PATCH 11/17 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.

Cc Tony Lindgren <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +8 -0
index 44993ec..e1bd052 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
#56 lore raw

Re: [PATCH 11/17] ARM: dts: dra7xx-clocks: Add missing 32khz clocks used for PHY

Hi Kishon,

Quoted 2 lines · 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.

Typo in $subject
s/clocks/clock

--
cheers,
-roger

Quoted 31 lines
Cc Tony Lindgren <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +8 -0
index 44993ec..e1bd052 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>;
#57 lore raw

Re: [PATCH 11/17] ARM: dts: dra7xx-clocks: Add missing 32khz clocks used for PHY

Quoted 9 lines · Roger Quadros

Hi Kishon,

Quoted 2 lines · 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.

Typo in $subject
s/clocks/clock

Will fix it.

Thanks
Kishon

Quoted 37 lines

--
cheers,
-roger

Quoted 31 lines
Cc Tony Lindgren <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/boot/dts/dra7xx-clocks.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7xx-clocks.dtsi +8 -0
index 44993ec..e1bd052 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>;
#58 lore raw

PATCH 12/17 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 f0ca46d..0d3c8c0 100644
@@ -876,6 +876,14 @@
 			};
 		};
 
+		omap_control_pcie1phy: omap-control-pciephy at 0x4a003c40 {
+			compatible = "ti,control-phy-pcie";
+			reg = <0x4a003c40 0x4>, <0x4a003c14 0x4>, <0x4a003c34 0x4>;
+			reg-names = "power", "control_sma", "pcie_pcs";
+			clocks = <&sys_clkin1>;
+			clock-names = "sysclk";
+		};
+
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
Signature · 1 line
1.7.9.5
#59 lore raw

PATCH 13/17 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 |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm/boot/dts/dra7.dtsi +23 -0
index 0d3c8c0..653b5f6 100644
@@ -903,6 +903,29 @@
 				clock-names = "sysclk";
 				#phy-cells = <0>;
 			};
+
+			pcie1_phy: pciephy at 4a094000 {
+				compatible = "ti,phy-pipe3-pcie";
+				reg = <0x4A094000 0x80>, /* phy_rx */
+				      <0x4A094400 0x64>; /* phy_tx */
+				reg-names = "phy_rx", "phy_tx";
+				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>,
+					 <&apll_pcie_in_clk_mux>,
+					 <&pciesref_acs_clk_ck>;
+				clock-names = "dpll_ref", "dpll_ref_m2",
+					      "wkupclk", "refclk",
+					      "div-clk", "phy-div",
+					      "apll_mux", "refclk_ext";
+				#phy-cells = <0>;
+				ti,hwmods = "pcie1-phy";
+				ti,ext-clk;
+			};
 		};
 
 		omap_dwc3_1 at 48880000 {
Signature · 1 line
1.7.9.5
#60 lore raw

PATCH 14/17 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.

Cc Tony Lindgren <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/boot/dts/dra7.dtsi |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/boot/dts/dra7.dtsi +22 -0
index 653b5f6..20b1a09 100644
@@ -1011,6 +1011,28 @@
 			};
 		};
 
+		pcie at 51000000 {
+			compatible = "ti,dra7xx-pcie";
+			reg = <0x51002000 0x14c>, <0x51000000 0x2000>;
+			reg-names = "ti_conf", "rc_dbics";
+			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";
+		};
+
 		sata: sata at 4a141100 {
 			compatible = "snps,dwc-ahci";
 			reg = <0x4a140000 0x1100>, <0x4a141100 0x7>;
Signature · 1 line
1.7.9.5
#61 lore raw

PATCH 15/17 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 cb31d43..b179e80 100644
@@ -75,6 +75,8 @@ config SOC_DRA7XX
 	select ARM_GIC
 	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
#62 lore raw

PATCH 16/17 pci: host: pcie-dra7xx: use reset framework APIs to reset PCIe

In reply to Kishon Vijay Abraham I

Get reset nodes from dt and use reset framework APIs to reset PCIe. This is needed since reset is handled by the SoC.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt |    2 ++
 drivers/pci/host/pci-dra7xx.c                    |   10 ++++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/pci/ti-pci.txt +2 -0
index 6cb6f09..cfb95c0 100644
@@ -9,6 +9,8 @@ This node should have the properties described in "designware-pcie.txt".
  - 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
 
 Example:
 pcie at 51000000 {
drivers/pci/host/pci-dra7xx.c +10 -0
index a37c25c..17d64ee 100644
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/resource.h>
+#include <linux/reset.h>
 #include <linux/types.h>
 
 #include "pcie-designware.h"
@@ -281,6 +282,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct dra7xx_pcie *dra7xx;
 	struct device *dev = &pdev->dev;
+	struct reset_control *rstc;
 
 	dra7xx = devm_kzalloc(&pdev->dev, sizeof(*dra7xx), GFP_KERNEL);
 	if (!dra7xx)
@@ -304,6 +306,14 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (!base)
 		return -ENOMEM;
 
+	rstc = devm_reset_control_get(dev, "reset");
+	if (IS_ERR(rstc))
+		return PTR_ERR(rstc);
+
+	ret = reset_control_deassert(rstc);
+	if (ret)
+		return ret;
+
 	phy = devm_phy_get(dev, "pcie-phy");
 	if (IS_ERR(phy))
 		return PTR_ERR(phy);
Signature · 1 line
1.7.9.5
#63 lore raw

Re: [TEMP PATCH 16/17] pci: host: pcie-dra7xx: use reset framework APIs to reset PCIe

Quoted 15 lines · Kishon Vijay Abraham I

Get reset nodes from dt and use reset framework APIs to reset PCIe. This is needed since reset is handled by the SoC.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt |    2 ++
 drivers/pci/host/pci-dra7xx.c                    |   10 ++++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/pci/ti-pci.txt +0 -0
index 6cb6f09..cfb95c0 100644

Documentation/devicetree/bindings/pci/ti-pci.txt This node should have the properties described in "designware-pcie.txt". · line 13

Quoted 5 lines
Documentation/devicetree/bindings/pci/ti-pci.txt +2 -0
@@ -9,6 +9,8 @@ This node should have the properties described in "designware-pcie.txt".
  - 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

You should just refer to the ti,reset.txt document for this.

Quoted 38 lines
Documentation/devicetree/bindings/pci/ti-pci.txt +0 -0
 Example:
 pcie at 51000000 {
drivers/pci/host/pci-dra7xx.c +10 -0
index a37c25c..17d64ee 100644
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/resource.h>
+#include <linux/reset.h>
 #include <linux/types.h>
 
 #include "pcie-designware.h"
@@ -281,6 +282,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct dra7xx_pcie *dra7xx;
 	struct device *dev = &pdev->dev;
+	struct reset_control *rstc;
 
 	dra7xx = devm_kzalloc(&pdev->dev, sizeof(*dra7xx), GFP_KERNEL);
 	if (!dra7xx)
@@ -304,6 +306,14 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (!base)
 		return -ENOMEM;
 
+	rstc = devm_reset_control_get(dev, "reset");
+	if (IS_ERR(rstc))
+		return PTR_ERR(rstc);
+
+	ret = reset_control_deassert(rstc);
+	if (ret)
+		return ret;
+
 	phy = devm_phy_get(dev, "pcie-phy");
 	if (IS_ERR(phy))
 		return PTR_ERR(phy);
Signature · 2 lines
------------------
Dan Murphy
#64 lore raw

PATCH 17/17 ARM: dts: dra7: Add *resets* property for PCIe dt node

In reply to Kishon Vijay Abraham I

Added *resets* and *reset-names* properies for PCIe dt node. The documention for this node can be found @ ../bindings/pci/ti-pci.txt.

---
 arch/arm/boot/dts/dra7.dtsi |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/dra7.dtsi +2 -0
index 20b1a09..7bc0555 100644
@@ -1031,6 +1031,8 @@
 			ti,hwmods = "pcie1";
 			phys = <&pcie1_phy>;
 			phy-names = "pcie-phy";
+			resets = <&prm_resets &device_reset>;
+			reset-names = "reset";
 		};
 
 		sata: sata at 4a141100 {
Signature · 1 line
1.7.9.5
#65 lore raw

Re: [TEMP PATCH 17/17] ARM: dts: dra7: Add *resets* property for PCIe dt node

Quoted 14 lines · Kishon Vijay Abraham I

Added *resets* and *reset-names* properies for PCIe dt node. The documention for this node can be found @ ../bindings/pci/ti-pci.txt.

---
 arch/arm/boot/dts/dra7.dtsi |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 20b1a09..7bc0555 100644

arch/arm/boot/dts/dra7.dtsi line 1034

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +1 -0
@@ -1031,6 +1031,8 @@
 			ti,hwmods = "pcie1";
 			phys = <&pcie1_phy>;
 			phy-names = "pcie-phy";
+			resets = <&prm_resets &device_reset>;

If you look @ v2 of the reset framework patchset your phandle should be

resets = <&prm_resets &pcie1_reset>;

If you call the device_reset phandle you will reset the SoC.

arch/arm/boot/dts/dra7.dtsi line 1035

Quoted 1 line
arch/arm/boot/dts/dra7.dtsi +1 -0
+			reset-names = "reset";

This needs to be more descriptive.

Quoted 3 lines
arch/arm/boot/dts/dra7.dtsi +0 -0
 		};
 
 		sata: sata at 4a141100 {
Signature · 2 lines
------------------
Dan Murphy