Add Naneng multi phy support for rk3568
v6 cover Add Naneng multi phy support for rk3568
=============================================
TEST COMPILED ONLY!
Driver not verified with hardware!
Produced in the hope that we can get some review progress with this serie for the documents and driver. Use at your own risk!
Renamed the combi phy driver to multi phy to highlight the different approach and not to confuse with the driver from the Rockchip manufacturer tree. By using a parent node it makes it hopefully easier to coordinate for new futures/functions between nodes.
Removed a few properties, because it's not entire clear how they should be used. To prevent the obligation to keep supporting them despite changed handling.
=============================================
Changes in v6:
- restyle
- rename defines
- change from comb to multi phy
- clean up includes
- add parent node
- change compatible strings
- remove rockchip,sgmii-mac-sel support
- remove rockchip,dis-u3otg0-port support
- remove rockchip,dis-u3otg1-port support
Changes in v5:
- modify description for ssc and ext-refclk
- remove apb reset
- add rockchip_combphy_updatel()
- restyle
Changes in v4:
- restyle
- remove some minItems
- add more properties
- remove reset-names
- move #phy-cells
- add rockchip,rk3568-pipe-grf
- add rockchip,rk3568-pipe-phy-grf
- add devm_reset_control_array_get()
- remove clk structure
- change refclk DT parse
- change dev_err message
- add dot to phrase
- add ext_refclk variable
- add enable_ssc variable
- rename rockchip_combphy_param_write
- remove param_read
- replace rockchip-naneng-combphy driver name
- rename node name
Changes in v3:
- Using api devm_reset_control_get_optional_exclusive and dev_err_probe.
- Remove apb_rst.
- Redefine registers address.
- Move pipe_phy_grf0 to rk3568.dtsi
Changes in v2:
- Fix dtschema/dtc warnings/errors
- Using api devm_platform_get_and_ioremap_resource.
- Modify rockchip_combphy_set_Mode.
- Add some PHY registers definition.
- Move phy0 to rk3568.dtsi
Johan Jonker (1):
dt-bindings: mfd: syscon: add naneng multi phy register compatible
Yifeng Zhao (3):
dt-bindings: phy: rockchip: add naneng multi phy bindings
phy: rockchip: add naneng multi phy for rk3568
arm64: dts: rockchip: add naneng multi phy nodes for rk3568
.../devicetree/bindings/mfd/syscon.yaml | 2 + .../phy/phy-rockchip-naneng-multiphy.yaml | 167 +++++ arch/arm64/boot/dts/rockchip/rk3566.dtsi | 4 + arch/arm64/boot/dts/rockchip/rk3568.dtsi | 23 + arch/arm64/boot/dts/rockchip/rk356x.dtsi | 50 ++ drivers/phy/rockchip/Kconfig | 8 + drivers/phy/rockchip/Makefile | 1 + .../rockchip/phy-rockchip-naneng-multiphy.c | 661 ++++++++++++++++++ 8 files changed, 916 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-naneng-multiphy.yaml create mode 100644 drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Signature · 1 line
2.20.1
RFC PATCH v6 1/4 dt-bindings: mfd: syscon: add naneng multi phy register compatible
Add Naneng multi phy register compatible.
--- Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
@@ -52,6 +52,8 @@ properties: - rockchip,rk3288-qos - rockchip,rk3368-qos - rockchip,rk3399-qos + - rockchip,rk3568-pipe-grf + - rockchip,rk3568-pipe-phy-grf - rockchip,rk3568-qos - samsung,exynos3-sysreg - samsung,exynos4-sysreg
Signature · 1 line
2.20.1
Re: [RFC PATCH v6 1/4] dt-bindings: mfd: syscon: add naneng multi phy register compatible
Hi Heiko,
The file grf.yaml is already pretty full with legacy stuff. Now rockchip,rk3568-usb2phy-grf is added, would you like these two compatible strings also there?
Could you give advice to Yifeng?
Kind regards,
Johan Jonker
Quoted 23 lines · Johan Jonker
Add Naneng multi phy register compatible.
Signed-off-by Johan Jonker <[email protected]>Signed-off-by Yifeng Zhao <[email protected]>Acked-by Rob Herring <[email protected]>--- Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/mfd/syscon.yaml +2
-0@@ -52,6 +52,8 @@ properties: - rockchip,rk3288-qos - rockchip,rk3368-qos - rockchip,rk3399-qos + - rockchip,rk3568-pipe-grf + - rockchip,rk3568-pipe-phy-grf - rockchip,rk3568-qos - samsung,exynos3-sysreg - samsung,exynos4-sysreg
Heiko Stübner
maintainerRe: [RFC PATCH v6 1/4] dt-bindings: mfd: syscon: add naneng multi phy register compatible
Hi Johan, Yifeng,
Am Dienstag, 28. Dezember 2021, 13:08:00 CET schrieb Johan Jonker:
Quoted 1 line
The file
grf.yamlis already pretty full with legacy stuff.
I wouldn't call that legacy stuff ;-) .
The grf as "dumping ground" for more or less unsorted parts will probably stay around in future socs as well.
Quoted 2 lines
Now rockchip,rk3568-usb2phy-grf is added, would you like these two compatible strings also there?
I guess that makes sense. The grf.yaml is a better match for grf compatible strings I guess.
Heiko
Quoted 32 lines
Could you give advice to Yifeng?
Kind regards,
Johan Jonker
Quoted 23 lines · Johan Jonker
Add Naneng multi phy register compatible.
Signed-off-by Johan Jonker <[email protected]>Signed-off-by Yifeng Zhao <[email protected]>Acked-by Rob Herring <[email protected]>--- Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/mfd/syscon.yaml +2
-0@@ -52,6 +52,8 @@ properties: - rockchip,rk3288-qos - rockchip,rk3368-qos - rockchip,rk3399-qos + - rockchip,rk3568-pipe-grf + - rockchip,rk3568-pipe-phy-grf - rockchip,rk3568-qos - samsung,exynos3-sysreg - samsung,exynos4-sysreg
RFC PATCH v6 2/4 dt-bindings: phy: rockchip: add naneng multi phy bindings
In reply to Johan JonkerFrom: Yifeng Zhao <[email protected]>
Add the compatible strings for the Naneng multi phy found on Rockchip SoCs.
---
Changes in v6:
- change from comb to multi phy
- add parent node
- change compatible strings
- remove rockchip,sgmii-mac-sel
- remove rockchip,dis-u3otg0-port
- remove rockchip,dis-u3otg1-port
Changes in v5:
- modify description for ssc and ext-refclk
- remove apb reset
Changes in v4:
- restyle
- remove some minItems
- add more properties
- remove reset-names
- move #phy-cells
- add rockchip,rk3568-pipe-grf
- add rockchip,rk3568-pipe-phy-grf
Changes in v3: None
Changes in v2:
- Fix dtschema/dtc warnings/errors
--- .../phy/phy-rockchip-naneng-multiphy.yaml | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-naneng-multiphy.yaml
Documentation/devicetree/bindings/phy/phy-rockchip-naneng-multiphy.yaml new file +167 -0
@@ -0,0 +1,167 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/phy-rockchip-naneng-multiphy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip SoC Naneng Multi Phy Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +properties: + compatible: + enum: + - rockchip,rk3566-naneng-multiphy + - rockchip,rk3568-naneng-multiphy + + rockchip,pipe-grf: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Some additional phy settings are accessed through GRF regs. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +patternProperties: + "multi-phy@[0-9a-f]+$": + type: object + + properties: + reg: + maxItems: 1 + + clocks: + items: + - description: reference clock + - description: apb clock + - description: pipe clock + + clock-names: + items: + - const: ref + - const: apb + - const: pipe + + resets: + items: + - description: exclusive PHY reset line + + rockchip,enable-ssc: + type: boolean + description: + The option SSC can be enabled for U3, SATA and PCIE. + Most commercially available platforms use SSC to reduce EMI. + + rockchip,ext-refclk: + type: boolean + description: + Many PCIe connections, especially backplane connections, + require a synchronous reference clock between the two link partners. + To achieve this a common clock source, referred to as REFCLK in + the PCI Express Card Electromechanical Specification, + should be used by both ends of the PCIe link. + In PCIe mode one can choose to use an internal + or an external reference clock. + By default the internal clock is selected. The PCIe PHY provides a 100MHz + differential clock output(optional with SSC) for system applications. + When selecting this option an externally 100MHz differential + reference clock needs to be provided to the PCIe PHY. + + rockchip,pipe-phy-grf: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Some additional pipe settings are accessed through GRF regs. + + "#phy-cells": + const: 1 + + required: + - reg + - clocks + - clock-names + - resets + - rockchip,pipe-phy-grf + - "#phy-cells" + + additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/rk3568-cru.h> + + pipegrf: syscon@fdc50000 { + compatible = "rockchip,rk3568-pipe-grf", "syscon"; + reg = <0xfdc50000 0x1000>; + }; + + pipe_phy_grf0: syscon@fdc70000 { + compatible = "rockchip,rk3568-pipe-phy-grf", "syscon"; + reg = <0xfdc70000 0x1000>; + }; + + pipe_phy_grf1: syscon@fdc80000 { + compatible = "rockchip,rk3568-pipe-phy-grf", "syscon"; + reg = <0xfdc80000 0x1000>; + }; + + pipe_phy_grf2: syscon@fdc90000 { + compatible = "rockchip,rk3568-pipe-phy-grf", "syscon"; + reg = <0xfdc90000 0x1000>; + }; + + multiphy: multiphy { + compatible = "rockchip,rk3568-naneng-multiphy"; + rockchip,pipe-grf = <&pipegrf>; + #address-cells = <2>; + #size-cells = <2>; + + multiphy0: multi-phy@fe820000 { + reg = <0x0 0xfe820000 0x0 0x100>; + clocks = <&pmucru CLK_PCIEPHY0_REF>, + <&cru PCLK_PIPEPHY0>, + <&cru PCLK_PIPE>; + clock-names = "ref", "apb", "pipe"; + assigned-clocks = <&pmucru CLK_PCIEPHY0_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_PIPEPHY0>; + rockchip,pipe-phy-grf = <&pipe_phy_grf0>; + #phy-cells = <1>; + }; + + multiphy1: multi-phy@fe830000 { + reg = <0x0 0xfe830000 0x0 0x100>; + clocks = <&pmucru CLK_PCIEPHY1_REF>, + <&cru PCLK_PIPEPHY1>, + <&cru PCLK_PIPE>; + clock-names = "ref", "apb", "pipe"; + assigned-clocks = <&pmucru CLK_PCIEPHY1_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_PIPEPHY1>; + rockchip,pipe-phy-grf = <&pipe_phy_grf1>; + #phy-cells = <1>; + }; + + multiphy2: multi-phy@fe840000 { + reg = <0x0 0xfe840000 0x0 0x100>; + clocks = <&pmucru CLK_PCIEPHY2_REF>, + <&cru PCLK_PIPEPHY2>, + <&cru PCLK_PIPE>; + clock-names = "ref", "apb", "pipe"; + assigned-clocks = <&pmucru CLK_PCIEPHY2_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_PIPEPHY2>; + rockchip,pipe-phy-grf = <&pipe_phy_grf2>; + #phy-cells = <1>; + }; + };
Signature · 1 line
2.20.1
RFC PATCH v6 3/4 phy: rockchip: add naneng multi phy for rk3568
In reply to Johan JonkerFrom: Yifeng Zhao <[email protected]>
This patch implements a multi phy driver for Rockchip SoCs with NaNeng IP block. This phy can be used as pcie-phy, usb3-phy, sata-phy or sgmii-phy.
---
TEST COMPILED ONLY!
Driver not verified with hardware!
---
Changes in v6:
- restyle
- rename defines
- change from comb to multi phy
- clean up includes
- add parent node
- change compatible strings
- remove rockchip,sgmii-mac-sel support
- remove rockchip,dis-u3otg0-port support
- remove rockchip,dis-u3otg1-port support
Changes in v5:
- add rockchip_combphy_updatel()
- restyle
Changes in v4:
- restyle
- add devm_reset_control_array_get()
- remove clk structure
- change refclk DT parse
- change dev_err message
- add dot to phrase
- add ext_refclk variable
- add enable_ssc variable
- rename rockchip_combphy_param_write
- remove param_read
- replace rockchip-naneng-combphy driver name
Changes in v3:
- Using api devm_reset_control_get_optional_exclusive and dev_err_probe.
- Remove apb_rst.
- Redefine registers address.
Changes in v2:
- Using api devm_platform_get_and_ioremap_resource.
- Modify rockchip_combphy_set_Mode.
- Add some PHY registers definition.
--- drivers/phy/rockchip/Kconfig | 8 + drivers/phy/rockchip/Makefile | 1 + .../rockchip/phy-rockchip-naneng-multiphy.c | 661 ++++++++++++++++++ 3 files changed, 670 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
drivers/phy/rockchip/Kconfig +8 -0
@@ -66,6 +66,14 @@ config PHY_ROCKCHIP_INNO_DSIDPHY Enable this to support the Rockchip MIPI/LVDS/TTL PHY with Innosilicon IP block. +config PHY_ROCKCHIP_NANENG_MULTI_PHY + tristate "Rockchip NANENG MULTI PHY Driver" + depends on ARCH_ROCKCHIP && OF + select GENERIC_PHY + help + Enable this to support the Rockchip PCIe/USB3.0/SATA/QSGMII + multi PHY with NaNeng IP block. + config PHY_ROCKCHIP_PCIE tristate "Rockchip PCIe PHY Driver" depends on (ARCH_ROCKCHIP && OF) || COMPILE_TEST
drivers/phy/rockchip/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_CSIDPHY) += phy-rockchip-inno-csidphy.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY) += phy-rockchip-inno-dsidphy.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI) += phy-rockchip-inno-hdmi.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o +obj-$(CONFIG_PHY_ROCKCHIP_NANENG_MULTI_PHY) += phy-rockchip-naneng-multiphy.o obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +661 -0
661 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [RFC PATCH v6 3/4] phy: rockchip: add naneng multi phy for rk3568
Hi Yifeng and others,
Some comments,have a look if it's useful.
If you like the multi phy approuch:
Could you carefully test with hardware and tell us what part of the code works or not and what to improve.
Produce a version 7 based on the code ideas and the comments below.
Kind regards,
Johan Jonker
Quoted 164 lines · Johan Jonker
From: Yifeng Zhao <[email protected]>
This patch implements a multi phy driver for Rockchip SoCs with NaNeng IP block. This phy can be used as pcie-phy, usb3-phy, sata-phy or sgmii-phy.
Signed-off-by Yifeng Zhao <[email protected]>Signed-off-by Johan Jonker <[email protected]>---
TEST COMPILED ONLY!
Driver not verified with hardware!---
Changes in v6:
- restyle
- rename defines
- change from comb to multi phy
- clean up includes
- add parent node
- change compatible strings
- remove rockchip,sgmii-mac-sel support
- remove rockchip,dis-u3otg0-port support
- remove rockchip,dis-u3otg1-port supportChanges in v5:
- addrockchip_combphy_updatel()
- restyleChanges in v4:
- restyle
- adddevm_reset_control_array_get()
- remove clk structure
- change refclk DT parse
- changedev_errmessage
- add dot to phrase
- addext_refclkvariable
- addenable_sscvariable
- renamerockchip_combphy_param_write
- removeparam_read
- replace rockchip-naneng-combphy driver nameChanges in v3:
- Using apidevm_reset_control_get_optional_exclusiveanddev_err_probe.
- Removeapb_rst.
- Redefine registers address.Changes in v2:
- Using apidevm_platform_get_and_ioremap_resource.
- Modifyrockchip_combphy_set_Mode.
- Add some PHY registers definition.--- drivers/phy/rockchip/Kconfig | 8 + drivers/phy/rockchip/Makefile | 1 + .../rockchip/phy-rockchip-naneng-multiphy.c | 661 ++++++++++++++++++ 3 files changed, 670 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-naneng-multiphy.cdrivers/phy/rockchip/Kconfig +8
-0@@ -66,6 +66,14 @@ config PHY_ROCKCHIP_INNO_DSIDPHY Enable this to support the Rockchip MIPI/LVDS/TTL PHY with Innosilicon IP block. +config PHY_ROCKCHIP_NANENG_MULTI_PHY + tristate "Rockchip NANENG MULTI PHY Driver" + depends on ARCH_ROCKCHIP && OF + select GENERIC_PHY + help + Enable this to support the Rockchip PCIe/USB3.0/SATA/QSGMII + multi PHY with NaNeng IP block. + config PHY_ROCKCHIP_PCIE tristate "Rockchip PCIe PHY Driver" depends on (ARCH_ROCKCHIP && OF) || COMPILE_TESTdrivers/phy/rockchip/Makefile +1
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_CSIDPHY) += phy-rockchip-inno-csidphy.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY) += phy-rockchip-inno-dsidphy.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI) += phy-rockchip-inno-hdmi.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o +obj-$(CONFIG_PHY_ROCKCHIP_NANENG_MULTI_PHY) += phy-rockchip-naneng-multiphy.o obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.odrivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +68
-0@@ -0,0 +1,661 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Rockchip PIPE USB3.0 PCIE SATA Multi Phy driver +* +* Copyright (C) 2021 Rockchip Electronics Co., Ltd. +*/ + +#include <dt-bindings/phy/phy.h> +#include <linux/clk.h> +#include <linux/mfd/syscon.h> +#include <linux/of_address.h> +#include <linux/of_device.h> +#include <linux/phy/phy.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/units.h> + +#define BIT_WRITEABLE_SHIFT 16 +#define REF_CLOCK_24MHz (24 * HZ_PER_MHZ) +#define REF_CLOCK_25MHz (25 * HZ_PER_MHZ) +#define REF_CLOCK_100MHz (100 * HZ_PER_MHZ) + +/* RK3568 MULTI PHY REG */ +#define RK3568_PHYREG6 0x14 +#define PHYREG6_PLL_DIV_MASK GENMASK(7, 6) +#define PHYREG6_PLL_DIV_SHIFT 6 +#define PHYREG6_PLL_DIV_2 1 + +#define RK3568_PHYREG7 0x18 +#define PHYREG7_TX_RTERM_MASK GENMASK(7, 4) +#define PHYREG7_TX_RTERM_SHIFT 4 +#define PHYREG7_TX_RTERM_50OHM 8 +#define PHYREG7_RX_RTERM_MASK GENMASK(3, 0) +#define PHYREG7_RX_RTERM_SHIFT 0 +#define PHYREG7_RX_RTERM_44OHM 15 + +#define RK3568_PHYREG8 0x1C +#define PHYREG8_SSC_EN BIT(4) + +#define RK3568_PHYREG11 0x28 +#define PHYREG11_SU_TRIM_0_7 0xF0 + +#define RK3568_PHYREG12 0x2C +#define PHYREG12_PLL_LPF_ADJ_VALUE 4 + +#define RK3568_PHYREG13 0x30 +#define PHYREG13_RESISTER_MASK GENMASK(5, 4) +#define PHYREG13_RESISTER_SHIFT 0x4 +#define PHYREG13_RESISTER_HIGH_Z 3 +#define PHYREG13_CKRCV_AMP0 BIT(7) + +#define RK3568_PHYREG14 0x34 +#define PHYREG14_CKRCV_AMP1 BIT(0) + +#define RK3568_PHYREG15 0x38 +#define PHYREG15_CTLE_EN BIT(0) +#define PHYREG15_SSC_CNT_MASK GENMASK(7, 6) +#define PHYREG15_SSC_CNT_SHIFT 6 +#define PHYREG15_SSC_CNT_VALUE 1 + +#define RK3568_PHYREG16 0x3C +#define PHYREG16_SSC_CNT_VALUE 0x5f + +#define RK3568_PHYREG18 0x44 +#define PHYREG18_PLL_LOOP 0x32 + +#define RK3568_PHYREG32 0x7C +#define PHYREG32_SSC_MASK GENMASK(7, 4)
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 78
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+#define PHYREG32_SSC_DIR_SHIFT 4 +#define PHYREG32_SSC_UPWARD 0 +#define PHYREG32_SSC_DOWNWARD 1 +#define PHYREG32_SSC_OFFSET_SHIFT 6 +#define PHYREG32_SSC_OFFSET_500PPM 1 + +#define RK3568_PHYREG33 0x80 +#define PHYREG33_PLL_KVCO_MASK GENMASK(4, 2) +#define PHYREG33_PLL_KVCO_SHIFT 2 +#define PHYREG33_PLL_KVCO_VALUE 2
/* RK3588 MULTI PHY REG */
Add more defines.
Quoted 33 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +33
-0+ +struct rockchip_multiphy_priv ; + +struct multiphy_reg { +u16 offset; +u16 bitend; +u16 bitstart; +u16 disable; +u16 enable; +}; + +struct rockchip_multiphy_grfcfg { +struct multiphy_reg pcie_mode_set; +struct multiphy_reg usb_mode_set; +struct multiphy_reg sgmii_mode_set; +struct multiphy_reg qsgmii_mode_set; +struct multiphy_reg pipe_rxterm_set; +struct multiphy_reg pipe_txelec_set; +struct multiphy_reg pipe_txcomp_set; +struct multiphy_reg pipe_clk_25m; +struct multiphy_reg pipe_clk_100m; +struct multiphy_reg pipe_phymode_sel; +struct multiphy_reg pipe_rate_sel; +struct multiphy_reg pipe_rxterm_sel; +struct multiphy_reg pipe_txelec_sel; +struct multiphy_reg pipe_txcomp_sel; +struct multiphy_reg pipe_clk_ext; +struct multiphy_reg pipe_sel_usb; +struct multiphy_reg pipe_sel_qsgmii; +struct multiphy_reg pipe_phy_status; +struct multiphy_reg con0_for_pcie; +struct multiphy_reg con1_for_pcie; +struct multiphy_reg con2_for_pcie;
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 121
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+struct multiphy_reg con3_for_pcie; +struct multiphy_reg con0_for_sata; +struct multiphy_reg con1_for_sata; +struct multiphy_reg con2_for_sata; +struct multiphy_reg con3_for_sata; +struct multiphy_reg pipe_con0_for_sata; +struct multiphy_reg pipe_sgmii_mac_sel; +struct multiphy_reg pipe_xpcs_phy_ready; +struct multiphy_reg u3otg0_port_en; +struct multiphy_reg u3otg1_port_en;
.num_phy
.regs
.cap
Add more phy properties for checks and control.
Quoted 155 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +155
-0+}; + +struct rockchip_multiphy_cfg { +const struct rockchip_multiphy_grfcfg *grfcfg; +int (*multiphy_cfg)(struct phy *phy); +}; + +struct rockchip_multiphy_node_priv { +int id; +u8 mode; +void __iomem *mmio; +int num_clks; +struct clk_bulk_data *clks; +struct regmap *phy_grf; +struct phy *phy; +struct reset_control *phy_rst; +struct clk *refclk; +bool enable_ssc; +bool ext_refclk; +}; + +struct rockchip_multiphy_priv { +struct device *dev; +int num_phy; +struct regmap *pipe_grf; +const struct rockchip_multiphy_cfg *cfg; +struct rockchip_multiphy_node_priv **node; +}; + +static void rockchip_multiphy_updatel (struct phy *phy,int mask,int val,int reg) +{ +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +unsigned int temp; + + temp =readl (node_priv->mmio + reg); + temp = (temp & ~(mask)) | val; +writel (temp, node_priv->mmio + reg); +} + +static int rockchip_multiphy_param_write (struct regmap *base, +const struct multiphy_reg *reg,bool en) +{ +u32 val, mask, tmp; + + tmp = en ? reg->enable : reg->disable; + mask =GENMASK (reg->bitend, reg->bitstart); + val = (tmp << reg->bitstart) | (mask <<BIT_WRITEABLE_SHIFT ); + +return regmap_write (base, reg->offset, val); +} + +static u32 rockchip_multiphy_is_ready (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +const struct rockchip_multiphy_grfcfg *cfg = priv->cfg->grfcfg; +u32 mask, val; + + mask =GENMASK (cfg->pipe_phy_status.bitend, + cfg->pipe_phy_status.bitstart); + +regmap_read (node_priv->phy_grf, cfg->pipe_phy_status.offset, &val); + val = (val & mask) >> cfg->pipe_phy_status.bitstart; + +return val; +} + +static int rockchip_multiphy_set_mode (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +int ret =0 ; + +switch (node_priv->mode) { +case PHY_TYPE_PCIE : +case PHY_TYPE_USB3 : +case PHY_TYPE_SATA : +case PHY_TYPE_SGMII : +case PHY_TYPE_QSGMII : +if (priv->cfg->multiphy_cfg) + ret = priv->cfg->multiphy_cfg (phy); +break ; +default : +dev_err (priv->dev,"incompatible PHY type\n" ); +return -EINVAL ; + } + +if (ret) +dev_err (priv->dev,"failed to init phy for phy mode %x\n" , node_priv->mode); + +return ret; +} + +static int rockchip_multiphy_init (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +const struct rockchip_multiphy_grfcfg *cfg = priv->cfg->grfcfg; +u32 val; +int ret; + + ret =clk_bulk_prepare_enable (node_priv->num_clks, node_priv->clks); +if (ret) { +dev_err (priv->dev,"failed to enable clks\n" ); +return ret; + } + + ret =rockchip_multiphy_set_mode (phy); +if (ret) + goto err_clk; + + ret =reset_control_deassert (node_priv->phy_rst); +if (ret) + goto err_clk; + +if (node_priv->mode ==PHY_TYPE_USB3 ) { + ret =readx_poll_timeout_atomic (rockchip_multiphy_is_ready, + phy, val, + val == cfg->pipe_phy_status.enable, +10 ,1000 ); +if (ret) +dev_warn (priv->dev,"wait phy status ready timeout\n" ); + } + +return 0 ; + +err_clk: +clk_bulk_disable_unprepare (node_priv->num_clks, node_priv->clks); + +return ret; +} + +static int rockchip_multiphy_exit (struct phy *phy) +{ +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); + +clk_bulk_disable_unprepare (node_priv->num_clks, node_priv->clks); +reset_control_assert (node_priv->phy_rst); + +return 0 ; +} + +static const struct phy_ops rochchip_multiphy_ops = { + .init = rockchip_multiphy_init, + .exit = rockchip_multiphy_exit, + .owner =THIS_MODULE , +}; + +static struct phy *rockchip_multiphy_xlate (struct device *dev,struct of_phandle_args *args) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (dev); +struct rockchip_multiphy_node_priv *node_priv =NULL ; +struct device_node *phy_np = args->np; +int index; +
[..]
Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +7
-0+ +for (index =0 ; index < priv->num_phy; index++) +if (phy_np == priv->node[index]->phy->dev.of_node) { + node_priv = priv->node[index]; +break ; + } +
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 297
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+if (!node_priv) { +dev_err (dev,"failed to find appropriate phy\n" ); +return ERR_PTR (-EINVAL ); + } + +if (node_priv->mode !=PHY_NONE && node_priv->mode != args->args[0 ]) +dev_warn (dev,"phy type select %d overwriting type %d\n" , + args->args[0 ], node_priv->mode); + + node_priv->mode = args->args[0 ];
if ((node_priv->mode == PHY_TYPE_SGMII && args->args_count != 2) ||
(node_priv->mode != PHY_TYPE_SGMII && args->args_count != 1) {
dev_err(dev, "invalid number of arguments\n");
return ERR_PTR(-EINVAL);
}Check number of argument based on capabillity.
===
if (node_priv->mode != priv->cap[node_priv->id]) {
dev_err(dev, "invalid mode\n");
return ERR_PTR(-EINVAL);
}Check mode and id with phy node capabilities.
===
if (node_priv->mode == PHY_TYPE_SGMII && args->args[1] == 0 ||
args->args[1] == 1)
node_priv->sgmii-mac-sel = args->args[1];
else {
dev_err(dev, "invalid gmac id\n");
return ERR_PTR(-EINVAL);
}Maybe obtain SGMII output from extra phy argument. Fix YAML document as well!
Quoted 17 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +17
-0+ +return node_priv->phy; +} + +static int rockchip_multiphy_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node; +struct device_node *child_np; +struct phy_provider *phy_provider; +struct resource res; +struct rockchip_multiphy_priv *priv; +int retval; +int id; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv)
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 323
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +9
-0+return -ENOMEM ; + + priv->cfg =of_device_get_match_data (dev); +if (!priv->cfg) { +dev_err (dev,"no OF match data provided\n" ); +return -EINVAL ; + } + + priv->num_phy =of_get_child_count (np);
Check priv->num_phy with max SoC capabilities.
Quoted 42 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +42
-0+ priv->node =devm_kcalloc (dev, priv->num_phy,sizeof (*priv->node),GFP_KERNEL ); +if (!priv->node) +return -ENOMEM ; + + priv->dev = dev; +dev_set_drvdata (dev, priv); + + priv->pipe_grf =syscon_regmap_lookup_by_phandle (dev->of_node,"rockchip,pipe-grf" ); +if (IS_ERR (priv->pipe_grf)) { +dev_err (dev,"failed to find peri_ctrl pipe-grf regmap\n" ); +return PTR_ERR (priv->pipe_grf); + } + + id =0 ; +for_each_child_of_node (np, child_np) { +struct rockchip_multiphy_node_priv *node_priv; +struct device *subdev; +struct phy *phy; +int i; + + node_priv =devm_kzalloc (dev,sizeof (*node_priv),GFP_KERNEL ); +if (!node_priv) { + retval = -ENOMEM ; + goto put_child; + } + + priv->node[id] = node_priv; + + phy =devm_phy_create (dev, child_np, &rochchip_multiphy_ops); +if (IS_ERR (phy)) { +dev_err (dev,"failed to create phy\n" ); + retval =PTR_ERR (phy); + goto put_child; + } + + subdev = &phy->dev; + retval =of_address_to_resource (child_np,0 , &res); +if (retval) { +dev_err (subdev,"failed to get address resource(id-%d)\n" , + id); + goto put_child; + }
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 374
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +9
-0+ + node_priv->mmio =devm_ioremap_resource (subdev, &res); +if (IS_ERR (node_priv->mmio)) { + retval =PTR_ERR (node_priv->mmio); + goto put_child; + } + + node_priv->phy = phy; + node_priv->id = id;
For a mode check based on id and phy node capabilities the id has to be based on reg address DT order.
Currently node_priv->id is based on node order.
Check reg address with a table and assign id from table index.
Quoted 192 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +192
-0+ node_priv->mode =PHY_NONE ; + id++; + +phy_set_drvdata (phy, node_priv); + + node_priv->num_clks =devm_clk_bulk_get_all (dev, &node_priv->clks); +if (node_priv->num_clks <1 ) { + retval = -EINVAL ; + goto put_child; + } + + node_priv->refclk =NULL ; +for (i =0 ; i < node_priv->num_clks; i++) { +if (!strncmp (node_priv->clks[i].id,"ref" ,3 )) { + node_priv->refclk = node_priv->clks[i].clk; +break ; + } + } + +if (!node_priv->refclk) { +dev_err (dev,"no refclk found\n" ); + retval = -EINVAL ; + goto put_child; + } + + node_priv->phy_grf =syscon_regmap_lookup_by_phandle (dev->of_node, +"rockchip,pipe-phy-grf" ); +if (IS_ERR (node_priv->phy_grf)) { + retval =PTR_ERR (node_priv->phy_grf); +dev_err (dev,"failed to find pipe-phy-grf regmap\n" ); + goto put_child; + } + + node_priv->enable_ssc =device_property_present (dev,"rockchip,enable-ssc" ); + + node_priv->ext_refclk =device_property_present (dev,"rockchip,ext-refclk" ); + + node_priv->phy_rst =devm_reset_control_array_get (dev, false, false); +if (IS_ERR (node_priv->phy_rst)) { + retval =PTR_ERR (node_priv->phy_rst); +dev_err (dev,"failed to get phy reset\n" ); + goto put_child; + } + + retval =reset_control_assert (node_priv->phy_rst); +if (retval) { +dev_err (dev,"failed to reset phy\n" ); + goto put_child; + } + } + + phy_provider =devm_of_phy_provider_register (dev, rockchip_multiphy_xlate); + +return PTR_ERR_OR_ZERO (phy_provider); +put_child: +of_node_put (child_np); +return retval; +} + +static int rk3568_multiphy_cfg (struct phy *phy) +{ +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +const struct rockchip_multiphy_grfcfg *cfg = priv->cfg->grfcfg; +unsigned long rate; +u32 val; + +switch (node_priv->mode) { +case PHY_TYPE_PCIE : +/* Set SSC downward spread spectrum. */ +rockchip_multiphy_updatel (phy,PHYREG32_SSC_MASK , +PHYREG32_SSC_DOWNWARD <<PHYREG32_SSC_DIR_SHIFT , +RK3568_PHYREG32 ); + +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con0_for_pcie, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con1_for_pcie, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con2_for_pcie, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con3_for_pcie, true); +break ; + +case PHY_TYPE_USB3 : +/* Set SSC downward spread spectrum. */ +rockchip_multiphy_updatel (phy,PHYREG32_SSC_MASK , +PHYREG32_SSC_DOWNWARD <<PHYREG32_SSC_DIR_SHIFT , +RK3568_PHYREG32 ); + +/* Enable adaptive CTLE for USB3.0 Rx. */ + val =readl (node_priv->mmio +RK3568_PHYREG15 ); + val |=PHYREG15_CTLE_EN ; +writel (val, node_priv->mmio +RK3568_PHYREG15 ); + +/* Set PLL KVCO fine tuning signals. */ +rockchip_multiphy_updatel (phy,PHYREG33_PLL_KVCO_MASK , +PHYREG33_PLL_KVCO_VALUE <<PHYREG33_PLL_KVCO_SHIFT , +RK3568_PHYREG33 ); + +/* Enable controlling random jitter. */ +writel (PHYREG12_PLL_LPF_ADJ_VALUE , node_priv->mmio +RK3568_PHYREG12 ); + +/* Set PLL input clock divider 1/2. */ +rockchip_multiphy_updatel (phy,PHYREG6_PLL_DIV_MASK , +PHYREG6_PLL_DIV_2 <<PHYREG6_PLL_DIV_SHIFT , +RK3568_PHYREG6 ); + +writel (PHYREG18_PLL_LOOP , node_priv->mmio +RK3568_PHYREG18 ); +writel (PHYREG11_SU_TRIM_0_7 , node_priv->mmio +RK3568_PHYREG11 ); + +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_sel_usb, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_txcomp_sel, false); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_txelec_sel, false); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->usb_mode_set, true); +break ; + +case PHY_TYPE_SATA : +/* Enable adaptive CTLE for SATA Rx. */ + val =readl (node_priv->mmio +RK3568_PHYREG15 ); + val |=PHYREG15_CTLE_EN ; +writel (val, node_priv->mmio +RK3568_PHYREG15 ); +/* +* Set tx_rterm=50ohm and rx_rterm=44ohm for SATA. +* 0: 60ohm, 8: 50ohm 15: 44ohm (by step abort 1ohm) +*/ + val =PHYREG7_TX_RTERM_50OHM <<PHYREG7_TX_RTERM_SHIFT ; + val |=PHYREG7_RX_RTERM_44OHM <<PHYREG7_RX_RTERM_SHIFT ; +writel (val, node_priv->mmio +RK3568_PHYREG7 ); + +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con0_for_sata, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con1_for_sata, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con2_for_sata, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->con3_for_sata, true); +rockchip_multiphy_param_write (priv->pipe_grf, &cfg->pipe_con0_for_sata, true); +break ; + +case PHY_TYPE_SGMII : +rockchip_multiphy_param_write (priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_phymode_sel, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_sel_qsgmii, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->sgmii_mode_set, true); +break ; + +case PHY_TYPE_QSGMII : +rockchip_multiphy_param_write (priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_phymode_sel, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_rate_sel, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_sel_qsgmii, true); +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->qsgmii_mode_set, true); +break ; + +default : +dev_err (priv->dev,"incompatible PHY type\n" ); +return -EINVAL ; + } + + rate =clk_get_rate (node_priv->refclk); + +switch (rate) { +case REF_CLOCK_24MHz: +if (node_priv->mode ==PHY_TYPE_USB3 || node_priv->mode ==PHY_TYPE_SATA ) { +/* Set ssc_cnt[9:0]=0101111101 & 31.5KHz. */ + val =PHYREG15_SSC_CNT_VALUE <<PHYREG15_SSC_CNT_SHIFT ; +rockchip_multiphy_updatel (phy,PHYREG15_SSC_CNT_MASK , + val,RK3568_PHYREG15 ); + +writel (PHYREG16_SSC_CNT_VALUE , node_priv->mmio +RK3568_PHYREG16 ); + } +break ; + +case REF_CLOCK_25MHz: +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_clk_25m, true); +break ; + +case REF_CLOCK_100MHz: +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_clk_100m, true); +if (node_priv->mode ==PHY_TYPE_PCIE ) { +/* PLL KVCO fine tuning. */ + val =PHYREG33_PLL_KVCO_VALUE <<PHYREG33_PLL_KVCO_SHIFT ; +rockchip_multiphy_updatel (phy,PHYREG33_PLL_KVCO_MASK , + val,RK3568_PHYREG33 ); + +/* Enable controlling random jitter. */ +writel (PHYREG12_PLL_LPF_ADJ_VALUE , node_priv->mmio +RK3568_PHYREG12 ); + + val =PHYREG6_PLL_DIV_2 <<PHYREG6_PLL_DIV_SHIFT ; +rockchip_multiphy_updatel (phy,PHYREG6_PLL_DIV_MASK , + val,RK3568_PHYREG6 ); + +writel (PHYREG18_PLL_LOOP , node_priv->mmio +RK3568_PHYREG18 ); +writel (PHYREG11_SU_TRIM_0_7 , node_priv->mmio +RK3568_PHYREG11 ); + }else if (node_priv->mode ==PHY_TYPE_SATA ) { +/* downward spread spectrum +500ppm */ + val =PHYREG32_SSC_DOWNWARD <<PHYREG32_SSC_DIR_SHIFT ; + val |=PHYREG32_SSC_OFFSET_500PPM <<PHYREG32_SSC_OFFSET_SHIFT ;
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 576
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+rockchip_multiphy_updatel (phy,PHYREG32_SSC_MASK , + val,RK3568_PHYREG32 ); +writel (val, node_priv->mmio +RK3568_PHYREG32 ); + } +break ; + +default : +dev_err (priv->dev,"unsupported rate: %lu\n" , rate); +return -EINVAL ; + }
condition1 = (SoC rk3568) && (id == 0) val = condition1 && (mode != USB3)? false : true; if (condition1) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->u3otg0_port_en, val);
condition2 = (SoC rk3566 or rk3568) && (id == 1) val = condition2 && (mode != USB3)? false : true; if (condition2) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->u3otg1_port_en, val);
========================
condition3 = (SoC rk3568) && (id == 1 || id == 2) && (mode == SGMII) val = condition3 && (node_priv->sgmii-mac-sel)? true : false; if (condition3) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->pipe_sgmii_mac_sel, val);
TODO:
Allow more phy data with:
YAML node:
"#phy-cells":
enum: [1, 2]DT node:
gmac0: ethernet@fe2a0000 {
phys = <&combphy1 PHY_TYPE_SGMII 0>;
phy-names = "sgmii-phy";or
phys = <&combphy2 PHY_TYPE_SGMII 0>;
phy-names = "sgmii-phy";
}
gmac1: ethernet@fe010000 {
phys = <&combphy1 PHY_TYPE_SGMII 1>;
phy-names = "sgmii-phy";or
phys = <&combphy2 PHY_TYPE_SGMII 1>; phy-names = "sgmii-phy"; }
Could someone test this idea?
Quoted 14 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +14
-0+ +if (node_priv->ext_refclk) { +rockchip_multiphy_param_write (node_priv->phy_grf, &cfg->pipe_clk_ext, true); +if (node_priv->mode ==PHY_TYPE_PCIE && rate == REF_CLOCK_100MHz) { + val =PHYREG13_RESISTER_HIGH_Z <<PHYREG13_RESISTER_SHIFT ; + val |=PHYREG13_CKRCV_AMP0 ; +rockchip_multiphy_updatel (phy,PHYREG13_RESISTER_MASK , + val,RK3568_PHYREG13 ); + + val =readl (node_priv->mmio +RK3568_PHYREG14 ); + val |=PHYREG14_CKRCV_AMP1 ; +writel (val, node_priv->mmio +RK3568_PHYREG14 ); + } + }
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 600
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+ +if (node_priv->enable_ssc) { + val =readl (node_priv->mmio +RK3568_PHYREG8 ); + val |=PHYREG8_SSC_EN ; +writel (val, node_priv->mmio +RK3568_PHYREG8 ); + } + +return 0 ; +} +
static const struct rockchip_multiphy_grfcfg rk3566_multiphy_grfcfgs = { [..]
Add maximum number of phy nodes for check with priv->num_phy.
.num_phy = 2,
Add reg addresses to detect phy id.
.regs =0xfe830000,0xfe840000,
Add table with SoC capabilities based on phy id.
PCie USB3 SATA SGMII
0: 0 x x 0 1: x x x 0
Don't confuse phy id with node label numbers!
};
Quoted 24 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +24
-0+static const struct rockchip_multiphy_grfcfg rk3568_multiphy_grfcfgs = { +/* pipe-phy-grf */ + .pcie_mode_set = {0x0000 ,5 ,0 ,0x00 ,0x11 }, + .usb_mode_set = {0x0000 ,5 ,0 ,0x00 ,0x04 }, + .sgmii_mode_set = {0x0000 ,5 ,0 ,0x00 ,0x01 }, + .qsgmii_mode_set = {0x0000 ,5 ,0 ,0x00 ,0x21 }, + .pipe_rxterm_set = {0x0000 ,12 ,12 ,0x00 ,0x01 }, + .pipe_txelec_set = {0x0004 ,1 ,1 ,0x00 ,0x01 }, + .pipe_txcomp_set = {0x0004 ,4 ,4 ,0x00 ,0x01 }, + .pipe_clk_25m = {0x0004 ,14 ,13 ,0x00 ,0x01 }, + .pipe_clk_100m = {0x0004 ,14 ,13 ,0x00 ,0x02 }, + .pipe_phymode_sel = {0x0008 ,1 ,1 ,0x00 ,0x01 }, + .pipe_rate_sel = {0x0008 ,2 ,2 ,0x00 ,0x01 }, + .pipe_rxterm_sel = {0x0008 ,8 ,8 ,0x00 ,0x01 }, + .pipe_txelec_sel = {0x0008 ,12 ,12 ,0x00 ,0x01 }, + .pipe_txcomp_sel = {0x0008 ,15 ,15 ,0x00 ,0x01 }, + .pipe_clk_ext = {0x000c ,9 ,8 ,0x02 ,0x01 }, + .pipe_sel_usb = {0x000c ,14 ,13 ,0x00 ,0x01 }, + .pipe_sel_qsgmii = {0x000c ,15 ,13 ,0x00 ,0x07 }, + .pipe_phy_status = {0x0034 ,6 ,6 ,0x01 ,0x00 }, + .con0_for_pcie = {0x0000 ,15 ,0 ,0x00 ,0x1000 }, + .con1_for_pcie = {0x0004 ,15 ,0 ,0x00 ,0x0000 }, + .con2_for_pcie = {0x0008 ,15 ,0 ,0x00 ,0x0101 }, + .con3_for_pcie = {0x000c ,15 ,0 ,0x00 ,0x0200 },
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 634
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +10
-0+ .con0_for_sata = { 0x0000, 15, 0, 0x00, 0x0119 }, + .con1_for_sata = { 0x0004, 15, 0, 0x00, 0x0040 }, + .con2_for_sata = { 0x0008, 15, 0, 0x00, 0x80c3 }, + .con3_for_sata = { 0x000c, 15, 0, 0x00, 0x4407 }, +/* pipe-grf */ + .pipe_con0_for_sata = { 0x0000, 15, 0, 0x00, 0x2220 }, + .pipe_sgmii_mac_sel = { 0x0040, 1, 1, 0x00, 0x01 }, + .pipe_xpcs_phy_ready = { 0x0040, 2, 2, 0x00, 0x01 }, + .u3otg0_port_en = { 0x0104, 15, 0, 0x0181, 0x1100 }, + .u3otg1_port_en = { 0x0144, 15, 0, 0x0181, 0x1100 },
Add maximum number of phy nodes for check with priv->num_phy.
.num_phy = 3,
Add reg addresses to detect phy id.
.regs =0xfe820000,0xfe830000,0xfe840000,
Add table with SoC capabilities based on phy id.
PCie USB3 SATA SGMII
0: 0 x x 0 1: 0 x x x 2: x x x x
Quoted 1 line
+};
static const struct rockchip_multiphy_grfcfg rk3588_multiphy_grfcfgs = { [..]
};
static const struct rockchip_multiphy_cfg rk3566_multiphy_cfgs = {
.grfcfg = &rk3566_multiphy_grfcfgs,
.multiphy_cfg = rk3568_multiphy_cfg,
};drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 640
Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +5
-0+ +static const struct rockchip_multiphy_cfg rk3568_multiphy_cfgs = { + .grfcfg = &rk3568_multiphy_grfcfgs, + .multiphy_cfg = rk3568_multiphy_cfg, +};
static const struct rockchip_multiphy_cfg rk3588_multiphy_cfgs = {
.grfcfg = &rk3588_multiphy_grfcfgs,
.multiphy_cfg = rk3588_multiphy_cfg,
};drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 644
Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +4
-0+ +static const struct of_device_id rockchip_multiphy_of_match[] = { + { .compatible ="rockchip,rk3566-naneng-multiphy" , + .data = &rk3568_multiphy_cfgs, },
.data = &rk3566_multiphy_cfgs, },
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c line 646
Quoted 2 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +2
-0+ { .compatible = "rockchip,rk3568-naneng-multiphy", + .data = &rk3568_multiphy_cfgs, },
{ .compatible = "rockchip,rk3588-naneng-multiphy",
.data = &rk3588_multiphy_cfgs, },Quoted 16 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c new file +15
-0+ { }, +}; +MODULE_DEVICE_TABLE (of, rockchip_multiphy_of_match); + +static struct platform_driver rockchip_multiphy_driver = { + .probe = rockchip_multiphy_probe, + .driver = { + .name ="rockchip-naneng-multiphy" , + .of_match_table = rockchip_multiphy_of_match, + }, +}; +module_platform_driver (rockchip_multiphy_driver); + +MODULE_DESCRIPTION ("Rockchip NANENG MULTIPHY driver" ); +MODULE_LICENSE ("GPL v2" );
Re: Re: [RFC PATCH v6 3/4] phy: rockchip: add naneng multi phy for rk3568
Hi,Johan
Thank you very much for submitting the changes,
but I think version 6 is complicated about add
a phy_id. The three combo phys are exactly the same,
They have independent registers with the same
definitions, including GRF configuration, so that
PHY drive can be simple, and differentiated parts
can be configured through DTS.
The version 5 driver is easy to supports RK3588, and
remains compatible with our RK3568 mass-produced devices.
I will produce a version 7 based on the version 5.
The changes are as follows:
1. The currently controversial DTS configurations will be deleted.
These are extended applications, and support will not be considered in this
version.
rockchip,dis-u3otg0-port
rockchip,dis-u3otg1-port
rockchip,sgmii-mac-sel
2. rename PHY REGs
The register definitions for rk3568 and rk3588 phys are the same,and remove prefix.
#define PHYREG5 0x14
#define PHYREG5_PLL_DIV_MASK GENMASK(7, 6)
#define PHYREG5_PLL_DIV_SHIFT 6
...
3. Some descriptions will be modified in file phy-rockchip-naneng-combphy.yaml
--------------
Yifeng
Quoted 9,441 lines
Hi Yifeng and others,
Some comments,have a look if it's useful.
If you like the multi phy approuch:
Could you carefully test with hardware and tell us
what part of the code works or not and what to improve.
Produce a version 7 based on the code ideas and the comments below.
Kind regards,
Johan Jonker
Quoted 1,721 lines · Johan Jonker
From: Yifeng Zhao <[email protected]>
This patch implements a multi phy driver for Rockchip SoCs
with NaNeng IP block. This phy can be used as pcie-phy, usb3-phy,
sata-phy or sgmii-phy.
Signed-off-by Yifeng Zhao <[email protected]>Signed-off-by Johan Jonker <[email protected]>---
TEST COMPILED ONLY!
Driver not verified with hardware!
---
Changes in v6:
- restyle
- rename defines
- change from comb to multi phy
- clean up includes
- add parent node
- change compatible strings
- remove rockchip,sgmii-mac-sel support
- remove rockchip,dis-u3otg0-port support
- remove rockchip,dis-u3otg1-port support
Changes in v5:
- add
rockchip_combphy_updatel()- restyle
Changes in v4:
- restyle
- add
devm_reset_control_array_get()- remove clk structure
- change refclk DT parse
- change
dev_errmessage- add dot to phrase
- add
ext_refclkvariable- add
enable_sscvariable- rename
rockchip_combphy_param_write- remove
param_read- replace rockchip-naneng-combphy driver name
Changes in v3:
- Using api
devm_reset_control_get_optional_exclusiveanddev_err_probe.- Remove
apb_rst.- Redefine registers address.
Changes in v2:
- Using api
devm_platform_get_and_ioremap_resource.- Modify
rockchip_combphy_set_Mode.- Add some PHY registers definition.
---
drivers/phy/rockchip/Kconfig | 8 +
drivers/phy/rockchip/Makefile | 1 +
.../rockchip/phy-rockchip-naneng-multiphy.c | 661 ++++++++++++++++++
3 files changed, 670 insertions(+)create mode 100644
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.cdrivers/phy/rockchip/Kconfig +0
-0index
e812adad7..a14e32b6f100644--- a/drivers/phy/rockchip/Kconfig
+++ b/drivers/phy/rockchip/Kconfig
drivers/phy/rockchip/Kconfig +0
-0@@ -66,6 +66,14 @@ config PHY_ROCKCHIP_INNO_DSIDPHYEnable this to support the Rockchip MIPI/LVDS/TTL PHY with
Innosilicon IP block.
drivers/phy/rockchip/Kconfig +8
-0+config PHY_ROCKCHIP_NANENG_MULTI_PHY + tristate "Rockchip NANENG MULTI PHY Driver" + depends on ARCH_ROCKCHIP && OF + select GENERIC_PHY + help + Enable this to support the Rockchip PCIe/USB3.0/SATA/QSGMII + multi PHY with NaNeng IP block. +config
PHY_ROCKCHIP_PCIEtristate "Rockchip PCIe PHY Driver"
depends on (
ARCH_ROCKCHIP&& OF) ||COMPILE_TESTdrivers/phy/rockchip/Makefile +0
-0index
f0eec212b..d5570452f100644--- a/drivers/phy/rockchip/Makefile
+++ b/drivers/phy/rockchip/Makefile
drivers/phy/rockchip/Makefile +0
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_CSIDPHY) += phy-rockchip-inno-csidphy.oobj-$(CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY) += phy-rockchip-inno-dsidphy.o
obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI) += phy-rockchip-inno-hdmi.o
obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o
+obj-$(CONFIG_PHY_ROCKCHIP_NANENG_MULTI_PHY) += phy-rockchip-naneng-multiphy.o
obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o
obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o
obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +0
-0new file mode 100644
index 000000000..765ede440
---
/dev/null+++
b/drivers/phy/rockchip/phy-rockchip-naneng-multiphy.cdrivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +77
-0@@ -0,0 +1,661 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Rockchip PIPE USB3.0 PCIE SATA Multi Phy driver +* +* Copyright (C) 2021 Rockchip Electronics Co., Ltd. +*/ + +#include <dt-bindings/phy/phy.h> +#include <linux/clk.h> +#include <linux/mfd/syscon.h> +#include <linux/of_address.h> +#include <linux/of_device.h> +#include <linux/phy/phy.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/units.h> + +#define BIT_WRITEABLE_SHIFT 16 +#define REF_CLOCK_24MHz (24 * HZ_PER_MHZ) +#define REF_CLOCK_25MHz (25 * HZ_PER_MHZ) +#define REF_CLOCK_100MHz (100 * HZ_PER_MHZ) + +/* RK3568 MULTI PHY REG */ +#define RK3568_PHYREG6 0x14 +#define PHYREG6_PLL_DIV_MASK GENMASK(7, 6) +#define PHYREG6_PLL_DIV_SHIFT 6 +#define PHYREG6_PLL_DIV_2 1 + +#define RK3568_PHYREG7 0x18 +#define PHYREG7_TX_RTERM_MASK GENMASK(7, 4) +#define PHYREG7_TX_RTERM_SHIFT 4 +#define PHYREG7_TX_RTERM_50OHM 8 +#define PHYREG7_RX_RTERM_MASK GENMASK(3, 0) +#define PHYREG7_RX_RTERM_SHIFT 0 +#define PHYREG7_RX_RTERM_44OHM 15 + +#define RK3568_PHYREG8 0x1C +#define PHYREG8_SSC_EN BIT(4) + +#define RK3568_PHYREG11 0x28 +#define PHYREG11_SU_TRIM_0_7 0xF0 + +#define RK3568_PHYREG12 0x2C +#define PHYREG12_PLL_LPF_ADJ_VALUE 4 + +#define RK3568_PHYREG13 0x30 +#define PHYREG13_RESISTER_MASK GENMASK(5, 4) +#define PHYREG13_RESISTER_SHIFT 0x4 +#define PHYREG13_RESISTER_HIGH_Z 3 +#define PHYREG13_CKRCV_AMP0 BIT(7) + +#define RK3568_PHYREG14 0x34 +#define PHYREG14_CKRCV_AMP1 BIT(0) + +#define RK3568_PHYREG15 0x38 +#define PHYREG15_CTLE_EN BIT(0) +#define PHYREG15_SSC_CNT_MASK GENMASK(7, 6) +#define PHYREG15_SSC_CNT_SHIFT 6 +#define PHYREG15_SSC_CNT_VALUE 1 + +#define RK3568_PHYREG16 0x3C +#define PHYREG16_SSC_CNT_VALUE 0x5f + +#define RK3568_PHYREG18 0x44 +#define PHYREG18_PLL_LOOP 0x32 + +#define RK3568_PHYREG32 0x7C +#define PHYREG32_SSC_MASK GENMASK(7, 4) +#define PHYREG32_SSC_DIR_SHIFT 4 +#define PHYREG32_SSC_UPWARD 0 +#define PHYREG32_SSC_DOWNWARD 1 +#define PHYREG32_SSC_OFFSET_SHIFT 6 +#define PHYREG32_SSC_OFFSET_500PPM 1 + +#define RK3568_PHYREG33 0x80 +#define PHYREG33_PLL_KVCO_MASK GENMASK(4, 2) +#define PHYREG33_PLL_KVCO_SHIFT 2drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +1
-0+#define PHYREG33_PLL_KVCO_VALUE 2/* RK3588 MULTI PHY REG */
Add more defines.
Quoted 411 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +42
-0+ +struct rockchip_multiphy_priv ; + +struct multiphy_reg { +u16 offset; +u16 bitend; +u16 bitstart; +u16 disable; +u16 enable; +}; + +struct rockchip_multiphy_grfcfg { +struct multiphy_reg pcie_mode_set; +struct multiphy_reg usb_mode_set; +struct multiphy_reg sgmii_mode_set; +struct multiphy_reg qsgmii_mode_set; +struct multiphy_reg pipe_rxterm_set; +struct multiphy_reg pipe_txelec_set; +struct multiphy_reg pipe_txcomp_set; +struct multiphy_reg pipe_clk_25m; +struct multiphy_reg pipe_clk_100m; +struct multiphy_reg pipe_phymode_sel; +struct multiphy_reg pipe_rate_sel; +struct multiphy_reg pipe_rxterm_sel; +struct multiphy_reg pipe_txelec_sel; +struct multiphy_reg pipe_txcomp_sel; +struct multiphy_reg pipe_clk_ext; +struct multiphy_reg pipe_sel_usb; +struct multiphy_reg pipe_sel_qsgmii; +struct multiphy_reg pipe_phy_status; +struct multiphy_reg con0_for_pcie; +struct multiphy_reg con1_for_pcie; +struct multiphy_reg con2_for_pcie; +struct multiphy_reg con3_for_pcie; +struct multiphy_reg con0_for_sata; +struct multiphy_reg con1_for_sata; +struct multiphy_reg con2_for_sata; +struct multiphy_reg con3_for_sata; +struct multiphy_reg pipe_con0_for_sata; +struct multiphy_reg pipe_sgmii_mac_sel; +struct multiphy_reg pipe_xpcs_phy_ready; +struct multiphy_reg u3otg0_port_en;drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +1
-0+struct multiphy_reg u3otg1_port_en;.num_phy
.regs
.cap
Add more phy properties for checks and control.
Quoted 1,541 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +155
-0+}; + +struct rockchip_multiphy_cfg { +const struct rockchip_multiphy_grfcfg *grfcfg; +int (*multiphy_cfg)(struct phy *phy); +}; + +struct rockchip_multiphy_node_priv { +int id; +u8 mode; +void __iomem *mmio; +int num_clks; +struct clk_bulk_data *clks; +struct regmap *phy_grf; +struct phy *phy; +struct reset_control *phy_rst; +struct clk *refclk; +bool enable_ssc; +bool ext_refclk; +}; + +struct rockchip_multiphy_priv { +struct device *dev; +int num_phy; +struct regmap *pipe_grf; +const struct rockchip_multiphy_cfg *cfg; +struct rockchip_multiphy_node_priv **node; +}; + +static void rockchip_multiphy_updatel (struct phy *phy,int mask,int val,int reg) +{ +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +unsigned int temp; + + temp =readl (node_priv->mmio + reg); + temp = (temp & ~(mask)) | val; +writel (temp, node_priv->mmio + reg); +} + +static int rockchip_multiphy_param_write (struct regmap *base, +const struct multiphy_reg *reg,bool en) +{ +u32 val, mask, tmp; + + tmp = en ? reg->enable : reg->disable; + mask =GENMASK (reg->bitend, reg->bitstart); + val = (tmp << reg->bitstart) | (mask <<BIT_WRITEABLE_SHIFT ); + +return regmap_write (base, reg->offset, val); +} + +static u32 rockchip_multiphy_is_ready (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +const struct rockchip_multiphy_grfcfg *cfg = priv->cfg->grfcfg; +u32 mask, val; + + mask =GENMASK (cfg->pipe_phy_status.bitend, + cfg->pipe_phy_status.bitstart); + +regmap_read (node_priv->phy_grf, cfg->pipe_phy_status.offset, &val); + val = (val & mask) >> cfg->pipe_phy_status.bitstart; + +return val; +} + +static int rockchip_multiphy_set_mode (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +int ret =0 ; + +switch (node_priv->mode) { +case PHY_TYPE_PCIE : +case PHY_TYPE_USB3 : +case PHY_TYPE_SATA : +case PHY_TYPE_SGMII : +case PHY_TYPE_QSGMII : +if (priv->cfg->multiphy_cfg) + ret = priv->cfg->multiphy_cfg (phy); +break ; +default : +dev_err (priv->dev,"incompatible PHY type\n" ); +return -EINVAL ; + } + +if (ret) +dev_err (priv->dev,"failed to init phy for phy mode %x\n" , node_priv->mode); + +return ret; +} + +static int rockchip_multiphy_init (struct phy *phy) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (phy->dev.parent); +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); +const struct rockchip_multiphy_grfcfg *cfg = priv->cfg->grfcfg; +u32 val; +int ret; + + ret =clk_bulk_prepare_enable (node_priv->num_clks, node_priv->clks); +if (ret) { +dev_err (priv->dev,"failed to enable clks\n" ); +return ret; + } + + ret =rockchip_multiphy_set_mode (phy); +if (ret) + goto err_clk; + + ret =reset_control_deassert (node_priv->phy_rst); +if (ret) + goto err_clk; + +if (node_priv->mode ==PHY_TYPE_USB3 ) { + ret =readx_poll_timeout_atomic (rockchip_multiphy_is_ready, + phy, val, + val == cfg->pipe_phy_status.enable, +10 ,1000 ); +if (ret) +dev_warn (priv->dev,"wait phy status ready timeout\n" ); + } + +return 0 ; + +err_clk: +clk_bulk_disable_unprepare (node_priv->num_clks, node_priv->clks); + +return ret; +} + +static int rockchip_multiphy_exit (struct phy *phy) +{ +struct rockchip_multiphy_node_priv *node_priv =phy_get_drvdata (phy); + +clk_bulk_disable_unprepare (node_priv->num_clks, node_priv->clks); +reset_control_assert (node_priv->phy_rst); + +return 0 ; +} + +static const struct phy_ops rochchip_multiphy_ops = { + .init = rockchip_multiphy_init, + .exit = rockchip_multiphy_exit, + .owner =THIS_MODULE , +}; + +static struct phy *rockchip_multiphy_xlate (struct device *dev,struct of_phandle_args *args) +{ +struct rockchip_multiphy_priv *priv =dev_get_drvdata (dev); +struct rockchip_multiphy_node_priv *node_priv =NULL ; +struct device_node *phy_np = args->np; +int index; +[..]
Quoted 151 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +16
-0+ +for (index =0 ; index < priv->num_phy; index++) +if (phy_np == priv->node[index]->phy->dev.of_node) { + node_priv = priv->node[index]; +break ; + } + +if (!node_priv) { +dev_err (dev,"failed to find appropriate phy\n" ); +return ERR_PTR (-EINVAL ); + } + +if (node_priv->mode !=PHY_NONE && node_priv->mode != args->args[0 ]) +dev_warn (dev,"phy type select %d overwriting type %d\n" , + args->args[0 ], node_priv->mode); +drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +1
-0+ node_priv->mode = args->args[0 ];if ((
node_priv->mode==PHY_TYPE_SGMII&&args->args_count!= 2) ||(
node_priv->mode!=PHY_TYPE_SGMII&&args->args_count!= 1) {dev_err(dev, "invalid number of arguments\n"); return ERR_PTR(-EINVAL); }Check number of argument based on capabillity.
===
if (node_priv->mode != priv->cap[node_priv->id]) { dev_err(dev, "invalid mode\n"); return ERR_PTR(-EINVAL); }Check mode and id with phy node capabilities.
===
if (node_priv->mode == PHY_TYPE_SGMII && args->args[1] == 0 ||args->args[1] == 1)
node_priv->sgmii-mac-sel = args->args[1]; else { dev_err(dev, "invalid gmac id\n"); return ERR_PTR(-EINVAL); }Maybe obtain SGMII output from extra phy argument.
Fix YAML document as well!
Quoted 251 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +25
-0+Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +1
-0+return node_priv->phy;Check
priv->num_phywith max SoC capabilities.drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 511 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +51
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
For a mode check based on id and phy node capabilities the id has to be
based on reg address DT order.
Currently
node_priv->idis based on node order.Check reg address with a table and assign id from table index.
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 2,011 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +202
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
condition1 = (SoC rk3568) && (id == 0) val = condition1 && (mode != USB3)? false : true; if (condition1) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->u3otg0_port_en, val);condition2 = (SoC rk3566 or rk3568) && (id == 1) val = condition2 && (mode != USB3)? false : true; if (condition2) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->u3otg1_port_en, val);========================
condition3 = (SoC rk3568) && (id == 1 || id == 2) && (mode == SGMII) val = condition3 && (node_priv->sgmii-mac-sel)? true : false; if (condition3) rockchip_combphy_param_write(priv->pipe_grf,
&phy_cfg->grfcfg->pipe_sgmii_mac_sel, val);TODO:
Allow more phy data with:
YAML node:
"#phy-cells":
enum: [1, 2]
DT node:
gmac0: ethernet@fe2a0000 { phys = <&combphy1 PHY_TYPE_SGMII 0>; phy-names = "sgmii-phy";or
phys = <&combphy2 PHY_TYPE_SGMII 0>; phy-names = "sgmii-phy"; } gmac1: ethernet@fe010000 { phys = <&combphy1 PHY_TYPE_SGMII 1>; phy-names = "sgmii-phy";or
phys = <&combphy2 PHY_TYPE_SGMII 1>; phy-names = "sgmii-phy"; }Could someone test this idea?
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 231 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +24
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
static const struct
rockchip_multiphy_grfcfgrk3566_multiphy_grfcfgs= {[..]
Add maximum number of phy nodes for check with
priv->num_phy..num_phy = 2,
Add reg addresses to detect phy id.
.regs =
0xfe830000,
0xfe840000,Add table with SoC capabilities based on phy id.
PCie USB3 SATA SGMII
0: 0 x x 0
1: x x x 0
Don't confuse phy id with node label numbers!
};
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 331 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +34
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Add maximum number of phy nodes for check with
priv->num_phy..num_phy = 3,
Add reg addresses to detect phy id.
.regs =
0xfe820000,
0xfe830000,
0xfe840000,Add table with SoC capabilities based on phy id.
PCie USB3 SATA SGMII
0: 0 x x 0
1: 0 x x x
2: x x x x
Quoted 1 line
+};
static const struct
rockchip_multiphy_grfcfgrk3588_multiphy_grfcfgs= {[..]
};
static const struct
rockchip_multiphy_cfgrk3566_multiphy_cfgs= {.grfcfg = &rk3566_multiphy_grfcfgs, .multiphy_cfg = rk3568_multiphy_cfg,};
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 41 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
static const struct
rockchip_multiphy_cfgrk3588_multiphy_cfgs= {.grfcfg = &rk3588_multiphy_grfcfgs, .multiphy_cfg = rk3588_multiphy_cfg,};
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 41 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
.data = &rk3566_multiphy_cfgs, },drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c
Quoted 11 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
{ .compatible = "rockchip,rk3588-naneng-multiphy", .data = &rk3588_multiphy_cfgs, },Quoted 151 lines
drivers/phy/rockchip/phy-rockchip-naneng-multiphy.c +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Part of the diff is not shown here. View the raw message.
RFC PATCH v6 4/4 arm64: dts: rockchip: add naneng multi phy nodes for rk3568
In reply to Johan JonkerFrom: Yifeng Zhao <[email protected]>
Add the core DT nodes for the rk3568 Naneng multi phys.
--- arch/arm64/boot/dts/rockchip/rk3566.dtsi | 4 ++ arch/arm64/boot/dts/rockchip/rk3568.dtsi | 23 +++++++++++ arch/arm64/boot/dts/rockchip/rk356x.dtsi | 50 ++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
arch/arm64/boot/dts/rockchip/rk3566.dtsi +4 -0
@@ -6,6 +6,10 @@ compatible = "rockchip,rk3566"; }; +&multiphy { + compatible = "rockchip,rk3566-naneng-multiphy"; +}; + &power { power-domain@RK3568_PD_PIPE { reg = <RK3568_PD_PIPE>;
arch/arm64/boot/dts/rockchip/rk3568.dtsi +23 -0
@@ -8,6 +8,11 @@ / { compatible = "rockchip,rk3568"; + pipe_phy_grf0: syscon@fdc70000 { + compatible = "rockchip,rk3568-pipe-phy-grf", "syscon"; + reg = <0x0 0xfdc70000 0x0 0x1000>; + }; + qos_pcie3x1: qos@fe190080 { compatible = "rockchip,rk3568-qos", "syscon"; reg = <0x0 0xfe190080 0x0 0x20>;
@@ -80,6 +85,24 @@ }; }; +&multiphy { + compatible = "rockchip,rk3568-naneng-multiphy"; + + multiphy0: multi-phy@fe820000 { + reg = <0x0 0xfe820000 0x0 0x100>; + clocks = <&pmucru CLK_PCIEPHY0_REF>, + <&cru PCLK_PIPEPHY0>, + <&cru PCLK_PIPE>; + clock-names = "ref", "apb", "pipe"; + assigned-clocks = <&pmucru CLK_PCIEPHY0_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_PIPEPHY0>; + rockchip,pipe-phy-grf = <&pipe_phy_grf0>; + #phy-cells = <1>; + status = "disabled"; + }; +}; + &power { power-domain@RK3568_PD_PIPE { reg = <RK3568_PD_PIPE>;
arch/arm64/boot/dts/rockchip/rk356x.dtsi +50 -0
67 lines not on this page · raw message
Signature · 1 line
2.20.1