rockchip: PHY drivers (USB)
Subsystems (6)
v2 cover rockchip: PHY drivers (USB)
This is next following series from previous PHY drivers on rockchip [1].
And also tested on top of Frank 'USB 3.0' series [2] from patches 0/9 to 6/9.
With this USB 3.0 Host port seems to detecting USB storage but need more testing on other modes as well.
Log on rock960 and NanoPC-t4:
rock960 => usb start
starting USB...
Bus usb@fe380000: USB EHCI 1.00
Bus usb@fe3c0000: USB EHCI 1.00
Bus dwc3: usb maximum-speed not found
Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe380000 for devices... 1 USB Device(s) found scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found scanning bus dwc3 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
rock960 => usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
u-boot EHCI Host Controller
1 Hub (480 Mb/s, 0mA)
u-boot EHCI Host Controller
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 200mA)
Generic Mass Storage 789CDB36
=> usb start
starting USB...
Bus usb@fe380000: USB EHCI 1.00
Bus usb@fe3c0000: USB EHCI 1.00
Bus dwc3: usb maximum-speed not founddwc3_of_parse: In
Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus dwc3: usb maximum-speed not founddwc3_of_parse: In
Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe380000 for devices... 1 USB Device(s) found scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found scanning bus dwc3 for devices... 1 USB Device(s) found scanning bus dwc3 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
=> usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
u-boot EHCI Host Controller
1 Hub (480 Mb/s, 0mA)
u-boot EHCI Host Controller
1 Hub (5 Gb/s, 0mA)
U-Boot XHCI Host Controller
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 200mA)
Generic Mass Storage 789CDB36
[2] https://patchwork.ozlabs.org/project/uboot/cover/20200430021620.25772-1-frank.wang-TNX95d0MmH7DzftRWevZcw@public.gmane.org/
[1] https://patchwork.ozlabs.org/project/uboot/cover/20200430214529.18887-1-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org/
Any inputs?
Jagan.
Jagan Teki (7):
clk: rk3399: Enable/Disable the USB2PHY clk
clk: rk3399: Set empty for TCPHY assigned-clocks
clk: rk3399: Enable/Disable TCPHY clocks
phy: rockchip: Add Rockchip USB2PHY driver
arm64: dts: rk3399: Move u2phy into root port
phy: rockchip: Add Rockchip USB TypeC PHY driver
usb: dwc3: add dis_del_phy_power_chg_quirk
arch/arm/dts/rk3399.dtsi | 108 +-- drivers/Makefile | 1 + drivers/clk/rockchip/clk_rk3399.c | 38 + drivers/phy/Kconfig | 1 + drivers/phy/rockchip/Kconfig | 21 + drivers/phy/rockchip/Makefile | 7 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 +++++++ drivers/phy/rockchip/phy-rockchip-typec.c | 796 ++++++++++++++++++ drivers/usb/dwc3/core.c | 6 + drivers/usb/dwc3/core.h | 1 + include/dwc3-uboot.h | 1 + 11 files changed, 1238 insertions(+), 54 deletions(-) create mode 100644 drivers/phy/rockchip/Kconfig create mode 100644 drivers/phy/rockchip/Makefile create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-usb2.c create mode 100644 drivers/phy/rockchip/phy-rockchip-typec.c
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): 20200506075025.1677-1-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org
PATCH v2 1/7 clk: rk3399: Enable/Disable the USB2PHY clk
Enable/Disable the USB2PHY clk for rk3399.
CLK is clear in enable and set in disable functionality.
---
Changes for v2:
- none
drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +12 -0
@@ -1091,6 +1091,12 @@ static int rk3399_clk_enable(struct clk *clk)case SCLK_MACREF_OUT :rk_clrreg (&priv->cru->clkgate_con[5 ],BIT (6 ));break ; +case SCLK_USB2PHY0_REF : +rk_clrreg (&priv->cru->clkgate_con[6 ],BIT (5 )); +break ; +case SCLK_USB2PHY1_REF : +rk_clrreg (&priv->cru->clkgate_con[6 ],BIT (6 )); +break ;case ACLK_GMAC :rk_clrreg (&priv->cru->clkgate_con[32 ],BIT (0 ));break ;
@@ -1167,6 +1173,12 @@ static int rk3399_clk_disable(struct clk *clk)case SCLK_MACREF_OUT :rk_setreg (&priv->cru->clkgate_con[5 ],BIT (6 ));break ; +case SCLK_USB2PHY0_REF : +rk_setreg (&priv->cru->clkgate_con[6 ],BIT (5 )); +break ; +case SCLK_USB2PHY1_REF : +rk_setreg (&priv->cru->clkgate_con[6 ],BIT (6 )); +break ;case ACLK_GMAC :rk_setreg (&priv->cru->clkgate_con[32 ],BIT (0 ));break ;
Signature · 1 line
2.17.1
PATCH v2 2/7 clk: rk3399: Set empty for TCPHY assigned-clocks
In reply to a message not in the archiveDue to v5.7-rc1 sync the SD controller nodes in rk3399.dtsi have SCLK_UPHY0_TCPDCORE, SCLK_UPHY1_TCPDCORE assigned-clocks which are usually required for Linux and don't require to handle them in U-Boot.
assigned-clocks = <&cru SCLK_UPHY0_TCPDCORE>; assigned-clocks = <&cru SCLK_UPHY1_TCPDCORE>;
So, mark them as empty in clock otherwise device probe on those typec phy driver would fail.
---
Changes for v2:
- new patch
drivers/clk/rockchip/clk_rk3399.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +2 -0
@@ -997,6 +997,8 @@ static ulong rk3399_clk_set_rate(struct clk *clk, ulong rate)case ACLK_VOP1 :case HCLK_VOP1 :case HCLK_SD : +case SCLK_UPHY0_TCPDCORE : +case SCLK_UPHY1_TCPDCORE :/** * assigned-clocks handling won't require for vopl, so * return 0 to satisfy clk_set_defaults during device probe.
Signature · 1 line
2.17.1
PATCH v2 3/7 clk: rk3399: Enable/Disable TCPHY clocks
In reply to a message not in the archiveEnable/Disable TCPHY clock for rk3399 platform.
---
Changes for v2:
- new patch
drivers/clk/rockchip/clk_rk3399.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +24 -0
@@ -1144,6 +1144,18 @@ static int rk3399_clk_enable(struct clk *clk)case HCLK_HOST1_ARB :rk_clrreg (&priv->cru->clksel_con[20 ],BIT (8 ));break ; +case SCLK_UPHY0_TCPDPHY_REF : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (4 )); +break ; +case SCLK_UPHY0_TCPDCORE : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (5 )); +break ; +case SCLK_UPHY1_TCPDPHY_REF : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (6 )); +break ; +case SCLK_UPHY1_TCPDCORE : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (7 )); +break ;case SCLK_PCIEPHY_REF :rk_clrreg (&priv->cru->clksel_con[18 ],BIT (10 ));break ;
@@ -1226,6 +1238,18 @@ static int rk3399_clk_disable(struct clk *clk)case HCLK_HOST1_ARB :rk_setreg (&priv->cru->clksel_con[20 ],BIT (8 ));break ; +case SCLK_UPHY0_TCPDPHY_REF : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (4 )); +break ; +case SCLK_UPHY0_TCPDCORE : +rk_setreg (&priv->cru->clkgate_con[13 ],BIT (5 )); +break ; +case SCLK_UPHY1_TCPDPHY_REF : +rk_clrreg (&priv->cru->clkgate_con[13 ],BIT (6 )); +break ; +case SCLK_UPHY1_TCPDCORE : +rk_setreg (&priv->cru->clkgate_con[13 ],BIT (7 )); +break ;case SCLK_PCIEPHY_REF :rk_clrreg (&priv->cru->clksel_con[18 ],BIT (10 ));break ;
Signature · 1 line
2.17.1
PATCH v2 4/7 phy: rockchip: Add Rockchip USB2PHY driver
In reply to a message not in the archiveAdd Rockchip USB2PHY driver with initial support.
This will help to use it for EHCI controller in host mode, and USB 3.0 controller in otg mode.
More functionality like charge, vbus detection will add it in future changes.
---
Changes for v2:
- update with Kconfig menu
drivers/Makefile | 1 + drivers/phy/Kconfig | 1 + drivers/phy/rockchip/Kconfig | 14 + drivers/phy/rockchip/Makefile | 6 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 ++++++++++++++++++ 5 files changed, 334 insertions(+) create mode 100644 drivers/phy/rockchip/Kconfig create mode 100644 drivers/phy/rockchip/Makefile create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-usb2.c
drivers/Makefile +1 -0
@@ -91,6 +91,7 @@ obj-y += dfu/ obj-$(CONFIG_PCH) += pch/ obj-y += phy/allwinner/ obj-y += phy/marvell/ +obj-y += phy/rockchip/ obj-y += rtc/ obj-y += scsi/ obj-y += sound/
drivers/phy/Kconfig +1 -0
@@ -217,4 +217,5 @@ config PHY_MTK_TPHY multi-ports is first version, otherwise is second veriosn, so you can easily distinguish them by banks layout. +source "drivers/phy/rockchip/Kconfig" endmenu
drivers/phy/rockchip/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# +# Phy drivers for Rockchip platforms +# + +menu "Rockchip PHY driver" + +config PHY_ROCKCHIP_INNO_USB2 + bool "Rockchip INNO USB2PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Support for Rockchip USB2.0 PHY with Innosilicon IP block. + +endmenu
drivers/phy/rockchip/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Amarula Solutions(India) +# + +obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o
drivers/phy/rockchip/phy-rockchip-inno-usb2.c new file +312 -0
312 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/7 arm64: dts: rk3399: Move u2phy into root port
In reply to a message not in the archiveYes, This is changing the actual device tree u2phy structure but the problem with the current Generic PHY subsystem is unable to find PHY if the PHY node is not part of the root structure.
This will be reverted once we support the PHY subsystem to get the PHY even though it is not part of the root node or any other relevant solution.
---
Changes for v2:
- none
arch/arm/dts/rk3399.dtsi | 108 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-)
arch/arm/dts/rk3399.dtsi +54 -54
@@ -1387,60 +1387,6 @@ status = "disabled"; }; - u2phy0: usb2-phy@e450 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe450 0x10>; - clocks = <&cru SCLK_USB2PHY0_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy0_480m"; - status = "disabled"; - - u2phy0_host: host-port { - #phy-cells = <0>; - interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH 0>; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy0_otg: otg-port { - #phy-cells = <0>; - interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH 0>; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - - u2phy1: usb2-phy@e460 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe460 0x10>; - clocks = <&cru SCLK_USB2PHY1_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy1_480m"; - status = "disabled"; - - u2phy1_host: host-port { - #phy-cells = <0>; - interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH 0>; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy1_otg: otg-port { - #phy-cells = <0>; - interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH 0>; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - emmc_phy: phy@f780 { compatible = "rockchip,rk3399-emmc-phy"; reg = <0xf780 0x24>;
@@ -1462,6 +1408,60 @@ }; }; + u2phy0: usb2-phy@e450 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe450 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY0_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy0_480m"; + status = "disabled"; + + u2phy0_host: host-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy0_otg: otg-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + + u2phy1: usb2-phy@e460 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe460 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY1_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy1_480m"; + status = "disabled"; + + u2phy1_host: host-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy1_otg: otg-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + tcphy0: phy@ff7c0000 { compatible = "rockchip,rk3399-typec-phy"; reg = <0x0 0xff7c0000 0x0 0x40000>;
Signature · 1 line
2.17.1
PATCH v2 6/7 phy: rockchip: Add Rockchip USB TypeC PHY driver
In reply to a message not in the archiveAdd USB TYPEC PHY driver for rockchip platform.
Referenced from Linux TypeC PHY driver, currently
supporting usb3-port and dp-port need to add it
in the future.
---
Changes for v2:
- new patch
drivers/phy/rockchip/Kconfig | 7 + drivers/phy/rockchip/Makefile | 1 + drivers/phy/rockchip/phy-rockchip-typec.c | 796 ++++++++++++++++++++++ 3 files changed, 804 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-typec.c
drivers/phy/rockchip/Kconfig +7 -0
@@ -11,4 +11,11 @@ config PHY_ROCKCHIP_INNO_USB2 help Support for Rockchip USB2.0 PHY with Innosilicon IP block. +config PHY_ROCKCHIP_TYPEC + bool "Rockchip TYPEC PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Enable this to support the Rockchip USB TYPEC PHY. + endmenu
drivers/phy/rockchip/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o +obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o
drivers/phy/rockchip/phy-rockchip-typec.c new file +796 -0
796 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 7/7 usb: dwc3: add dis_del_phy_power_chg_quirk
In reply to a message not in the archiveAdd a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, which specifies whether disable delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively.
Reference from below Linux commit,
commit <00fe081dc3a3> ("usb: dwc3: add dis_del_phy_power_chg_quirk")
---
Changes for v2:
- new patch
drivers/usb/dwc3/core.c | 6 ++++++ drivers/usb/dwc3/core.h | 1 + include/dwc3-uboot.h | 1 + 3 files changed, 8 insertions(+)
drivers/usb/dwc3/core.c +6 -0
@@ -377,6 +377,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u3_susphy_quirk) reg &= ~DWC3_GUSB3PIPECTL_SUSPHY ; +if (dwc->dis_del_phy_power_chg_quirk) + reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE ; +dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg);mdelay (100 );
@@ -715,6 +718,7 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->rx_detect_poll_quirk = dwc3_dev->rx_detect_poll_quirk; dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk; + dwc->dis_del_phy_power_chg_quirk = dwc3_dev->dis_del_phy_power_chg_quirk; dwc->tx_de_emphasis_quirk = dwc3_dev->tx_de_emphasis_quirk;if (dwc3_dev->tx_de_emphasis)
@@ -975,6 +979,8 @@ void dwc3_of_parse(struct dwc3 *dwc) "snps,dis_u3_susphy_quirk"); dwc->dis_u2_susphy_quirk =dev_read_bool (dev,"snps,dis_u2_susphy_quirk" ); + dwc->dis_del_phy_power_chg_quirk =dev_read_bool (dev, +"snps,dis-del-phy-power-chg-quirk" ); dwc->tx_de_emphasis_quirk =dev_read_bool (dev,"snps,tx_de_emphasis_quirk" ); tmp =dev_read_u8_array_ptr (dev,"snps,tx_de_emphasis" ,1 );
drivers/usb/dwc3/core.h +1 -0
@@ -821,6 +821,7 @@ struct dwc3 { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_del_phy_power_chg_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
include/dwc3-uboot.h +1 -0
@@ -32,6 +32,7 @@ struct dwc3_device {unsigned rx_detect_poll_quirk;unsigned dis_u3_susphy_quirk;unsigned dis_u2_susphy_quirk; +unsigned dis_del_phy_power_chg_quirk;unsigned tx_de_emphasis_quirk;unsigned tx_de_emphasis;int index;
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): 20200506075025.1677-8-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org
Marek Vasut
AppliedRe: [PATCH v2 7/7] usb: dwc3: add dis_del_phy_power_chg_quirk
Quoted 8 lines · Jagan Teki
Add a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, which specifies whether disable delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively.
Reference from below Linux commit,
commit <
00fe081dc3a3> ("usb: dwc3: adddis_del_phy_power_chg_quirk")
Applied, thanks.