* [PATCH v8 0/2] phy: Add CIX Sky1 USB3 PHY support @ 2026-11-17 2:28 ` Hongliang Yang 0 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang This series adds support for the USB3 PHY integrated in the CIX Sky1 SoC: the device tree binding and the PHY driver. It is a PHY series only; the arm64 device tree nodes belong to the SoC subsystem and will be sent separately once the binding is accepted. The PHY and the USBSSP controller series were split in v4 and are posted independently. The PHY provides the SuperSpeed lanes for the two USB3 Type-A (USB4 and USB5) Cadence USBSSP controllers of the SoC. There is one PHY block with two lanes: they share one register block, the same clocks and resets, and one initialization sequence, so the binding describes the block as a single provider with #phy-cells = <0> and both controllers reference the same phandle. The PHY core reference counts the phy_init() and phy_exit() calls accordingly. v5 described one child node per lane. v6 collapsed them into the parent node, but nothing in the binding or in the changelog said where the second lane went. The second lane did not go anywhere: it is the second lane of the same block and has no registers, clocks or resets of its own. The binding description and the commit message now say that. Tested on Radxa Orion O6 (Sky1) together with the USBSSP controller series: the PHY probes and USB 3.x devices enumerate at SuperSpeed. The series applies on top of v7.4-rc1. Changes in v8: - Rely on the PHY core for serialization and reference counting of phy_init() and phy_exit() instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations; the per-SoC callback structure and its duplicate error messages are gone. - Drop the register macros that the initialization sequence does not use from the private header. Changes in v7: - Removed the arm64 dts from the series; it is a separate SoC patchset. - Describe the two lanes as one PHY provider and say why, instead of dropping the per-lane child nodes without an explanation. - Renamed the register header to phy-cix-usb3.h: it holds the register map of the USB3 PHY, and the usbdp name suggested a USB/DP combo PHY. - Fixed the module description and the Kconfig help text. Changes in v6: - Dropped the per-port child nodes; the PHY node itself is the provider with #phy-cells = <0> and the driver exports a single PHY instance shared by both controllers. - Selected REGMAP in the PHY Kconfig. - Used dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path. Hongliang Yang (2): dt-bindings: phy: Add CIX Sky1 USB3 PHY phy: cix: Add CIX Sky1 USB3 PHY driver .../bindings/phy/cix,sky1-usb3-phy.yaml | 78 +++++ MAINTAINERS | 2 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 21 ++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 313 ++++++++++++++++++ drivers/phy/cix/phy-cix-usb3.h | 180 ++++++++++ 8 files changed, 602 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usb3.h -- 2.54.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v8 0/2] phy: Add CIX Sky1 USB3 PHY support @ 2026-11-17 2:28 ` Hongliang Yang 0 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang This series adds support for the USB3 PHY integrated in the CIX Sky1 SoC: the device tree binding and the PHY driver. It is a PHY series only; the arm64 device tree nodes belong to the SoC subsystem and will be sent separately once the binding is accepted. The PHY and the USBSSP controller series were split in v4 and are posted independently. The PHY provides the SuperSpeed lanes for the two USB3 Type-A (USB4 and USB5) Cadence USBSSP controllers of the SoC. There is one PHY block with two lanes: they share one register block, the same clocks and resets, and one initialization sequence, so the binding describes the block as a single provider with #phy-cells = <0> and both controllers reference the same phandle. The PHY core reference counts the phy_init() and phy_exit() calls accordingly. v5 described one child node per lane. v6 collapsed them into the parent node, but nothing in the binding or in the changelog said where the second lane went. The second lane did not go anywhere: it is the second lane of the same block and has no registers, clocks or resets of its own. The binding description and the commit message now say that. Tested on Radxa Orion O6 (Sky1) together with the USBSSP controller series: the PHY probes and USB 3.x devices enumerate at SuperSpeed. The series applies on top of v7.4-rc1. Changes in v8: - Rely on the PHY core for serialization and reference counting of phy_init() and phy_exit() instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations; the per-SoC callback structure and its duplicate error messages are gone. - Drop the register macros that the initialization sequence does not use from the private header. Changes in v7: - Removed the arm64 dts from the series; it is a separate SoC patchset. - Describe the two lanes as one PHY provider and say why, instead of dropping the per-lane child nodes without an explanation. - Renamed the register header to phy-cix-usb3.h: it holds the register map of the USB3 PHY, and the usbdp name suggested a USB/DP combo PHY. - Fixed the module description and the Kconfig help text. Changes in v6: - Dropped the per-port child nodes; the PHY node itself is the provider with #phy-cells = <0> and the driver exports a single PHY instance shared by both controllers. - Selected REGMAP in the PHY Kconfig. - Used dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path. Hongliang Yang (2): dt-bindings: phy: Add CIX Sky1 USB3 PHY phy: cix: Add CIX Sky1 USB3 PHY driver .../bindings/phy/cix,sky1-usb3-phy.yaml | 78 +++++ MAINTAINERS | 2 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 21 ++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 313 ++++++++++++++++++ drivers/phy/cix/phy-cix-usb3.h | 180 ++++++++++ 8 files changed, 602 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usb3.h -- 2.54.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v8 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY 2026-11-17 2:28 ` Hongliang Yang @ 2026-11-17 2:28 ` Hongliang Yang -1 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang Add device tree binding for the CIX Sky1 USB3 PHY, the SuperSpeedPlus PHY of the two USB3 Type-A ports of the SoC. The two lanes are not separate devices: they live in one register block, share the same clocks and resets, and are brought up by the same initialization sequence. The node is therefore a single PHY provider with #phy-cells = <0>, referenced by both controllers, and the driver reference counts phy_init() and phy_exit() so that the block is set up once for all of them. Signed-off-by: Hongliang Yang <hongliang.yang@cixtech.com> --- Changes in v7: - Describe the PHY as one provider of both lanes and say why. v5 had one child node per lane, v6 dropped them, and nothing in the binding or the changelog said where the second lane went. - Reword the description so that it describes the provider instead of the register programming of the block. Changes in v6: - Drop the per-port child nodes. The parent node is the PHY provider with #phy-cells = <0>, as the block drives both lanes and the ports share the initialization sequence. --- .../bindings/phy/cix,sky1-usb3-phy.yaml | 78 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file mode 100644 index 000000000000..205140bf84e7 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <hongliang.yang@cixtech.com> + +description: | + The CIX Sky1 USB3 PHY provides the SuperSpeed lanes of the USB3 Type-A + ports of the SoC. + + Both lanes are programmed through one register block and share the + same clocks and resets, so the node is a single PHY provider with + #phy-cells = <0> that all consumers reference. The driver reference + counts phy_init() and phy_exit(), so the block is set up once for all + its consumers. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb + - const: ref + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: core + - const: apb + +required: + - compatible + - reg + - "#phy-cells" + - clocks + - clock-names + - resets + - reset-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x9210000 0x40000>; + #phy-cells = <0>; + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb", "ref"; + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "core", "apb"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 93abbb315065..73783abe027e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2903,6 +2903,7 @@ S: Maintained T: git https://github.com/cixtech/linux-mainline.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c K: \bcix\b -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v8 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY @ 2026-11-17 2:28 ` Hongliang Yang 0 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang Add device tree binding for the CIX Sky1 USB3 PHY, the SuperSpeedPlus PHY of the two USB3 Type-A ports of the SoC. The two lanes are not separate devices: they live in one register block, share the same clocks and resets, and are brought up by the same initialization sequence. The node is therefore a single PHY provider with #phy-cells = <0>, referenced by both controllers, and the driver reference counts phy_init() and phy_exit() so that the block is set up once for all of them. Signed-off-by: Hongliang Yang <hongliang.yang@cixtech.com> --- Changes in v7: - Describe the PHY as one provider of both lanes and say why. v5 had one child node per lane, v6 dropped them, and nothing in the binding or the changelog said where the second lane went. - Reword the description so that it describes the provider instead of the register programming of the block. Changes in v6: - Drop the per-port child nodes. The parent node is the PHY provider with #phy-cells = <0>, as the block drives both lanes and the ports share the initialization sequence. --- .../bindings/phy/cix,sky1-usb3-phy.yaml | 78 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file mode 100644 index 000000000000..205140bf84e7 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <hongliang.yang@cixtech.com> + +description: | + The CIX Sky1 USB3 PHY provides the SuperSpeed lanes of the USB3 Type-A + ports of the SoC. + + Both lanes are programmed through one register block and share the + same clocks and resets, so the node is a single PHY provider with + #phy-cells = <0> that all consumers reference. The driver reference + counts phy_init() and phy_exit(), so the block is set up once for all + its consumers. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb + - const: ref + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: core + - const: apb + +required: + - compatible + - reg + - "#phy-cells" + - clocks + - clock-names + - resets + - reset-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x9210000 0x40000>; + #phy-cells = <0>; + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb", "ref"; + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "core", "apb"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 93abbb315065..73783abe027e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2903,6 +2903,7 @@ S: Maintained T: git https://github.com/cixtech/linux-mainline.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c K: \bcix\b -- 2.54.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v8 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY 2026-11-17 2:28 ` Hongliang Yang @ 2026-11-17 2:52 ` sashiko-bot -1 siblings, 0 replies; 8+ messages in thread From: sashiko-bot @ 2026-11-17 2:52 UTC (permalink / raw) To: Hongliang Yang Cc: linux-phy, devicetree, robh, conor+dt, vkoul, neil.armstrong, olteanv Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: phy: cix,sky1-usb3-phy uses #phy-cells = 0 for two-lane PHY -- commit c8a29919e01294d52dd3eac0bc1ce8854b5d00a0 Author: Hongliang Yang <hongliang.yang@cixtech.com> dt-bindings: phy: Add CIX Sky1 USB3 PHY This commit adds the Device Tree binding schema for the CIX Sky1 USB3 SuperSpeedPlus PHY and updates MAINTAINERS. > diff --git a/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml > new file mode 100644 > index 0000000000000..205140bf84e7c > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml > @@ -0,0 +1,78 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: CIX Sky1 USB3 PHY > + > +maintainers: > + - Hongliang Yang <hongliang.yang@cixtech.com> > + > +description: | > + The CIX Sky1 USB3 PHY provides the SuperSpeed lanes of the USB3 Type-A > + ports of the SoC. > + > + Both lanes are programmed through one register block and share the > + same clocks and resets, so the node is a single PHY provider with > + #phy-cells = <0> that all consumers reference. The driver reference > + counts phy_init() and phy_exit(), so the block is set up once for all > + its consumers. > + > +properties: > + compatible: > + const: cix,sky1-usb3-phy > + > + reg: > + maxItems: 1 > + > + "#phy-cells": > + const: 0 [Severity: Low] As reported by Krzysztof Kozlowski on v6 [1], shouldn't #phy-cells be 1 instead of 0 so that each USB3 controller consumer node can specify which of the two PHY lanes it is connected to? The hardware block has two distinct lanes with separate per-lane register sets serving two independent USB3 controllers. Locking #phy-cells to 0 omits the per-lane routing from the Device Tree ABI and prevents any future per-lane control or tuning without breaking the binding. Also, the description references Linux driver internals (phy_init() and phy_exit() reference counting) rather than strictly describing the hardware. [1] https://lore.kernel.org/r/20261105-kind-macaque-of-enhancement-ee0365@quoll -- Sashiko AI review · https://sashiko.dev/#/patchset/20261117022858.2210212-1-hongliang.yang@cixtech.com?part=1 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v8 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY @ 2026-11-17 2:52 ` sashiko-bot 0 siblings, 0 replies; 8+ messages in thread From: sashiko-bot @ 2026-11-17 2:52 UTC (permalink / raw) To: Hongliang Yang Cc: linux-phy, devicetree, robh, conor+dt, vkoul, neil.armstrong, olteanv Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: phy: cix,sky1-usb3-phy uses #phy-cells = 0 for two-lane PHY -- commit c8a29919e01294d52dd3eac0bc1ce8854b5d00a0 Author: Hongliang Yang <hongliang.yang@cixtech.com> dt-bindings: phy: Add CIX Sky1 USB3 PHY This commit adds the Device Tree binding schema for the CIX Sky1 USB3 SuperSpeedPlus PHY and updates MAINTAINERS. > diff --git a/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml > new file mode 100644 > index 0000000000000..205140bf84e7c > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml > @@ -0,0 +1,78 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: CIX Sky1 USB3 PHY > + > +maintainers: > + - Hongliang Yang <hongliang.yang@cixtech.com> > + > +description: | > + The CIX Sky1 USB3 PHY provides the SuperSpeed lanes of the USB3 Type-A > + ports of the SoC. > + > + Both lanes are programmed through one register block and share the > + same clocks and resets, so the node is a single PHY provider with > + #phy-cells = <0> that all consumers reference. The driver reference > + counts phy_init() and phy_exit(), so the block is set up once for all > + its consumers. > + > +properties: > + compatible: > + const: cix,sky1-usb3-phy > + > + reg: > + maxItems: 1 > + > + "#phy-cells": > + const: 0 [Severity: Low] As reported by Krzysztof Kozlowski on v6 [1], shouldn't #phy-cells be 1 instead of 0 so that each USB3 controller consumer node can specify which of the two PHY lanes it is connected to? The hardware block has two distinct lanes with separate per-lane register sets serving two independent USB3 controllers. Locking #phy-cells to 0 omits the per-lane routing from the Device Tree ABI and prevents any future per-lane control or tuning without breaking the binding. Also, the description references Linux driver internals (phy_init() and phy_exit() reference counting) rather than strictly describing the hardware. [1] https://lore.kernel.org/r/20261105-kind-macaque-of-enhancement-ee0365@quoll -- Sashiko AI review · https://sashiko.dev/#/patchset/20261117022858.2210212-1-hongliang.yang@cixtech.com?part=1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v8 2/2] phy: cix: Add CIX Sky1 USB3 PHY driver 2026-11-17 2:28 ` Hongliang Yang @ 2026-11-17 2:28 ` Hongliang Yang -1 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang Add a driver for the Cadence SD0803 USB3 PHY integrated in the CIX Sky1 SoC. The driver enables the APB and reference clocks, releases the resets, programs the register sequence of the PHY, and exports a single PHY instance for the two lanes of the block. The PHY core reference counts phy_init() and phy_exit(), so the sequence is programmed once and the block stays powered while any of its consumers is active. Signed-off-by: Hongliang Yang <hongliang.yang@cixtech.com> --- Changes in v8: - Rely on the PHY core for serialization and reference counting instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations: the per-SoC callback structure and its duplicate error messages are gone. - Drop the register macros that the initialization sequence does not use from the private header. Changes in v7: - Rename the register header to phy-cix-usb3.h: it is the register map of the USB3 PHY, and the old usbdp name suggested a USB/DP combo PHY. - Fix the module description and the Kconfig help text. Changes in v6: - Select REGMAP in the Kconfig. - Use dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path. - Assert the resets before registering the PHY provider, disable the clocks in LIFO order, and fix the error unroll path so that clocks which were never enabled are not disabled. --- MAINTAINERS | 1 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 21 +++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 313 +++++++++++++++++++++++++++++++++ drivers/phy/cix/phy-cix-usb3.h | 180 +++++++++++++++++++ 7 files changed, 523 insertions(+) create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usb3.h diff --git a/MAINTAINERS b/MAINTAINERS index 73783abe027e..b857e529e5e2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2906,6 +2906,7 @@ F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORT diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 105fbe408aa2..876e5857634c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -176,6 +176,7 @@ source "drivers/phy/axiado/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/canaan/Kconfig" +source "drivers/phy/cix/Kconfig" source "drivers/phy/eswin/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c6dd02003bbe..5a31c5df1746 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ broadcom/ \ cadence/ \ canaan/ \ + cix/ \ eswin/ \ freescale/ \ hisilicon/ \ diff --git a/drivers/phy/cix/Kconfig b/drivers/phy/cix/Kconfig new file mode 100644 index 000000000000..24452144ff78 --- /dev/null +++ b/drivers/phy/cix/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# PHY drivers for CIX PHYs +# + +if ARCH_CIX || COMPILE_TEST + +config PHY_CIX_USB3 + tristate "CIX Sky1 USB3 Type-A PHY support" + depends on OF && HAS_IOMEM + select GENERIC_PHY + select REGMAP + help + Enable this to support the USB3 SuperSpeed PHY of the Type-A + ports on CIX Sky1 SoCs. The PHY provides the SuperSpeed lanes + used by the two Cadence USBSSP controllers (USB4 and USB5) of + the SoC, and is shared between them. + + If unsure, say N. + +endif # ARCH_CIX || COMPILE_TEST diff --git a/drivers/phy/cix/Makefile b/drivers/phy/cix/Makefile new file mode 100644 index 000000000000..58ec925a4425 --- /dev/null +++ b/drivers/phy/cix/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the CIX PHY drivers. +# + +obj-$(CONFIG_PHY_CIX_USB3) += phy-cix-usb3.o diff --git a/drivers/phy/cix/phy-cix-usb3.c b/drivers/phy/cix/phy-cix-usb3.c new file mode 100644 index 000000000000..ca6a0e764e90 --- /dev/null +++ b/drivers/phy/cix/phy-cix-usb3.c @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * phy driver for cdn_sd0803_t7g_typea + * + * Author: Hongliang Yang <hongliang.yang@cixtech.com> + */ + +#include <linux/array_size.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include "phy-cix-usb3.h" + +/* + * Cadence SD0803 Type-A USB3 PHY initialization sequence for the CIX + * Sky1 SoC, taken from the vendor-provided PHY register programming + * sequence for this SoC. + */ +static const struct reg_sequence sky1_u3phy_conf[] = { + {CMN_SSM_BIAS_TMR, 0x0018}, + {CMN_PLLSM0_PLLPRE_TMR, 0x0030}, + {CMN_PLLSM0_PLLLOCK_TMR, 0x00f0}, + {CMN_PLLSM1_PLLPRE_TMR, 0x0030}, + {CMN_PLLSM1_PLLLOCK_TMR, 0x00f0}, + {CMN_BGCAL_INIT_TMR, 0x0078}, + {CMN_BGCAL_ITER_TMR, 0x0078}, + {CMN_IBCAL_INIT_TMR, 0x0018}, + {CMN_TXPUCAL_INIT_TMR, 0x001d}, + {CMN_TXPDCAL_INIT_TMR, 0x001d}, + {CMN_RXCAL_INIT_TMR, 0x02d0}, + {CMN_SD_CAL_PLLCNT_START, 0x0137}, + {RX_SDCAL0_INIT_TMR_LANE0, 0x0018}, + {RX_SDCAL0_INIT_TMR_LANE1, 0x0018}, + {RX_SDCAL0_ITER_TMR_LANE0, 0x0078}, + {RX_SDCAL0_ITER_TMR_LANE1, 0x0078}, + {RX_SDCAL1_INIT_TMR_LANE0, 0x0018}, + {RX_SDCAL1_INIT_TMR_LANE1, 0x0018}, + {RX_SDCAL1_ITER_TMR_LANE0, 0x0078}, + {RX_SDCAL1_ITER_TMR_LANE1, 0x0078}, + {TX_RCVDET_ST_TMR_LANE0, 0x0960}, + {TX_RCVDET_ST_TMR_LANE1, 0x0960}, + + {PHY_PLL_CFG_0803, 0x0000}, + {CMN_PDIAG_PLL0_CLK_SEL_M0, 0x8600}, + {XCVR_DIAG_HSCLK_SEL_LANE0, 0x0000}, + {XCVR_DIAG_HSCLK_SEL_LANE1, 0x0000}, + {XCVR_DIAG_HSCLK_DIV_LANE0, 0x0001}, + {XCVR_DIAG_HSCLK_DIV_LANE1, 0x0001}, + {XCVR_DIAG_PLLDRC_CTRL_LANE0, 0x0041}, + {XCVR_DIAG_PLLDRC_CTRL_LANE1, 0x0041}, + {CMN_PLL0_DSM_DIAG_M0, 0x0004}, + {CMN_PLL1_DSM_DIAG_M0, 0x0004}, + {CMN_PDIAG_PLL1_ITRIM_M0, 0x003f}, + {CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0b17}, + {CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0b17}, + {CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0e01}, + {CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0e01}, + {CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0d05}, + {CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0d05}, + {CMN_PLL0_INTDIV_M0, 0x01a0}, + {CMN_PLL1_INTDIV_M0, 0x01a0}, + {CMN_PLL0_FRACDIVL_M0, 0xaaab}, + {CMN_PLL1_FRACDIVL_M0, 0xaaab}, + {CMN_PLL0_FRACDIVH_M0, 0x0002}, + {CMN_PLL1_FRACDIVH_M0, 0x0002}, + {CMN_PLL0_HIGH_THR_M0, 0x0116}, + {CMN_PLL1_HIGH_THR_M0, 0x0116}, + {CMN_PDIAG_PLL0_CTRL_M0, 0x1002}, + {CMN_PDIAG_PLL1_CTRL_M0, 0x1002}, + {CMN_PLL0_SS_CTRL1_M0, 0x0001}, /* SSC enabled */ + {CMN_PLL0_VCOCAL_INIT_TMR, 0x00f0}, + {CMN_PLL1_VCOCAL_INIT_TMR, 0x00f0}, + {CMN_PLL0_VCOCAL_ITER_TMR, 0x0004}, + {CMN_PLL1_VCOCAL_ITER_TMR, 0x0004}, + {CMN_PLL0_VCOCAL_REFTIM_START, 0x02f8}, + {CMN_PLL1_VCOCAL_REFTIM_START, 0x02f8}, + {CMN_PLL0_VCOCAL_PLLCNT_START, 0x02f8}, + {CMN_PLL1_VCOCAL_PLLCNT_START, 0x02f8}, + {CMN_PLL0_VCOCAL_TCTRL, 0x0003}, + {CMN_PLL1_VCOCAL_TCTRL, 0x0003}, + {CMN_PLL0_LOCK_REFCNT_START, 0x00bf}, + {CMN_PLL1_LOCK_REFCNT_START, 0x00bf}, + {CMN_PLL0_LOCK_PLLCNT_START, 0x00bf}, + {CMN_PLL1_LOCK_PLLCNT_START, 0x00bf}, + {CMN_PLL0_LOCK_PLLCNT_THR, 0x0003}, + {CMN_PLL1_LOCK_PLLCNT_THR, 0x0003}, + {PHY_PIPE_USB3_GEN2_PRE_CFG0_0803, 0x0a0a}, + {PHY_PIPE_USB3_GEN2_POST_CFG0_0803, 0x1000}, + {PHY_PIPE_USB3_GEN2_POST_CFG1_0803, 0x0010}, + {CMN_CDIAG_CDB_PWRI_OVRD, 0x8200}, + {CMN_CDIAG_XCVRC_PWRI_OVRD, 0x8200}, + {TX_PSC_A0_LANE0, 0x02ff}, + {TX_PSC_A0_LANE1, 0x02ff}, + {TX_PSC_A1_LANE0, 0x06af}, + {TX_PSC_A1_LANE1, 0x06af}, + {TX_PSC_A2_LANE0, 0x06ae}, + {TX_PSC_A2_LANE1, 0x06ae}, + {TX_PSC_A3_LANE0, 0x06ae}, + {TX_PSC_A3_LANE1, 0x06ae}, + {RX_PSC_A0_LANE0, 0x0d1d}, + {RX_PSC_A0_LANE1, 0x0d1d}, + {RX_PSC_A1_LANE0, 0x0d1d}, + {RX_PSC_A1_LANE1, 0x0d1d}, + {RX_PSC_A2_LANE0, 0x0d00}, + {RX_PSC_A2_LANE1, 0x0d00}, + {RX_PSC_A3_LANE0, 0x0500}, + {RX_PSC_A3_LANE1, 0x0500}, + {TX_TXCC_CTRL_LANE0, 0x2a82}, + {TX_TXCC_CTRL_LANE1, 0x2a82}, + {TX_TXCC_CPOST_MULT_01_LANE0, 0x0014}, + {TX_TXCC_CPOST_MULT_01_LANE1, 0x0014}, + {TX_TXCC_MGNFS_MULT_000_LANE0, 0x0002}, + {TX_TXCC_MGNFS_MULT_000_LANE1, 0x0002}, + {RX_SIGDET_HL_FILT_TMR_LANE0, 0x0013}, + {RX_SIGDET_HL_FILT_TMR_LANE1, 0x0013}, + {RX_REE_GCSM1_CTRL_LANE0, 0x0000}, + {RX_REE_GCSM1_CTRL_LANE1, 0x0000}, + {RX_REE_ATTEN_THR_LANE0, 0x0c02}, + {RX_REE_ATTEN_THR_LANE1, 0x0c02}, + {RX_REE_SMGM_CTRL1_LANE0, 0x0330}, + {RX_REE_SMGM_CTRL1_LANE1, 0x0330}, + {RX_REE_SMGM_CTRL2_LANE0, 0x0300}, + {RX_REE_SMGM_CTRL2_LANE1, 0x0300}, + {XCVR_DIAG_PSC_OVRD_LANE0, 0x0003}, + {XCVR_DIAG_PSC_OVRD_LANE1, 0x0003}, + {RX_DIAG_SIGDET_TUNE_LANE0, 0x1004}, + {RX_DIAG_SIGDET_TUNE_LANE1, 0x1004}, + {RX_DIAG_NQST_CTRL_LANE0, 0x00f9}, + {RX_DIAG_NQST_CTRL_LANE1, 0x00f9}, + {RX_DIAG_DFE_AMP_TUNE_2_LANE0, 0x0c01}, + {RX_DIAG_DFE_AMP_TUNE_2_LANE1, 0x0c01}, + {RX_DIAG_DFE_AMP_TUNE_3_LANE0, 0x0002}, + {RX_DIAG_DFE_AMP_TUNE_3_LANE1, 0x0002}, + {RX_DIAG_PI_CAP_LANE0, 0x0000}, + {RX_DIAG_PI_CAP_LANE1, 0x0000}, + {RX_DIAG_PI_RATE_LANE0, 0x0031}, + {RX_DIAG_PI_RATE_LANE1, 0x0031}, + {RX_CDRLF_CNFG_LANE0, 0x018c}, + {RX_CDRLF_CNFG_LANE1, 0x018c}, + {RX_CDRLF_CNFG3_LANE0, 0x0003}, + {RX_CDRLF_CNFG3_LANE1, 0x0003} +}; + +struct cix_u3phy { + struct device *dev; + void __iomem *base; + struct regmap *phy_regmap; + struct reset_control *preset; + struct reset_control *reset; + struct clk *apb_clk; + struct clk *ref_clk; +}; + +static int cix_u3phy_exit(struct phy *phy) +{ + struct cix_u3phy *u3phy = phy_get_drvdata(phy); + + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + clk_disable_unprepare(u3phy->ref_clk); + clk_disable_unprepare(u3phy->apb_clk); + return 0; +} + +static int cix_u3phy_init(struct phy *phy) +{ + struct cix_u3phy *u3phy = phy_get_drvdata(phy); + int ret; + + /* usb rcsu reset is default deassert */ + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + + ret = clk_prepare_enable(u3phy->apb_clk); + if (ret) { + dev_err(u3phy->dev, "failed to enable the APB clock\n"); + return ret; + } + ret = clk_prepare_enable(u3phy->ref_clk); + if (ret) { + dev_err(u3phy->dev, "failed to enable the reference clock\n"); + goto disable_apb_clk; + } + reset_control_deassert(u3phy->preset); + ret = regmap_multi_reg_write(u3phy->phy_regmap, sky1_u3phy_conf, + ARRAY_SIZE(sky1_u3phy_conf)); + if (ret) { + dev_err(u3phy->dev, "failed to write the PHY register sequence\n"); + goto assert_reset_preset; + } + reset_control_deassert(u3phy->reset); + return 0; + +assert_reset_preset: + reset_control_assert(u3phy->preset); + reset_control_assert(u3phy->reset); + clk_disable_unprepare(u3phy->ref_clk); +disable_apb_clk: + clk_disable_unprepare(u3phy->apb_clk); + return ret; +} + +static int u3phy_regmap_write(void *context, unsigned int reg, unsigned int val) +{ + struct cix_u3phy *u3phy = context; + u32 offset = reg << 2; + + writel(val, u3phy->base + offset); + return 0; +} + +static int u3phy_regmap_read(void *context, unsigned int reg, unsigned int *val) +{ + struct cix_u3phy *u3phy = context; + u32 offset = reg << 2; + + *val = readl(u3phy->base + offset); + return 0; +} + +static const struct regmap_config cix_u3phy_regmap_cfg = { + .reg_bits = 32, + .reg_stride = 1, + .val_bits = 16, + .fast_io = true, + .reg_write = u3phy_regmap_write, + .reg_read = u3phy_regmap_read, +}; + +static const struct phy_ops cix_u3phy_ops = { + .init = cix_u3phy_init, + .exit = cix_u3phy_exit, + .owner = THIS_MODULE, +}; + +static int cix_u3phy_probe(struct platform_device *pdev) +{ + struct cix_u3phy *u3phy; + struct device *dev = &pdev->dev; + struct phy_provider *phy_provider; + struct phy *phy; + + u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); + if (!u3phy) + return -ENOMEM; + u3phy->dev = dev; + u3phy->reset = devm_reset_control_get_exclusive(dev, "core"); + if (IS_ERR(u3phy->reset)) + return dev_err_probe(dev, PTR_ERR(u3phy->reset), + "failed to get core reset\n"); + u3phy->preset = devm_reset_control_get_exclusive(dev, "apb"); + if (IS_ERR(u3phy->preset)) + return dev_err_probe(dev, PTR_ERR(u3phy->preset), + "failed to get APB reset\n"); + u3phy->apb_clk = devm_clk_get(dev, "apb"); + if (IS_ERR(u3phy->apb_clk)) + return dev_err_probe(dev, PTR_ERR(u3phy->apb_clk), + "failed to get APB clock\n"); + u3phy->ref_clk = devm_clk_get(dev, "ref"); + if (IS_ERR(u3phy->ref_clk)) + return dev_err_probe(dev, PTR_ERR(u3phy->ref_clk), + "failed to get reference clock\n"); + u3phy->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(u3phy->base)) + return PTR_ERR(u3phy->base); + u3phy->phy_regmap = devm_regmap_init(dev, NULL, u3phy, &cix_u3phy_regmap_cfg); + if (IS_ERR(u3phy->phy_regmap)) + return dev_err_probe(dev, PTR_ERR(u3phy->phy_regmap), + "failed to init PHY regmap\n"); + /* + * The PHY block drives both USB3 lanes, so a single PHY instance is + * exported for the two controllers that share it. The PHY core + * serializes and reference counts the init and exit calls. + */ + phy = devm_phy_create(dev, NULL, &cix_u3phy_ops); + if (IS_ERR(phy)) + return dev_err_probe(dev, PTR_ERR(phy), "failed to create phy\n"); + phy_set_drvdata(phy, u3phy); + + /* keep the PHY in reset until a consumer calls phy_init() */ + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return dev_err_probe(dev, PTR_ERR(phy_provider), + "failed to register phy provider\n"); + return 0; +} + +static const struct of_device_id cix_u3phy_dt_match[] = { + { .compatible = "cix,sky1-usb3-phy" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, cix_u3phy_dt_match); + +static struct platform_driver cix_usb3_phy_driver = { + .probe = cix_u3phy_probe, + .driver = { + .name = "cix-usb3-phy", + .of_match_table = cix_u3phy_dt_match, + }, +}; + +module_platform_driver(cix_usb3_phy_driver); + +MODULE_AUTHOR("Hongliang Yang <hongliang.yang@cixtech.com>"); +MODULE_DESCRIPTION("CIX Sky1 USB3 PHY driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/phy/cix/phy-cix-usb3.h b/drivers/phy/cix/phy-cix-usb3.h new file mode 100644 index 000000000000..b36744124edd --- /dev/null +++ b/drivers/phy/cix/phy-cix-usb3.h @@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _PHY_CIX_USB3_H +#define _PHY_CIX_USB3_H + +#define CMN_SSM_BIAS_TMR 0x0022 +#define CMN_PLLSM0_PLLPRE_TMR 0x002a +#define CMN_PLLSM0_PLLLOCK_TMR 0x002c +#define CMN_PLLSM1_PLLPRE_TMR 0x0032 +#define CMN_PLLSM1_PLLLOCK_TMR 0x0034 +#define CMN_BGCAL_INIT_TMR 0x0064 +#define CMN_BGCAL_ITER_TMR 0x0065 +#define CMN_IBCAL_INIT_TMR 0x0074 +#define CMN_PLL0_SS_CTRL1_M0 0x0098 +#define CMN_TXPUCAL_INIT_TMR 0x0104 +#define CMN_TXPDCAL_INIT_TMR 0x010c +#define CMN_RXCAL_INIT_TMR 0x0114 +#define CMN_SD_CAL_PLLCNT_START 0x0128 +#define CMN_PDIAG_PLL1_ITRIM_M0 0x01c3 + +#define RX_SDCAL0_INIT_TMR_LANE0 0x8044 +#define RX_SDCAL0_INIT_TMR_LANE1 0x8244 + +#define RX_SDCAL0_ITER_TMR_LANE0 0x8045 +#define RX_SDCAL0_ITER_TMR_LANE1 0x8245 + +#define RX_SDCAL1_INIT_TMR_LANE0 0x804c +#define RX_SDCAL1_INIT_TMR_LANE1 0x824c + +#define RX_SDCAL1_ITER_TMR_LANE0 0x804d +#define RX_SDCAL1_ITER_TMR_LANE1 0x824d + +#define TX_RCVDET_ST_TMR_LANE0 0x4123 +#define TX_RCVDET_ST_TMR_LANE1 0x4323 + +#define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01a1 + +#define XCVR_DIAG_HSCLK_SEL_LANE0 0x40e6 +#define XCVR_DIAG_HSCLK_SEL_LANE1 0x42e6 + +#define XCVR_DIAG_HSCLK_DIV_LANE0 0x40e7 +#define XCVR_DIAG_HSCLK_DIV_LANE1 0x42e7 + +#define XCVR_DIAG_PLLDRC_CTRL_LANE0 0x40e5 +#define XCVR_DIAG_PLLDRC_CTRL_LANE1 0x42e5 + +#define CMN_PLL0_DSM_DIAG_M0 0x0094 +#define CMN_PLL1_DSM_DIAG_M0 0x00d4 +#define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01a4 +#define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01c4 + +#define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01a5 +#define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01c5 +#define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01a6 +#define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01c6 + +#define CMN_PLL0_INTDIV_M0 0x0090 +#define CMN_PLL1_INTDIV_M0 0x00d0 +#define CMN_PLL0_FRACDIVL_M0 0x0091 +#define CMN_PLL1_FRACDIVL_M0 0x00d1 + +#define CMN_PLL0_FRACDIVH_M0 0x0092 +#define CMN_PLL1_FRACDIVH_M0 0x00d2 +#define CMN_PLL0_HIGH_THR_M0 0x0093 +#define CMN_PLL1_HIGH_THR_M0 0x00d3 + +#define CMN_PDIAG_PLL0_CTRL_M0 0x01a0 +#define CMN_PDIAG_PLL1_CTRL_M0 0x01c0 + +#define CMN_PLL0_VCOCAL_TCTRL 0x0082 +#define CMN_PLL1_VCOCAL_TCTRL 0x00c2 + +#define CMN_PLL0_VCOCAL_INIT_TMR 0x0084 +#define CMN_PLL1_VCOCAL_INIT_TMR 0x00c4 + +#define CMN_PLL0_VCOCAL_ITER_TMR 0x0085 +#define CMN_PLL1_VCOCAL_ITER_TMR 0x00c5 + +#define CMN_PLL0_VCOCAL_REFTIM_START 0x0086 +#define CMN_PLL1_VCOCAL_REFTIM_START 0x00c6 + +#define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088 +#define CMN_PLL1_VCOCAL_PLLCNT_START 0x00c8 + +#define CMN_PLL0_LOCK_REFCNT_START 0x009c +#define CMN_PLL1_LOCK_REFCNT_START 0x00dc + +#define CMN_PLL0_LOCK_PLLCNT_START 0x009e +#define CMN_PLL1_LOCK_PLLCNT_START 0x00de + +#define CMN_PLL0_LOCK_PLLCNT_THR 0x009f +#define CMN_PLL1_LOCK_PLLCNT_THR 0x00df + +#define CMN_CDIAG_CDB_PWRI_OVRD 0x0041 +#define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047 + +#define TX_PSC_A0_LANE0 0x4100 +#define TX_PSC_A0_LANE1 0x4300 + +#define TX_PSC_A1_LANE0 0x4101 +#define TX_PSC_A1_LANE1 0x4301 + +#define TX_PSC_A2_LANE0 0x4102 +#define TX_PSC_A2_LANE1 0x4302 + +#define TX_PSC_A3_LANE0 0x4103 +#define TX_PSC_A3_LANE1 0x4303 + +#define RX_PSC_A0_LANE0 0x8000 +#define RX_PSC_A0_LANE1 0x8200 + +#define RX_PSC_A1_LANE0 0x8001 +#define RX_PSC_A1_LANE1 0x8201 + +#define RX_PSC_A2_LANE0 0x8002 +#define RX_PSC_A2_LANE1 0x8202 + +#define RX_PSC_A3_LANE0 0x8003 +#define RX_PSC_A3_LANE1 0x8203 + +#define TX_TXCC_CTRL_LANE0 0x4040 +#define TX_TXCC_CTRL_LANE1 0x4240 + +#define TX_TXCC_CPOST_MULT_01_LANE0 0x404d +#define TX_TXCC_CPOST_MULT_01_LANE1 0x424d + +#define TX_TXCC_MGNFS_MULT_000_LANE0 0x4050 +#define TX_TXCC_MGNFS_MULT_000_LANE1 0x4250 + +#define RX_SIGDET_HL_FILT_TMR_LANE0 0x8090 +#define RX_SIGDET_HL_FILT_TMR_LANE1 0x8290 + +#define RX_REE_GCSM1_CTRL_LANE0 0x8108 +#define RX_REE_GCSM1_CTRL_LANE1 0x8308 + +#define RX_REE_ATTEN_THR_LANE0 0x8149 +#define RX_REE_ATTEN_THR_LANE1 0x8349 + +#define RX_REE_SMGM_CTRL1_LANE0 0x8177 +#define RX_REE_SMGM_CTRL1_LANE1 0x8377 + +#define RX_REE_SMGM_CTRL2_LANE0 0x8178 +#define RX_REE_SMGM_CTRL2_LANE1 0x8378 + +#define XCVR_DIAG_PSC_OVRD_LANE0 0x40eb +#define XCVR_DIAG_PSC_OVRD_LANE1 0x42eb + +#define RX_DIAG_SIGDET_TUNE_LANE0 0x81e8 +#define RX_DIAG_SIGDET_TUNE_LANE1 0x83e8 + +#define RX_DIAG_NQST_CTRL_LANE0 0x81e5 +#define RX_DIAG_NQST_CTRL_LANE1 0x83e5 + +#define RX_DIAG_DFE_AMP_TUNE_2_LANE0 0x81e2 +#define RX_DIAG_DFE_AMP_TUNE_2_LANE1 0x83e2 + +#define RX_DIAG_DFE_AMP_TUNE_3_LANE0 0x81e3 +#define RX_DIAG_DFE_AMP_TUNE_3_LANE1 0x83e3 + +#define RX_DIAG_PI_CAP_LANE0 0x81f5 +#define RX_DIAG_PI_CAP_LANE1 0x83f5 + +#define RX_DIAG_PI_RATE_LANE0 0x81f4 +#define RX_DIAG_PI_RATE_LANE1 0x83f4 + +#define RX_CDRLF_CNFG_LANE0 0x8080 +#define RX_CDRLF_CNFG_LANE1 0x8280 + +#define RX_CDRLF_CNFG3_LANE0 0x8082 +#define RX_CDRLF_CNFG3_LANE1 0x8282 + +/* Bits */ + +#define PHY_PLL_CFG_0803 0xC00E +/* 0803 phy register */ +#define PHY_PIPE_USB3_GEN2_PRE_CFG0_0803 0xc01c +#define PHY_PIPE_USB3_GEN2_POST_CFG0_0803 0xc01e +#define PHY_PIPE_USB3_GEN2_POST_CFG1_0803 0xc01f + +#endif -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v8 2/2] phy: cix: Add CIX Sky1 USB3 PHY driver @ 2026-11-17 2:28 ` Hongliang Yang 0 siblings, 0 replies; 8+ messages in thread From: Hongliang Yang @ 2026-11-17 2:28 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Gary Yang, Fugang Duan Cc: linux-phy, linux-arm-kernel, devicetree, linux-kernel, cix-kernel-upstream, Hongliang Yang Add a driver for the Cadence SD0803 USB3 PHY integrated in the CIX Sky1 SoC. The driver enables the APB and reference clocks, releases the resets, programs the register sequence of the PHY, and exports a single PHY instance for the two lanes of the block. The PHY core reference counts phy_init() and phy_exit(), so the sequence is programmed once and the block stays powered while any of its consumers is active. Signed-off-by: Hongliang Yang <hongliang.yang@cixtech.com> --- Changes in v8: - Rely on the PHY core for serialization and reference counting instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations: the per-SoC callback structure and its duplicate error messages are gone. - Drop the register macros that the initialization sequence does not use from the private header. Changes in v7: - Rename the register header to phy-cix-usb3.h: it is the register map of the USB3 PHY, and the old usbdp name suggested a USB/DP combo PHY. - Fix the module description and the Kconfig help text. Changes in v6: - Select REGMAP in the Kconfig. - Use dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path. - Assert the resets before registering the PHY provider, disable the clocks in LIFO order, and fix the error unroll path so that clocks which were never enabled are not disabled. --- MAINTAINERS | 1 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 21 +++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 313 +++++++++++++++++++++++++++++++++ drivers/phy/cix/phy-cix-usb3.h | 180 +++++++++++++++++++ 7 files changed, 523 insertions(+) create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usb3.h diff --git a/MAINTAINERS b/MAINTAINERS index 73783abe027e..b857e529e5e2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2906,6 +2906,7 @@ F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORT diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 105fbe408aa2..876e5857634c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -176,6 +176,7 @@ source "drivers/phy/axiado/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/canaan/Kconfig" +source "drivers/phy/cix/Kconfig" source "drivers/phy/eswin/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c6dd02003bbe..5a31c5df1746 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ broadcom/ \ cadence/ \ canaan/ \ + cix/ \ eswin/ \ freescale/ \ hisilicon/ \ diff --git a/drivers/phy/cix/Kconfig b/drivers/phy/cix/Kconfig new file mode 100644 index 000000000000..24452144ff78 --- /dev/null +++ b/drivers/phy/cix/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# PHY drivers for CIX PHYs +# + +if ARCH_CIX || COMPILE_TEST + +config PHY_CIX_USB3 + tristate "CIX Sky1 USB3 Type-A PHY support" + depends on OF && HAS_IOMEM + select GENERIC_PHY + select REGMAP + help + Enable this to support the USB3 SuperSpeed PHY of the Type-A + ports on CIX Sky1 SoCs. The PHY provides the SuperSpeed lanes + used by the two Cadence USBSSP controllers (USB4 and USB5) of + the SoC, and is shared between them. + + If unsure, say N. + +endif # ARCH_CIX || COMPILE_TEST diff --git a/drivers/phy/cix/Makefile b/drivers/phy/cix/Makefile new file mode 100644 index 000000000000..58ec925a4425 --- /dev/null +++ b/drivers/phy/cix/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the CIX PHY drivers. +# + +obj-$(CONFIG_PHY_CIX_USB3) += phy-cix-usb3.o diff --git a/drivers/phy/cix/phy-cix-usb3.c b/drivers/phy/cix/phy-cix-usb3.c new file mode 100644 index 000000000000..ca6a0e764e90 --- /dev/null +++ b/drivers/phy/cix/phy-cix-usb3.c @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * phy driver for cdn_sd0803_t7g_typea + * + * Author: Hongliang Yang <hongliang.yang@cixtech.com> + */ + +#include <linux/array_size.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include "phy-cix-usb3.h" + +/* + * Cadence SD0803 Type-A USB3 PHY initialization sequence for the CIX + * Sky1 SoC, taken from the vendor-provided PHY register programming + * sequence for this SoC. + */ +static const struct reg_sequence sky1_u3phy_conf[] = { + {CMN_SSM_BIAS_TMR, 0x0018}, + {CMN_PLLSM0_PLLPRE_TMR, 0x0030}, + {CMN_PLLSM0_PLLLOCK_TMR, 0x00f0}, + {CMN_PLLSM1_PLLPRE_TMR, 0x0030}, + {CMN_PLLSM1_PLLLOCK_TMR, 0x00f0}, + {CMN_BGCAL_INIT_TMR, 0x0078}, + {CMN_BGCAL_ITER_TMR, 0x0078}, + {CMN_IBCAL_INIT_TMR, 0x0018}, + {CMN_TXPUCAL_INIT_TMR, 0x001d}, + {CMN_TXPDCAL_INIT_TMR, 0x001d}, + {CMN_RXCAL_INIT_TMR, 0x02d0}, + {CMN_SD_CAL_PLLCNT_START, 0x0137}, + {RX_SDCAL0_INIT_TMR_LANE0, 0x0018}, + {RX_SDCAL0_INIT_TMR_LANE1, 0x0018}, + {RX_SDCAL0_ITER_TMR_LANE0, 0x0078}, + {RX_SDCAL0_ITER_TMR_LANE1, 0x0078}, + {RX_SDCAL1_INIT_TMR_LANE0, 0x0018}, + {RX_SDCAL1_INIT_TMR_LANE1, 0x0018}, + {RX_SDCAL1_ITER_TMR_LANE0, 0x0078}, + {RX_SDCAL1_ITER_TMR_LANE1, 0x0078}, + {TX_RCVDET_ST_TMR_LANE0, 0x0960}, + {TX_RCVDET_ST_TMR_LANE1, 0x0960}, + + {PHY_PLL_CFG_0803, 0x0000}, + {CMN_PDIAG_PLL0_CLK_SEL_M0, 0x8600}, + {XCVR_DIAG_HSCLK_SEL_LANE0, 0x0000}, + {XCVR_DIAG_HSCLK_SEL_LANE1, 0x0000}, + {XCVR_DIAG_HSCLK_DIV_LANE0, 0x0001}, + {XCVR_DIAG_HSCLK_DIV_LANE1, 0x0001}, + {XCVR_DIAG_PLLDRC_CTRL_LANE0, 0x0041}, + {XCVR_DIAG_PLLDRC_CTRL_LANE1, 0x0041}, + {CMN_PLL0_DSM_DIAG_M0, 0x0004}, + {CMN_PLL1_DSM_DIAG_M0, 0x0004}, + {CMN_PDIAG_PLL1_ITRIM_M0, 0x003f}, + {CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0b17}, + {CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0b17}, + {CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0e01}, + {CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0e01}, + {CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0d05}, + {CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0d05}, + {CMN_PLL0_INTDIV_M0, 0x01a0}, + {CMN_PLL1_INTDIV_M0, 0x01a0}, + {CMN_PLL0_FRACDIVL_M0, 0xaaab}, + {CMN_PLL1_FRACDIVL_M0, 0xaaab}, + {CMN_PLL0_FRACDIVH_M0, 0x0002}, + {CMN_PLL1_FRACDIVH_M0, 0x0002}, + {CMN_PLL0_HIGH_THR_M0, 0x0116}, + {CMN_PLL1_HIGH_THR_M0, 0x0116}, + {CMN_PDIAG_PLL0_CTRL_M0, 0x1002}, + {CMN_PDIAG_PLL1_CTRL_M0, 0x1002}, + {CMN_PLL0_SS_CTRL1_M0, 0x0001}, /* SSC enabled */ + {CMN_PLL0_VCOCAL_INIT_TMR, 0x00f0}, + {CMN_PLL1_VCOCAL_INIT_TMR, 0x00f0}, + {CMN_PLL0_VCOCAL_ITER_TMR, 0x0004}, + {CMN_PLL1_VCOCAL_ITER_TMR, 0x0004}, + {CMN_PLL0_VCOCAL_REFTIM_START, 0x02f8}, + {CMN_PLL1_VCOCAL_REFTIM_START, 0x02f8}, + {CMN_PLL0_VCOCAL_PLLCNT_START, 0x02f8}, + {CMN_PLL1_VCOCAL_PLLCNT_START, 0x02f8}, + {CMN_PLL0_VCOCAL_TCTRL, 0x0003}, + {CMN_PLL1_VCOCAL_TCTRL, 0x0003}, + {CMN_PLL0_LOCK_REFCNT_START, 0x00bf}, + {CMN_PLL1_LOCK_REFCNT_START, 0x00bf}, + {CMN_PLL0_LOCK_PLLCNT_START, 0x00bf}, + {CMN_PLL1_LOCK_PLLCNT_START, 0x00bf}, + {CMN_PLL0_LOCK_PLLCNT_THR, 0x0003}, + {CMN_PLL1_LOCK_PLLCNT_THR, 0x0003}, + {PHY_PIPE_USB3_GEN2_PRE_CFG0_0803, 0x0a0a}, + {PHY_PIPE_USB3_GEN2_POST_CFG0_0803, 0x1000}, + {PHY_PIPE_USB3_GEN2_POST_CFG1_0803, 0x0010}, + {CMN_CDIAG_CDB_PWRI_OVRD, 0x8200}, + {CMN_CDIAG_XCVRC_PWRI_OVRD, 0x8200}, + {TX_PSC_A0_LANE0, 0x02ff}, + {TX_PSC_A0_LANE1, 0x02ff}, + {TX_PSC_A1_LANE0, 0x06af}, + {TX_PSC_A1_LANE1, 0x06af}, + {TX_PSC_A2_LANE0, 0x06ae}, + {TX_PSC_A2_LANE1, 0x06ae}, + {TX_PSC_A3_LANE0, 0x06ae}, + {TX_PSC_A3_LANE1, 0x06ae}, + {RX_PSC_A0_LANE0, 0x0d1d}, + {RX_PSC_A0_LANE1, 0x0d1d}, + {RX_PSC_A1_LANE0, 0x0d1d}, + {RX_PSC_A1_LANE1, 0x0d1d}, + {RX_PSC_A2_LANE0, 0x0d00}, + {RX_PSC_A2_LANE1, 0x0d00}, + {RX_PSC_A3_LANE0, 0x0500}, + {RX_PSC_A3_LANE1, 0x0500}, + {TX_TXCC_CTRL_LANE0, 0x2a82}, + {TX_TXCC_CTRL_LANE1, 0x2a82}, + {TX_TXCC_CPOST_MULT_01_LANE0, 0x0014}, + {TX_TXCC_CPOST_MULT_01_LANE1, 0x0014}, + {TX_TXCC_MGNFS_MULT_000_LANE0, 0x0002}, + {TX_TXCC_MGNFS_MULT_000_LANE1, 0x0002}, + {RX_SIGDET_HL_FILT_TMR_LANE0, 0x0013}, + {RX_SIGDET_HL_FILT_TMR_LANE1, 0x0013}, + {RX_REE_GCSM1_CTRL_LANE0, 0x0000}, + {RX_REE_GCSM1_CTRL_LANE1, 0x0000}, + {RX_REE_ATTEN_THR_LANE0, 0x0c02}, + {RX_REE_ATTEN_THR_LANE1, 0x0c02}, + {RX_REE_SMGM_CTRL1_LANE0, 0x0330}, + {RX_REE_SMGM_CTRL1_LANE1, 0x0330}, + {RX_REE_SMGM_CTRL2_LANE0, 0x0300}, + {RX_REE_SMGM_CTRL2_LANE1, 0x0300}, + {XCVR_DIAG_PSC_OVRD_LANE0, 0x0003}, + {XCVR_DIAG_PSC_OVRD_LANE1, 0x0003}, + {RX_DIAG_SIGDET_TUNE_LANE0, 0x1004}, + {RX_DIAG_SIGDET_TUNE_LANE1, 0x1004}, + {RX_DIAG_NQST_CTRL_LANE0, 0x00f9}, + {RX_DIAG_NQST_CTRL_LANE1, 0x00f9}, + {RX_DIAG_DFE_AMP_TUNE_2_LANE0, 0x0c01}, + {RX_DIAG_DFE_AMP_TUNE_2_LANE1, 0x0c01}, + {RX_DIAG_DFE_AMP_TUNE_3_LANE0, 0x0002}, + {RX_DIAG_DFE_AMP_TUNE_3_LANE1, 0x0002}, + {RX_DIAG_PI_CAP_LANE0, 0x0000}, + {RX_DIAG_PI_CAP_LANE1, 0x0000}, + {RX_DIAG_PI_RATE_LANE0, 0x0031}, + {RX_DIAG_PI_RATE_LANE1, 0x0031}, + {RX_CDRLF_CNFG_LANE0, 0x018c}, + {RX_CDRLF_CNFG_LANE1, 0x018c}, + {RX_CDRLF_CNFG3_LANE0, 0x0003}, + {RX_CDRLF_CNFG3_LANE1, 0x0003} +}; + +struct cix_u3phy { + struct device *dev; + void __iomem *base; + struct regmap *phy_regmap; + struct reset_control *preset; + struct reset_control *reset; + struct clk *apb_clk; + struct clk *ref_clk; +}; + +static int cix_u3phy_exit(struct phy *phy) +{ + struct cix_u3phy *u3phy = phy_get_drvdata(phy); + + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + clk_disable_unprepare(u3phy->ref_clk); + clk_disable_unprepare(u3phy->apb_clk); + return 0; +} + +static int cix_u3phy_init(struct phy *phy) +{ + struct cix_u3phy *u3phy = phy_get_drvdata(phy); + int ret; + + /* usb rcsu reset is default deassert */ + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + + ret = clk_prepare_enable(u3phy->apb_clk); + if (ret) { + dev_err(u3phy->dev, "failed to enable the APB clock\n"); + return ret; + } + ret = clk_prepare_enable(u3phy->ref_clk); + if (ret) { + dev_err(u3phy->dev, "failed to enable the reference clock\n"); + goto disable_apb_clk; + } + reset_control_deassert(u3phy->preset); + ret = regmap_multi_reg_write(u3phy->phy_regmap, sky1_u3phy_conf, + ARRAY_SIZE(sky1_u3phy_conf)); + if (ret) { + dev_err(u3phy->dev, "failed to write the PHY register sequence\n"); + goto assert_reset_preset; + } + reset_control_deassert(u3phy->reset); + return 0; + +assert_reset_preset: + reset_control_assert(u3phy->preset); + reset_control_assert(u3phy->reset); + clk_disable_unprepare(u3phy->ref_clk); +disable_apb_clk: + clk_disable_unprepare(u3phy->apb_clk); + return ret; +} + +static int u3phy_regmap_write(void *context, unsigned int reg, unsigned int val) +{ + struct cix_u3phy *u3phy = context; + u32 offset = reg << 2; + + writel(val, u3phy->base + offset); + return 0; +} + +static int u3phy_regmap_read(void *context, unsigned int reg, unsigned int *val) +{ + struct cix_u3phy *u3phy = context; + u32 offset = reg << 2; + + *val = readl(u3phy->base + offset); + return 0; +} + +static const struct regmap_config cix_u3phy_regmap_cfg = { + .reg_bits = 32, + .reg_stride = 1, + .val_bits = 16, + .fast_io = true, + .reg_write = u3phy_regmap_write, + .reg_read = u3phy_regmap_read, +}; + +static const struct phy_ops cix_u3phy_ops = { + .init = cix_u3phy_init, + .exit = cix_u3phy_exit, + .owner = THIS_MODULE, +}; + +static int cix_u3phy_probe(struct platform_device *pdev) +{ + struct cix_u3phy *u3phy; + struct device *dev = &pdev->dev; + struct phy_provider *phy_provider; + struct phy *phy; + + u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); + if (!u3phy) + return -ENOMEM; + u3phy->dev = dev; + u3phy->reset = devm_reset_control_get_exclusive(dev, "core"); + if (IS_ERR(u3phy->reset)) + return dev_err_probe(dev, PTR_ERR(u3phy->reset), + "failed to get core reset\n"); + u3phy->preset = devm_reset_control_get_exclusive(dev, "apb"); + if (IS_ERR(u3phy->preset)) + return dev_err_probe(dev, PTR_ERR(u3phy->preset), + "failed to get APB reset\n"); + u3phy->apb_clk = devm_clk_get(dev, "apb"); + if (IS_ERR(u3phy->apb_clk)) + return dev_err_probe(dev, PTR_ERR(u3phy->apb_clk), + "failed to get APB clock\n"); + u3phy->ref_clk = devm_clk_get(dev, "ref"); + if (IS_ERR(u3phy->ref_clk)) + return dev_err_probe(dev, PTR_ERR(u3phy->ref_clk), + "failed to get reference clock\n"); + u3phy->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(u3phy->base)) + return PTR_ERR(u3phy->base); + u3phy->phy_regmap = devm_regmap_init(dev, NULL, u3phy, &cix_u3phy_regmap_cfg); + if (IS_ERR(u3phy->phy_regmap)) + return dev_err_probe(dev, PTR_ERR(u3phy->phy_regmap), + "failed to init PHY regmap\n"); + /* + * The PHY block drives both USB3 lanes, so a single PHY instance is + * exported for the two controllers that share it. The PHY core + * serializes and reference counts the init and exit calls. + */ + phy = devm_phy_create(dev, NULL, &cix_u3phy_ops); + if (IS_ERR(phy)) + return dev_err_probe(dev, PTR_ERR(phy), "failed to create phy\n"); + phy_set_drvdata(phy, u3phy); + + /* keep the PHY in reset until a consumer calls phy_init() */ + reset_control_assert(u3phy->reset); + reset_control_assert(u3phy->preset); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return dev_err_probe(dev, PTR_ERR(phy_provider), + "failed to register phy provider\n"); + return 0; +} + +static const struct of_device_id cix_u3phy_dt_match[] = { + { .compatible = "cix,sky1-usb3-phy" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, cix_u3phy_dt_match); + +static struct platform_driver cix_usb3_phy_driver = { + .probe = cix_u3phy_probe, + .driver = { + .name = "cix-usb3-phy", + .of_match_table = cix_u3phy_dt_match, + }, +}; + +module_platform_driver(cix_usb3_phy_driver); + +MODULE_AUTHOR("Hongliang Yang <hongliang.yang@cixtech.com>"); +MODULE_DESCRIPTION("CIX Sky1 USB3 PHY driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/phy/cix/phy-cix-usb3.h b/drivers/phy/cix/phy-cix-usb3.h new file mode 100644 index 000000000000..b36744124edd --- /dev/null +++ b/drivers/phy/cix/phy-cix-usb3.h @@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _PHY_CIX_USB3_H +#define _PHY_CIX_USB3_H + +#define CMN_SSM_BIAS_TMR 0x0022 +#define CMN_PLLSM0_PLLPRE_TMR 0x002a +#define CMN_PLLSM0_PLLLOCK_TMR 0x002c +#define CMN_PLLSM1_PLLPRE_TMR 0x0032 +#define CMN_PLLSM1_PLLLOCK_TMR 0x0034 +#define CMN_BGCAL_INIT_TMR 0x0064 +#define CMN_BGCAL_ITER_TMR 0x0065 +#define CMN_IBCAL_INIT_TMR 0x0074 +#define CMN_PLL0_SS_CTRL1_M0 0x0098 +#define CMN_TXPUCAL_INIT_TMR 0x0104 +#define CMN_TXPDCAL_INIT_TMR 0x010c +#define CMN_RXCAL_INIT_TMR 0x0114 +#define CMN_SD_CAL_PLLCNT_START 0x0128 +#define CMN_PDIAG_PLL1_ITRIM_M0 0x01c3 + +#define RX_SDCAL0_INIT_TMR_LANE0 0x8044 +#define RX_SDCAL0_INIT_TMR_LANE1 0x8244 + +#define RX_SDCAL0_ITER_TMR_LANE0 0x8045 +#define RX_SDCAL0_ITER_TMR_LANE1 0x8245 + +#define RX_SDCAL1_INIT_TMR_LANE0 0x804c +#define RX_SDCAL1_INIT_TMR_LANE1 0x824c + +#define RX_SDCAL1_ITER_TMR_LANE0 0x804d +#define RX_SDCAL1_ITER_TMR_LANE1 0x824d + +#define TX_RCVDET_ST_TMR_LANE0 0x4123 +#define TX_RCVDET_ST_TMR_LANE1 0x4323 + +#define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01a1 + +#define XCVR_DIAG_HSCLK_SEL_LANE0 0x40e6 +#define XCVR_DIAG_HSCLK_SEL_LANE1 0x42e6 + +#define XCVR_DIAG_HSCLK_DIV_LANE0 0x40e7 +#define XCVR_DIAG_HSCLK_DIV_LANE1 0x42e7 + +#define XCVR_DIAG_PLLDRC_CTRL_LANE0 0x40e5 +#define XCVR_DIAG_PLLDRC_CTRL_LANE1 0x42e5 + +#define CMN_PLL0_DSM_DIAG_M0 0x0094 +#define CMN_PLL1_DSM_DIAG_M0 0x00d4 +#define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01a4 +#define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01c4 + +#define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01a5 +#define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01c5 +#define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01a6 +#define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01c6 + +#define CMN_PLL0_INTDIV_M0 0x0090 +#define CMN_PLL1_INTDIV_M0 0x00d0 +#define CMN_PLL0_FRACDIVL_M0 0x0091 +#define CMN_PLL1_FRACDIVL_M0 0x00d1 + +#define CMN_PLL0_FRACDIVH_M0 0x0092 +#define CMN_PLL1_FRACDIVH_M0 0x00d2 +#define CMN_PLL0_HIGH_THR_M0 0x0093 +#define CMN_PLL1_HIGH_THR_M0 0x00d3 + +#define CMN_PDIAG_PLL0_CTRL_M0 0x01a0 +#define CMN_PDIAG_PLL1_CTRL_M0 0x01c0 + +#define CMN_PLL0_VCOCAL_TCTRL 0x0082 +#define CMN_PLL1_VCOCAL_TCTRL 0x00c2 + +#define CMN_PLL0_VCOCAL_INIT_TMR 0x0084 +#define CMN_PLL1_VCOCAL_INIT_TMR 0x00c4 + +#define CMN_PLL0_VCOCAL_ITER_TMR 0x0085 +#define CMN_PLL1_VCOCAL_ITER_TMR 0x00c5 + +#define CMN_PLL0_VCOCAL_REFTIM_START 0x0086 +#define CMN_PLL1_VCOCAL_REFTIM_START 0x00c6 + +#define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088 +#define CMN_PLL1_VCOCAL_PLLCNT_START 0x00c8 + +#define CMN_PLL0_LOCK_REFCNT_START 0x009c +#define CMN_PLL1_LOCK_REFCNT_START 0x00dc + +#define CMN_PLL0_LOCK_PLLCNT_START 0x009e +#define CMN_PLL1_LOCK_PLLCNT_START 0x00de + +#define CMN_PLL0_LOCK_PLLCNT_THR 0x009f +#define CMN_PLL1_LOCK_PLLCNT_THR 0x00df + +#define CMN_CDIAG_CDB_PWRI_OVRD 0x0041 +#define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047 + +#define TX_PSC_A0_LANE0 0x4100 +#define TX_PSC_A0_LANE1 0x4300 + +#define TX_PSC_A1_LANE0 0x4101 +#define TX_PSC_A1_LANE1 0x4301 + +#define TX_PSC_A2_LANE0 0x4102 +#define TX_PSC_A2_LANE1 0x4302 + +#define TX_PSC_A3_LANE0 0x4103 +#define TX_PSC_A3_LANE1 0x4303 + +#define RX_PSC_A0_LANE0 0x8000 +#define RX_PSC_A0_LANE1 0x8200 + +#define RX_PSC_A1_LANE0 0x8001 +#define RX_PSC_A1_LANE1 0x8201 + +#define RX_PSC_A2_LANE0 0x8002 +#define RX_PSC_A2_LANE1 0x8202 + +#define RX_PSC_A3_LANE0 0x8003 +#define RX_PSC_A3_LANE1 0x8203 + +#define TX_TXCC_CTRL_LANE0 0x4040 +#define TX_TXCC_CTRL_LANE1 0x4240 + +#define TX_TXCC_CPOST_MULT_01_LANE0 0x404d +#define TX_TXCC_CPOST_MULT_01_LANE1 0x424d + +#define TX_TXCC_MGNFS_MULT_000_LANE0 0x4050 +#define TX_TXCC_MGNFS_MULT_000_LANE1 0x4250 + +#define RX_SIGDET_HL_FILT_TMR_LANE0 0x8090 +#define RX_SIGDET_HL_FILT_TMR_LANE1 0x8290 + +#define RX_REE_GCSM1_CTRL_LANE0 0x8108 +#define RX_REE_GCSM1_CTRL_LANE1 0x8308 + +#define RX_REE_ATTEN_THR_LANE0 0x8149 +#define RX_REE_ATTEN_THR_LANE1 0x8349 + +#define RX_REE_SMGM_CTRL1_LANE0 0x8177 +#define RX_REE_SMGM_CTRL1_LANE1 0x8377 + +#define RX_REE_SMGM_CTRL2_LANE0 0x8178 +#define RX_REE_SMGM_CTRL2_LANE1 0x8378 + +#define XCVR_DIAG_PSC_OVRD_LANE0 0x40eb +#define XCVR_DIAG_PSC_OVRD_LANE1 0x42eb + +#define RX_DIAG_SIGDET_TUNE_LANE0 0x81e8 +#define RX_DIAG_SIGDET_TUNE_LANE1 0x83e8 + +#define RX_DIAG_NQST_CTRL_LANE0 0x81e5 +#define RX_DIAG_NQST_CTRL_LANE1 0x83e5 + +#define RX_DIAG_DFE_AMP_TUNE_2_LANE0 0x81e2 +#define RX_DIAG_DFE_AMP_TUNE_2_LANE1 0x83e2 + +#define RX_DIAG_DFE_AMP_TUNE_3_LANE0 0x81e3 +#define RX_DIAG_DFE_AMP_TUNE_3_LANE1 0x83e3 + +#define RX_DIAG_PI_CAP_LANE0 0x81f5 +#define RX_DIAG_PI_CAP_LANE1 0x83f5 + +#define RX_DIAG_PI_RATE_LANE0 0x81f4 +#define RX_DIAG_PI_RATE_LANE1 0x83f4 + +#define RX_CDRLF_CNFG_LANE0 0x8080 +#define RX_CDRLF_CNFG_LANE1 0x8280 + +#define RX_CDRLF_CNFG3_LANE0 0x8082 +#define RX_CDRLF_CNFG3_LANE1 0x8282 + +/* Bits */ + +#define PHY_PLL_CFG_0803 0xC00E +/* 0803 phy register */ +#define PHY_PIPE_USB3_GEN2_PRE_CFG0_0803 0xc01c +#define PHY_PIPE_USB3_GEN2_POST_CFG0_0803 0xc01e +#define PHY_PIPE_USB3_GEN2_POST_CFG1_0803 0xc01f + +#endif -- 2.54.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-17 2:52 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-17 2:28 [PATCH v8 0/2] phy: Add CIX Sky1 USB3 PHY support Hongliang Yang 2026-11-17 2:28 ` Hongliang Yang 2026-11-17 2:28 ` [PATCH v8 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY Hongliang Yang 2026-11-17 2:28 ` Hongliang Yang 2026-11-17 2:52 ` sashiko-bot 2026-11-17 2:52 ` sashiko-bot 2026-11-17 2:28 ` [PATCH v8 2/2] phy: cix: Add CIX Sky1 USB3 PHY driver Hongliang Yang 2026-11-17 2:28 ` Hongliang Yang
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.