phy: Add support for Airoha AN7583 USB PHY
Subsystems (2)
v2 cover phy: Add support for Airoha AN7583 USB PHY
This small series ass support for Airoha USB PHY and Gen2 PCIe PHY.
Changes v2:
- Add Documentation
- Out of RFC
- Rework to Serdes PHY instead of SCU (following
for consistency AN7581 implementation)
Christian Marangi (2):
dt-bindings: phy: Add documentation for Airoha AN7583 USB PHY
phy: airoha: Add support for Airoha AN7583 USB PHY
.../bindings/phy/airoha,an7583-usb-phy.yaml | 205 +- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 3 +- drivers/phy/airoha/Kconfig | 11 + drivers/phy/airoha/Makefile | 3 + drivers/phy/airoha/phy-an7583-usb.c | 2009 +++++++++++++++++ 6 files changed, 2194 insertions(+), 38 deletions(-) create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-an7583-usb.c
Signature · 1 line
2.53.0
PATCH v2 1/2 dt-bindings: phy: Add documentation for Airoha AN7583 USB PHY
Add documentation for Airoha AN7583 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7583 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.
To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.
To correctly setup the Serdes mode attached to the USB 3.0 mode, a phys property is required with the phandle pointing to the correct Serdes port provided by the SCU node. Providing the phys property is optional if USB 3.0 is not used.
The second USB PHY on Airoha AN7583 SoC is used for PCIe Gen2 usage and similar to USB 3.0 require a phys property to configure the serdes.
--- .../bindings/phy/airoha,an7583-usb-phy.yaml | 205 ++++++++++++++---- 1 file changed, 168 insertions(+), 37 deletions(-)
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +168 -37
@@ -26,64 +26,195 @@ description: > properties: compatible: - const: airoha,an7583-usb-phy + enum: + - airoha,an7583-usb-phy + - airoha,an7583-pcie-phy reg: - items: - - description: phy register - - description: ana register - - description: pma register - - description: dig register + minItems: 3 + maxItems: 4 reg-names: - itmes: - const: phy - const: ana - const: pma - const: dif + minItems: 3 + maxItems: 4 - usb2-phy: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + usb3-phy: type: object properties: - reg: [0, 0x1000] + phys: + items: + - description: phandle to Serdes PHY - airoha,usb2-monitor-clk-sel: - description: Describe what oscillator across the available 4 - should be selected for USB 2.0 Slew Rate calibration. - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1, 2, 3] + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 - '#phy-cells': - description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, - as defined in dt-bindings/phy/phy.h. - const: 1 + required: + - phys + - '#phy-cells' - usb3-phy: + additionalProperties: false + + pcie-phy: + type: object + + properties: + phys: + items: + - description: phandle to Serdes PHY + + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_PCIE or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - phys + - '#phy-cells' + + additionalProperties: false - phys: - items: - - description: phandle to Serdes PHY. Optional if USB 3.0 is not used. +patternProperties: + '^usb2-phy@[0-9-a-f]+$': + type: object + + properties: + reg: + enum: [0x0, 0x1000] + airoha,usb2-monitor-clk-sel: + description: Describe what oscillator across the available 4 + should be selected for USB 2.0 Slew Rate calibration. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + + additionalProperties: false required: - compatible - reg - - airoha,usb2-monitor-clk-sel - - '#phy-cells' - -additionalProperties: false + - reg-names + +allOf: + - if: + properties: + compatible: + const: airoha,an7583-usb-phy + + then: + properties: + reg: + items: + - description: phy register + - description: ana register + - description: pma register + - description: dig register + + reg-names: + items: + - const: phy + - const: ana + - const: pma + - const: dig + + pcie-phy: false + + required: + - '#address-cells' + - '#size-cells' + + - if: + properties: + compatible: + const: airoha,an7583-pcie-phy + + then: + properties: + reg: + items: + - description: ana register + - description: pma register + - description: dig register + + reg-names: + items: + - const: ana + - const: pma + - const: dig + + usb3-phy: false + + '#address-cells': false + + '#size-cells': false + + patternProperties: + '^usb2-phy@[0-9a-f]+$': false + +unevaluatedProperties: false examples: - | - #include <dt-bindings/soc/airoha,scu-ssr.h> - phy@1fac0000 { - compatible = "airoha,an7581-usb-phy"; - reg = <0x1fac0000 0x10000>; + compatible = "airoha,an7583-usb-phy"; + reg = <0x1fac0000 0x11ff>, + <0x1fa6f000 0xff>, + <0x1fa6e000 0x3ff>, + <0x1fa6a000 0x8ff>; + reg-names = "phy", "ana", "pma", "dig"; + + #address-cells = <1>; + #size-cells = <0>; + + usb2-phy@0 { + reg = <0x0>; + airoha,usb2-monitor-clk-sel = <0>; + + #phy-cells = <1>; + }; + + usb2-phy@1000 { + reg = <0x1000>; + airoha,usb2-monitor-clk-sel = <1>; + + #phy-cells = <1>; + }; + + usb3-phy { + phys = <&serdes_phy>; + + #phy-cells = <1>; + }; + }; + + phy@1fa5f000 { + compatible = "airoha,an7583-pcie-phy"; + reg = <0x1fa5f000 0xff>, + <0x1fa5e000 0x3ff>, + <0x1fa5a000 0x8ff>; + reg-names = "ana", "pma", "dig"; - airoha,usb2-monitor-clk-sel = <1>; - phys = <&scu AIROHA_SCU_SERDES_USB1>; + pcie-phy { + phys = <&serdes_phy>; - #phy-cells = <1>; + #phy-cells = <1>; + }; };
Signature · 1 line
2.53.0
PATCH v2 2/2 phy: airoha: Add support for Airoha AN7583 USB PHY
In reply to Christian MarangiAdd support for USB PHY for Airoha AN7583 SoC, this share some U2 init from AN7581 but use a totally different init phase for PLL and calibration for U3. Also on AN7583 there is a single USB PHY that init 2 U2 port and one U3 port. (the USB controller expose 2 hub, one with 2 usb 2.0 port and one with one 3.0 port)
A second USB PHY is used for PCIe Gen2 controller and follow the same calibration and setup logic of USB.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 3 +- drivers/phy/airoha/Kconfig | 11 + drivers/phy/airoha/Makefile | 3 + drivers/phy/airoha/phy-an7583-usb.c | 2009 +++++++++++++++++++++++++++ 5 files changed, 2026 insertions(+), 1 deletion(-) create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-an7583-usb.c
drivers/phy/Kconfig +1 -0
@@ -168,6 +168,7 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +source "drivers/phy/airoha/Kconfig" source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/apple/Kconfig"
drivers/phy/Makefile +2 -1
@@ -20,7 +20,8 @@ obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o obj-$(CONFIG_PHY_SNPS_EUSB2) += phy-snps-eusb2.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o -obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ +obj-$(CONFIG_GENERIC_PHY) += airoha/ \ + allwinner/ \ amlogic/ \ apple/ \ axiado/ \
drivers/phy/airoha/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config PHY_AIROHA_AN7583_USB + tristate "Airoha AN7583 USB PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Say 'Y' here to add support for Airoha AN7583 USB PHY driver. + This driver create the basic PHY instance and provides initialize + callback for USB port.
drivers/phy/airoha/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PHY_AIROHA_AN7583_USB) += phy-an7583-usb.o
drivers/phy/airoha/phy-an7583-usb.c new file +2009 -0
2,009 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v2 1/2] dt-bindings: phy: Add documentation for Airoha AN7583 USB PHY
In reply to Christian MarangiQuoted 33 lines · Christian Marangi
Add documentation for Airoha AN7583 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7583 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.
To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.
To correctly setup the Serdes mode attached to the USB 3.0 mode, a phys property is required with the phandle pointing to the correct Serdes port provided by the SCU node. Providing the phys property is optional if USB 3.0 is not used.
The second USB PHY on Airoha AN7583 SoC is used for PCIe Gen2 usage and similar to USB 3.0 require a phys property to configure the serdes.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/phy/airoha,an7583-usb-phy.yaml | 205 ++++++++++++++---- 1 file changed, 168 insertions(+), 37 deletions(-)Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +0
-0
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 31
Quoted 7 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +3
-1@@ -26,64 +26,195 @@ description: > properties: compatible: - const: airoha,an7583-usb-phy + enum: + - airoha,an7583-usb-phy + - airoha,an7583-pcie-phy
Keep the list sorted.
Quoted 15 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +2
-9reg: - items: - - description: phy register - - description: ana register - - description: pma register - - description: dig register + minItems: 3 + maxItems: 4 reg-names: - itmes: - const: phy - const: ana - const: pma
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 45
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +7
-2- const: dif + minItems: 3 + maxItems: 4 - usb2-phy: + '#address-cells': + const: 1 + + '#size-cells': + const: 0
I don't understand this diff. Why do you add cells if you do not have chidlren with addressing for new device (pcie)?
Quoted 68 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +46
-14+ + usb3-phy: type: object properties: - reg: [0, 0x1000] + phys: + items: + - description: phandle to Serdes PHY - airoha,usb2-monitor-clk-sel: - description: Describe what oscillator across the available 4 - should be selected for USB 2.0 Slew Rate calibration. - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1, 2, 3] + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 - '#phy-cells': - description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, - as defined in dt-bindings/phy/phy.h. - const: 1 + required: + - phys + - '#phy-cells' - usb3-phy: + additionalProperties: false + + pcie-phy: + type: object + + properties: + phys: + items: + - description: phandle to Serdes PHY + + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_PCIE or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - phys + - '#phy-cells' + + additionalProperties: false - phys: - items: - - description: phandle to Serdes PHY. Optional if USB 3.0 is not used. +patternProperties: + '^usb2-phy@[0-9-a-f]+$': + type: object + + properties: + reg: + enum: [0x0, 0x1000] + airoha,usb2-monitor-clk-sel: + description: Describe what oscillator across the available 4 + should be selected for USB 2.0 Slew Rate calibration. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + '#phy-cells':
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 109
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +10
-0+ description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + + additionalProperties: false
Looking at the amount of changes this should not be the same binding. Also, things would be simpler if children were called 'phy', but OTOH why do you need children in the first place? Your pcie-phy child has no resources, except phy which can go to the parent device.
Best regards,
Krzysztof
Re: [PATCH v2 1/2] dt-bindings: phy: Add documentation for Airoha AN7583 USB PHY
Quoted 148 lines · Krzysztof Kozlowski
Quoted 33 lines · Christian Marangi
Add documentation for Airoha AN7583 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7583 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.
To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.
To correctly setup the Serdes mode attached to the USB 3.0 mode, a phys property is required with the phandle pointing to the correct Serdes port provided by the SCU node. Providing the phys property is optional if USB 3.0 is not used.
The second USB PHY on Airoha AN7583 SoC is used for PCIe Gen2 usage and similar to USB 3.0 require a phys property to configure the serdes.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/phy/airoha,an7583-usb-phy.yaml | 205 ++++++++++++++---- 1 file changed, 168 insertions(+), 37 deletions(-)Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +0
-0Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 31
Quoted 7 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +3
-1@@ -26,64 +26,195 @@ description: > properties: compatible: - const: airoha,an7583-usb-phy + enum: + - airoha,an7583-usb-phy + - airoha,an7583-pcie-phyKeep the list sorted.
Quoted 15 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +2
-9reg: - items: - - description: phy register - - description: ana register - - description: pma register - - description: dig register + minItems: 3 + maxItems: 4 reg-names: - itmes: - const: phy - const: ana - const: pmaDocumentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 45
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +7
-2- const: dif + minItems: 3 + maxItems: 4 - usb2-phy: + '#address-cells': + const: 1 + + '#size-cells': + const: 0I don't understand this diff. Why do you add cells if you do not have chidlren with addressing for new device (pcie)?
Quoted 75 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +53
-14+ + usb3-phy: type: object properties: - reg: [0, 0x1000] + phys: + items: + - description: phandle to Serdes PHY - airoha,usb2-monitor-clk-sel: - description: Describe what oscillator across the available 4 - should be selected for USB 2.0 Slew Rate calibration. - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1, 2, 3] + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 - '#phy-cells': - description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, - as defined in dt-bindings/phy/phy.h. - const: 1 + required: + - phys + - '#phy-cells' - usb3-phy: + additionalProperties: false + + pcie-phy: + type: object + + properties: + phys: + items: + - description: phandle to Serdes PHY + + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_PCIE or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - phys + - '#phy-cells' + + additionalProperties: false - phys: - items: - - description: phandle to Serdes PHY. Optional if USB 3.0 is not used. +patternProperties: + '^usb2-phy@[0-9-a-f]+$': + type: object + + properties: + reg: + enum: [0x0, 0x1000] + airoha,usb2-monitor-clk-sel: + description: Describe what oscillator across the available 4 + should be selected for USB 2.0 Slew Rate calibration. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + '#phy-cells': + description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3, + as defined in dt-bindings/phy/phy.h. + const: 1 + + required: + - reg + - airoha,usb2-monitor-clk-sel
Quoted 9 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml description: > · line 83
Quoted 3 lines
Documentation/devicetree/bindings/phy/airoha,an7583-usb-phy.yaml +3
-0+ - '#phy-cells' + + additionalProperties: falseLooking at the amount of changes this should not be the same binding. Also, things would be simpler if children were called 'phy', but OTOH why do you need children in the first place? Your pcie-phy child has no resources, except phy which can go to the parent device.
Yes while writing the schema I also got this doubt that I should have just made 2 different schema. I wanted to put everything in one as they are the same HW and driver.
I will just split these 2 to simplify it.
The child is just for consistency with the USB and easier implementation on the driver. But I guess for DT this is a no go. I will rework the driver to drop the redundant child for the PCIe variant.
Signature · 1 line
Ansuel