Add PCIe PHY driver support for Realtek DHC SoCs
Subsystems (2)
cover Add PCIe PHY driver support for Realtek DHC SoCs
These patches add the bindings and the PCIe phy driver for Realtek DHC(Digital Home Center) RTD SoCs(RTD1319, RTD1619B, RTD1319D and RTD1315E).
Tzuyi Chang (2):
dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
phy: realtek: pcie: Add PCIe PHY support for Realtek DHC RTD SoCs
.../bindings/phy/realtek,rtd-pcie-phy.yaml | 61 ++ drivers/phy/realtek/Kconfig | 8 + drivers/phy/realtek/Makefile | 1 + drivers/phy/realtek/phy-rtk-pcie.c | 738 ++++++++++++++++++ 4 files changed, 808 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml create mode 100644 drivers/phy/realtek/phy-rtk-pcie.c
Signature · 1 line
2.43.0
PATCH 1/2 dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Add the device tree bindings for the Realtek DHC(Digital Home Center) RTD SoCs PCIe PHY.
--- .../bindings/phy/realtek,rtd-pcie-phy.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Realtek Semiconductor Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/realtek,rtd-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek DHC PCIe PHY + +maintainers: + - Tzuyi Chang <[email protected]> + +description: + Realtek PCIe PHY supports the DHC(Digital Home Center) RTD series SoCs. + The PCIe PHY driver is designed to support physical layer functionality + of the PCIe controller. + +properties: + compatible: + enum: + - realtek,rtd1319-pcie0-phy + - realtek,rtd1319-pcie1-phy + - realtek,rtd1319-pcie2-phy + - realtek,rtd1619b-pcie1-phy + - realtek,rtd1619b-pcie2-phy + - realtek,rtd1319d-pcie1-phy + - realtek,rtd1315e-pcie1-phy + + "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description: + Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names: + items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register. + +required: + - compatible + - realtek,pcie-syscon + - "#phy-cells" + +additionalProperties: false + +examples: + - | + pcie1_phy { + compatible = "realtek,rtd1319d-pcie1-phy"; + realtek,pcie-syscon = <&pcie1>; + #phy-cells = <0>; + nvmem-cells = <&otp_pcie_tx_swing_trim>; + nvmem-cell-names = "tx_swing_trim"; + };
Signature · 1 line
2.43.0
Re: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Quoted 31 lines · Tzuyi Chang
Add the device tree bindings for the Realtek DHC(Digital Home Center) RTD SoCs PCIe PHY.
Signed-off-by Tzuyi Chang <[email protected]>--- .../bindings/phy/realtek,rtd-pcie-phy.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yamlDocumentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +16
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Realtek Semiconductor Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/realtek,rtd-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek DHC PCIe PHY + +maintainers: + - Tzuyi Chang <[email protected]> + +description: + Realtek PCIe PHY supports the DHC(Digital Home Center) RTD series SoCs. + The PCIe PHY driver is designed to support physical layer functionality + of the PCIe controller.
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 25
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +9
-0+ +properties: + compatible: + enum: + - realtek,rtd1319-pcie0-phy + - realtek,rtd1319-pcie1-phy + - realtek,rtd1319-pcie2-phy + - realtek,rtd1619b-pcie1-phy + - realtek,rtd1619b-pcie2-phy
Please explain why different PHYs on the same SoC need different compatibles.
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 27
Quoted 2 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +2
-0+ - realtek,rtd1319d-pcie1-phy + - realtek,rtd1315e-pcie1-phy
And why bother with the 1 here given there is no 0 or 2?
This looks suspiciously like abuse of the compatible - especially since most of the ops are the same despite the differing compatibles. The case where that does not apply, it looks like the issue is down to the portion of the nvmem cell corresponding to the PHY, which has nothing to do with the programming model of the PHY itself IMO.
Cheers,
Conor.
Quoted 37 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +34
-0+ + "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description: + Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names: + items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register. + +required: + - compatible + - realtek,pcie-syscon + - "#phy-cells" + +additionalProperties: false + +examples: + - | + pcie1_phy { + compatible = "realtek,rtd1319d-pcie1-phy"; + realtek,pcie-syscon = <&pcie1>; + #phy-cells = <0>; + nvmem-cells = <&otp_pcie_tx_swing_trim>; + nvmem-cell-names = "tx_swing_trim"; + };Signature · 1 line
2.43.0
RE: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Hi Conor,
Thank you for the review.
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +3
-0+properties: + compatible: + enum:
Quoted 8 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 25
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +5
-0+ - realtek,rtd1319-pcie0-phy + - realtek,rtd1319-pcie1-phy + - realtek,rtd1319-pcie2-phy + - realtek,rtd1619b-pcie1-phy + - realtek,rtd1619b-pcie2-phyPlease explain why different PHYs on the same SoC need different compatibles.
I hadn't thought this clearly. I added the compatible for each PCIe ports. However, only one compatible is needed for the PHY driver on each SoC.
I will revise it in the next version.
There are multiple ports for PCIe on different SoCs. RTD1319 has three PCIe ports (port 0, port1, port2). RTD1619B has two PCIe ports. Both RTD1319D and RTD1315E have one PCIe port.
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 27
Quoted 2 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +2
-0+ - realtek,rtd1319d-pcie1-phy + - realtek,rtd1315e-pcie1-phyAnd why bother with the 1 here given there is no 0 or 2?
I'm sorry for the confusion caused by the naming. The PCIe controller register address on RTD1319D and RTD1315E is the same as RTD1319's PCIe port1, so I named it as pcie1. I'll refrain from using such naming in the future.
Quoted 5 lines
This looks suspiciously like abuse of the compatible - especially since most of the ops are the same despite the differing compatibles. The case where that does not apply, it looks like the issue is down to the portion of the nvmem cell corresponding to the PHY, which has nothing to do with the programming model of the PHY itself IMO.
Thanks,
Tzuyi Chang
Re: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
In reply to Tzuyi ChangQuoted 6 lines · Tzuyi Chang
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +6
-0+ "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description:
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +10
-0+ Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names: + items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register.
Why this does not have reg property but syscon? This looks hacky.
Where is the DTS of your platform so we can verify the bindings? In the past Realtek bindings and DTS were sent without testing.
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 55
Quoted 11 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +11
-0+ +required: + - compatible + - realtek,pcie-syscon + - "#phy-cells" + +additionalProperties: false + +examples: + - | + pcie1_phy {
phy {
Best regards,
Krzysztof
RE: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Hi Krzysztof,
Thank you for the review.
Quoted 11 lines · Tzuyi Chang
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +10
-0+ "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description: + Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names:
Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 44
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +6
-0+ items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register.Why this does not have reg property but syscon? This looks hacky.
Our PCIe PHY driver needs to access two registers:
1. PCIe MDIO register: Utilized for configuring the PCIe PHY.
2. PCIe MAC Link Control and Link Status Register: Use to get the current link speed for calibration purposes.
Both these registers reside within the PCIe controller registers. The PCIe driver has mapped these register address region, so I use regmap to access these registers.
Quoted 2 lines
Where is the DTS of your platform so we can verify the bindings? In the past Realtek bindings and DTS were sent without testing.
The bindings and DTS for our platform are continuously being adjusted for the upstream.
Therefore, I only modified and tested the DTS node of the binding documentations I submitted. The DTS node is the same as the examples in the binding documentation. I tested it using the command "make dtbs_check DT_SCHEMA_FILES=..." without encountering any errors.
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +5
-0+ +required: + - compatible + - realtek,pcie-syscon + - "#phy-cells"
Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 55
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +6
-0+ +additionalProperties: false + +examples: + - | + pcie1_phy {phy {
I will fix it in the next version.
Thanks,
Tzuyi Chang
Re: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Quoted 25 lines · TY_Chang[張子逸]
Hi Krzysztof,
Thank you for the review.
Quoted 11 lines · Tzuyi Chang
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +10
-0+ "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description: + Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names:Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 44
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +6
-0+ items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register.Why this does not have reg property but syscon? This looks hacky.
Quoted 8 lines
Our PCIe PHY driver needs to access two registers:
1. PCIe MDIO register: Utilized for configuring the PCIe PHY.
2. PCIe MAC Link Control and Link Status Register: Use to get the current link speed for calibration purposes.Both these registers reside within the PCIe controller registers. The PCIe driver has mapped these register address region, so I use regmap to access these registers.
Hm, isn't in such case PCIe PHY a child of the PCIe controller? How is it with resources, like power domains or regulators?
Best regards,
Krzysztof
RE: [PATCH 1/2] dt-bindings: phy: realtek: Add Realtek DHC RTD SoC PCIe PHY
Hi Krzysztof,
Quoted 26 lines
Quoted 26 lines
Quoted 11 lines · Tzuyi Chang
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +10
-0+ "#phy-cells": + const: 0 + + nvmem-cells: + maxItems: 1 + description: + Phandle to nvmem cell that contains 'Tx swing trim' + tuning parameter value for PCIe phy. + + nvmem-cell-names:Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml line 44
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,rtd-pcie-phy.yaml new file +6
-0+ items: + - const: tx_swing_trim + + realtek,pcie-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle of syscon used to control PCIe MDIO register.Why this does not have reg property but syscon? This looks hacky.
Our PCIe PHY driver needs to access two registers:
1. PCIe MDIO register: Utilized for configuring the PCIe PHY.
2. PCIe MAC Link Control and Link Status Register: Use to get the current link speed for calibration purposes.
Quoted 6 lines
Quoted 3 lines
Both these registers reside within the PCIe controller registers. The PCIe driver has mapped these register address region, so I use regmap to access these registers.
Hm, isn't in such case PCIe PHY a child of the PCIe controller? How is it with resources, like power domains or regulators?
In fact, I positioned the PCIe PHY node outside the PCIe controller node. It would be more appropriate for the PCIe PHY as the child node of the PCIe controller. I will revise to this structure.
I will also remove the "realtek,pcie-syscon" property and use dev->parent->of_node to get the syscon of the PCIe controller.
Since the MDIO register is located within the PCIe controller registers, it can
only be accessed after enabling the clock and asserting the resets of the PCIe controller. Therefore, the PCIe PHY driver only registers the callback functions of phy_ops (.init and .calibrate). After the PCIe controller driver sets the clock and resets, it will execute PHY framework API to configure the PHY.
Thanks,
Tzuyi Chang
PATCH 2/2 phy: realtek: pcie: Add PCIe PHY support for Realtek DHC RTD SoCs
In reply to Tzuyi ChangImplement the phy driver to support PCIe PHY for Realtek DHC (Digital Home Center) RTD SoCs.
--- drivers/phy/realtek/Kconfig | 8 + drivers/phy/realtek/Makefile | 1 + drivers/phy/realtek/phy-rtk-pcie.c | 738 +++++++++++++++++++++++++++++ 3 files changed, 747 insertions(+) create mode 100644 drivers/phy/realtek/phy-rtk-pcie.c
drivers/phy/realtek/Kconfig +8 -0
@@ -29,4 +29,12 @@ config PHY_RTK_RTD_USB3PHY DWC3 USB IP. This driver will do the PHY initialization of the parameters. +config PHY_RTD_PCIE + tristate "Realtek RTD PCIe PHY driver" + depends on OF + select GENERIC_PHY + help + Enable this to support the PCIe PHY on Realtek DHC (digital home center) + RTD series SoCs. + endif # ARCH_REALTEK || COMPILE_TEST
drivers/phy/realtek/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PHY_RTK_RTD_USB2PHY) += phy-rtk-usb2.o obj-$(CONFIG_PHY_RTK_RTD_USB3PHY) += phy-rtk-usb3.o +obj-$(CONFIG_PHY_RTD_PCIE) += phy-rtk-pcie.o
drivers/phy/realtek/phy-rtk-pcie.c new file +738 -0
738 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 2/2] phy: realtek: pcie: Add PCIe PHY support for Realtek DHC RTD SoCs
Quoted 46 lines · Tzuyi Chang
Implement the phy driver to support PCIe PHY for Realtek DHC (Digital Home Center) RTD SoCs.
Signed-off-by Tzuyi Chang <[email protected]>--- drivers/phy/realtek/Kconfig | 8 + drivers/phy/realtek/Makefile | 1 + drivers/phy/realtek/phy-rtk-pcie.c | 738 +++++++++++++++++++++++++++++ 3 files changed, 747 insertions(+) create mode 100644 drivers/phy/realtek/phy-rtk-pcie.cdrivers/phy/realtek/Kconfig +8
-0@@ -29,4 +29,12 @@ config PHY_RTK_RTD_USB3PHY DWC3 USB IP. This driver will do the PHY initialization of the parameters. +config PHY_RTD_PCIE + tristate "Realtek RTD PCIe PHY driver" + depends on OF + select GENERIC_PHY + help + Enable this to support the PCIe PHY on Realtek DHC (digital home center) + RTD series SoCs. + endif # ARCH_REALTEK || COMPILE_TESTdrivers/phy/realtek/Makefile +1
-0@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PHY_RTK_RTD_USB2PHY) += phy-rtk-usb2.o obj-$(CONFIG_PHY_RTK_RTD_USB3PHY) += phy-rtk-usb3.o +obj-$(CONFIG_PHY_RTD_PCIE) += phy-rtk-pcie.odrivers/phy/realtek/phy-rtk-pcie.c new file +2
-0@@ -0,0 +1,738 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/*
drivers/phy/realtek/phy-rtk-pcie.c line 12
Quoted 10 lines
drivers/phy/realtek/phy-rtk-pcie.c new file +10
-0+* Realtek DHC PCIe PHY driver +* +* Copyright (c) 2023 Realtek Semiconductor Corp. +*/ + +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/of_address.h> +#include <linux/of_device.h>
You probably don't need this header and the implicit includes it makes are dropped now in linux-next. Please check what you actually need and make them explicit.
of_address.h is likely not needed either. Please check.
Rob
RE: [PATCH 2/2] phy: realtek: pcie: Add PCIe PHY support for Realtek DHC RTD SoCs
Hi Rob,
Thank you for the review.
Quoted 24 lines
Quoted 9 lines
drivers/phy/realtek/phy-rtk-pcie.c new file +2
-0@@ -0,0 +1,738 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* drivers/phy/realtek/phy-rtk-pcie.c line 12
Quoted 10 lines
drivers/phy/realtek/phy-rtk-pcie.c new file +10
-0+* Realtek DHC PCIe PHY driver +* +* Copyright (c) 2023 Realtek Semiconductor Corp. +*/ + +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/of_address.h> +#include <linux/of_device.h> You probably don't need this header and the implicit includes it makes are dropped now in linux-next. Please check what you actually need and make them explicit.
Quoted 3 lines
of_address.his likely not needed either. Please check.Rob
I will check and revise it.
Thanks,
Tzuyi Chang