rockchip: Add PHY drivers
Subsystems (5)
cover rockchip: Add PHY drivers
This patch add support for USB2PHY and PCIe PHY driver on rockchip platform and tested the same in rk3399.
Basic code is referenced from Linux, hence all the license SPDX are reused.
The reason behind sending this as RFC is PHY devices for u2phy, pcie_phy nodes are unable to get via Generic PHY framework. The observed reasons are
1) u2phy is not part of root node.
2) pcie_phy is not part of root node and also parent is of non-PHY type.
This is sample PHY provider topology that Generic PHY is failed to get PHY device.
/{
grf: syscon@ff770000 {
compatible = "rockchip,rk3399-grf", "syscon", "simple-mfd";
reg = <0x0 0xff770000 0x0 0x10000>;
#address-cells = <1>;
#size-cells = <1>;
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";
};
};
pcie_phy: pcie-phy {
compatible = "rockchip,rk3399-pcie-phy";
clocks = <&cru SCLK_PCIEPHY_REF>;
clock-names = "refclk";
#phy-cells = <1>;
resets = <&cru SRST_PCIEPHY>;
drive-impedance-ohm = <50>;
reset-names = "phy";
status = "disabled";
};};
So, this series moved these nodes as part of root to make it work but of course any suggestions on this will be taken into consideration.
Any inputs?
Jagan.
Jagan Teki (7):
phy: Add Rockchip PCIe PHY driver
clk: rk3399: Enable/Disable the USB2PHY clk
phy: rockchip: Add Rockchip USB2PHY driver
arm64: dts: rk3399: Move u2phy into root port
arm64: dts: rk3399: Move pcie_phy into root port
pci: rockchip: Switch to generic-phy
pci: rockchip: Drop legacy PHY driver
arch/arm/dts/rk3399.dtsi | 118 +++---- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/clk/rockchip/clk_rk3399.c | 12 + drivers/pci/Makefile | 2 +- drivers/pci/pcie_rockchip.c | 95 +++++- drivers/pci/pcie_rockchip.h | 142 -------- drivers/pci/pcie_rockchip_phy.c | 205 ------------ drivers/phy/rockchip/Kconfig | 16 + drivers/phy/rockchip/Makefile | 7 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 ++++++++++++++++++ drivers/phy/rockchip/phy-rockchip-pcie.c | 271 +++++++++++++++ 12 files changed, 764 insertions(+), 419 deletions(-) delete mode 100644 drivers/pci/pcie_rockchip.h delete mode 100644 drivers/pci/pcie_rockchip_phy.c 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-pcie.c
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): 20200430214529.18887-1-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org
RFC 1/7 phy: Add Rockchip PCIe PHY driver
Add the Rockchip PCIe PHY driver as part of
Generic PHY framework.
--- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/phy/rockchip/Kconfig | 9 + drivers/phy/rockchip/Makefile | 6 + drivers/phy/rockchip/phy-rockchip-pcie.c | 271 +++++++++++++++++++++++ 5 files changed, 289 insertions(+) create mode 100644 drivers/phy/rockchip/Kconfig create mode 100644 drivers/phy/rockchip/Makefile create mode 100644 drivers/phy/rockchip/phy-rockchip-pcie.c
drivers/Kconfig +2 -0
@@ -76,6 +76,8 @@ source "drivers/phy/allwinner/Kconfig" source "drivers/phy/marvell/Kconfig" +source "drivers/phy/rockchip/Kconfig" + source "drivers/pinctrl/Kconfig" source "drivers/power/Kconfig"
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/rockchip/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +# +# Phy drivers for Rockchip platforms +# +config PHY_ROCKCHIP_PCIE + bool "Rockchip PCIe PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Enable this to support the Rockchip PCIe PHY.
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_PCIE) += phy-rockchip-pcie.o
drivers/phy/rockchip/phy-rockchip-pcie.c new file +271 -0
271 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 2/7 clk: rk3399: Enable/Disable the USB2PHY clk
In reply to a message not in the archiveEnable/Disable the USB2PHY clk for rk3399.
CLK is clear in enable and set in disable functionality.
--- 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
RFC 3/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.
--- drivers/phy/rockchip/Kconfig | 7 + drivers/phy/rockchip/Makefile | 1 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 ++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-usb2.c
drivers/phy/rockchip/Kconfig +7 -0
@@ -7,3 +7,10 @@ config PHY_ROCKCHIP_PCIE select PHY help Enable this to support the Rockchip PCIe PHY. + +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.
drivers/phy/rockchip/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o +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
RFC 4/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.
--- 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
RFC 5/7 arm64: dts: rk3399: Move pcie_phy into root port
In reply to a message not in the archiveYes, This is changing the actual device tree pcie_phy 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 and also PHY parent is non-PHY type.
This will be reverted once we support the PHY subsystem to get the PHY whose parent has non-PHY type or any other relevant solution.
--- arch/arm/dts/rk3399.dtsi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/dts/rk3399.dtsi +10 -10
@@ -1395,17 +1395,17 @@ #phy-cells = <0>; status = "disabled"; }; + }; - pcie_phy: pcie-phy { - compatible = "rockchip,rk3399-pcie-phy"; - clocks = <&cru SCLK_PCIEPHY_REF>; - clock-names = "refclk"; - #phy-cells = <1>; - resets = <&cru SRST_PCIEPHY>; - drive-impedance-ohm = <50>; - reset-names = "phy"; - status = "disabled"; - }; + pcie_phy: pcie-phy { + compatible = "rockchip,rk3399-pcie-phy"; + clocks = <&cru SCLK_PCIEPHY_REF>; + clock-names = "refclk"; + #phy-cells = <1>; + resets = <&cru SRST_PCIEPHY>; + drive-impedance-ohm = <50>; + reset-names = "phy"; + status = "disabled"; }; u2phy0: usb2-phy@e450 {
Signature · 7 lines
2.17.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
RFC 6/7 pci: rockchip: Switch to generic-phy
In reply to a message not in the archiveNow, we have a PCIe PHY driver as part of the Generic PHY framework. Let's use it instead of legacy PHY driver.
--- drivers/pci/pcie_rockchip.c | 20 ++++++++++---------- drivers/pci/pcie_rockchip.h | 5 +++++ 2 files changed, 15 insertions(+), 10 deletions(-)
drivers/pci/pcie_rockchip.c +10 -10
@@ -159,8 +159,6 @@ static int rockchip_pcie_atr_init(struct rockchip_pcie *priv)static int rockchip_pcie_init_port (struct udevice *dev) {struct rockchip_pcie *priv =dev_get_priv (dev); -struct rockchip_pcie_phy *phy =pcie_get_phy (priv); -struct rockchip_pcie_phy_ops *ops =phy_get_ops (phy);u32 cr, val, status;int ret;
@@ -185,7 +183,7 @@ static int rockchip_pcie_init_port(struct udevice *dev)return ret; } - ret = ops->init (phy); + ret =generic_phy_init (&priv->pcie_phy);if (ret) {dev_err (dev,"failed to init phy (ret=%d)\n" , ret); goto err_exit_phy;
@@ -242,7 +240,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) cr |=PCIE_CLIENT_CONF_ENABLE |PCIE_CLIENT_MODE_RC ;writel (cr, priv->apb_base +PCIE_CLIENT_CONFIG ); - ret = ops->power_on (phy); + ret =generic_phy_power_on (&priv->pcie_phy);if (ret) {dev_err (dev,"failed to power on phy (ret=%d)\n" , ret); goto err_power_off_phy;
@@ -311,9 +309,9 @@ static int rockchip_pcie_init_port(struct udevice *dev)return 0 ; err_power_off_phy: - ops->power_off (phy); +generic_phy_power_off (&priv->pcie_phy); err_exit_phy: - ops->exit (phy); +generic_phy_exit (&priv->pcie_phy);return ret; }
@@ -436,6 +434,12 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)return ret; } + ret =generic_phy_get_by_index (dev,0 , &priv->pcie_phy); +if (ret) { +dev_err (dev,"failed to get pcie-phy (ret=%d)\n" , ret); +return ret; + } +return 0 ; }
@@ -453,10 +457,6 @@ static int rockchip_pcie_probe(struct udevice *dev)if (ret)return ret; - ret =rockchip_pcie_phy_get (dev); -if (ret) -return ret; - ret =rockchip_pcie_set_vpcie (dev);if (ret)return ret;
drivers/pci/pcie_rockchip.h +5 -0
@@ -9,6 +9,8 @@* */ +#include <generic-phy.h> +#define HIWORD_UPDATE (mask, val) (((mask) << 16) | (val))#define HIWORD_UPDATE_BIT (val) HIWORD_UPDATE(val, val)
@@ -126,6 +128,9 @@ struct rockchip_pcie {struct udevice *vpcie3v3;struct udevice *vpcie1v8;struct udevice *vpcie0v9; + +/* phy */ +struct phy pcie_phy; };int rockchip_pcie_phy_get (struct udevice *dev);
Signature · 1 line
2.17.1
RFC 7/7 pci: rockchip: Drop legacy PHY driver
In reply to a message not in the archiveDrop the legacy PHY driver and it's associated code since the PHY handling driver now part of Generic PHY framework.
--- drivers/pci/Makefile | 2 +- drivers/pci/pcie_rockchip.c | 75 +++++++++++- drivers/pci/pcie_rockchip.h | 147 ----------------------- drivers/pci/pcie_rockchip_phy.c | 205 -------------------------------- 4 files changed, 74 insertions(+), 355 deletions(-) delete mode 100644 drivers/pci/pcie_rockchip.h delete mode 100644 drivers/pci/pcie_rockchip_phy.c
drivers/pci/Makefile +1 -1
@@ -43,4 +43,4 @@ obj-$(CONFIG_PCI_PHYTIUM) += pcie_phytium.o obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o -obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o pcie_rockchip_phy.o +obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o
drivers/pci/pcie_rockchip.c +73 -2
89 lines not on this page · raw message
drivers/pci/pcie_rockchip.h deleted +0 -147
147 lines not on this page · raw message
drivers/pci/pcie_rockchip_phy.c deleted +0 -205
205 lines not on this page · raw message
Signature · 1 line
2.17.1