Skip to contentSkip to conversation

phy: rockchip-usb: correct pll handling and usb-uart

PATCH Superseded Heiko Stuebner 2 participants 20 messages Nov 8, 2015 – Nov 9, 2015

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

v2 cover phy: rockchip-usb: correct pll handling and usb-uart

changes in v2:
- add Doug's review-tag to patches 1 and 3
- address comment and add the missing transistional rk_phy->base assignment in patch2

Patches 1-7 fix a long-standing issue with the clock-tree of Rockchip SoCs namely our ignorance of the usbphy-internal pll that creates the needed 480MHz but is also a supply-clock back to the core clock-controller in Rockchip SoCs.

Till now that was worked around using a virtual clock in the cru itself, but that is of course ignorant of other parts then disabling the phy behind the cru's back, thus breaking potential users of these clocks.

Patch 8, while not associated with the new pll handling, also builds on the groundwork introduced there and adds support for the function repurposing one of the phys as passthrough for uart-data. This enables attaching a ttl converter to the D+ and D- pins of an usb cable to receive uart data this way, when it is not really possible to attach a regular serial console to a board.

One point of critique in my first iteration [0] of this was, that due to when the reconfiguration happens we may miss parts of the logs when earlycon is enabled. So far early_initcall gets used as the unflattened devicetree is necessary to set this up. Doing this for example in the early_param directly would require parsing the flattened devicetree to get needed nodes and properties.

I still maintain that if you're working on anything before smp-bringup you should use a real dev-board instead or try to solder uart cables on hopefully available test-points :-) .

In any case, if patch 8 causes to much headache, it could be dropped to not hinder the earlier 7 patches.

[0] http://comments.gmane.org/gmane.linux.ports.arm.rockchip/715

Heiko Stuebner (8):
phy: rockchip-usb: fix clock get-put mismatch
phy: rockchip-usb: introduce a common data-struct for the device
phy: rockchip-usb: move per-phy init into a separate function
phy: rockchip-usb: expose the phy-internal PLLs
clk: rockchip: fix usbphy-related clocks
ARM: dts: rockchip: add clock-cells for usb phy nodes
ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on
veyron
phy: rockchip-usb: add handler for usb-uart functionality

 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   6 +-
 Documentation/kernel-parameters.txt                |   6 +
 arch/arm/boot/dts/rk3066a.dtsi                     |   2 +
 arch/arm/boot/dts/rk3188.dtsi                      |   2 +
 arch/arm/boot/dts/rk3288-veyron.dtsi               |   2 +-
 arch/arm/boot/dts/rk3288.dtsi                      |   3 +
 drivers/clk/rockchip/clk-rk3188.c                  |  11 +-
 drivers/clk/rockchip/clk-rk3288.c                  |  16 +-
 drivers/phy/phy-rockchip-usb.c                     | 449 ++++++++++++++++++---
 9 files changed, 416 insertions(+), 81 deletions(-)
Signature · 1 line
2.6.2
author maintainer
#1 lore raw

PATCH v2 1/8 phy: rockchip-usb: fix clock get-put mismatch

Currently the phy driver only gets the optional clock reference but never puts it again, neither during error handling nor on remove. Fix that by moving the clk_put to a devm-action that gets called at the right time when all other devm actions are done.

---
 drivers/phy/phy-rockchip-usb.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/phy/phy-rockchip-usb.c +15 -0
index 91d6f34..dfc056b 100644
@@ -90,6 +90,14 @@ static const struct phy_ops ops = {
 	.owner		= THIS_MODULE,
 };
 
+static void rockchip_usb_phy_action(void *data)
+{
+	struct rockchip_usb_phy *rk_phy = data;
+
+	if (rk_phy->clk)
+		clk_put(rk_phy->clk);
+}
+
 static int rockchip_usb_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -124,6 +132,13 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 		if (IS_ERR(rk_phy->clk))
 			rk_phy->clk = NULL;
 
+		err = devm_add_action(dev, rockchip_usb_phy_action, rk_phy);
+		if (err) {
+			if (rk_phy->clk)
+				clk_put(rk_phy->clk);
+			return err;
+		}
+
 		rk_phy->phy = devm_phy_create(dev, child, &ops);
 		if (IS_ERR(rk_phy->phy)) {
 			dev_err(dev, "failed to create PHY\n");
Signature · 1 line
2.6.2
author maintainer
#2 lore raw

PATCH v2 2/8 phy: rockchip-usb: introduce a common data-struct for the device

In reply to Heiko Stuebner

This introduces a common struct that holds data belonging to the umbrella device that contains all the phys and that we want to use later.

---
 drivers/phy/phy-rockchip-usb.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/phy/phy-rockchip-usb.c +19 -7
index dfc056b..e081053 100644
@@ -36,9 +36,14 @@
 #define SIDDQ_ON		BIT(13)
 #define SIDDQ_OFF		(0 << 13)
 
+struct rockchip_usb_phy_base {
+	struct device *dev;
+	struct regmap *reg_base;
+};
+
 struct rockchip_usb_phy {
+	struct rockchip_usb_phy_base *base;
 	unsigned int	reg_offset;
-	struct regmap	*reg_base;
 	struct clk	*clk;
 	struct phy	*phy;
 };
@@ -46,7 +51,7 @@ struct rockchip_usb_phy {
 static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
 					   bool siddq)
 {
-	return regmap_write(phy->reg_base, phy->reg_offset,
+	return regmap_write(phy->base->reg_base, phy->reg_offset,
 			    SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
 }
 
@@ -101,17 +106,23 @@ static void rockchip_usb_phy_action(void *data)
 static int rockchip_usb_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct rockchip_usb_phy_base *phy_base;
 	struct rockchip_usb_phy *rk_phy;
 	struct phy_provider *phy_provider;
 	struct device_node *child;
-	struct regmap *grf;
 	unsigned int reg_offset;
 	int err;
 
-	grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf");
-	if (IS_ERR(grf)) {
+	phy_base = devm_kzalloc(dev, sizeof(*phy_base), GFP_KERNEL);
+	if (!phy_base)
+		return -ENOMEM;
+
+	phy_base->dev = dev;
+	phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node,
+							     "rockchip,grf");
+	if (IS_ERR(phy_base->reg_base)) {
 		dev_err(&pdev->dev, "Missing rockchip,grf property\n");
-		return PTR_ERR(grf);
+		return PTR_ERR(phy_base->reg_base);
 	}
 
 	for_each_available_child_of_node(dev->of_node, child) {
@@ -119,6 +130,8 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 		if (!rk_phy)
 			return -ENOMEM;
 
+		rk_phy->base = phy_base;
+
 		if (of_property_read_u32(child, "reg", &reg_offset)) {
 			dev_err(dev, "missing reg property in node %s\n",
 				child->name);
@@ -126,7 +139,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 		}
 
 		rk_phy->reg_offset = reg_offset;
-		rk_phy->reg_base = grf;
 
 		rk_phy->clk = of_clk_get_by_name(child, "phyclk");
 		if (IS_ERR(rk_phy->clk))
Signature · 1 line
2.6.2
author maintainer
#3 lore raw

PATCH v2 3/8 phy: rockchip-usb: move per-phy init into a separate function

In reply to Heiko Stuebner

This unclutters the loop in probe a lot and makes current (and future) error handling easier to read.

---
 drivers/phy/phy-rockchip-usb.c | 82 +++++++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 36 deletions(-)
drivers/phy/phy-rockchip-usb.c +46 -36
index e081053..3b69f61 100644
@@ -103,14 +103,57 @@ static void rockchip_usb_phy_action(void *data)
 		clk_put(rk_phy->clk);
 }
 
+static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
+				 struct device_node *child)
+{
+	struct rockchip_usb_phy *rk_phy;
+	unsigned int reg_offset;
+	int err;
+
+	rk_phy = devm_kzalloc(base->dev, sizeof(*rk_phy), GFP_KERNEL);
+	if (!rk_phy)
+		return -ENOMEM;
+
+	rk_phy->base = base;
+
+	if (of_property_read_u32(child, "reg", &reg_offset)) {
+		dev_err(base->dev, "missing reg property in node %s\n",
+			child->name);
+		return -EINVAL;
+	}
+
+	rk_phy->reg_offset = reg_offset;
+
+	rk_phy->clk = of_clk_get_by_name(child, "phyclk");
+	if (IS_ERR(rk_phy->clk))
+		rk_phy->clk = NULL;
+
+	err = devm_add_action(base->dev, rockchip_usb_phy_action, rk_phy);
+	if (err)
+		goto err_devm_action;
+
+	rk_phy->phy = devm_phy_create(base->dev, child, &ops);
+	if (IS_ERR(rk_phy->phy)) {
+		dev_err(base->dev, "failed to create PHY\n");
+		return PTR_ERR(rk_phy->phy);
+	}
+	phy_set_drvdata(rk_phy->phy, rk_phy);
+
+	/* only power up usb phy when it use, so disable it when init*/
+	return rockchip_usb_phy_power(rk_phy, 1);
+
+err_devm_action:
+	if (rk_phy->clk)
+		clk_put(rk_phy->clk);
+	return err;
+}
+
 static int rockchip_usb_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct rockchip_usb_phy_base *phy_base;
-	struct rockchip_usb_phy *rk_phy;
 	struct phy_provider *phy_provider;
 	struct device_node *child;
-	unsigned int reg_offset;
 	int err;
 
 	phy_base = devm_kzalloc(dev, sizeof(*phy_base), GFP_KERNEL);
@@ -126,40 +169,7 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	}
 
 	for_each_available_child_of_node(dev->of_node, child) {
-		rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL);
-		if (!rk_phy)
-			return -ENOMEM;
-
-		rk_phy->base = phy_base;
-
-		if (of_property_read_u32(child, "reg", &reg_offset)) {
-			dev_err(dev, "missing reg property in node %s\n",
-				child->name);
-			return -EINVAL;
-		}
-
-		rk_phy->reg_offset = reg_offset;
-
-		rk_phy->clk = of_clk_get_by_name(child, "phyclk");
-		if (IS_ERR(rk_phy->clk))
-			rk_phy->clk = NULL;
-
-		err = devm_add_action(dev, rockchip_usb_phy_action, rk_phy);
-		if (err) {
-			if (rk_phy->clk)
-				clk_put(rk_phy->clk);
-			return err;
-		}
-
-		rk_phy->phy = devm_phy_create(dev, child, &ops);
-		if (IS_ERR(rk_phy->phy)) {
-			dev_err(dev, "failed to create PHY\n");
-			return PTR_ERR(rk_phy->phy);
-		}
-		phy_set_drvdata(rk_phy->phy, rk_phy);
-
-		/* only power up usb phy when it use, so disable it when init*/
-		err = rockchip_usb_phy_power(rk_phy, 1);
+		err = rockchip_usb_phy_init(phy_base, child);
 		if (err)
 			return err;
 	}
Signature · 1 line
2.6.2
author maintainer
#4 lore raw

PATCH v2 4/8 phy: rockchip-usb: expose the phy-internal PLLs

In reply to Heiko Stuebner

The USB phys on Rockchip SoCs contain their own internal PLLs to create the 480MHz needed. Additionally this PLL output is also fed back into the core clock-controller as possible source for clocks like the GPU or others.

Until now this was modelled incorrectly with a "virtual" factor clock in the clock controller. The one big caveat is that if we turn off the usb phy via the siddq signal, all analog components get turned off, including the PLLs. It is therefore possible that a source clock gets disabled without the clock driver ever knowing, possibly making the system hang.

Therefore register the phy-plls as real clocks that the clock driver can then reference again normally, making the clock hirarchy finally reflect the actual hardware.

The phy-ops get converted to simply turning that new clock on and off which in turn controls the siddq signal of the phy.

Through this the driver gains handling for platform-specific data, to handle the phy->clock name association.

---
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   6 +-
 drivers/phy/phy-rockchip-usb.c                     | 177 ++++++++++++++++++---
 2 files changed, 160 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt +5 -1
index 826454a..68498d5 100644
@@ -1,7 +1,10 @@
 ROCKCHIP USB2 PHY
 
 Required properties:
- - compatible: rockchip,rk3288-usb-phy
+ - compatible: matching the soc type, one of
+     "rockchip,rk3066a-usb-phy"
+     "rockchip,rk3188-usb-phy"
+     "rockchip,rk3288-usb-phy"
  - rockchip,grf : phandle to the syscon managing the "general
    register files"
  - #address-cells: should be 1
@@ -21,6 +24,7 @@ required properties:
 Optional Properties:
 - clocks : phandle + clock specifier for the phy clocks
 - clock-names: string, clock name, must be "phyclk"
+- #clock-cells: for users of the phy-pll, should be 0
 
 Example:
 
drivers/phy/phy-rockchip-usb.c +155 -22

276 lines not on this page · raw message

Signature · 1 line
2.6.2
#5 lore raw

Re: [PATCH v2 4/8] phy: rockchip-usb: expose the phy-internal PLLs

Heiko,

Quoted 13 lines · Heiko Stuebner
drivers/phy/phy-rockchip-usb.c +13 -0
+static const struct rockchip_usb_phy_pdata rk3066a_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x17c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x188, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3188_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x10c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x11c, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }

drivers/phy/phy-rockchip-usb.c static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, · line 270

Quoted 10 lines
drivers/phy/phy-rockchip-usb.c +10 -0
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3288_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x320, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x334, .pll_name = "sclk_otgphy1_480m" },
+               { .reg = 0x348, .pll_name = "sclk_otgphy2_480m" },
+               { /* sentinel */ }
+       },

Slighly annoying to have to add a table for each SoC. I'd imagine this growing quite large.

Would it be possible to query our parent clock name and then append a "_480m" suffix? Then you can magically get the name you want, right? That doesn't preclude you from later overriding this or adding a "dts" property for it, but it means no tables for now and (hopefully) for the forseeable future. ...and you get to kill a bunch of code in this patch...

You could fall back to some generic name based on the PHY device tree node name if you wanted, or use the ID allocator...

Otherwise, this all looks good to me. If you have a good reason why using the parent name isn't a good idea, let me know and I can add my Reviewed-by on this patch.

-Doug

author maintainer
#6 lore raw

Re: [PATCH v2 4/8] phy: rockchip-usb: expose the phy-internal PLLs

Hi Doug,

Am Montag, 9. November 2015, 12:59:58 schrieb Doug Anderson:

Quoted 35 lines · Heiko Stuebner
Quoted 13 lines
drivers/phy/phy-rockchip-usb.c +13 -0
+static const struct rockchip_usb_phy_pdata rk3066a_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x17c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x188, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3188_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x10c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x11c, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }

drivers/phy/phy-rockchip-usb.c static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, · line 270

Quoted 10 lines
drivers/phy/phy-rockchip-usb.c +10 -0
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3288_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x320, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x334, .pll_name = "sclk_otgphy1_480m" },
+               { .reg = 0x348, .pll_name = "sclk_otgphy2_480m" },
+               { /* sentinel */ }
+       },

Slighly annoying to have to add a table for each SoC. I'd imagine this growing quite large.

Would it be possible to query our parent clock name and then append a "_480m" suffix? Then you can magically get the name you want, right? That doesn't preclude you from later overriding this or adding a "dts" property for it, but it means no tables for now and (hopefully) for the forseeable future. ...and you get to kill a bunch of code in this patch...

Quoted 7 lines

You could fall back to some generic name based on the PHY device tree node name if you wanted, or use the ID allocator...

Otherwise, this all looks good to me. If you have a good reason why using the parent name isn't a good idea, let me know and I can add my Reviewed-by on this patch.

Adding a _480m suffix was my initial solution. But the phy-supply clock is actually optional in the binding, so it may not be specified at all. Still the code needs this pll to work at all after the change, and inventing some completely random clock name seemed very strange (like pll_usbphy_REG or something) - especially as this would never have worked with the downstream clocks. As it is now, the downstream clock-tree will work indepent of the supply clock being specified.

Also Rockchip seems to have moved to a different phy-ip, with one supplying clock, one pll and everything more tightly coupled, so we're probably getting a new driver for it, instead of additional entries for the picophy.

Heiko

Reviewed-by
#7 lore raw

Re: [PATCH v2 4/8] phy: rockchip-usb: expose the phy-internal PLLs

Heiko,

Quoted 54 lines · Heiko Stuebner

Hi Doug,

Am Montag, 9. November 2015, 12:59:58 schrieb Doug Anderson:

Quoted 35 lines · Heiko Stuebner
Quoted 13 lines
drivers/phy/phy-rockchip-usb.c +13 -0
+static const struct rockchip_usb_phy_pdata rk3066a_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x17c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x188, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3188_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x10c, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x11c, .pll_name = "sclk_otgphy1_480m" },
+               { /* sentinel */ }

drivers/phy/phy-rockchip-usb.c static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, · line 270

Quoted 10 lines
drivers/phy/phy-rockchip-usb.c +10 -0
+       },
+};
+
+static const struct rockchip_usb_phy_pdata rk3288_pdata = {
+       .phys = (struct rockchip_usb_phys[]){
+               { .reg = 0x320, .pll_name = "sclk_otgphy0_480m" },
+               { .reg = 0x334, .pll_name = "sclk_otgphy1_480m" },
+               { .reg = 0x348, .pll_name = "sclk_otgphy2_480m" },
+               { /* sentinel */ }
+       },

Slighly annoying to have to add a table for each SoC. I'd imagine this growing quite large.

Would it be possible to query our parent clock name and then append a "_480m" suffix? Then you can magically get the name you want, right? That doesn't preclude you from later overriding this or adding a "dts" property for it, but it means no tables for now and (hopefully) for the forseeable future. ...and you get to kill a bunch of code in this patch...

Quoted 7 lines

You could fall back to some generic name based on the PHY device tree node name if you wanted, or use the ID allocator...

Otherwise, this all looks good to me. If you have a good reason why using the parent name isn't a good idea, let me know and I can add my Reviewed-by on this patch.

Adding a _480m suffix was my initial solution. But the phy-supply clock is actually optional in the binding, so it may not be specified at all. Still the code needs this pll to work at all after the change, and inventing some completely random clock name seemed very strange (like pll_usbphy_REG or something) - especially as this would never have worked with the downstream clocks. As it is now, the downstream clock-tree will work indepent of the supply clock being specified.

Quoted 4 lines

Also Rockchip seems to have moved to a different phy-ip, with one supplying clock, one pll and everything more tightly coupled, so we're probably getting a new driver for it, instead of additional entries for the picophy.

OK, seems quite reasonable to me.

author maintainer
#8 lore raw

PATCH v2 5/8 clk: rockchip: fix usbphy-related clocks

In reply to Heiko Stuebner

The otgphy clocks really only drive the phy blocks. These in turn contain plls that then generate the 480m clocks the clock controller uses to supply some other clocks like uart0, gpu or the video-codec.

So fix this structure to actually respect that hirarchy and removed that usb480m fixed-rate clock working as a placeholder till now, as this wouldn't even work if the supplying phy gets turned off while its pll-output gets used elsewhere.

---
 drivers/clk/rockchip/clk-rk3188.c | 11 +++--------
 drivers/clk/rockchip/clk-rk3288.c | 16 +++++-----------
 2 files changed, 8 insertions(+), 19 deletions(-)
drivers/clk/rockchip/clk-rk3188.c +3 -8
index abb4760..7836a97 100644
@@ -319,9 +319,9 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = {
 	 * the 480m are generated inside the usb block from these clocks,
 	 * but they are also a source for the hsicphy clock.
 	 */
-	GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED,
+	GATE(SCLK_OTGPHY0, "sclk_otgphy0", "xin24m", CLK_IGNORE_UNUSED,
 			RK2928_CLKGATE_CON(1), 5, GFLAGS),
-	GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED,
+	GATE(SCLK_OTGPHY1, "sclk_otgphy1", "xin24m", CLK_IGNORE_UNUSED,
 			RK2928_CLKGATE_CON(1), 6, GFLAGS),
 
 	COMPOSITE(0, "mac_src", mux_mac_p, 0,
@@ -635,7 +635,7 @@ static struct clk_div_table div_rk3188_aclk_core_t[] = {
 	{ /* sentinel */ },
 };
 
-PNAME(mux_hsicphy_p)		= { "sclk_otgphy0", "sclk_otgphy1",
+PNAME(mux_hsicphy_p)		= { "sclk_otgphy0_480m", "sclk_otgphy1_480m",
 				    "gpll", "cpll" };
 
 static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = {
@@ -739,11 +739,6 @@ static void __init rk3188_common_clk_init(struct device_node *np)
 		pr_warn("%s: could not register clock xin12m: %ld\n",
 			__func__, PTR_ERR(clk));
 
-	clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
-	if (IS_ERR(clk))
-		pr_warn("%s: could not register clock usb480m: %ld\n",
-			__func__, PTR_ERR(clk));
-
 	rockchip_clk_register_branches(common_clk_branches,
 				  ARRAY_SIZE(common_clk_branches));
 
drivers/clk/rockchip/clk-rk3288.c +5 -11
index 3fceda1..58e6d8c 100644
@@ -195,8 +195,8 @@ PNAME(mux_hsadcout_p)	= { "hsadc_src", "ext_hsadc" };
 PNAME(mux_edp_24m_p)	= { "ext_edp_24m", "xin24m" };
 PNAME(mux_tspout_p)	= { "cpll", "gpll", "npll", "xin27m" };
 
-PNAME(mux_usbphy480m_p)		= { "sclk_otgphy1", "sclk_otgphy2",
-				    "sclk_otgphy0" };
+PNAME(mux_usbphy480m_p)		= { "sclk_otgphy1_480m", "sclk_otgphy2_480m",
+				    "sclk_otgphy0_480m" };
 PNAME(mux_hsicphy480m_p)	= { "cpll", "gpll", "usbphy480m_src" };
 PNAME(mux_hsicphy12m_p)		= { "hsicphy12m_xin12m", "hsicphy12m_usbphy" };
 
@@ -506,11 +506,11 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
 			RK3288_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS,
 			RK3288_CLKGATE_CON(4), 10, GFLAGS),
 
-	GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED,
+	GATE(SCLK_OTGPHY0, "sclk_otgphy0", "xin24m", CLK_IGNORE_UNUSED,
 			RK3288_CLKGATE_CON(13), 4, GFLAGS),
-	GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED,
+	GATE(SCLK_OTGPHY1, "sclk_otgphy1", "xin24m", CLK_IGNORE_UNUSED,
 			RK3288_CLKGATE_CON(13), 5, GFLAGS),
-	GATE(SCLK_OTGPHY2, "sclk_otgphy2", "usb480m", CLK_IGNORE_UNUSED,
+	GATE(SCLK_OTGPHY2, "sclk_otgphy2", "xin24m", CLK_IGNORE_UNUSED,
 			RK3288_CLKGATE_CON(13), 6, GFLAGS),
 	GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", CLK_IGNORE_UNUSED,
 			RK3288_CLKGATE_CON(13), 7, GFLAGS),
@@ -874,12 +874,6 @@ static void __init rk3288_clk_init(struct device_node *np)
 		pr_warn("%s: could not register clock xin12m: %ld\n",
 			__func__, PTR_ERR(clk));
 
-
-	clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
-	if (IS_ERR(clk))
-		pr_warn("%s: could not register clock usb480m: %ld\n",
-			__func__, PTR_ERR(clk));
-
 	clk = clk_register_fixed_factor(NULL, "hclk_vcodec_pre",
 					"hclk_vcodec_pre_v", 0, 1, 4);
 	if (IS_ERR(clk))
Signature · 1 line
2.6.2
Reviewed-by on v2 5/8
#9 lore raw

Re: [PATCH v2 5/8] clk: rockchip: fix usbphy-related clocks

Heiko,

Quoted 9 lines · Heiko Stuebner

The otgphy clocks really only drive the phy blocks. These in turn contain plls that then generate the 480m clocks the clock controller uses to supply some other clocks like uart0, gpu or the video-codec.

So fix this structure to actually respect that hirarchy and removed that usb480m fixed-rate clock working as a placeholder till now, as this wouldn't even work if the supplying phy gets turned off while its pll-output gets used elsewhere.

Quoted 5 lines
---
 drivers/clk/rockchip/clk-rk3188.c | 11 +++--------
 drivers/clk/rockchip/clk-rk3288.c | 16 +++++-----------
 2 files changed, 8 insertions(+), 19 deletions(-)
author maintainer
#10 lore raw

PATCH v2 6/8 ARM: dts: rockchip: add clock-cells for usb phy nodes

In reply to Heiko Stuebner

Add the #clock-cells properties for the usbphy nodes as they provide the pll-clocks now.

---
 arch/arm/boot/dts/rk3066a.dtsi | 2 ++
 arch/arm/boot/dts/rk3188.dtsi  | 2 ++
 arch/arm/boot/dts/rk3288.dtsi  | 3 +++
 3 files changed, 7 insertions(+)
arch/arm/boot/dts/rk3066a.dtsi +2 -0
index 946f187..3e4b41b 100644
@@ -181,6 +181,7 @@
 			reg = <0x17c>;
 			clocks = <&cru SCLK_OTGPHY0>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 
 		usbphy1: usb-phy1 {
@@ -188,6 +189,7 @@
 			reg = <0x188>;
 			clocks = <&cru SCLK_OTGPHY1>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 	};
 
arch/arm/boot/dts/rk3188.dtsi +2 -0
index 6399942..48a287e 100644
@@ -156,6 +156,7 @@
 			reg = <0x10c>;
 			clocks = <&cru SCLK_OTGPHY0>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 
 		usbphy1: usb-phy1 {
@@ -163,6 +164,7 @@
 			reg = <0x11c>;
 			clocks = <&cru SCLK_OTGPHY1>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 	};
 
arch/arm/boot/dts/rk3288.dtsi +3 -0
index e978fb2..f778458 100644
@@ -960,6 +960,7 @@
 			reg = <0x320>;
 			clocks = <&cru SCLK_OTGPHY0>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 
 		usbphy1: usb-phy1 {
@@ -967,6 +968,7 @@
 			reg = <0x334>;
 			clocks = <&cru SCLK_OTGPHY1>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 
 		usbphy2: usb-phy2 {
@@ -974,6 +976,7 @@
 			reg = <0x348>;
 			clocks = <&cru SCLK_OTGPHY2>;
 			clock-names = "phyclk";
+			#clock-cells = <0>;
 		};
 	};
 
Signature · 1 line
2.6.2
Reviewed-by on v2 6/8
#11 lore raw

Re: [PATCH v2 6/8] ARM: dts: rockchip: add clock-cells for usb phy nodes

Heiko,

Quoted 9 lines · Heiko Stuebner

Add the #clock-cells properties for the usbphy nodes as they provide the pll-clocks now.

---
 arch/arm/boot/dts/rk3066a.dtsi | 2 ++
 arch/arm/boot/dts/rk3188.dtsi  | 2 ++
 arch/arm/boot/dts/rk3288.dtsi  | 3 +++
 3 files changed, 7 insertions(+)
author maintainer
#12 lore raw

PATCH v2 7/8 ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on veyron

In reply to Heiko Stuebner

Veyron devices try to always set the source for usbphy480m to the usbphy0 that is the phy connected to the otg controller, because the firmware- default is usbphy1, the ehci-controller connected to the internal camera that might get turned off way easier to save power.

In the mainline kernel we currently don't use the usbphy480m_src at all, as it mainly powers the uart0 source that is connected to the bluetooth component of the wifi/bt combo.

So move that assignment over to the new real pll clock inside the usbphy.

---
 arch/arm/boot/dts/rk3288-veyron.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/rk3288-veyron.dtsi +1 -1
index d4263ed..c8329b5 100644
@@ -410,7 +410,7 @@
 	status = "okay";
 
 	assigned-clocks = <&cru SCLK_USBPHY480M_SRC>;
-	assigned-clock-parents = <&cru SCLK_OTGPHY0>;
+	assigned-clock-parents = <&usbphy0>;
 	dr_mode = "host";
 };
 
Signature · 1 line
2.6.2
Reviewed-by on v2 7/8
#13 lore raw

Re: [PATCH v2 7/8] ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on veyron

Heiko,

Quoted 21 lines · Heiko Stuebner

Veyron devices try to always set the source for usbphy480m to the usbphy0 that is the phy connected to the otg controller, because the firmware- default is usbphy1, the ehci-controller connected to the internal camera that might get turned off way easier to save power.

In the mainline kernel we currently don't use the usbphy480m_src at all, as it mainly powers the uart0 source that is connected to the bluetooth component of the wifi/bt combo.

So move that assignment over to the new real pll clock inside the usbphy.

---
 arch/arm/boot/dts/rk3288-veyron.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/rk3288-veyron.dtsi +0 -0
index d4263ed..c8329b5 100644

arch/arm/boot/dts/rk3288-veyron.dtsi line 415

Quoted 7 lines
arch/arm/boot/dts/rk3288-veyron.dtsi +1 -1
@@ -410,7 +410,7 @@
        status = "okay";
 
        assigned-clocks = <&cru SCLK_USBPHY480M_SRC>;
-       assigned-clock-parents = <&cru SCLK_OTGPHY0>;
+       assigned-clock-parents = <&usbphy0>;
        dr_mode = "host";
 };

This is right, hence:

...you will slightly break bisectability with this series though, right? In the previous patch in this series you changed the clocks in the mux away from the fake ones to be the real ones. If you have either that patch without this one or this patch without that one then clock parents won't get assigned properly...

I seem to remember that one of the USB phy clocks was kinds jittery (I want to say it was the EHCI one) and that was causing problems talking to the BT UART at 3Mbps. I kinda doubt we have anyone running BT on upstream over that UART (only used on veyron devices with Broadcom WiFi), so maybe this is OK. ...but if you had any other ideas for how to avoid breaking bisect that would be nice.

If nothing else, if we're going to break bisect then the two commits should reference each other and say that you need both and that with only one you might see a different clock selected...

-Doug

author maintainer
#14 lore raw

Re: [PATCH v2 7/8] ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on veyron

Am Montag, 9. November 2015, 13:08:43 schrieb Doug Anderson:

Quoted 12 lines

Heiko,

Quoted 9 lines · Heiko Stuebner

Veyron devices try to always set the source for usbphy480m to the usbphy0 that is the phy connected to the otg controller, because the firmware- default is usbphy1, the ehci-controller connected to the internal camera that might get turned off way easier to save power.

In the mainline kernel we currently don't use the usbphy480m_src at all, as it mainly powers the uart0 source that is connected to the bluetooth component of the wifi/bt combo.

Quoted 8 lines

Review

Quoted 8 lines

So move that assignment over to the new real pll clock inside the usbphy.

---
 arch/arm/boot/dts/rk3288-veyron.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-veyron.dtsi

Quoted 29 lines

arch/arm/boot/dts/rk3288-veyron.dtsi line 415

Quoted 11 lines

index d4263ed..c8329b5 100644

arch/arm/boot/dts/rk3288-veyron.dtsi +1 -1
@@ -410,7 +410,7 @@
        status = "okay";
 
        assigned-clocks = <&cru SCLK_USBPHY480M_SRC>;
-       assigned-clock-parents = <&cru SCLK_OTGPHY0>;
+       assigned-clock-parents = <&usbphy0>;
        dr_mode = "host";
 };

This is right, hence:

...you will slightly break bisectability with this series though, right? In the previous patch in this series you changed the clocks in the mux away from the fake ones to be the real ones. If you have either that patch without this one or this patch without that one then clock parents won't get assigned properly...

I seem to remember that one of the USB phy clocks was kinds jittery (I want to say it was the EHCI one) and that was causing problems talking to the BT UART at 3Mbps. I kinda doubt we have anyone running BT on upstream over that UART (only used on veyron devices with Broadcom WiFi), so maybe this is OK. ...but if you had any other ideas for how to avoid breaking bisect that would be nice.

Quoted 3 lines

If nothing else, if we're going to break bisect then the two commits should reference each other and say that you need both and that with only one you might see a different clock selected...

hmm, I wouldn't say that it breaks bisectability, because that would require that some working feature does break between those two changes in the first place. On Chromebooks we have either mwifiex, that doesn't even do wifi sucessfully right now and the (from what I've read) not well supported bcm, of which I don't know if it supports the veyron-variant's bluetooth yet.

The ehci-phy getting turned off was the more pressing reason from what I've read, and we're actually fixing that now :-) .

One possible way to still solve that would probably be moving the #clock-cells patch before the clock-tree change and merge this dts change into the clk one. I'll take a look into that tomorrow.

Heiko

author maintainer
#15 lore raw

PATCH v2 8/8 phy: rockchip-usb: add handler for usb-uart functionality

In reply to Heiko Stuebner

Most newer Rockchip SoCs provide the possibility to use a usb-phy as passthrough for the debug uart (uart2), making it possible to for example get console output without needing to open the device.

This patch adds an early_initcall to enable this functionality conditionally via the commandline and also disables the corresponding usb controller in the devicetree.

Currently only data for the rk3288 is provided, but at least the rk3188 and arm64 rk3368 also provide this functionality and will be enabled later.

On a spliced usb cable the signals are tx on white wire(D+) and rx on green wire(D-).

The one caveat is that currently the reconfiguration of the phy happens as early_initcall, as the code depends on the unflattened devicetree being available. Everything is fine if only a regular console is active as the console-replay will happen after the reconfiguation. But with earlycon active output up to smp-init currently will get lost.

The phy is an optional property for the connected dwc2 controller, so we still provide the phy device but fail all phy-ops with -EBUSY to make sure the dwc2 does not try to transmit anything on the repurposed phy.

---
 Documentation/kernel-parameters.txt |   6 +
 drivers/phy/phy-rockchip-usb.c      | 231 ++++++++++++++++++++++++++++++------
 2 files changed, 201 insertions(+), 36 deletions(-)
Documentation/kernel-parameters.txt +6 -0
index c6dd5f3..8d9a86e 100644
@@ -3370,6 +3370,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 
 	ro		[KNL] Mount root device read-only on boot
 
+	rockchip.usb_uart
+			Enable the uart passthrough on the designated usb port
+			on Rockchip SoCs. When active, the signals of the
+			debug-uart get routed to the D+ and D- pins of the usb
+			port and the regular usb controller gets disabled.
+
 	root=		[KNL] Root filesystem
 			See name_to_dev_t comment in init/do_mounts.c.
 
drivers/phy/phy-rockchip-usb.c +195 -36

318 lines not on this page · raw message

Signature · 1 line
2.6.2
#16 lore raw
In reply to Heiko Stuebner

Heiko,

Quoted 51 lines · Heiko Stuebner

changes in v2:
- add Doug's review-tag to patches 1 and 3
- address comment and add the missing transistional rk_phy->base assignment in patch2

Patches 1-7 fix a long-standing issue with the clock-tree of Rockchip SoCs namely our ignorance of the usbphy-internal pll that creates the needed 480MHz but is also a supply-clock back to the core clock-controller in Rockchip SoCs.

Till now that was worked around using a virtual clock in the cru itself, but that is of course ignorant of other parts then disabling the phy behind the cru's back, thus breaking potential users of these clocks.

Patch 8, while not associated with the new pll handling, also builds on the groundwork introduced there and adds support for the function repurposing one of the phys as passthrough for uart-data. This enables attaching a ttl converter to the D+ and D- pins of an usb cable to receive uart data this way, when it is not really possible to attach a regular serial console to a board.

One point of critique in my first iteration [0] of this was, that due to when the reconfiguration happens we may miss parts of the logs when earlycon is enabled. So far early_initcall gets used as the unflattened devicetree is necessary to set this up. Doing this for example in the early_param directly would require parsing the flattened devicetree to get needed nodes and properties.

I still maintain that if you're working on anything before smp-bringup you should use a real dev-board instead or try to solder uart cables on hopefully available test-points :-) .

In any case, if patch 8 causes to much headache, it could be dropped to not hinder the earlier 7 patches.

[0] http://comments.gmane.org/gmane.linux.ports.arm.rockchip/715

Heiko Stuebner (8):
phy: rockchip-usb: fix clock get-put mismatch
phy: rockchip-usb: introduce a common data-struct for the device
phy: rockchip-usb: move per-phy init into a separate function
phy: rockchip-usb: expose the phy-internal PLLs
clk: rockchip: fix usbphy-related clocks
ARM: dts: rockchip: add clock-cells for usb phy nodes
ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on
veyron
phy: rockchip-usb: add handler for usb-uart functionality

Quoted 10 lines
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   6 +-
 Documentation/kernel-parameters.txt                |   6 +
 arch/arm/boot/dts/rk3066a.dtsi                     |   2 +
 arch/arm/boot/dts/rk3188.dtsi                      |   2 +
 arch/arm/boot/dts/rk3288-veyron.dtsi               |   2 +-
 arch/arm/boot/dts/rk3288.dtsi                      |   3 +
 drivers/clk/rockchip/clk-rk3188.c                  |  11 +-
 drivers/clk/rockchip/clk-rk3288.c                  |  16 +-
 drivers/phy/phy-rockchip-usb.c                     | 449 ++++++++++++++++++---
 9 files changed, 416 insertions(+), 81 deletions(-)

If you happened to be in the mood for cleaning up this PHY and wanted to fix up one more thing that I noticed...

...you could actually increase the range of registers managed by the PHYs. For instance, in rk3288, the "host1" port isn't just managed by 1 register, but by 4 (GRF_UOC2_CON0 - GRF_UOC2_CON3). I think there are 5 for the OTG port.

Obviously not required for this series and there's no (current) reason to do anything with the rest of those registers, but it might be interesting for the future...

-Doug

author maintainer
#17 lore raw

Am Montag, 9. November 2015, 13:11:18 schrieb Doug Anderson:

Quoted 68 lines

Heiko,

Quoted 51 lines · Heiko Stuebner

changes in v2:
- add Doug's review-tag to patches 1 and 3
- address comment and add the missing transistional rk_phy->base assignment in patch2

Patches 1-7 fix a long-standing issue with the clock-tree of Rockchip SoCs namely our ignorance of the usbphy-internal pll that creates the needed 480MHz but is also a supply-clock back to the core clock-controller in Rockchip SoCs.

Till now that was worked around using a virtual clock in the cru itself, but that is of course ignorant of other parts then disabling the phy behind the cru's back, thus breaking potential users of these clocks.

Patch 8, while not associated with the new pll handling, also builds on the groundwork introduced there and adds support for the function repurposing one of the phys as passthrough for uart-data. This enables attaching a ttl converter to the D+ and D- pins of an usb cable to receive uart data this way, when it is not really possible to attach a regular serial console to a board.

One point of critique in my first iteration [0] of this was, that due to when the reconfiguration happens we may miss parts of the logs when earlycon is enabled. So far early_initcall gets used as the unflattened devicetree is necessary to set this up. Doing this for example in the early_param directly would require parsing the flattened devicetree to get needed nodes and properties.

I still maintain that if you're working on anything before smp-bringup you should use a real dev-board instead or try to solder uart cables on hopefully available test-points :-) .

In any case, if patch 8 causes to much headache, it could be dropped to not hinder the earlier 7 patches.

[0] http://comments.gmane.org/gmane.linux.ports.arm.rockchip/715

Heiko Stuebner (8):
phy: rockchip-usb: fix clock get-put mismatch
phy: rockchip-usb: introduce a common data-struct for the device
phy: rockchip-usb: move per-phy init into a separate function
phy: rockchip-usb: expose the phy-internal PLLs
clk: rockchip: fix usbphy-related clocks
ARM: dts: rockchip: add clock-cells for usb phy nodes
ARM: dts: rockchip: assign usbphy480m_src to the new usbphy pll on
veyron
phy: rockchip-usb: add handler for usb-uart functionality

Quoted 10 lines
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   6 +-
 Documentation/kernel-parameters.txt                |   6 +
 arch/arm/boot/dts/rk3066a.dtsi                     |   2 +
 arch/arm/boot/dts/rk3188.dtsi                      |   2 +
 arch/arm/boot/dts/rk3288-veyron.dtsi               |   2 +-
 arch/arm/boot/dts/rk3288.dtsi                      |   3 +
 drivers/clk/rockchip/clk-rk3188.c                  |  11 +-
 drivers/clk/rockchip/clk-rk3288.c                  |  16 +-
 drivers/phy/phy-rockchip-usb.c                     | 449 ++++++++++++++++++---
 9 files changed, 416 insertions(+), 81 deletions(-)

If you happened to be in the mood for cleaning up this PHY and wanted to fix up one more thing that I noticed...

Quoted 8 lines

...you could actually increase the range of registers managed by the PHYs. For instance, in rk3288, the "host1" port isn't just managed by 1 register, but by 4 (GRF_UOC2_CON0 - GRF_UOC2_CON3). I think there are 5 for the OTG port.

Obviously not required for this series and there's no (current) reason to do anything with the rest of those registers, but it might be interesting for the future...

I'm not sure what change you're proposing :-) .

I currently see the reg-property both in the dts and in the code as "offset" - the start-register, because it points to uoc_con0 for each phy. So if needed I was just planning on doing reg+x , as they're coming from the GRF anyway.

One interesting point would be to move that under the GRF node, similar to what we're doing with the power-domains under the PMU.

In retrospect I think exposing the phys individually was not the best decision - especially as when you dive deeper, they are not that similar anymore and individual functions change. But we'll have to live with that.

That is by the way, also one of the reasons for having these per-phy structs, so that we have the possility to identify phys again and describe individual phy-functions but still keep the current binding. The usb-uart is the first user for that :-)

Heiko

#18 lore raw

Heiko,

Quoted 8 lines · Heiko Stuebner
Quoted 8 lines

If you happened to be in the mood for cleaning up this PHY and wanted to fix up one more thing that I noticed...

...you could actually increase the range of registers managed by the PHYs. For instance, in rk3288, the "host1" port isn't just managed by 1 register, but by 4 (GRF_UOC2_CON0 - GRF_UOC2_CON3). I think there are 5 for the OTG port.

Quoted 5 lines
Quoted 3 lines

Obviously not required for this series and there's no (current) reason to do anything with the rest of those registers, but it might be interesting for the future...

I'm not sure what change you're proposing :-) .

I was proposing changing the PHY to look like:

usbphy: phy {
compatible = "rockchip,rk3288-usb-phy";
rockchip,grf = <&grf>;
#address-cells = <1>;
#size-cells = <1>;
status = "disabled";

  usbphy0: usb-phy0 {
    #phy-cells = <0>;
    reg = <0x320 0x14>;
    clocks = <&cru SCLK_OTGPHY0>;
    clock-names = "phyclk";

};
...
};

...in other words change the "size-cells" for the main PHY to 1 and add a length to the registers.

Quoted 4 lines

I currently see the reg-property both in the dts and in the code as "offset" - the start-register, because it points to uoc_con0 for each phy. So if needed I was just planning on doing reg+x , as they're coming from the GRF anyway.

Yeah, that would work. I was just trying to make it more obvious in the DTS that there was actually a range of registers managed here...

Quoted 6 lines

One interesting point would be to move that under the GRF node, similar to what we're doing with the power-domains under the PMU.

In retrospect I think exposing the phys individually was not the best decision - especially as when you dive deeper, they are not that similar anymore and individual functions change. But we'll have to live with that.

Now it's my turn: I'm not sure I understand... ;)

author maintainer
#19 lore raw

Am Montag, 9. November 2015, 13:32:28 schrieb Doug Anderson:

Quoted 39 lines

Heiko,

Quoted 8 lines · Heiko Stuebner
Quoted 8 lines

If you happened to be in the mood for cleaning up this PHY and wanted to fix up one more thing that I noticed...

...you could actually increase the range of registers managed by the PHYs. For instance, in rk3288, the "host1" port isn't just managed by 1 register, but by 4 (GRF_UOC2_CON0 - GRF_UOC2_CON3). I think there are 5 for the OTG port.

Quoted 5 lines
Quoted 3 lines

Obviously not required for this series and there's no (current) reason to do anything with the rest of those registers, but it might be interesting for the future...

I'm not sure what change you're proposing :-) .

I was proposing changing the PHY to look like:

usbphy: phy {
compatible = "rockchip,rk3288-usb-phy";
rockchip,grf = <&grf>;
#address-cells = <1>;
#size-cells = <1>;
status = "disabled";

  usbphy0: usb-phy0 {
    #phy-cells = <0>;
    reg = <0x320 0x14>;
    clocks = <&cru SCLK_OTGPHY0>;
    clock-names = "phyclk";

};
...
};

...in other words change the "size-cells" for the main PHY to 1 and add a length to the registers.

Quoted 7 lines
Quoted 4 lines

I currently see the reg-property both in the dts and in the code as "offset" - the start-register, because it points to uoc_con0 for each phy. So if needed I was just planning on doing reg+x , as they're coming from the GRF anyway.

Yeah, that would work. I was just trying to make it more obvious in the DTS that there was actually a range of registers managed here...

ok, that would make sense to make that a bit more visible, and it would even require functional changes ;-)

Quoted 8 lines
Quoted 6 lines

One interesting point would be to move that under the GRF node, similar to what we're doing with the power-domains under the PMU.

In retrospect I think exposing the phys individually was not the best decision - especially as when you dive deeper, they are not that similar anymore and individual functions change. But we'll have to live with that.

Now it's my turn: I'm not sure I understand... ;)

as the driver currently stands (without my changes) every phy is seen as the same function block - it looks like phy0...phy2 have the same functionality and the driver cannot distinguish between them. The similarity is true for SIDDQ and some other generic bits (even across different Rockchip SoCs), but for more special functionality bits move their location between phys. This is even more visisble if you compare rk3066/rk3188/rk3288 phys.

What I mean, and would like to have for the new phy-IP for rk3368 etc would be to have one node, then do the reference via an index like <&usbphy 1> and hide the internals in the driver instead of having that in the dts.

That's why it's nice to be able to reidentify the phy in the driver again via the register/structs introduced, because now you can again know that phyX is actually the OTG phy etc.

Heiko