Skip to contentSkip to conversation

Deprecate phy-omap-control and use SYSCON

PATCH In review Kishon Vijay Abraham I 3 participants 50 messages Jun 23, 2015 – Jun 24, 2015

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

cover Deprecate phy-omap-control and use SYSCON

phy-omap-control driver was added when there was no proper infrastructure for doing control module initializations. Now with SYSCON framework being added to the kernel, phy-omap-control shouldn't be needed.

This series is about adapting phy-omap-usb2, phy-ti-pipe3 and omap2430 to use SYSCON framework instead of phy-omap-control. However we can't remove the phy-omap-control driver altogether since that will break older dtbs.

Performed USB enumeration testing in DRA72-EVM, AM43XX-EVM, OMAP5-uEVM and OMAP4 PANDA.

Performed SATA enumeration testing in DRA72-EVM and OMAP5-uEVM

Performed PCIe enumeration testing in DRA72-EVM.

This patch series is developed on top of Linux 4.1-rc8 +
http://lkml.iu.edu/hypermail/linux/kernel/1505.1/03099.html

Kishon Vijay Abraham I (17):
phy: ti-pipe3: use ti_pipe3_power_off to power off the PHY during
probe
phy: ti-pipe3: use *syscon* framework to power on/off the PHY
phy: ti-pipe3: use *syscon* framework to set PCS value of the PHY
phy: omap-usb2: use omap_usb_power_off to power off the PHY during
probe
phy: omap-usb2: Add a new compatible string for USB2 PHY2
phy: omap-usb2: use *syscon* framework to power on/off the PHY
usb: musb: omap2430: use *syscon* framework to write to mailbox
register
ARM: dts: dra7: Add dt node for the sycon pcie
ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in
SATA PHY node
ARM: dts: dra7: Use "syscon-phy-power" and "syscon-pcs" in PCIe PHY
node
ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2
PHY2
ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in
USB PHY node
ARM: dts: am4372: Use "syscon-phy-power" instead of "ctrl-module" in
USB PHY node
ARM: dts: OMAP5: Use "syscon-phy-power" instead of "ctrl-module" in
USB PHY node
ARM: dts: OMAP5: Use "syscon-phy-power" instead of "ctrl-module" in
SATA PHY node
ARM: dts: omap4: Use "syscon-phy-power" instead of "ctrl-module" in
USB PHY node
ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB
node

 Documentation/devicetree/bindings/phy/ti-phy.txt   |   20 +++-
 Documentation/devicetree/bindings/usb/omap-usb.txt |    7 +-
 arch/arm/boot/dts/am4372.dtsi                      |   16 +--
 arch/arm/boot/dts/dra7.dtsi                        |   69 +++--------
 arch/arm/boot/dts/omap4.dtsi                       |   16 +--
 arch/arm/boot/dts/omap5.dtsi                       |   26 +---
 drivers/phy/phy-omap-usb2.c                        |  112 +++++++++++++++---
 drivers/phy/phy-ti-pipe3.c                         |  125 +++++++++++++++++---
 drivers/usb/musb/omap2430.c                        |  118 ++++++++++++++----
 include/linux/phy/omap_usb.h                       |   18 +++
 10 files changed, 365 insertions(+), 162 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/17 phy: ti-pipe3: use ti_pipe3_power_off to power off the PHY during probe

No functional change. Previously omap_control_phy_power() was used to power off the PHY during probe. But once PIPE3 driver is adapted to use syscon, omap_control_phy_power() cannot be used. Hence used ti_pipe3_power_off to power off the PHY.

---
 drivers/phy/phy-ti-pipe3.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-ti-pipe3.c +2 -2
index 08020dc..d784426 100644
@@ -431,8 +431,6 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 
 	phy->control_dev = &control_pdev->dev;
 
-	omap_control_phy_power(phy->control_dev, 0);
-
 	platform_set_drvdata(pdev, phy);
 	pm_runtime_enable(phy->dev);
 
@@ -451,6 +449,8 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 		return PTR_ERR(generic_phy);
 
 	phy_set_drvdata(generic_phy, phy);
+	ti_pipe3_power_off(generic_phy);
+
 	phy_provider = devm_of_phy_provider_register(phy->dev,
 			of_phy_simple_xlate);
 	if (IS_ERR(phy_provider))
Signature · 1 line
1.7.9.5
Acked-by on v1 1/17
#2 lore raw

Re: [PATCH 01/17] phy: ti-pipe3: use ti_pipe3_power_off to power off the PHY during probe

Quoted 6 lines · On Tue, 23 Jun 2015 17:28:46 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

No functional change. Previously omap_control_phy_power() was used to power off the PHY during probe. But once PIPE3 driver is adapted to use syscon, omap_control_phy_power() cannot be used. Hence used ti_pipe3_power_off to power off the PHY.

cheers,
-roger

Quoted 29 lines
---
 drivers/phy/phy-ti-pipe3.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-ti-pipe3.c +2 -2
index 08020dc..d784426 100644
@@ -431,8 +431,6 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 
 	phy->control_dev = &control_pdev->dev;
 
-	omap_control_phy_power(phy->control_dev, 0);
-
 	platform_set_drvdata(pdev, phy);
 	pm_runtime_enable(phy->dev);
 
@@ -451,6 +449,8 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 		return PTR_ERR(generic_phy);
 
 	phy_set_drvdata(generic_phy, phy);
+	ti_pipe3_power_off(generic_phy);
+
 	phy_provider = devm_of_phy_provider_register(phy->dev,
 			of_phy_simple_xlate);
 	if (IS_ERR(phy_provider))
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/17 phy: ti-pipe3: use *syscon* framework to power on/off the PHY

In reply to Kishon Vijay Abraham I

Deprecate using phy-omap-control driver to power on/off the PHY and use *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
 drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
 2 files changed, 86 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +8 -2
index f0f5537..d3ad3bf 100644
@@ -77,8 +77,6 @@ Required properties:
    * "div-clk" - apll clock
 
 Optional properties:
- - ctrl-module : phandle of the control module used by PHY driver to power on
-   the PHY.
  - id: If there are multiple instance of the same type, in order to
    differentiate between each instance "id" can be used (e.g., multi-lane PCIe
    PHY). If "id" is not provided, it is set to default value of '1'.
@@ -86,6 +84,14 @@ Optional properties:
    CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
    register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
 
+Deprecated properties:
+ - ctrl-module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
+Recommended properies:
+ - syscon-phy-power : phandle/offset pair. Phandle to the system control
+   module and the register offset to power on/off the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb3phy at 4a084400 {
drivers/phy/phy-ti-pipe3.c +78 -13

129 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY

Hi Kishon,

Quoted 93 lines · On Tue, 23 Jun 2015 17:28:47 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to power on/off the PHY and use *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
 drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
 2 files changed, 86 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +8 -2
index f0f5537..d3ad3bf 100644
@@ -77,8 +77,6 @@ Required properties:
    * "div-clk" - apll clock
 
 Optional properties:
- - ctrl-module : phandle of the control module used by PHY driver to power on
-   the PHY.
  - id: If there are multiple instance of the same type, in order to
    differentiate between each instance "id" can be used (e.g., multi-lane PCIe
    PHY). If "id" is not provided, it is set to default value of '1'.
@@ -86,6 +84,14 @@ Optional properties:
    CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
    register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
 
+Deprecated properties:
+ - ctrl-module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
+Recommended properies:
+ - syscon-phy-power : phandle/offset pair. Phandle to the system control
+   module and the register offset to power on/off the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb3phy at 4a084400 {
drivers/phy/phy-ti-pipe3.c +24 -1
index d784426..78bac00 100644
@@ -56,6 +56,15 @@
 
 #define SATA_PLL_SOFT_RESET	BIT(18)
 
+#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK	0x003FC000
+#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT	14
+
+#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK	0xFFC00000
+#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT	22
+
+#define PIPE3_PHY_TX_RX_POWERON		0x3
+#define PIPE3_PHY_TX_RX_POWEROFF	0x0
+
 /*
  * This is an Empirical value that works, need to confirm the actual
  * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -86,8 +95,10 @@ struct ti_pipe3 {
 	struct clk		*refclk;
 	struct clk		*div_clk;
 	struct pipe3_dpll_map	*dpll_map;
+	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
 	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
 	unsigned int		dpll_reset_reg; /* reg. index within syscon */
+	unsigned int		power_reg; /* power reg. index within syscon */
 	bool			sata_refclk_enabled;
 };
 
@@ -144,18 +155,49 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
 
 static int ti_pipe3_power_off(struct phy *x)
 {
+	u32 val;
+	int ret;
 	struct ti_pipe3 *phy = phy_get_drvdata(x);
 
-	omap_control_phy_power(phy->control_dev, 0);
+	if (phy->phy_power_syscon) {
+		val = PIPE3_PHY_TX_RX_POWEROFF <<
+			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+
+		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
+					 PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, 0);
+	}
 
 	return 0;
 }
 
 static int ti_pipe3_power_on(struct phy *x)

drivers/phy/phy-ti-pipe3.c static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy); · line 186

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +6 -1
 {
+	u32 val;
+	u32 mask;
+	int ret;
+	unsigned long rate;
 	struct ti_pipe3 *phy = phy_get_drvdata(x);
 
-	omap_control_phy_power(phy->control_dev, 1);
+	if (phy->phy_power_syscon) {
+		rate = clk_get_rate(phy->sys_clk);

what if clk_get_rate() returns 0?

Quoted 21 lines
drivers/phy/phy-ti-pipe3.c +14 -0
+		rate = rate / 1000000;
+		mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
+			  OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
+		val = PIPE3_PHY_TX_RX_POWERON <<
+			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+		val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
+
+		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
+					 mask, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, 1);
+	}
 
 	return 0;
 }
@@ -417,19 +459,42 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 		phy->div_clk = ERR_PTR(-ENODEV);
 	}
 

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

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +5 -5
-	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;
-	}
+	phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
+							"syscon-phy-power");
+	if (IS_ERR(phy->phy_power_syscon)) {
+		dev_info(&pdev->dev,
+			 "can't get syscon-phy-power, using control device\n");

dev_dbg()? as we don't want to annoy old DT users?

Quoted 18 lines
drivers/phy/phy-ti-pipe3.c +12 -5
+		phy->phy_power_syscon = NULL;
+
+		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);
-	if (!control_pdev) {
-		dev_err(&pdev->dev, "Failed to get control device\n");
-		return -EINVAL;
-	}
+		control_pdev = of_find_device_by_node(control_node);
+		if (!control_pdev) {
+			dev_err(&pdev->dev, "Failed to get control device\n");
+			return -EINVAL;

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

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +8 -1
+		}
 
-	phy->control_dev = &control_pdev->dev;
+		phy->control_dev = &control_pdev->dev;
+	} else {
+		phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
+		if (IS_ERR(phy->sys_clk)) {
+			dev_err(&pdev->dev, "unable to get sysclk\n");
+			return -EINVAL;
+		}

we're already doing this at another place in pipe3_probe. Let's do it at one place.

Quoted 15 lines
drivers/phy/phy-ti-pipe3.c +9 -0
+
+		if (of_property_read_u32_index(node,
+					       "syscon-phy-power", 1,
+					       &phy->power_reg)) {
+			dev_err(&pdev->dev,
+				"couldn't get power reg. offset\n");
+			return -EINVAL;
+		}
+	}
 
 	platform_set_drvdata(pdev, phy);
 	pm_runtime_enable(phy->dev);
Signature · 1 line
1.7.9.5

cheers,
-roger

#5 lore raw

Re: [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY

Hi,

Quoted 105 lines · Roger Quadros

Hi Kishon,

Quoted 100 lines · On Tue, 23 Jun 2015 17:28:47 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to power on/off the PHY and use *syscon* framework to do the same.

---
  Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
  drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
  2 files changed, 86 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +8 -2
index f0f5537..d3ad3bf 100644
@@ -77,8 +77,6 @@ Required properties:
     * "div-clk" - apll clock
 
  Optional properties:
- - ctrl-module : phandle of the control module used by PHY driver to power on
-   the PHY.
   - id: If there are multiple instance of the same type, in order to
     differentiate between each instance "id" can be used (e.g., multi-lane PCIe
     PHY). If "id" is not provided, it is set to default value of '1'.
@@ -86,6 +84,14 @@ Optional properties:
     CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
     register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
 
+Deprecated properties:
+ - ctrl-module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
+Recommended properies:
+ - syscon-phy-power : phandle/offset pair. Phandle to the system control
+   module and the register offset to power on/off the PHY.
+
  This is usually a subnode of ocp2scp to which it is connected.
 
  usb3phy at 4a084400 {
drivers/phy/phy-ti-pipe3.c +28 -1
index d784426..78bac00 100644
@@ -56,6 +56,15 @@
 
  #define SATA_PLL_SOFT_RESET	BIT(18)
 
+#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK	0x003FC000
+#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT	14
+
+#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK	0xFFC00000
+#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT	22
+
+#define PIPE3_PHY_TX_RX_POWERON		0x3
+#define PIPE3_PHY_TX_RX_POWEROFF	0x0
+
  /*
   * This is an Empirical value that works, need to confirm the actual
   * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -86,8 +95,10 @@ struct ti_pipe3 {
  	struct clk		*refclk;
  	struct clk		*div_clk;
  	struct pipe3_dpll_map	*dpll_map;
+	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
  	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
  	unsigned int		dpll_reset_reg; /* reg. index within syscon */
+	unsigned int		power_reg; /* power reg. index within syscon */
  	bool			sata_refclk_enabled;
  };
 
@@ -144,18 +155,49 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
 
  static int ti_pipe3_power_off(struct phy *x)
  {
+	u32 val;
+	int ret;
  	struct ti_pipe3 *phy = phy_get_drvdata(x);
 
-	omap_control_phy_power(phy->control_dev, 0);
+	if (phy->phy_power_syscon) {
+		val = PIPE3_PHY_TX_RX_POWEROFF <<
+			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+
+		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
+					 PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, 0);
+	}
 
  	return 0;
  }
 
  static int ti_pipe3_power_on(struct phy *x)
  {
+	u32 val;
+	u32 mask;
+	int ret;
+	unsigned long rate;
  	struct ti_pipe3 *phy = phy_get_drvdata(x);
 
Quoted 5 lines

drivers/phy/phy-ti-pipe3.c static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy); · line 186

Quoted 3 lines
drivers/phy/phy-ti-pipe3.c +2 -1
-	omap_control_phy_power(phy->control_dev, 1);
+	if (phy->phy_power_syscon) {
+		rate = clk_get_rate(phy->sys_clk);

what if clk_get_rate() returns 0?

hmm.. If '0' is an error value of clk_get_rate() then it would be good to return with an error message.

Quoted 22 lines
Quoted 22 lines
drivers/phy/phy-ti-pipe3.c +14 -0
+		rate = rate / 1000000;
+		mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
+			  OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
+		val = PIPE3_PHY_TX_RX_POWERON <<
+			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+		val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
+
+		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
+					 mask, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, 1);
+	}
 
  	return 0;
  }
@@ -417,19 +459,42 @@ static int ti_pipe3_probe(struct platform_device *pdev)
  		phy->div_clk = ERR_PTR(-ENODEV);
  	}
 
Quoted 12 lines

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

Quoted 10 lines
drivers/phy/phy-ti-pipe3.c +5 -5
-	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;
-	}
+	phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
+							"syscon-phy-power");
+	if (IS_ERR(phy->phy_power_syscon)) {
+		dev_info(&pdev->dev,
+			 "can't get syscon-phy-power, using control device\n");

dev_dbg()? as we don't want to annoy old DT users?

okay.

Quoted 21 lines
Quoted 21 lines
drivers/phy/phy-ti-pipe3.c +13 -5
+		phy->phy_power_syscon = NULL;
+
+		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);
-	if (!control_pdev) {
-		dev_err(&pdev->dev, "Failed to get control device\n");
-		return -EINVAL;
-	}
+		control_pdev = of_find_device_by_node(control_node);
+		if (!control_pdev) {
+			dev_err(&pdev->dev, "Failed to get control device\n");
+			return -EINVAL;
+		}
 
Quoted 10 lines

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

Quoted 8 lines
drivers/phy/phy-ti-pipe3.c +7 -1
-	phy->control_dev = &control_pdev->dev;
+		phy->control_dev = &control_pdev->dev;
+	} else {
+		phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
+		if (IS_ERR(phy->sys_clk)) {
+			dev_err(&pdev->dev, "unable to get sysclk\n");
+			return -EINVAL;
+		}

we're already doing this at another place in pipe3_probe. Let's do it at one place.

right, this can be improved.

Thanks
Kishon

#6 lore raw

PATCH 3/17 phy: ti-pipe3: use *syscon* framework to set PCS value of the PHY

In reply to Kishon Vijay Abraham I

Deprecate using phy-omap-control driver to set PCS value of the PHY and start using *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
 drivers/phy/phy-ti-pipe3.c                       |   32 +++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index d3ad3bf..52c7a92 100644
@@ -83,6 +83,8 @@ Optional properties:
  - syscon-pllreset: Handle to system control region that contains the
    CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
    register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
+ - syscon-pcs : phandle/offset pair. Phandle to the system control module and the
+   register offset to write the PCS delay value.
 
 Deprecated properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +31 -1
index 78bac00..e2f9ad7 100644
@@ -65,6 +65,9 @@
 #define PIPE3_PHY_TX_RX_POWERON		0x3
 #define PIPE3_PHY_TX_RX_POWEROFF	0x0
 
+#define PCIE_PCS_MASK			0xFF0000
+#define PCIE_PCS_DELAY_COUNT_SHIFT	0x10
+
 /*
  * This is an Empirical value that works, need to confirm the actual
  * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -96,9 +99,11 @@ struct ti_pipe3 {
 	struct clk		*div_clk;
 	struct pipe3_dpll_map	*dpll_map;
 	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
+	struct regmap		*pcs_syscon; /* ctrl. reg. acces */
 	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
 	unsigned int		dpll_reset_reg; /* reg. index within syscon */
 	unsigned int		power_reg; /* power reg. index within syscon */
+	unsigned int		pcie_pcs_reg; /* pcs reg. index in syscon */
 	bool			sata_refclk_enabled;
 };
 
@@ -271,7 +276,16 @@ static int ti_pipe3_init(struct phy *x)
 	 * 18-1804.
 	 */
 	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
-		omap_control_pcie_pcs(phy->control_dev, 0x96);
+		if (phy->pcs_syscon) {
+			val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
+			ret = regmap_update_bits(phy->pcs_syscon,
+						 phy->pcie_pcs_reg,
+						 PCIE_PCS_MASK, val);
+			if (ret < 0)
+				return ret;
+		} else {
+			omap_control_pcie_pcs(phy->control_dev, 0x96);
+		}
 		return 0;
 	}
 
@@ -455,6 +469,22 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "unable to get div-clk\n");
 			return PTR_ERR(phy->div_clk);
 		}
+
+		phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node,
+								  "syscon-pcs");
+		if (IS_ERR(phy->pcs_syscon)) {
+			dev_dbg(&pdev->dev,
+				 "can't get syscon-pcs, using omap control\n");
+			phy->pcs_syscon = NULL;
+		} else {
+			if (of_property_read_u32_index(node,
+						       "syscon-pcs", 1,
+						       &phy->pcie_pcs_reg)) {
+				dev_err(&pdev->dev,
+					"couldn't get pcie pcs reg. offset\n");
+				return -EINVAL;
+			}
+		}
 	} else {
 		phy->div_clk = ERR_PTR(-ENODEV);
 	}
Signature · 1 line
1.7.9.5
Acked-by on v1 3/17
#7 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: use *syscon* framework to set PCS value of the PHY

Quoted 14 lines · On Tue, 23 Jun 2015 17:28:48 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to set PCS value of the PHY and start using *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
 drivers/phy/phy-ti-pipe3.c                       |   32 +++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
index d3ad3bf..52c7a92 100644

Documentation/devicetree/bindings/phy/ti-phy.txt Optional properties: · line 87

Quoted 5 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
@@ -83,6 +83,8 @@ Optional properties:
  - syscon-pllreset: Handle to system control region that contains the
    CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
    register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
+ - syscon-pcs : phandle/offset pair. Phandle to the system control module and the
+   register offset to write the PCS delay value.

What is PCS?
Is this valid only for PCIe? If yes we could mention it here.

Quoted 73 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
 Deprecated properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +31 -1
index 78bac00..e2f9ad7 100644
@@ -65,6 +65,9 @@
 #define PIPE3_PHY_TX_RX_POWERON		0x3
 #define PIPE3_PHY_TX_RX_POWEROFF	0x0
 
+#define PCIE_PCS_MASK			0xFF0000
+#define PCIE_PCS_DELAY_COUNT_SHIFT	0x10
+
 /*
  * This is an Empirical value that works, need to confirm the actual
  * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -96,9 +99,11 @@ struct ti_pipe3 {
 	struct clk		*div_clk;
 	struct pipe3_dpll_map	*dpll_map;
 	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
+	struct regmap		*pcs_syscon; /* ctrl. reg. acces */
 	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
 	unsigned int		dpll_reset_reg; /* reg. index within syscon */
 	unsigned int		power_reg; /* power reg. index within syscon */
+	unsigned int		pcie_pcs_reg; /* pcs reg. index in syscon */
 	bool			sata_refclk_enabled;
 };
 
@@ -271,7 +276,16 @@ static int ti_pipe3_init(struct phy *x)
 	 * 18-1804.
 	 */
 	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
-		omap_control_pcie_pcs(phy->control_dev, 0x96);
+		if (phy->pcs_syscon) {
+			val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
+			ret = regmap_update_bits(phy->pcs_syscon,
+						 phy->pcie_pcs_reg,
+						 PCIE_PCS_MASK, val);
+			if (ret < 0)
+				return ret;
+		} else {
+			omap_control_pcie_pcs(phy->control_dev, 0x96);
+		}
 		return 0;
 	}
 
@@ -455,6 +469,22 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "unable to get div-clk\n");
 			return PTR_ERR(phy->div_clk);
 		}
+
+		phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node,
+								  "syscon-pcs");
+		if (IS_ERR(phy->pcs_syscon)) {
+			dev_dbg(&pdev->dev,
+				 "can't get syscon-pcs, using omap control\n");
+			phy->pcs_syscon = NULL;
+		} else {
+			if (of_property_read_u32_index(node,
+						       "syscon-pcs", 1,
+						       &phy->pcie_pcs_reg)) {
+				dev_err(&pdev->dev,
+					"couldn't get pcie pcs reg. offset\n");
+				return -EINVAL;
+			}
+		}
 	} else {
 		phy->div_clk = ERR_PTR(-ENODEV);
 	}
Signature · 1 line
1.7.9.5

Other than that,

cheers,
-roger

#8 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: use *syscon* framework to set PCS value of the PHY

Hi,

Quoted 12 lines · Roger Quadros
Quoted 9 lines · On Tue, 23 Jun 2015 17:28:48 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to set PCS value of the PHY and start using *syscon* framework to do the same.

---
  Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
  drivers/phy/phy-ti-pipe3.c                       |   32 +++++++++++++++++++++-
  2 files changed, 33 insertions(+), 1 deletion(-)
Quoted 12 lines

Documentation/devicetree/bindings/phy/ti-phy.txt Optional properties: · line 87

Quoted 10 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index d3ad3bf..52c7a92 100644
@@ -83,6 +83,8 @@ Optional properties:
   - syscon-pllreset: Handle to system control region that contains the
     CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
     register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
+ - syscon-pcs : phandle/offset pair. Phandle to the system control module and the
+   register offset to write the PCS delay value.

What is PCS?

IIRC physical coding subsystem.

Quoted 1 line

Is this valid only for PCIe? If yes we could mention it here.

This is introduced specifically for PCIe. But there are other PCS registers with a different register map altogether for USB. I'm not sure if we will ever have to do those settings.

Thanks
Kishon

Quoted 82 lines
Quoted 74 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
  Deprecated properties:
   - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +31 -1
index 78bac00..e2f9ad7 100644
@@ -65,6 +65,9 @@
  #define PIPE3_PHY_TX_RX_POWERON		0x3
  #define PIPE3_PHY_TX_RX_POWEROFF	0x0
 
+#define PCIE_PCS_MASK			0xFF0000
+#define PCIE_PCS_DELAY_COUNT_SHIFT	0x10
+
  /*
   * This is an Empirical value that works, need to confirm the actual
   * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -96,9 +99,11 @@ struct ti_pipe3 {
  	struct clk		*div_clk;
  	struct pipe3_dpll_map	*dpll_map;
  	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
+	struct regmap		*pcs_syscon; /* ctrl. reg. acces */
  	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
  	unsigned int		dpll_reset_reg; /* reg. index within syscon */
  	unsigned int		power_reg; /* power reg. index within syscon */
+	unsigned int		pcie_pcs_reg; /* pcs reg. index in syscon */
  	bool			sata_refclk_enabled;
  };
 
@@ -271,7 +276,16 @@ static int ti_pipe3_init(struct phy *x)
  	 * 18-1804.
  	 */
  	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
-		omap_control_pcie_pcs(phy->control_dev, 0x96);
+		if (phy->pcs_syscon) {
+			val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
+			ret = regmap_update_bits(phy->pcs_syscon,
+						 phy->pcie_pcs_reg,
+						 PCIE_PCS_MASK, val);
+			if (ret < 0)
+				return ret;
+		} else {
+			omap_control_pcie_pcs(phy->control_dev, 0x96);
+		}
  		return 0;
  	}
 
@@ -455,6 +469,22 @@ static int ti_pipe3_probe(struct platform_device *pdev)
  			dev_err(&pdev->dev, "unable to get div-clk\n");
  			return PTR_ERR(phy->div_clk);
  		}
+
+		phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node,
+								  "syscon-pcs");
+		if (IS_ERR(phy->pcs_syscon)) {
+			dev_dbg(&pdev->dev,
+				 "can't get syscon-pcs, using omap control\n");
+			phy->pcs_syscon = NULL;
+		} else {
+			if (of_property_read_u32_index(node,
+						       "syscon-pcs", 1,
+						       &phy->pcie_pcs_reg)) {
+				dev_err(&pdev->dev,
+					"couldn't get pcie pcs reg. offset\n");
+				return -EINVAL;
+			}
+		}
  	} else {
  		phy->div_clk = ERR_PTR(-ENODEV);
  	}
Signature · 1 line
1.7.9.5

Other than that,

cheers,
-roger

#9 lore raw

Re: [PATCH 03/17] phy: ti-pipe3: use *syscon* framework to set PCS value of the PHY

Quoted 28 lines · On Wed, 24 Jun 2015 18:46:08 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Hi,

Quoted 12 lines · Roger Quadros
Quoted 9 lines · On Tue, 23 Jun 2015 17:28:48 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to set PCS value of the PHY and start using *syscon* framework to do the same.

---
  Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
  drivers/phy/phy-ti-pipe3.c                       |   32 +++++++++++++++++++++-
  2 files changed, 33 insertions(+), 1 deletion(-)
Quoted 12 lines

Documentation/devicetree/bindings/phy/ti-phy.txt Optional properties: · line 87

Quoted 10 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index d3ad3bf..52c7a92 100644
@@ -83,6 +83,8 @@ Optional properties:
   - syscon-pllreset: Handle to system control region that contains the
     CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
     register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
+ - syscon-pcs : phandle/offset pair. Phandle to the system control module and the
+   register offset to write the PCS delay value.

What is PCS?

Quoted 6 lines

IIRC physical coding subsystem.

Quoted 1 line

Is this valid only for PCIe? If yes we could mention it here.

This is introduced specifically for PCIe. But there are other PCS registers with a different register map altogether for USB. I'm not sure if we will ever have to do those settings.

OK then let's not say it is PCIe specific.

cheers,
-roger

Quoted 83 lines
Quoted 83 lines
Quoted 75 lines
Documentation/devicetree/bindings/phy/ti-phy.txt +0 -0
  Deprecated properties:
   - ctrl-module : phandle of the control module used by PHY driver to power on
drivers/phy/phy-ti-pipe3.c +31 -1
index 78bac00..e2f9ad7 100644
@@ -65,6 +65,9 @@
  #define PIPE3_PHY_TX_RX_POWERON		0x3
  #define PIPE3_PHY_TX_RX_POWEROFF	0x0
 
+#define PCIE_PCS_MASK			0xFF0000
+#define PCIE_PCS_DELAY_COUNT_SHIFT	0x10
+
  /*
   * This is an Empirical value that works, need to confirm the actual
   * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -96,9 +99,11 @@ struct ti_pipe3 {
  	struct clk		*div_clk;
  	struct pipe3_dpll_map	*dpll_map;
  	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
+	struct regmap		*pcs_syscon; /* ctrl. reg. acces */
  	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
  	unsigned int		dpll_reset_reg; /* reg. index within syscon */
  	unsigned int		power_reg; /* power reg. index within syscon */
+	unsigned int		pcie_pcs_reg; /* pcs reg. index in syscon */
  	bool			sata_refclk_enabled;
  };
 
@@ -271,7 +276,16 @@ static int ti_pipe3_init(struct phy *x)
  	 * 18-1804.
  	 */
  	if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
-		omap_control_pcie_pcs(phy->control_dev, 0x96);
+		if (phy->pcs_syscon) {
+			val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
+			ret = regmap_update_bits(phy->pcs_syscon,
+						 phy->pcie_pcs_reg,
+						 PCIE_PCS_MASK, val);
+			if (ret < 0)
+				return ret;
+		} else {
+			omap_control_pcie_pcs(phy->control_dev, 0x96);
+		}
  		return 0;
  	}
 
@@ -455,6 +469,22 @@ static int ti_pipe3_probe(struct platform_device *pdev)
  			dev_err(&pdev->dev, "unable to get div-clk\n");
  			return PTR_ERR(phy->div_clk);
  		}
+
+		phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node,
+								  "syscon-pcs");
+		if (IS_ERR(phy->pcs_syscon)) {
+			dev_dbg(&pdev->dev,
+				 "can't get syscon-pcs, using omap control\n");
+			phy->pcs_syscon = NULL;
+		} else {
+			if (of_property_read_u32_index(node,
+						       "syscon-pcs", 1,
+						       &phy->pcie_pcs_reg)) {
+				dev_err(&pdev->dev,
+					"couldn't get pcie pcs reg. offset\n");
+				return -EINVAL;
+			}
+		}
  	} else {
  		phy->div_clk = ERR_PTR(-ENODEV);
  	}
Signature · 1 line
1.7.9.5

Other than that,

cheers,
-roger

#10 lore raw

PATCH 4/17 phy: omap-usb2: use omap_usb_power_off to power off the PHY during probe

In reply to Kishon Vijay Abraham I

No functional change. Previously omap_control_phy_power() was used to power off the PHY during probe. But once phy-omap-usb2 driver is adapted to use syscon, omap_control_phy_power() cannot be used. Hence used omap_usb_power_off to power off the PHY.

---
 drivers/phy/phy-omap-usb2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-omap-usb2.c +1 -1
index c1a4686..b5c266a 100644
@@ -241,7 +241,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	}
 
 	phy->control_dev = &control_pdev->dev;
-	omap_control_phy_power(phy->control_dev, 0);
 
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
@@ -261,6 +260,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	}
 
 	phy_set_drvdata(generic_phy, phy);
+	omap_usb_power_off(generic_phy);
 
 	phy_provider = devm_of_phy_provider_register(phy->dev,
 			of_phy_simple_xlate);
Signature · 1 line
1.7.9.5
Acked-by on v1 4/17
#11 lore raw

Re: [PATCH 04/17] phy: omap-usb2: use omap_usb_power_off to power off the PHY during probe

Quoted 6 lines · On Tue, 23 Jun 2015 17:28:49 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

No functional change. Previously omap_control_phy_power() was used to power off the PHY during probe. But once phy-omap-usb2 driver is adapted to use syscon, omap_control_phy_power() cannot be used. Hence used omap_usb_power_off to power off the PHY.

cheers,
-roger

Quoted 27 lines
---
 drivers/phy/phy-omap-usb2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-omap-usb2.c +1 -1
index c1a4686..b5c266a 100644
@@ -241,7 +241,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	}
 
 	phy->control_dev = &control_pdev->dev;
-	omap_control_phy_power(phy->control_dev, 0);
 
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
@@ -261,6 +260,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	}
 
 	phy_set_drvdata(generic_phy, phy);
+	omap_usb_power_off(generic_phy);
 
 	phy_provider = devm_of_phy_provider_register(phy->dev,
 			of_phy_simple_xlate);
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 5/17 phy: omap-usb2: Add a new compatible string for USB2 PHY2

In reply to Kishon Vijay Abraham I

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, add a new "compatible" string.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
 drivers/phy/phy-omap-usb2.c                      |    9 +++++++++
 2 files changed, 11 insertions(+)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index 52c7a92..b9101b9 100644
@@ -31,6 +31,8 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be "ti,omap-usb2"
+	       Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY
+			in DRA7x
  - reg : Address and length of the register set for the device.
  - #phy-cells: determine the number of cells that should be given in the
    phandle while referencing this phy.
drivers/phy/phy-omap-usb2.c +9 -0
index b5c266a..2f7220f 100644
@@ -159,6 +159,11 @@ static const struct usb_phy_data dra7x_usb2_data = {
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
 };
 
+static const struct usb_phy_data dra7x_usb2_phy2_data = {
+	.label = "dra7x_usb2_phy2",
+	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+};
+
 static const struct usb_phy_data am437x_usb2_data = {
 	.label = "am437x_usb2",
 	.flags =  0,
@@ -178,6 +183,10 @@ static const struct of_device_id omap_usb2_id_table[] = {
 		.data = &dra7x_usb2_data,
 	},
 	{
+		.compatible = "ti,dra7x-usb2-phy2",
+		.data = &dra7x_usb2_phy2_data,
+	},
+	{
 		.compatible = "ti,am437x-usb2",
 		.data = &am437x_usb2_data,
 	},
Signature · 1 line
1.7.9.5
#13 lore raw

Re: [PATCH 05/17] phy: omap-usb2: Add a new compatible string for USB2 PHY2

Quoted 28 lines · On Tue, 23 Jun 2015 17:28:50 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, add a new "compatible" string.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
 drivers/phy/phy-omap-usb2.c                      |    9 +++++++++
 2 files changed, 11 insertions(+)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index 52c7a92..b9101b9 100644
@@ -31,6 +31,8 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be "ti,omap-usb2"
+	       Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY
+			in DRA7x
  - reg : Address and length of the register set for the device.
  - #phy-cells: determine the number of cells that should be given in the
    phandle while referencing this phy.
drivers/phy/phy-omap-usb2.c +0 -0
index b5c266a..2f7220f 100644

drivers/phy/phy-omap-usb2.c static const struct usb_phy_data dra7x_usb2_data = { · line 164

Quoted 6 lines
drivers/phy/phy-omap-usb2.c +3 -0
@@ -159,6 +159,11 @@ static const struct usb_phy_data dra7x_usb2_data = {
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
 };
 
+static const struct usb_phy_data dra7x_usb2_phy2_data = {
+	.label = "dra7x_usb2_phy2",
+	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,

Isn't it better to define the register map in usb_phy_data so that you don't need to check for compatible flag everytime?

Quoted 19 lines
drivers/phy/phy-omap-usb2.c +6 -0
+};
+
 static const struct usb_phy_data am437x_usb2_data = {
 	.label = "am437x_usb2",
 	.flags =  0,
@@ -178,6 +183,10 @@ static const struct of_device_id omap_usb2_id_table[] = {
 		.data = &dra7x_usb2_data,
 	},
 	{
+		.compatible = "ti,dra7x-usb2-phy2",
+		.data = &dra7x_usb2_phy2_data,
+	},
+	{
 		.compatible = "ti,am437x-usb2",
 		.data = &am437x_usb2_data,
 	},
Signature · 1 line
1.7.9.5

cheers,
-roger

#14 lore raw

Re: [PATCH 05/17] phy: omap-usb2: Add a new compatible string for USB2 PHY2

Hi,

Quoted 34 lines · Roger Quadros
Quoted 31 lines · On Tue, 23 Jun 2015 17:28:50 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, add a new "compatible" string.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    2 ++
 drivers/phy/phy-omap-usb2.c                      |    9 +++++++++
 2 files changed, 11 insertions(+)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
index 52c7a92..b9101b9 100644
@@ -31,6 +31,8 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be "ti,omap-usb2"
+	       Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY
+			in DRA7x
  - reg : Address and length of the register set for the device.
  - #phy-cells: determine the number of cells that should be given in the
    phandle while referencing this phy.
drivers/phy/phy-omap-usb2.c +0 -0
index b5c266a..2f7220f 100644
@@ -159,6 +159,11 @@ static const struct usb_phy_data dra7x_usb2_data = {
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
 };
 
Quoted 7 lines

drivers/phy/phy-omap-usb2.c static const struct usb_phy_data dra7x_usb2_data = { · line 164

Quoted 3 lines
drivers/phy/phy-omap-usb2.c +3 -0
+static const struct usb_phy_data dra7x_usb2_phy2_data = {
+	.label = "dra7x_usb2_phy2",
+	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,

Isn't it better to define the register map in usb_phy_data so that you don't need to check for compatible flag everytime?

We could may be define it for DRA7x USB2 PHYs but for am437x-usb2, it might not be good.

Thanks
Kishon

#15 lore raw

PATCH 6/17 phy: omap-usb2: use *syscon* framework to power on/off the PHY

In reply to Kishon Vijay Abraham I

Deprecate using phy-omap-control driver to power on/off the PHY, and use *syscon* framework to do the same. This handles powering on/off the PHY for the USB2 PHYs used in various TI SoCs.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    6 +-
 drivers/phy/phy-omap-usb2.c                      |  101 ++++++++++++++++++----
 include/linux/phy/omap_usb.h                     |   18 ++++
 3 files changed, 107 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +5 -1
index b9101b9..5bfe461 100644
@@ -42,10 +42,14 @@ Required properties:
    * "wkupclk" - wakeup clock.
    * "refclk" - reference clock (optional).
 
-Optional properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
    the PHY.
 
+Recommended properies:
+- syscon-phy-power : phandle/offset pair. Phandle to the system control
+  module and the register offset to power on/off the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy at 4a0ad080 {
drivers/phy/phy-omap-usb2.c +84 -17

164 lines not on this page · raw message

include/linux/phy/omap_usb.h +18 -0
index dc2c541..de933ab 100644
@@ -30,6 +30,12 @@ struct usb_dpll_params {
 	u32	mf;
 };
 
+enum omap_usb_phy_type {
+	TYPE_USB2,    /* USB2_PHY, power down in CONTROL_DEV_CONF */
+	TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
+	TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
+};
+
 struct omap_usb {
 	struct usb_phy		phy;
 	struct phy_companion	*comparator;
@@ -40,11 +46,15 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	enum omap_usb_phy_type	type;
+	struct regmap		*syscon_phy_power; /* ctrl. reg. acces */
+	unsigned int		power_reg; /* power reg. index within syscon */
 };
 
 struct usb_phy_data {
 	const char *label;
 	u8 flags;
+	enum omap_usb_phy_type type;
 };
 
 /* Driver Flags */
@@ -52,6 +62,14 @@ struct usb_phy_data {
 #define OMAP_USB2_HAS_SET_VBUS (1 << 1)
 #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
 
+#define OMAP_DEV_PHY_PD		BIT(0)
+#define OMAP_USB2_PHY_PD	BIT(28)
+
+#define AM437X_USB2_PHY_PD		BIT(0)
+#define AM437X_USB2_OTG_PD		BIT(1)
+#define AM437X_USB2_OTGVDET_EN		BIT(19)
+#define AM437X_USB2_OTGSESSEND_EN	BIT(20)
+
 #define	phy_to_omapusb(x)	container_of((x), struct omap_usb, phy)
 
 #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
Signature · 1 line
1.7.9.5
#16 lore raw

Re: [PATCH 06/17] phy: omap-usb2: use *syscon* framework to power on/off the PHY

Quoted 238 lines · On Tue, 23 Jun 2015 17:28:51 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to power on/off the PHY, and use *syscon* framework to do the same. This handles powering on/off the PHY for the USB2 PHYs used in various TI SoCs.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    6 +-
 drivers/phy/phy-omap-usb2.c                      |  101 ++++++++++++++++++----
 include/linux/phy/omap_usb.h                     |   18 ++++
 3 files changed, 107 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +5 -1
index b9101b9..5bfe461 100644
@@ -42,10 +42,14 @@ Required properties:
    * "wkupclk" - wakeup clock.
    * "refclk" - reference clock (optional).
 
-Optional properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
    the PHY.
 
+Recommended properies:
+- syscon-phy-power : phandle/offset pair. Phandle to the system control
+  module and the register offset to power on/off the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy at 4a0ad080 {
drivers/phy/phy-omap-usb2.c +84 -17
index 2f7220f..180b066 100644
@@ -29,6 +29,8 @@
 #include <linux/delay.h>
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 #include <linux/of_platform.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
@@ -97,22 +99,65 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
 	return 0;
 }
 
-static int omap_usb_power_off(struct phy *x)
+static int omap_usb_phy_power(struct omap_usb *phy, int on)
 {
-	struct omap_usb *phy = phy_get_drvdata(x);
+	u32 val = 0;
+	u32 mask;
+	int ret;
 
-	omap_control_phy_power(phy->control_dev, 0);
+	if (phy->syscon_phy_power) {
+		switch (phy->type) {
+		case TYPE_USB2:
+			mask = OMAP_DEV_PHY_PD;
+			if (!on)
+				val = OMAP_DEV_PHY_PD;
+			break;
+		case TYPE_DRA7USB2:
+			mask = OMAP_USB2_PHY_PD;
+			if (!on)
+				val = OMAP_USB2_PHY_PD;
+			break;
+		case TYPE_AM437USB2:
+			mask = AM437X_USB2_PHY_PD |
+				AM437X_USB2_OTG_PD |
+				AM437X_USB2_OTGVDET_EN |
+				AM437X_USB2_OTGSESSEND_EN;
+			if (on) {
+				val = AM437X_USB2_OTGVDET_EN |
+					AM437X_USB2_OTGSESSEND_EN;
+			} else {
+				val = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD;
+			}
+			break;
+		default:
+			dev_err(phy->dev, "%s: type %d not recognized\n",
+				__func__, phy->type);
+			return -EINVAL;
+		}
+
+		ret = regmap_update_bits(phy->syscon_phy_power, phy->power_reg,
+					 mask, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, on);
+	}
 
 	return 0;
 }
 
-static int omap_usb_power_on(struct phy *x)
+static int omap_usb_power_off(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
-	omap_control_phy_power(phy->control_dev, 1);
+	return omap_usb_phy_power(phy, false);
+}
 
-	return 0;
+static int omap_usb_power_on(struct phy *x)
+{
+	struct omap_usb *phy = phy_get_drvdata(x);
+
+	return omap_usb_phy_power(phy, true);
 }
 
 static int omap_usb_init(struct phy *x)
@@ -147,26 +192,31 @@ static struct phy_ops ops = {
 static const struct usb_phy_data omap_usb2_data = {
 	.label = "omap_usb2",
 	.flags = OMAP_USB2_HAS_START_SRP | OMAP_USB2_HAS_SET_VBUS,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data omap5_usb2_data = {
 	.label = "omap5_usb2",
 	.flags = 0,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data dra7x_usb2_data = {
 	.label = "dra7x_usb2",
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data dra7x_usb2_phy2_data = {
 	.label = "dra7x_usb2_phy2",
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+	.type = TYPE_DRA7USB2,
 };
 
 static const struct usb_phy_data am437x_usb2_data = {
 	.label = "am437x_usb2",
 	.flags =  0,
+	.type = TYPE_AM437USB2,
 };
 
 static const struct of_device_id omap_usb2_id_table[] = {
@@ -223,6 +273,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	phy->dev		= &pdev->dev;
+	phy->type		= phy_data->type;
 
 	phy->phy.dev		= phy->dev;
 	phy->phy.label		= phy_data->label;
@@ -237,20 +288,36 @@ static int omap_usb2_probe(struct platform_device *pdev)
 		phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
 	}
 
-	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;
-	}
+	phy->syscon_phy_power = syscon_regmap_lookup_by_phandle(node,
+							"syscon-phy-power");
+	if (IS_ERR(phy->syscon_phy_power)) {
+		dev_info(&pdev->dev,
+			 "can't get syscon-phy-power, using control device\n");
+		phy->syscon_phy_power = NULL;
+
+		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);
-	if (!control_pdev) {
-		dev_err(&pdev->dev, "Failed to get control device\n");
-		return -EINVAL;
+		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;
+	} else {
+		if (of_property_read_u32_index(node,
+					       "syscon-phy-power", 1,
+					       &phy->power_reg)) {
+			dev_err(&pdev->dev,
+				"couldn't get power reg. offset\n");
+			return -EINVAL;
+		}
 	}
 
-	phy->control_dev = &control_pdev->dev;
-
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +10 -0
index dc2c541..de933ab 100644
@@ -30,6 +30,12 @@ struct usb_dpll_params {
 	u32	mf;
 };
 
+enum omap_usb_phy_type {
+	TYPE_USB2,    /* USB2_PHY, power down in CONTROL_DEV_CONF */
+	TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
+	TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
+};
+
 struct omap_usb {
 	struct usb_phy		phy;
 	struct phy_companion	*comparator;
@@ -40,11 +46,15 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	enum omap_usb_phy_type	type;
+	struct regmap		*syscon_phy_power; /* ctrl. reg. acces */
+	unsigned int		power_reg; /* power reg. index within syscon */
 };
 
 struct usb_phy_data {
 	const char *label;
 	u8 flags;
+	enum omap_usb_phy_type type;
 };
 
 /* Driver Flags */

include/linux/phy/omap_usb.h struct usb_phy_data { · line 68

Quoted 7 lines
include/linux/phy/omap_usb.h +4 -0
@@ -52,6 +62,14 @@ struct usb_phy_data {
 #define OMAP_USB2_HAS_SET_VBUS (1 << 1)
 #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
 
+#define OMAP_DEV_PHY_PD		BIT(0)
+#define OMAP_USB2_PHY_PD	BIT(28)
+
+#define AM437X_USB2_PHY_PD		BIT(0)

This PD bit can be set in usb_phy_data and used by a single block of code for all 3 phys.

Quoted 10 lines
include/linux/phy/omap_usb.h +4 -0
+#define AM437X_USB2_OTG_PD		BIT(1)
+#define AM437X_USB2_OTGVDET_EN		BIT(19)
+#define AM437X_USB2_OTGSESSEND_EN	BIT(20)
+
 #define	phy_to_omapusb(x)	container_of((x), struct omap_usb, phy)
 
 #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
Signature · 1 line
1.7.9.5

cheers,
-roger

#17 lore raw

Re: [PATCH 06/17] phy: omap-usb2: use *syscon* framework to power on/off the PHY

Hi,

Quoted 244 lines · Roger Quadros
Quoted 241 lines · On Tue, 23 Jun 2015 17:28:51 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to power on/off the PHY, and use *syscon* framework to do the same. This handles powering on/off the PHY for the USB2 PHYs used in various TI SoCs.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt |    6 +-
 drivers/phy/phy-omap-usb2.c                      |  101 ++++++++++++++++++----
 include/linux/phy/omap_usb.h                     |   18 ++++
 3 files changed, 107 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/phy/ti-phy.txt +5 -1
index b9101b9..5bfe461 100644
@@ -42,10 +42,14 @@ Required properties:
    * "wkupclk" - wakeup clock.
    * "refclk" - reference clock (optional).
 
-Optional properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
    the PHY.
 
+Recommended properies:
+- syscon-phy-power : phandle/offset pair. Phandle to the system control
+  module and the register offset to power on/off the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy at 4a0ad080 {
drivers/phy/phy-omap-usb2.c +84 -17
index 2f7220f..180b066 100644
@@ -29,6 +29,8 @@
 #include <linux/delay.h>
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 #include <linux/of_platform.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
@@ -97,22 +99,65 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
 	return 0;
 }
 
-static int omap_usb_power_off(struct phy *x)
+static int omap_usb_phy_power(struct omap_usb *phy, int on)
 {
-	struct omap_usb *phy = phy_get_drvdata(x);
+	u32 val = 0;
+	u32 mask;
+	int ret;
 
-	omap_control_phy_power(phy->control_dev, 0);
+	if (phy->syscon_phy_power) {
+		switch (phy->type) {
+		case TYPE_USB2:
+			mask = OMAP_DEV_PHY_PD;
+			if (!on)
+				val = OMAP_DEV_PHY_PD;
+			break;
+		case TYPE_DRA7USB2:
+			mask = OMAP_USB2_PHY_PD;
+			if (!on)
+				val = OMAP_USB2_PHY_PD;
+			break;
+		case TYPE_AM437USB2:
+			mask = AM437X_USB2_PHY_PD |
+				AM437X_USB2_OTG_PD |
+				AM437X_USB2_OTGVDET_EN |
+				AM437X_USB2_OTGSESSEND_EN;
+			if (on) {
+				val = AM437X_USB2_OTGVDET_EN |
+					AM437X_USB2_OTGSESSEND_EN;
+			} else {
+				val = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD;
+			}
+			break;
+		default:
+			dev_err(phy->dev, "%s: type %d not recognized\n",
+				__func__, phy->type);
+			return -EINVAL;
+		}
+
+		ret = regmap_update_bits(phy->syscon_phy_power, phy->power_reg,
+					 mask, val);
+		if (ret < 0)
+			return ret;
+	} else {
+		omap_control_phy_power(phy->control_dev, on);
+	}
 
 	return 0;
 }
 
-static int omap_usb_power_on(struct phy *x)
+static int omap_usb_power_off(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
-	omap_control_phy_power(phy->control_dev, 1);
+	return omap_usb_phy_power(phy, false);
+}
 
-	return 0;
+static int omap_usb_power_on(struct phy *x)
+{
+	struct omap_usb *phy = phy_get_drvdata(x);
+
+	return omap_usb_phy_power(phy, true);
 }
 
 static int omap_usb_init(struct phy *x)
@@ -147,26 +192,31 @@ static struct phy_ops ops = {
 static const struct usb_phy_data omap_usb2_data = {
 	.label = "omap_usb2",
 	.flags = OMAP_USB2_HAS_START_SRP | OMAP_USB2_HAS_SET_VBUS,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data omap5_usb2_data = {
 	.label = "omap5_usb2",
 	.flags = 0,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data dra7x_usb2_data = {
 	.label = "dra7x_usb2",
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+	.type = TYPE_USB2,
 };
 
 static const struct usb_phy_data dra7x_usb2_phy2_data = {
 	.label = "dra7x_usb2_phy2",
 	.flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+	.type = TYPE_DRA7USB2,
 };
 
 static const struct usb_phy_data am437x_usb2_data = {
 	.label = "am437x_usb2",
 	.flags =  0,
+	.type = TYPE_AM437USB2,
 };
 
 static const struct of_device_id omap_usb2_id_table[] = {
@@ -223,6 +273,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	phy->dev		= &pdev->dev;
+	phy->type		= phy_data->type;
 
 	phy->phy.dev		= phy->dev;
 	phy->phy.label		= phy_data->label;
@@ -237,20 +288,36 @@ static int omap_usb2_probe(struct platform_device *pdev)
 		phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
 	}
 
-	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;
-	}
+	phy->syscon_phy_power = syscon_regmap_lookup_by_phandle(node,
+							"syscon-phy-power");
+	if (IS_ERR(phy->syscon_phy_power)) {
+		dev_info(&pdev->dev,
+			 "can't get syscon-phy-power, using control device\n");
+		phy->syscon_phy_power = NULL;
+
+		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);
-	if (!control_pdev) {
-		dev_err(&pdev->dev, "Failed to get control device\n");
-		return -EINVAL;
+		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;
+	} else {
+		if (of_property_read_u32_index(node,
+					       "syscon-phy-power", 1,
+					       &phy->power_reg)) {
+			dev_err(&pdev->dev,
+				"couldn't get power reg. offset\n");
+			return -EINVAL;
+		}
 	}
 
-	phy->control_dev = &control_pdev->dev;
-
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +10 -0
index dc2c541..de933ab 100644
@@ -30,6 +30,12 @@ struct usb_dpll_params {
 	u32	mf;
 };
 
+enum omap_usb_phy_type {
+	TYPE_USB2,    /* USB2_PHY, power down in CONTROL_DEV_CONF */
+	TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
+	TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
+};
+
 struct omap_usb {
 	struct usb_phy		phy;
 	struct phy_companion	*comparator;
@@ -40,11 +46,15 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	enum omap_usb_phy_type	type;
+	struct regmap		*syscon_phy_power; /* ctrl. reg. acces */
+	unsigned int		power_reg; /* power reg. index within syscon */
 };
 
 struct usb_phy_data {
 	const char *label;
 	u8 flags;
+	enum omap_usb_phy_type type;
 };
 
 /* Driver Flags */
@@ -52,6 +62,14 @@ struct usb_phy_data {
 #define OMAP_USB2_HAS_SET_VBUS (1 << 1)
 #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
 
Quoted 7 lines

include/linux/phy/omap_usb.h struct usb_phy_data { · line 68

Quoted 4 lines
include/linux/phy/omap_usb.h +4 -0
+#define OMAP_DEV_PHY_PD		BIT(0)
+#define OMAP_USB2_PHY_PD	BIT(28)
+
+#define AM437X_USB2_PHY_PD		BIT(0)

This PD bit can be set in usb_phy_data and used by a single block of code for all 3 phys.

yeah, that could be done.

Thanks
Kishon

#18 lore raw

PATCH 7/17 usb: musb: omap2430: use *syscon* framework to write to mailbox register

In reply to Kishon Vijay Abraham I

Deprecate using phy-omap-control driver to write to the mailbox register and start using *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/usb/omap-usb.txt |    7 +-
 drivers/usb/musb/omap2430.c                        |  118 ++++++++++++++++----
 2 files changed, 102 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/usb/omap-usb.txt +6 -1
index 38d9bb8..c001306 100644
@@ -20,10 +20,15 @@ OMAP MUSB GLUE
  - phy-names : the names of the PHY corresponding to the PHYs present in the
    *phy* phandle.
 
-Optional properties:
+Optional Properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module this glue uses to write to
    mailbox
 
+Recommended properies:
+ - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
+   register offset of the mailbox.
+
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs at 4a0ab000 {
 	compatible = "ti,omap4-musb";
drivers/usb/musb/omap2430.c +96 -22

194 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#19 lore raw

Re: [PATCH 07/17] usb: musb: omap2430: use *syscon* framework to write to mailbox register

Quoted 171 lines · On Tue, 23 Jun 2015 17:28:52 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to write to the mailbox register and start using *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/usb/omap-usb.txt |    7 +-
 drivers/usb/musb/omap2430.c                        |  118 ++++++++++++++++----
 2 files changed, 102 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/usb/omap-usb.txt +6 -1
index 38d9bb8..c001306 100644
@@ -20,10 +20,15 @@ OMAP MUSB GLUE
  - phy-names : the names of the PHY corresponding to the PHYs present in the
    *phy* phandle.
 
-Optional properties:
+Optional Properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module this glue uses to write to
    mailbox
 
+Recommended properies:
+ - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
+   register offset of the mailbox.
+
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs at 4a0ab000 {
 	compatible = "ti,omap4-musb";
drivers/usb/musb/omap2430.c +58 -9
index cc752d8..bcd6d1e 100644
@@ -39,16 +39,27 @@
 #include <linux/usb/musb-omap.h>
 #include <linux/phy/omap_control_phy.h>
 #include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #include "musb_core.h"
 #include "omap2430.h"
 
+#define OMAP2430_MUSB_MODE_MASK	0x1f
+#define OMAP2430_MUSB_AVALID	(0x1 << 0)
+#define OMAP2430_MUSB_BVALID	(0x1 << 1)
+#define OMAP2430_MUSB_VBUSVALID	(0x1 << 2)
+#define OMAP2430_MUSB_SESSEND	(0x1 << 3)
+#define OMAP2430_MUSB_IDDIG	(0x1 << 4)
+
 struct omap2430_glue {
 	struct device		*dev;
 	struct platform_device	*musb;
 	enum omap_musb_vbus_id_status status;
 	struct work_struct	omap_musb_mailbox_work;
 	struct device		*control_otghs;
+	struct regmap		*syscon_otghs; /* ctrl. reg. acces */
+	unsigned int            otghs_reg; /* otghs reg. index within syscon */
 };
 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
 
@@ -253,6 +264,47 @@ void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
 }
 EXPORT_SYMBOL_GPL(omap_musb_mailbox);
 
+static void omap2430_musb_set_usbmode(struct omap2430_glue *glue,
+				      enum omap_control_usb_mode mode)
+{
+	u32 val;
+	int ret;
+
+	if (glue->syscon_otghs) {
+		switch (mode) {
+		case USB_MODE_HOST:
+			val = OMAP2430_MUSB_AVALID | OMAP2430_MUSB_VBUSVALID;
+			break;
+
+		case USB_MODE_DEVICE:
+			val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_AVALID |
+				OMAP2430_MUSB_VBUSVALID;
+			break;
+
+		case USB_MODE_DISCONNECT:
+			val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_SESSEND;
+			break;
+
+		default:
+			dev_dbg(glue->dev, "Invalid mode\n");
+			goto err_regmap_update;
+		}
+
+		ret = regmap_update_bits(glue->syscon_otghs,
+					 glue->otghs_reg,
+					 OMAP2430_MUSB_MODE_MASK, val);
+		if (ret < 0)
+			goto err_regmap_update;
+	} else {
+		omap_control_usb_set_mode(glue->control_otghs, mode);
+	}
+
+	return;
+
+err_regmap_update:
+	dev_err(glue->dev, "Failed to set mode to %d\n", mode);
+}
+
 static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 {
 	struct musb *musb = glue_to_musb(glue);
@@ -270,8 +322,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_ID;
 		if (musb->gadget_driver) {
 			pm_runtime_get_sync(dev);
-			omap_control_usb_set_mode(glue->control_otghs,
-				USB_MODE_HOST);
+			omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
 			omap2430_musb_set_vbus(musb, 1);
 		}
 		break;
@@ -284,7 +335,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_VBUS;
 		if (musb->gadget_driver)
 			pm_runtime_get_sync(dev);
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
 		break;
 
 	case OMAP_MUSB_ID_FLOAT:
@@ -301,8 +352,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		if (data->interface_type == MUSB_INTERFACE_UTMI)
 			otg_set_vbus(musb->xceiv->otg, 0);
 
-		omap_control_usb_set_mode(glue->control_otghs,
-			USB_MODE_DISCONNECT);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
 		break;
 	default:
 		dev_dbg(dev, "ID float\n");
@@ -444,7 +494,7 @@ static void omap2430_musb_enable(struct musb *musb)
 	switch (glue->status) {
 
 	case OMAP_MUSB_ID_GROUND:
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
+		omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
 		if (data->interface_type != MUSB_INTERFACE_UTMI)
 			break;
 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
@@ -463,7 +513,7 @@ static void omap2430_musb_enable(struct musb *musb)
 		break;
 
 	case OMAP_MUSB_VBUS_VALID:
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
 		break;
 
 	default:
@@ -477,8 +527,7 @@ static void omap2430_musb_disable(struct musb *musb)
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
 
 	if (glue->status != OMAP_MUSB_UNKNOWN)
-		omap_control_usb_set_mode(glue->control_otghs,
-			USB_MODE_DISCONNECT);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
 }
 
 static int omap2430_musb_exit(struct musb *musb)
@@ -507,6 +556,40 @@ static const struct musb_platform_ops omap2430_ops = {
 
 static u64 omap2430_dmamask = DMA_BIT_MASK(32);
 

drivers/usb/musb/omap2430.c static const struct musb_platform_ops omap2430_ops = { · line 568

Quoted 10 lines
drivers/usb/musb/omap2430.c +10 -0
+static int omap2430_get_control(struct omap2430_glue *glue,
+				struct device_node *np)
+{
+	struct device_node *control_node;
+	struct platform_device *control_pdev;
+
+	glue->syscon_otghs = syscon_regmap_lookup_by_phandle(np,
+							     "syscon-otghs");
+	if (IS_ERR(glue->syscon_otghs)) {
+		dev_info(glue->dev, "can't get syscon, using control device\n");

dev_dbg().

Quoted 48 lines
drivers/usb/musb/omap2430.c +24 -10
+		glue->syscon_otghs = NULL;
+
+		control_node = of_parse_phandle(np, "ctrl-module", 0);
+		if (control_node) {
+			control_pdev = of_find_device_by_node(control_node);
+			if (!control_pdev) {
+				dev_err(glue->dev,
+					"Failed to get control device\n");
+				return -EINVAL;
+			}
+			glue->control_otghs = &control_pdev->dev;
+		}
+	} else {
+		if (of_property_read_u32_index(np, "syscon-otghs", 1,
+					       &glue->otghs_reg)) {
+			dev_err(glue->dev,
+				"couldn't get otghs reg. offset\n");
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 static int omap2430_probe(struct platform_device *pdev)
 {
 	struct resource			musb_resources[3];
@@ -538,9 +621,6 @@ static int omap2430_probe(struct platform_device *pdev)
 	glue->control_otghs = ERR_PTR(-ENODEV);
 
 	if (np) {
-		struct device_node *control_node;
-		struct platform_device *control_pdev;
-
 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 		if (!pdata)
 			goto err2;
@@ -567,16 +647,10 @@ static int omap2430_probe(struct platform_device *pdev)
 		pdata->board_data	= data;
 		pdata->config		= config;
 
-		control_node = of_parse_phandle(np, "ctrl-module", 0);
-		if (control_node) {
-			control_pdev = of_find_device_by_node(control_node);
-			if (!control_pdev) {
-				dev_err(&pdev->dev, "Failed to get control device\n");
-				ret = -EINVAL;
-				goto err2;

drivers/usb/musb/omap2430.c static int omap2430_probe(struct platform_device *pdev) · line 656

Quoted 10 lines
drivers/usb/musb/omap2430.c +4 -3
-			}
-			glue->control_otghs = &control_pdev->dev;
-		}
+		ret = omap2430_get_control(glue, np);
+		if (ret)
+			goto err2;
+
 	}
 	pdata->platform_ops		= &omap2430_ops;
 

cheers,
-roger

#20 lore raw

Re: [PATCH 07/17] usb: musb: omap2430: use *syscon* framework to write to mailbox register

Hi,

Quoted 174 lines · Roger Quadros
Quoted 171 lines · On Tue, 23 Jun 2015 17:28:52 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Deprecate using phy-omap-control driver to write to the mailbox register and start using *syscon* framework to do the same.

---
 Documentation/devicetree/bindings/usb/omap-usb.txt |    7 +-
 drivers/usb/musb/omap2430.c                        |  118 ++++++++++++++++----
 2 files changed, 102 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/usb/omap-usb.txt +6 -1
index 38d9bb8..c001306 100644
@@ -20,10 +20,15 @@ OMAP MUSB GLUE
  - phy-names : the names of the PHY corresponding to the PHYs present in the
    *phy* phandle.
 
-Optional properties:
+Optional Properties:
+Deprecated properties:
  - ctrl-module : phandle of the control module this glue uses to write to
    mailbox
 
+Recommended properies:
+ - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
+   register offset of the mailbox.
+
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs at 4a0ab000 {
 	compatible = "ti,omap4-musb";
drivers/usb/musb/omap2430.c +58 -9
index cc752d8..bcd6d1e 100644
@@ -39,16 +39,27 @@
 #include <linux/usb/musb-omap.h>
 #include <linux/phy/omap_control_phy.h>
 #include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #include "musb_core.h"
 #include "omap2430.h"
 
+#define OMAP2430_MUSB_MODE_MASK	0x1f
+#define OMAP2430_MUSB_AVALID	(0x1 << 0)
+#define OMAP2430_MUSB_BVALID	(0x1 << 1)
+#define OMAP2430_MUSB_VBUSVALID	(0x1 << 2)
+#define OMAP2430_MUSB_SESSEND	(0x1 << 3)
+#define OMAP2430_MUSB_IDDIG	(0x1 << 4)
+
 struct omap2430_glue {
 	struct device		*dev;
 	struct platform_device	*musb;
 	enum omap_musb_vbus_id_status status;
 	struct work_struct	omap_musb_mailbox_work;
 	struct device		*control_otghs;
+	struct regmap		*syscon_otghs; /* ctrl. reg. acces */
+	unsigned int            otghs_reg; /* otghs reg. index within syscon */
 };
 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
 
@@ -253,6 +264,47 @@ void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
 }
 EXPORT_SYMBOL_GPL(omap_musb_mailbox);
 
+static void omap2430_musb_set_usbmode(struct omap2430_glue *glue,
+				      enum omap_control_usb_mode mode)
+{
+	u32 val;
+	int ret;
+
+	if (glue->syscon_otghs) {
+		switch (mode) {
+		case USB_MODE_HOST:
+			val = OMAP2430_MUSB_AVALID | OMAP2430_MUSB_VBUSVALID;
+			break;
+
+		case USB_MODE_DEVICE:
+			val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_AVALID |
+				OMAP2430_MUSB_VBUSVALID;
+			break;
+
+		case USB_MODE_DISCONNECT:
+			val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_SESSEND;
+			break;
+
+		default:
+			dev_dbg(glue->dev, "Invalid mode\n");
+			goto err_regmap_update;
+		}
+
+		ret = regmap_update_bits(glue->syscon_otghs,
+					 glue->otghs_reg,
+					 OMAP2430_MUSB_MODE_MASK, val);
+		if (ret < 0)
+			goto err_regmap_update;
+	} else {
+		omap_control_usb_set_mode(glue->control_otghs, mode);
+	}
+
+	return;
+
+err_regmap_update:
+	dev_err(glue->dev, "Failed to set mode to %d\n", mode);
+}
+
 static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 {
 	struct musb *musb = glue_to_musb(glue);
@@ -270,8 +322,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_ID;
 		if (musb->gadget_driver) {
 			pm_runtime_get_sync(dev);
-			omap_control_usb_set_mode(glue->control_otghs,
-				USB_MODE_HOST);
+			omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
 			omap2430_musb_set_vbus(musb, 1);
 		}
 		break;
@@ -284,7 +335,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_VBUS;
 		if (musb->gadget_driver)
 			pm_runtime_get_sync(dev);
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
 		break;
 
 	case OMAP_MUSB_ID_FLOAT:
@@ -301,8 +352,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		if (data->interface_type == MUSB_INTERFACE_UTMI)
 			otg_set_vbus(musb->xceiv->otg, 0);
 
-		omap_control_usb_set_mode(glue->control_otghs,
-			USB_MODE_DISCONNECT);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
 		break;
 	default:
 		dev_dbg(dev, "ID float\n");
@@ -444,7 +494,7 @@ static void omap2430_musb_enable(struct musb *musb)
 	switch (glue->status) {
 
 	case OMAP_MUSB_ID_GROUND:
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
+		omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
 		if (data->interface_type != MUSB_INTERFACE_UTMI)
 			break;
 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
@@ -463,7 +513,7 @@ static void omap2430_musb_enable(struct musb *musb)
 		break;
 
 	case OMAP_MUSB_VBUS_VALID:
-		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
 		break;
 
 	default:
@@ -477,8 +527,7 @@ static void omap2430_musb_disable(struct musb *musb)
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
 
 	if (glue->status != OMAP_MUSB_UNKNOWN)
-		omap_control_usb_set_mode(glue->control_otghs,
-			USB_MODE_DISCONNECT);
+		omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
 }
 
 static int omap2430_musb_exit(struct musb *musb)
@@ -507,6 +556,40 @@ static const struct musb_platform_ops omap2430_ops = {
 
 static u64 omap2430_dmamask = DMA_BIT_MASK(32);
 
Quoted 12 lines

drivers/usb/musb/omap2430.c static const struct musb_platform_ops omap2430_ops = { · line 568

Quoted 10 lines
drivers/usb/musb/omap2430.c +10 -0
+static int omap2430_get_control(struct omap2430_glue *glue,
+				struct device_node *np)
+{
+	struct device_node *control_node;
+	struct platform_device *control_pdev;
+
+	glue->syscon_otghs = syscon_regmap_lookup_by_phandle(np,
+							     "syscon-otghs");
+	if (IS_ERR(glue->syscon_otghs)) {
+		dev_info(glue->dev, "can't get syscon, using control device\n");

dev_dbg().

Alright.

Thanks
Kishon

#21 lore raw

Re: [PATCH 07/17] usb: musb: omap2430: use *syscon* framework to write to mailbox register

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

Deprecate using phy-omap-control driver to write to the mailbox register and start using *syscon* framework to do the same.

All this stuff needs to go to some generic syscon USB phy driver. Let's not start adding phy specific stuff to a USB driver.

Regards,

Tony

#22 lore raw

Re: [PATCH 07/17] usb: musb: omap2430: use *syscon* framework to write to mailbox register

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Kishon Vijay Abraham I

Deprecate using phy-omap-control driver to write to the mailbox register and start using *syscon* framework to do the same.

All this stuff needs to go to some generic syscon USB phy driver. Let's not start adding phy specific stuff to a USB driver.

Mailbox register is actually part of OMAP USB glue that should be written in order to inform the usbmode to the MUSB core.

Thanks
Kishon

#23 lore raw

PATCH 8/17 ARM: dts: dra7: Add dt node for the sycon pcie

In reply to Kishon Vijay Abraham I

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +5 -0
index 260f300..3f434f7 100644
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+
 		sdma: dma-controller at 4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
Signature · 1 line
1.7.9.5
#24 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

Quoted 13 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644

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

Quoted 8 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Quoted 6 lines
arch/arm/boot/dts/dra7.dtsi +0 -0
 		sdma: dma-controller at 4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
Signature · 1 line
1.7.9.5

cheers,
-roger

#25 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

Quoted 19 lines · On Wed, 24 Jun 2015 14:50:17 +0300 Roger Quadros <[email protected]> wrote:
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
Quoted 8 lines

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Also, why can't this dra7_ctrl_pcie node be where scm_conf is.

Quoted 14 lines
Quoted 7 lines
arch/arm/boot/dts/dra7.dtsi +0 -0
 		sdma: dma-controller at 4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
Signature · 1 line
1.7.9.5

cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

Quoted 31 lines · Roger Quadros
Quoted 19 lines · On Wed, 24 Jun 2015 14:50:17 +0300 Roger Quadros <[email protected]> wrote:
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
Quoted 8 lines

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Quoted 1 line

Also, why can't this dra7_ctrl_pcie node be where scm_conf is.

Yes all the scm children should be under scm at 2000 entry in the dra7.dtsi file.

And BTW, there's nothing stopping a driver doing of_ioremap on a larger range and be a child under scm at 2000 in the dra7.dtsi if that range is dedicated to a single driver.

My take is we should only use regmap for the scm_conf area in general.

Regards,

Tony

#27 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

Quoted 32 lines · On Wed, 24 Jun 2015 05:09:39 -0700 Tony Lindgren <[email protected]> wrote:
Quoted 31 lines · Roger Quadros
Quoted 27 lines · On Wed, 24 Jun 2015 14:50:17 +0300 Roger Quadros <[email protected]> wrote:
Quoted 13 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644

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

Quoted 8 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Quoted 8 lines
Quoted 1 line

Also, why can't this dra7_ctrl_pcie node be where scm_conf is.

Yes all the scm children should be under scm at 2000 entry in the dra7.dtsi file.

And BTW, there's nothing stopping a driver doing of_ioremap on a larger range and be a child under scm at 2000 in the dra7.dtsi if that range is dedicated to a single driver.

Agreed.

Quoted 3 lines

My take is we should only use regmap for the scm_conf area in general.

+1

should we get rid of dra7_ctrl_core and dra7_ctrl_general? or move them to scm node?

cheers,
-roger

#28 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

Quoted 10 lines · Roger Quadros
Quoted 3 lines · On Wed, 24 Jun 2015 05:09:39 -0700 Tony Lindgren <[email protected]> wrote:

My take is we should only use regmap for the scm_conf area in general.

+1

should we get rid of dra7_ctrl_core and dra7_ctrl_general? or move them to scm node?

Well at least move them. And if there are clear dedicated register ranges there claimed only by a single device driver, then those drivers should be just regular loadable driver modules doing of_ioremap on the range. And in that case they can be removed.

We have examples of both in dra7.dtsi, pbias_regulator using the scm_conf via syscon, and then dra7_pmx_core ioremapping a dedicated register range. So unless there are other messy register ranges like the scm_conf area then there should not be need for other syscon areas.

Regards,

Tony

#29 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

In reply to Roger Quadros

Hi,

Quoted 31 lines · Roger Quadros
Quoted 19 lines · On Wed, 24 Jun 2015 14:50:17 +0300 Roger Quadros <[email protected]> wrote:
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
Quoted 8 lines

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Quoted 1 line

Also, why can't this dra7_ctrl_pcie node be where scm_conf is.

Yes. I think that's the right thing to do. I saw dra7_ctrl_core and dra7_ctrl_general and added it.

Thanks
Kishon

#30 lore raw

Re: [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie

In reply to Roger Quadros

Hi,

Quoted 19 lines · Roger Quadros
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:53 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add new device tree node for the control module register space where PCIe registers are present.

---
 arch/arm/boot/dts/dra7.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/dra7.dtsi +0 -0
index 260f300..3f434f7 100644
@@ -291,6 +291,11 @@
 			reg = <0x4a002e00 0x7c>;
 		};
 
Quoted 8 lines

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+		dra7_ctrl_pcie: tisyscon at 4a003c00 {
+			compatible = "syscon";
+			reg = <0x4a003c00 0x48>;
+		};
+

Why do you need to start from 0x4a003c00?
CTRL_CORE_PCIESS1_PCS1 is at 0x4a003c24

Actually wanted to have minimum number of syscon dt nodes. So thought even others can use dra7_ctrl_pcie phandle. But I looked only at dra7_ctrl_core and dra7_ctrl_general and not scm_conf :-(

Thanks
Kishon

#31 lore raw

PATCH 9/17 ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from SATA PHY node. Since "omap_control_sata" note is no longer used, remove it.

---
 arch/arm/boot/dts/dra7.dtsi |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/arm/boot/dts/dra7.dtsi +1 -9
index 3f434f7..92e0741 100644
@@ -1115,14 +1115,6 @@
 			status = "disabled";
 		};
 
-		omap_control_sata: control-phy at 4a002374 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002374 0x4>;
-			reg-names = "power";
-			clocks = <&sys_clkin1>;
-			clock-names = "sysclk";
-		};
-
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
@@ -1137,7 +1129,7 @@
 				      <0x4A096400 0x64>, /* phy_tx */
 				      <0x4A096800 0x40>; /* pll_ctrl */
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_sata>;
+				syscon-phy-power = <&dra7_ctrl_core 0x374>;
 				clocks = <&sys_clkin1>, <&sata_ref_clk>;
 				clock-names = "sysclk", "refclk";
 				syscon-pllreset = <&dra7_ctrl_core 0x3fc>;
Signature · 1 line
1.7.9.5
Acked-by on v1 9/17
#32 lore raw

Re: [PATCH 09/17] ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node

Quoted 5 lines · On Tue, 23 Jun 2015 17:28:54 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from SATA PHY node. Since "omap_control_sata" note is no longer used, remove it.

cheers,
-roger

Quoted 35 lines
---
 arch/arm/boot/dts/dra7.dtsi |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/arm/boot/dts/dra7.dtsi +1 -9
index 3f434f7..92e0741 100644
@@ -1115,14 +1115,6 @@
 			status = "disabled";
 		};
 
-		omap_control_sata: control-phy at 4a002374 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002374 0x4>;
-			reg-names = "power";
-			clocks = <&sys_clkin1>;
-			clock-names = "sysclk";
-		};
-
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
@@ -1137,7 +1129,7 @@
 				      <0x4A096400 0x64>, /* phy_tx */
 				      <0x4A096800 0x40>; /* pll_ctrl */
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_sata>;
+				syscon-phy-power = <&dra7_ctrl_core 0x374>;
 				clocks = <&sys_clkin1>, <&sata_ref_clk>;
 				clock-names = "sysclk", "refclk";
 				syscon-pllreset = <&dra7_ctrl_core 0x3fc>;
Signature · 1 line
1.7.9.5
#33 lore raw

Re: [PATCH 09/17] ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node

Quoted 10 lines · On Wed, 24 Jun 2015 15:06:02 +0300 Roger Quadros <[email protected]> wrote:
Quoted 5 lines · On Tue, 23 Jun 2015 17:28:54 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from SATA PHY node. Since "omap_control_sata" note is no longer used, remove it.

One comment though.

Quoted 22 lines
Quoted 22 lines
---
 arch/arm/boot/dts/dra7.dtsi |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/arm/boot/dts/dra7.dtsi +0 -8
index 3f434f7..92e0741 100644
@@ -1115,14 +1115,6 @@
 			status = "disabled";
 		};
 
-		omap_control_sata: control-phy at 4a002374 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002374 0x4>;
-			reg-names = "power";
-			clocks = <&sys_clkin1>;
-			clock-names = "sysclk";
-		};
-
 		/* OCP2SCP3 */
Quoted 8 lines

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

Quoted 8 lines
arch/arm/boot/dts/dra7.dtsi +1 -1
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
@@ -1137,7 +1129,7 @@
 				      <0x4A096400 0x64>, /* phy_tx */
 				      <0x4A096800 0x40>; /* pll_ctrl */
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_sata>;
+				syscon-phy-power = <&dra7_ctrl_core 0x374>;

why can't we use scm_conf instead of dra7_ctrl_core? dra7_ctrl_core seems to be redundant and wrongly placed.

Quoted 6 lines
Quoted 6 lines
arch/arm/boot/dts/dra7.dtsi +0 -0
 				clocks = <&sys_clkin1>, <&sata_ref_clk>;
 				clock-names = "sysclk", "refclk";
 				syscon-pllreset = <&dra7_ctrl_core 0x3fc>;
Signature · 1 line
1.7.9.5

cheers,
-roger

#34 lore raw

Re: [PATCH 09/17] ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node

Quoted 41 lines · Roger Quadros
Quoted 10 lines · On Wed, 24 Jun 2015 15:06:02 +0300 Roger Quadros <[email protected]> wrote:
Quoted 5 lines · On Tue, 23 Jun 2015 17:28:54 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from SATA PHY node. Since "omap_control_sata" note is no longer used, remove it.

One comment though.

Quoted 25 lines
Quoted 25 lines
---
 arch/arm/boot/dts/dra7.dtsi |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/arm/boot/dts/dra7.dtsi +0 -8
index 3f434f7..92e0741 100644
@@ -1115,14 +1115,6 @@
 			status = "disabled";
 		};
 
-		omap_control_sata: control-phy at 4a002374 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002374 0x4>;
-			reg-names = "power";
-			clocks = <&sys_clkin1>;
-			clock-names = "sysclk";
-		};
-
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
@@ -1137,7 +1129,7 @@
Quoted 8 lines
Quoted 5 lines

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +1 -1
 				      <0x4A096400 0x64>, /* phy_tx */
 				      <0x4A096800 0x40>; /* pll_ctrl */
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_sata>;
+				syscon-phy-power = <&dra7_ctrl_core 0x374>;

why can't we use scm_conf instead of dra7_ctrl_core? dra7_ctrl_core seems to be redundant and wrongly placed.

Agreed!

Thanks
Kishon

#35 lore raw

PATCH 10/17 ARM: dts: dra7: Use "syscon-phy-power" and "syscon-pcs" in PCIe PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and "syscon-pcs" property which can be used to perform the control module initializations and remove the deprecated "ctrl-module" property from PCIe PHY dt nodes.

Phandle to "sysclk" clock node is also added to the PCIe PHY node since some of the syscon initializations is based on system clock frequency.

Since "omap_control_pcie1phy" and "omap_control_pcie2phy" devicetree nodes are no longer used, remove it.

---
 arch/arm/boot/dts/dra7.dtsi |   28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
arch/arm/boot/dts/dra7.dtsi +7 -21
index 92e0741..f69db70 100644
@@ -1141,16 +1141,18 @@
 				reg = <0x4a094000 0x80>, /* phy_rx */
 				      <0x4a094400 0x64>; /* phy_tx */
 				reg-names = "phy_rx", "phy_tx";
-				ctrl-module = <&omap_control_pcie1phy>;
+				syscon-phy-power = <&dra7_ctrl_pcie 0x40>;
+				syscon-pcs = <&dra7_ctrl_pcie 0x34>;
 				clocks = <&dpll_pcie_ref_ck>,
 					 <&dpll_pcie_ref_m2ldo_ck>,
 					 <&optfclk_pciephy1_32khz>,
 					 <&optfclk_pciephy1_clk>,
 					 <&optfclk_pciephy1_div_clk>,
-					 <&optfclk_pciephy_div>;
+					 <&optfclk_pciephy_div>,
+					 <&sys_clkin1>;
 				clock-names = "dpll_ref", "dpll_ref_m2",
 					      "wkupclk", "refclk",
-					      "div-clk", "phy-div";
+					      "div-clk", "phy-div", "sysclk";
 				#phy-cells = <0>;
 			};
 
@@ -1159,7 +1161,8 @@
 				reg = <0x4a095000 0x80>, /* phy_rx */
 				      <0x4a095400 0x64>; /* phy_tx */
 				reg-names = "phy_rx", "phy_tx";
-				ctrl-module = <&omap_control_pcie2phy>;
+				syscon-phy-power = <&dra7_ctrl_pcie 0x44>;
+				syscon-pcs = <&dra7_ctrl_pcie 0x34>;
 				clocks = <&dpll_pcie_ref_ck>,
 					 <&dpll_pcie_ref_m2ldo_ck>,
 					 <&optfclk_pciephy2_32khz>,
@@ -1184,23 +1187,6 @@
 			ti,hwmods = "sata";
 		};
 
-		omap_control_pcie1phy: control-phy 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";
-		};
-
-		omap_control_pcie2phy: control-pcie at 0x4a003c44 {
-			compatible = "ti,control-phy-pcie";
-			reg = <0x4a003c44 0x4>, <0x4a003c14 0x4>, <0x4a003c34 0x4>;
-			reg-names = "power", "control_sma", "pcie_pcs";
-			clocks = <&sys_clkin1>;
-			clock-names = "sysclk";
-			status = "disabled";
-		};
-
 		rtc: rtc at 48838000 {
 			compatible = "ti,am3352-rtc";
 			reg = <0x48838000 0x100>;
Signature · 1 line
1.7.9.5
#36 lore raw

PATCH 11/17 ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2 PHY2

In reply to Kishon Vijay Abraham I

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, use the new compatible string "ti,dra7x-usb2-phy2" for the second instance of USB2 PHY.

---
 arch/arm/boot/dts/dra7.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +1 -1
index f69db70..a8ee829 100644
@@ -1235,7 +1235,7 @@
 			};
 
 			usb2_phy2: phy at 4a085000 {
-				compatible = "ti,omap-usb2";
+				compatible = "ti,dra7x-usb2-phy2", "ti,omap-usb2";
 				reg = <0x4a085000 0x400>;
 				ctrl-module = <&omap_control_usb2phy2>;
 				clocks = <&usb_phy2_always_on_clk32k>,
Signature · 1 line
1.7.9.5
#37 lore raw

Re: [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2 PHY2

Quoted 14 lines · On Tue, 23 Jun 2015 17:28:56 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, use the new compatible string "ti,dra7x-usb2-phy2" for the second instance of USB2 PHY.

---
 arch/arm/boot/dts/dra7.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +0 -0
index f69db70..a8ee829 100644

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

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +1 -1
@@ -1235,7 +1235,7 @@
 			};
 
 			usb2_phy2: phy at 4a085000 {
-				compatible = "ti,omap-usb2";
+				compatible = "ti,dra7x-usb2-phy2", "ti,omap-usb2";

Why do you want to retain "ti,omap-usb2".
It is not backward compatible with it right?

Quoted 6 lines
arch/arm/boot/dts/dra7.dtsi +0 -0
 				reg = <0x4a085000 0x400>;
 				ctrl-module = <&omap_control_usb2phy2>;
 				clocks = <&usb_phy2_always_on_clk32k>,
Signature · 1 line
1.7.9.5

cheers,
-roger

#38 lore raw

Re: [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2 PHY2

Hi,

Quoted 19 lines · Roger Quadros
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:56 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, use the new compatible string "ti,dra7x-usb2-phy2" for the second instance of USB2 PHY.

---
 arch/arm/boot/dts/dra7.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +0 -0
index f69db70..a8ee829 100644
@@ -1235,7 +1235,7 @@
 			};
 
Quoted 6 lines

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

Quoted 3 lines
arch/arm/boot/dts/dra7.dtsi +1 -1
 			usb2_phy2: phy at 4a085000 {
-				compatible = "ti,omap-usb2";
+				compatible = "ti,dra7x-usb2-phy2", "ti,omap-usb2";

Why do you want to retain "ti,omap-usb2".
It is not backward compatible with it right?

The newer dtbs will anyway have "ti,dra7x-usb2-phy2", so "ti,omap-usb2" was kept just for legacy reasons.

Thanks
Kishon

#39 lore raw

Re: [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2 PHY2

Quoted 29 lines · On Wed, 24 Jun 2015 18:40:31 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

Hi,

Quoted 19 lines · Roger Quadros
Quoted 16 lines · On Tue, 23 Jun 2015 17:28:56 +0530 Kishon Vijay Abraham I <[email protected]> wrote:

The USB2 PHY2 has a different register map compared to USB2 PHY1 to power on/off the PHY. In order to handle it, use the new compatible string "ti,dra7x-usb2-phy2" for the second instance of USB2 PHY.

---
 arch/arm/boot/dts/dra7.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +0 -0
index f69db70..a8ee829 100644
@@ -1235,7 +1235,7 @@
 			};
 
Quoted 6 lines

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

Quoted 3 lines
arch/arm/boot/dts/dra7.dtsi +1 -1
 			usb2_phy2: phy at 4a085000 {
-				compatible = "ti,omap-usb2";
+				compatible = "ti,dra7x-usb2-phy2", "ti,omap-usb2";

Why do you want to retain "ti,omap-usb2".
It is not backward compatible with it right?

Quoted 2 lines

The newer dtbs will anyway have "ti,dra7x-usb2-phy2", so "ti,omap-usb2" was kept just for legacy reasons.

OK then.

cheers,
-roger

#40 lore raw

PATCH 12/17 ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from USB PHY devicetree nodes.

Since "omap_control_usb2phy1", "omap_control_usb3phy1" and "omap_control_usb2phy2" devicetree nodes are no longer used, remove it.

---
 arch/arm/boot/dts/dra7.dtsi |   24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)
arch/arm/boot/dts/dra7.dtsi +3 -21
index a8ee829..e82ac00 100644
@@ -1196,24 +1196,6 @@
 			clocks = <&sys_32k_ck>;
 		};
 
-		omap_control_usb2phy1: control-phy at 4a002300 {
-			compatible = "ti,control-phy-usb2";
-			reg = <0x4a002300 0x4>;
-			reg-names = "power";
-		};
-
-		omap_control_usb3phy1: control-phy at 4a002370 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002370 0x4>;
-			reg-names = "power";
-		};
-
-		omap_control_usb2phy2: control-phy at 0x4a002e74 {
-			compatible = "ti,control-phy-usb2-dra7";
-			reg = <0x4a002e74 0x4>;
-			reg-names = "power";
-		};
-
 		/* OCP2SCP1 */
 		ocp2scp at 4a080000 {
 			compatible = "ti,omap-ocp2scp";
@@ -1226,7 +1208,7 @@
 			usb2_phy1: phy at 4a084000 {
 				compatible = "ti,omap-usb2";
 				reg = <0x4a084000 0x400>;
-				ctrl-module = <&omap_control_usb2phy1>;
+				syscon-phy-power = <&dra7_ctrl_core 0x300>;
 				clocks = <&usb_phy1_always_on_clk32k>,
 					 <&usb_otg_ss1_refclk960m>;
 				clock-names =	"wkupclk",
@@ -1237,7 +1219,7 @@
 			usb2_phy2: phy at 4a085000 {
 				compatible = "ti,dra7x-usb2-phy2", "ti,omap-usb2";
 				reg = <0x4a085000 0x400>;
-				ctrl-module = <&omap_control_usb2phy2>;
+				syscon-phy-power = <&dra7_ctrl_general 0x74>;
 				clocks = <&usb_phy2_always_on_clk32k>,
 					 <&usb_otg_ss2_refclk960m>;
 				clock-names =	"wkupclk",
@@ -1251,7 +1233,7 @@
 				      <0x4a084800 0x64>,
 				      <0x4a084c00 0x40>;
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_usb3phy1>;
+				syscon-phy-power = <&dra7_ctrl_core 0x370>;
 				clocks = <&usb_phy3_always_on_clk32k>,
 					 <&sys_clkin1>,
 					 <&usb_otg_ss1_refclk960m>;
Signature · 1 line
1.7.9.5
#41 lore raw

PATCH 13/17 ARM: dts: am4372: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from USB PHY device tree node.

Since "am43xx_control_usb2phy1" and "am43xx_control_usb2phy2" devicetree nodes are no longer used, remove it.

---
 arch/arm/boot/dts/am4372.dtsi |   16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
arch/arm/boot/dts/am4372.dtsi +2 -14
index c80a3e2..0754e0da 100644
@@ -796,18 +796,6 @@
 			status = "disabled";
 		};
 
-		am43xx_control_usb2phy1: control-phy at 44e10620 {
-			compatible = "ti,control-phy-usb2-am437";
-			reg = <0x44e10620 0x4>;
-			reg-names = "power";
-		};
-
-		am43xx_control_usb2phy2: control-phy at 0x44e10628 {
-			compatible = "ti,control-phy-usb2-am437";
-			reg = <0x44e10628 0x4>;
-			reg-names = "power";
-		};
-
 		ocp2scp0: ocp2scp at 483a8000 {
 			compatible = "ti,am437x-ocp2scp", "ti,omap-ocp2scp";
 			#address-cells = <1>;
@@ -818,7 +806,7 @@
 			usb2_phy1: phy at 483a8000 {
 				compatible = "ti,am437x-usb2";
 				reg = <0x483a8000 0x8000>;
-				ctrl-module = <&am43xx_control_usb2phy1>;
+				syscon-phy-power = <&scm_conf 0x620>;
 				clocks = <&usb_phy0_always_on_clk32k>,
 					 <&usb_otg_ss0_refclk960m>;
 				clock-names = "wkupclk", "refclk";
@@ -837,7 +825,7 @@
 			usb2_phy2: phy at 483e8000 {
 				compatible = "ti,am437x-usb2";
 				reg = <0x483e8000 0x8000>;
-				ctrl-module = <&am43xx_control_usb2phy2>;
+				syscon-phy-power = <&scm_conf 0x628>;
 				clocks = <&usb_phy1_always_on_clk32k>,
 					 <&usb_otg_ss1_refclk960m>;
 				clock-names = "wkupclk", "refclk";
Signature · 1 line
1.7.9.5
#42 lore raw

PATCH 14/17 ARM: dts: OMAP5: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from USB PHY devicetree node.

Since "omap_control_usb2phy" and "omap_control_usb3phy" devicetree nodes are no longer used, remove it.

---
 arch/arm/boot/dts/omap5.dtsi |   16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
arch/arm/boot/dts/omap5.dtsi +2 -14
index 7d24ae0..9b50314 100644
@@ -846,18 +846,6 @@
 			hw-caps-temp-alert;
 		};
 
-		omap_control_usb2phy: control-phy at 4a002300 {
-			compatible = "ti,control-phy-usb2";
-			reg = <0x4a002300 0x4>;
-			reg-names = "power";
-		};
-
-		omap_control_usb3phy: control-phy at 4a002370 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002370 0x4>;
-			reg-names = "power";
-		};
-
 		usb3: omap_dwc3 at 4a020000 {
 			compatible = "ti,dwc3";
 			ti,hwmods = "usb_otg_ss";
@@ -888,7 +876,7 @@
 			usb2_phy: usb2phy at 4a084000 {
 				compatible = "ti,omap-usb2";
 				reg = <0x4a084000 0x7c>;
-				ctrl-module = <&omap_control_usb2phy>;
+				syscon-phy-power = <&scm_conf 0x300>;
 				clocks = <&usb_phy_cm_clk32k>, <&usb_otg_ss_refclk960m>;
 				clock-names = "wkupclk", "refclk";
 				#phy-cells = <0>;
@@ -900,7 +888,7 @@
 				      <0x4a084800 0x64>,
 				      <0x4a084c00 0x40>;
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_usb3phy>;
+				syscon-phy-power = <&scm_conf 0x370>;
 				clocks = <&usb_phy_cm_clk32k>,
 					 <&sys_clkin>,
 					 <&usb_otg_ss_refclk960m>;
Signature · 1 line
1.7.9.5
#43 lore raw

PATCH 15/17 ARM: dts: OMAP5: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from SATA PHY node.

Since "omap_control_sata" devicetree node is no longer used, remove it.

---
 arch/arm/boot/dts/omap5.dtsi |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/arm/boot/dts/omap5.dtsi +1 -9
index 9b50314..ca0a77f 100644
@@ -944,14 +944,6 @@
 			#thermal-sensor-cells = <1>;
 		};
 
-		omap_control_sata: control-phy at 4a002374 {
-			compatible = "ti,control-phy-pipe3";
-			reg = <0x4a002374 0x4>;
-			reg-names = "power";
-			clocks = <&sys_clkin>;
-			clock-names = "sysclk";
-		};
-
 		/* OCP2SCP3 */
 		ocp2scp at 4a090000 {
 			compatible = "ti,omap-ocp2scp";
@@ -966,7 +958,7 @@
 				      <0x4A096400 0x64>, /* phy_tx */
 				      <0x4A096800 0x40>; /* pll_ctrl */
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
-				ctrl-module = <&omap_control_sata>;
+				syscon-phy-power = <&scm_conf 0x374>;
 				clocks = <&sys_clkin>, <&sata_ref_clk>;
 				clock-names = "sysclk", "refclk";
 				#phy-cells = <0>;
Signature · 1 line
1.7.9.5
#44 lore raw

PATCH 16/17 ARM: dts: omap4: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node

In reply to Kishon Vijay Abraham I

Add "syscon-phy-power" property and remove the deprecated "ctrl-module" property from USB PHY dt node.

Since "omap_control_usb2phy" devicetree node is no longer used, remove it.

---
 arch/arm/boot/dts/omap4.dtsi |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/boot/dts/omap4.dtsi +1 -7
index f884d6a..d0e0960 100644
@@ -701,7 +701,7 @@
 			usb2_phy: usb2phy at 4a0ad080 {
 				compatible = "ti,omap-usb2";
 				reg = <0x4a0ad080 0x58>;
-				ctrl-module = <&omap_control_usb2phy>;
+				syscon-phy-power = <&scm_conf 0x300>;
 				clocks = <&usb_phy_cm_clk32k>;
 				clock-names = "wkupclk";
 				#phy-cells = <0>;
@@ -852,12 +852,6 @@
 			};
 		};
 
-		omap_control_usb2phy: control-phy at 4a002300 {
-			compatible = "ti,control-phy-usb2";
-			reg = <0x4a002300 0x4>;
-			reg-names = "power";
-		};
-
 		omap_control_usbotg: control-phy at 4a00233c {
 			compatible = "ti,control-phy-otghs";
 			reg = <0x4a00233c 0x4>;
Signature · 1 line
1.7.9.5
#45 lore raw

PATCH 17/17 ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node

In reply to Kishon Vijay Abraham I

Add "syscon-otghs" property and remove the deprecated "ctrl-module" property from MUSB devicetree node.

Since "omap_control_usbotg" devicetree node is no longer used, remove it.

---
 arch/arm/boot/dts/omap4.dtsi |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/boot/dts/omap4.dtsi +1 -7
index d0e0960..3bc77b1 100644
@@ -852,12 +852,6 @@
 			};
 		};
 
-		omap_control_usbotg: control-phy at 4a00233c {
-			compatible = "ti,control-phy-otghs";
-			reg = <0x4a00233c 0x4>;
-			reg-names = "otghs_control";
-		};
-
 		usb_otg_hs: usb_otg_hs at 4a0ab000 {
 			compatible = "ti,omap4-musb";
 			reg = <0x4a0ab000 0x7ff>;
@@ -870,7 +864,7 @@
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
-			ctrl-module = <&omap_control_usbotg>;
+			syscon-otghs = <&scm_conf 0x33c>;
 		};
 
 		aes: aes at 4b501000 {
Signature · 1 line
1.7.9.5
#46 lore raw

Re: [PATCH 17/17] ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node

Quoted 16 lines · Kishon Vijay Abraham I
arch/arm/boot/dts/omap4.dtsi +0 -6
@@ -852,12 +852,6 @@
 			};
 		};
 
-		omap_control_usbotg: control-phy at 4a00233c {
-			compatible = "ti,control-phy-otghs";
-			reg = <0x4a00233c 0x4>;
-			reg-names = "otghs_control";
-		};
-
 		usb_otg_hs: usb_otg_hs at 4a0ab000 {
 			compatible = "ti,omap4-musb";
 			reg = <0x4a0ab000 0x7ff>;

arch/arm/boot/dts/omap4.dtsi line 870

Quoted 8 lines
arch/arm/boot/dts/omap4.dtsi +1 -1
@@ -870,7 +864,7 @@
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
-			ctrl-module = <&omap_control_usbotg>;
+			syscon-otghs = <&scm_conf 0x33c>;
 		};
 
 		aes: aes at 4b501000 {

We should still keep a separate entry for the phy in the dtsi files. And the phy should be a child of the scm_conf area in the dtsi file.

This is because the scm and usb_otg_hs are separate devices and can be clocked separately. So the phy driver needs to be a separate driver to avoid spaghetti code and issues with clocking.

Regards,

Tony

#47 lore raw

Re: [PATCH 17/17] ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node

Hi Tony,

Quoted 30 lines · Tony Lindgren
Quoted 16 lines · Kishon Vijay Abraham I
arch/arm/boot/dts/omap4.dtsi +0 -6
@@ -852,12 +852,6 @@
  			};
  		};
 
-		omap_control_usbotg: control-phy at 4a00233c {
-			compatible = "ti,control-phy-otghs";
-			reg = <0x4a00233c 0x4>;
-			reg-names = "otghs_control";
-		};
-
  		usb_otg_hs: usb_otg_hs at 4a0ab000 {
  			compatible = "ti,omap4-musb";
  			reg = <0x4a0ab000 0x7ff>;

arch/arm/boot/dts/omap4.dtsi line 870

Quoted 8 lines
arch/arm/boot/dts/omap4.dtsi +1 -1
@@ -870,7 +864,7 @@
  			multipoint = <1>;
  			num-eps = <16>;
  			ram-bits = <12>;
-			ctrl-module = <&omap_control_usbotg>;
+			syscon-otghs = <&scm_conf 0x33c>;
  		};
 
  		aes: aes at 4b501000 {

We should still keep a separate entry for the phy in the dtsi files. And the phy should be a child of the scm_conf area in the dtsi file.

Quoted 3 lines

This is because the scm and usb_otg_hs are separate devices and can be clocked separately. So the phy driver needs to be a separate driver to avoid spaghetti code and issues with clocking.

AFAIK SCM is clocked by L4CFG_L4_GICLK which is either free running or is managed automatically by the HW i.e gated when there is no access to the CTRL_MODULE_CORE registers.

Having a separate control-PHY driver only to do a regmap update to SCM is unnecessary IMHO.

Thanks
Kishon

#48 lore raw

Re: [PATCH 17/17] ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node

Quoted 31 lines · Kishon Vijay Abraham I
Quoted 30 lines · Tony Lindgren
Quoted 16 lines · Kishon Vijay Abraham I
arch/arm/boot/dts/omap4.dtsi +0 -6
@@ -852,12 +852,6 @@
 			};
 		};
 
-		omap_control_usbotg: control-phy at 4a00233c {
-			compatible = "ti,control-phy-otghs";
-			reg = <0x4a00233c 0x4>;
-			reg-names = "otghs_control";
-		};
-
 		usb_otg_hs: usb_otg_hs at 4a0ab000 {
 			compatible = "ti,omap4-musb";
 			reg = <0x4a0ab000 0x7ff>;

arch/arm/boot/dts/omap4.dtsi line 870

Quoted 8 lines
arch/arm/boot/dts/omap4.dtsi +1 -1
@@ -870,7 +864,7 @@
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
-			ctrl-module = <&omap_control_usbotg>;
+			syscon-otghs = <&scm_conf 0x33c>;
 		};
 
 		aes: aes at 4b501000 {

We should still keep a separate entry for the phy in the dtsi files. And the phy should be a child of the scm_conf area in the dtsi file.

Quoted 7 lines
Quoted 3 lines

This is because the scm and usb_otg_hs are separate devices and can be clocked separately. So the phy driver needs to be a separate driver to avoid spaghetti code and issues with clocking.

AFAIK SCM is clocked by L4CFG_L4_GICLK which is either free running or is managed automatically by the HW i.e gated when there is no access to the CTRL_MODULE_CORE registers.

The point is they are separate devices on the interconnect. And we don't want to add dependencies between separate devices. And there is nothing stopping us from starting to idle the SCM module.

Quoted 2 lines

Having a separate control-PHY driver only to do a regmap update to SCM is unnecessary IMHO.

Not true. The phy driver can be generic and used by multiple platforms.

And the phy driver should be capable of idling the phy separately independent of the USB module. And the phy driver should be able to tell the system things like ID pin status, VBUS status and so on.

So to summarize, we are _not_ going to start tinkering with the sycon registers directly from random device drivers in a separate IO space.

Anything using the syscon registers must implement a driver for some Linux generic framework such as phy, clock, or regulator framework.

Regards,

Tony

#49 lore raw

Re: [PATCH 17/17] ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node

In reply to Tony Lindgren
Quoted 24 lines · On Wed, 24 Jun 2015 03:41:16 -0700 Tony Lindgren <[email protected]> wrote:
Quoted 23 lines · Kishon Vijay Abraham I
arch/arm/boot/dts/omap4.dtsi +1 -7
@@ -852,12 +852,6 @@
 			};
 		};
 
-		omap_control_usbotg: control-phy at 4a00233c {
-			compatible = "ti,control-phy-otghs";
-			reg = <0x4a00233c 0x4>;
-			reg-names = "otghs_control";
-		};
-
 		usb_otg_hs: usb_otg_hs at 4a0ab000 {
 			compatible = "ti,omap4-musb";
 			reg = <0x4a0ab000 0x7ff>;
@@ -870,7 +864,7 @@
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
-			ctrl-module = <&omap_control_usbotg>;
+			syscon-otghs = <&scm_conf 0x33c>;
 		};
 
Quoted 5 lines

arch/arm/boot/dts/omap4.dtsi line 870

Quoted 1 line
arch/arm/boot/dts/omap4.dtsi +0 -0
 		aes: aes at 4b501000 {

We should still keep a separate entry for the phy in the dtsi files. And the phy should be a child of the scm_conf area in the dtsi file.

The PHY already has a separate entry with its own set of registers. Just that some bits have been shoved into the control module space not only for PHY but for other modules as well like DSS, DCAN, etc.

Quoted 4 lines

This is because the scm and usb_otg_hs are separate devices and can be clocked separately. So the phy driver needs to be a separate driver to avoid spaghetti code and issues with clocking.

for the PHY register space this is already done.

But for the register bits that lie in control module space isn't that taken care by syscon driver?

cheers,
-roger