linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] usb-phy support for the old rk3036 soc
@ 2025-05-03 20:15 Heiko Stuebner
  2025-05-03 20:15 ` [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible Heiko Stuebner
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Heiko Stuebner @ 2025-05-03 20:15 UTC (permalink / raw)
  To: vkoul, kishon
  Cc: robh, krzk+dt, conor+dt, heiko, linux-phy, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

While trying to resurrect the rk3036 board in my boardfarm, I also
implemented the up to now missing usb2phy support.

The implementation is quite similar to the rk3128, except the not-
supported charger-detection, so its addition was quite simple.


Heiko Stuebner (3):
  dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible
  phy: rockchip: inno-usb2: add phy definition for rk3036
  ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin

 .../bindings/phy/rockchip,inno-usb2phy.yaml   |  2 ++
 arch/arm/boot/dts/rockchip/rk3036-kylin.dts   | 12 +++++++
 arch/arm/boot/dts/rockchip/rk3036.dtsi        | 35 +++++++++++++++++++
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 32 +++++++++++++++++
 4 files changed, 81 insertions(+)

-- 
2.47.2



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible
  2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
@ 2025-05-03 20:15 ` Heiko Stuebner
  2025-05-06 16:22   ` Conor Dooley
  2025-05-03 20:15 ` [PATCH 2/3] phy: rockchip: inno-usb2: add phy definition for rk3036 Heiko Stuebner
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Heiko Stuebner @ 2025-05-03 20:15 UTC (permalink / raw)
  To: vkoul, kishon
  Cc: robh, krzk+dt, conor+dt, heiko, linux-phy, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

Add compatible for the USB2 phy in the Rockchip RK3036 SoC.

Apart from some bits that got swapped around in the phy registers, the
block is nearly the same as the one on the rk3128.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 .../devicetree/bindings/phy/rockchip,inno-usb2phy.yaml          | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml
index 6a7ef556414c..7bcefe8c22d1 100644
--- a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml
+++ b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml
@@ -13,6 +13,7 @@ properties:
   compatible:
     enum:
       - rockchip,px30-usb2phy
+      - rockchip,rk3036-usb2phy
       - rockchip,rk3128-usb2phy
       - rockchip,rk3228-usb2phy
       - rockchip,rk3308-usb2phy
@@ -184,6 +185,7 @@ allOf:
           contains:
             enum:
               - rockchip,px30-usb2phy
+              - rockchip,rk3036-usb2phy
               - rockchip,rk3128-usb2phy
               - rockchip,rk3228-usb2phy
               - rockchip,rk3308-usb2phy
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] phy: rockchip: inno-usb2: add phy definition for rk3036
  2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
  2025-05-03 20:15 ` [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible Heiko Stuebner
@ 2025-05-03 20:15 ` Heiko Stuebner
  2025-05-03 20:15 ` [PATCH 3/3] ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin Heiko Stuebner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Heiko Stuebner @ 2025-05-03 20:15 UTC (permalink / raw)
  To: vkoul, kishon
  Cc: robh, krzk+dt, conor+dt, heiko, linux-phy, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

The usb2phy on rk3036 is very similar to rk3128 but not 100% identical.
While most registers and bits are the same, a small fraction did get moved
around.

So we can re-use the phy-tuning function, but need a new set a bits.
The biggest change might be that the phy on rk3036 does not support the
charger detection, that rk3128 (and newer phys) have.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index b5e6a864deeb..32fdd64d7c2a 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1583,6 +1583,37 @@ static int rk3588_usb2phy_tuning(struct rockchip_usb2phy *rphy)
 	return ret;
 }
 
+static const struct rockchip_usb2phy_cfg rk3036_phy_cfgs[] = {
+	{
+		.reg = 0x17c,
+		.num_ports	= 2,
+		.phy_tuning	= rk3128_usb2phy_tuning,
+		.clkout_ctl	= { 0x017c, 11, 11, 1, 0 },
+		.port_cfgs	= {
+			[USB2PHY_PORT_OTG] = {
+				.phy_sus	= { 0x017c, 8, 0, 0, 0x1d1 },
+				.bvalid_det_en	= { 0x017c, 14, 14, 0, 1 },
+				.bvalid_det_st	= { 0x017c, 15, 15, 0, 1 },
+				.bvalid_det_clr	= { 0x017c, 15, 15, 0, 1 },
+				.ls_det_en	= { 0x017c, 12, 12, 0, 1 },
+				.ls_det_st	= { 0x017c, 13, 13, 0, 1 },
+				.ls_det_clr	= { 0x017c, 13, 13, 0, 1 },
+				.utmi_bvalid	= { 0x014c, 8, 8, 0, 1 },
+				.utmi_id	= { 0x014c, 11, 11, 0, 1 },
+				.utmi_ls	= { 0x014c, 10, 9, 0, 1 },
+
+			},
+			[USB2PHY_PORT_HOST] = {
+				.phy_sus	= { 0x0194, 8, 0, 0, 0x1d1 },
+				.ls_det_en	= { 0x0194, 14, 14, 0, 1 },
+				.ls_det_st	= { 0x0194, 15, 15, 0, 1 },
+				.ls_det_clr	= { 0x0194, 15, 15, 0, 1 }
+			}
+		},
+	},
+	{ /* sentinel */ }
+};
+
 static const struct rockchip_usb2phy_cfg rk3128_phy_cfgs[] = {
 	{
 		.reg = 0x17c,
@@ -2204,6 +2235,7 @@ static const struct rockchip_usb2phy_cfg rv1108_phy_cfgs[] = {
 
 static const struct of_device_id rockchip_usb2phy_dt_match[] = {
 	{ .compatible = "rockchip,px30-usb2phy", .data = &rk3328_phy_cfgs },
+	{ .compatible = "rockchip,rk3036-usb2phy", .data = &rk3036_phy_cfgs },
 	{ .compatible = "rockchip,rk3128-usb2phy", .data = &rk3128_phy_cfgs },
 	{ .compatible = "rockchip,rk3228-usb2phy", .data = &rk3228_phy_cfgs },
 	{ .compatible = "rockchip,rk3308-usb2phy", .data = &rk3308_phy_cfgs },
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin
  2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
  2025-05-03 20:15 ` [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible Heiko Stuebner
  2025-05-03 20:15 ` [PATCH 2/3] phy: rockchip: inno-usb2: add phy definition for rk3036 Heiko Stuebner
@ 2025-05-03 20:15 ` Heiko Stuebner
  2025-05-14 11:37 ` (subset) [PATCH 0/3] usb-phy support for the old rk3036 soc Vinod Koul
  2025-05-15 12:50 ` Heiko Stuebner
  4 siblings, 0 replies; 7+ messages in thread
From: Heiko Stuebner @ 2025-05-03 20:15 UTC (permalink / raw)
  To: vkoul, kishon
  Cc: robh, krzk+dt, conor+dt, heiko, linux-phy, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

The rk3036 does contain a usb2phy, just until now it was just used
implicitly without additional configuration. As we now have the bits
in place for it getting actually controlled, add the necessary phy-node
to the GRF simple-mfd.

Enable the phy-ports in the same patch to not create bisectability
issues, as hooking up the phys to the usb controllers would create
probe deferrals until a board enables them. Doing everything in one
patch, solves that issue.

Only rk3036-kylin actually enabled the usb controllers, so is the only
board affected.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm/boot/dts/rockchip/rk3036-kylin.dts | 12 +++++++
 arch/arm/boot/dts/rockchip/rk3036.dtsi      | 35 +++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/rockchip/rk3036-kylin.dts b/arch/arm/boot/dts/rockchip/rk3036-kylin.dts
index 4f928c7898e9..51a74f79c935 100644
--- a/arch/arm/boot/dts/rockchip/rk3036-kylin.dts
+++ b/arch/arm/boot/dts/rockchip/rk3036-kylin.dts
@@ -382,6 +382,18 @@ &usb_otg {
 	status = "okay";
 };
 
+&usb2phy {
+	status = "okay";
+};
+
+&usb2phy_host {
+	status = "okay";
+};
+
+&usb2phy_otg {
+	status = "okay";
+};
+
 &vop {
 	status = "okay";
 };
diff --git a/arch/arm/boot/dts/rockchip/rk3036.dtsi b/arch/arm/boot/dts/rockchip/rk3036.dtsi
index f4292b586bc2..fca21ebb224b 100644
--- a/arch/arm/boot/dts/rockchip/rk3036.dtsi
+++ b/arch/arm/boot/dts/rockchip/rk3036.dtsi
@@ -213,6 +213,8 @@ usb_otg: usb@10180000 {
 		g-np-tx-fifo-size = <16>;
 		g-rx-fifo-size = <275>;
 		g-tx-fifo-size = <256 128 128 64 64 32>;
+		phys = <&usb2phy_otg>;
+		phy-names = "usb2-phy";
 		status = "disabled";
 	};
 
@@ -224,6 +226,8 @@ usb_host: usb@101c0000 {
 		clocks = <&cru HCLK_OTG1>;
 		clock-names = "otg";
 		dr_mode = "host";
+		phys = <&usb2phy_host>;
+		phy-names = "usb2-phy";
 		status = "disabled";
 	};
 
@@ -342,6 +346,37 @@ cru: clock-controller@20000000 {
 	grf: syscon@20008000 {
 		compatible = "rockchip,rk3036-grf", "syscon", "simple-mfd";
 		reg = <0x20008000 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		usb2phy: usb2phy@17c {
+			compatible = "rockchip,rk3036-usb2phy";
+			reg = <0x017c 0x20>;
+			clocks = <&cru SCLK_OTGPHY0>;
+			clock-names = "phyclk";
+			clock-output-names = "usb480m_phy";
+			assigned-clocks = <&cru SCLK_USB480M>;
+			assigned-clock-parents = <&usb2phy>;
+			#clock-cells = <0>;
+			status = "disabled";
+
+			usb2phy_host: host-port {
+				interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;
+				interrupt-names = "linestate";
+				#phy-cells = <0>;
+				status = "disabled";
+			};
+
+			usb2phy_otg: otg-port {
+				interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+				interrupt-names = "otg-bvalid", "otg-id",
+						  "linestate";
+				#phy-cells = <0>;
+				status = "disabled";
+			};
+		};
 
 		power: power-controller {
 			compatible = "rockchip,rk3036-power-controller";
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible
  2025-05-03 20:15 ` [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible Heiko Stuebner
@ 2025-05-06 16:22   ` Conor Dooley
  0 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2025-05-06 16:22 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: vkoul, kishon, robh, krzk+dt, conor+dt, linux-phy, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

On Sat, May 03, 2025 at 10:15:10PM +0200, Heiko Stuebner wrote:
> Add compatible for the USB2 phy in the Rockchip RK3036 SoC.
> 
> Apart from some bits that got swapped around in the phy registers, the
> block is nearly the same as the one on the rk3128.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: (subset) [PATCH 0/3] usb-phy support for the old rk3036 soc
  2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
                   ` (2 preceding siblings ...)
  2025-05-03 20:15 ` [PATCH 3/3] ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin Heiko Stuebner
@ 2025-05-14 11:37 ` Vinod Koul
  2025-05-15 12:50 ` Heiko Stuebner
  4 siblings, 0 replies; 7+ messages in thread
From: Vinod Koul @ 2025-05-14 11:37 UTC (permalink / raw)
  To: kishon, Heiko Stuebner
  Cc: robh, krzk+dt, conor+dt, linux-phy, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel


On Sat, 03 May 2025 22:15:09 +0200, Heiko Stuebner wrote:
> While trying to resurrect the rk3036 board in my boardfarm, I also
> implemented the up to now missing usb2phy support.
> 
> The implementation is quite similar to the rk3128, except the not-
> supported charger-detection, so its addition was quite simple.
> 
> 
> [...]

Applied, thanks!

[1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible
      commit: d78b565371314e48242cb9383d0f9d331119ab2e
[2/3] phy: rockchip: inno-usb2: add phy definition for rk3036
      commit: 3ca48b955bb34a3b07dd915318d73a23740de282

Best regards,
-- 
~Vinod




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: (subset) [PATCH 0/3] usb-phy support for the old rk3036 soc
  2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
                   ` (3 preceding siblings ...)
  2025-05-14 11:37 ` (subset) [PATCH 0/3] usb-phy support for the old rk3036 soc Vinod Koul
@ 2025-05-15 12:50 ` Heiko Stuebner
  4 siblings, 0 replies; 7+ messages in thread
From: Heiko Stuebner @ 2025-05-15 12:50 UTC (permalink / raw)
  To: vkoul, kishon, Heiko Stuebner
  Cc: robh, krzk+dt, conor+dt, linux-phy, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel


On Sat, 03 May 2025 22:15:09 +0200, Heiko Stuebner wrote:
> While trying to resurrect the rk3036 board in my boardfarm, I also
> implemented the up to now missing usb2phy support.
> 
> The implementation is quite similar to the rk3128, except the not-
> supported charger-detection, so its addition was quite simple.
> 
> 
> [...]

Applied, thanks!

[3/3] ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin
      commit: 9e010737dd434e3eee1fa75938abea0dc2fab8e2

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-15 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-03 20:15 [PATCH 0/3] usb-phy support for the old rk3036 soc Heiko Stuebner
2025-05-03 20:15 ` [PATCH 1/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3036 compatible Heiko Stuebner
2025-05-06 16:22   ` Conor Dooley
2025-05-03 20:15 ` [PATCH 2/3] phy: rockchip: inno-usb2: add phy definition for rk3036 Heiko Stuebner
2025-05-03 20:15 ` [PATCH 3/3] ARM: dts: rockchip: add rk3036 usb2phy nodes and enable them on kylin Heiko Stuebner
2025-05-14 11:37 ` (subset) [PATCH 0/3] usb-phy support for the old rk3036 soc Vinod Koul
2025-05-15 12:50 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).