airoha: an7581: USB support
Subsystems (3)
v11 cover airoha: an7581: USB support
This is a major rework of the old v2 series.
The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.
The previous implementation of a dedicated SSR driver was too complex and fragile for the simple task of configuring a register hence it was dropped and the handling is entirely in the PHY driver.
Everything was reducted to the dt-bindings to describe the Serdes line.
Also the property for the PHY are renamed to a more suitable name and everything is now mandatory to simplify the implementation. (the PHY are always present and active on the SoC)
Also other unrelated patch are dropped from this series.
Changes v11:
- Remove clk patch and move to dedicated series
Changes v10:
- Rebase on top of linux-next
- Add review tag for DT patch
Changes v9:
- Add spinlock init
- Add ack tag
- Add review tag
- Add additional comments for phys on USB 3.0
- Add extra logic to make phys optional for USB 3.0
Changes v8:
- Squash header to clk Documentation patch
- Address comments from AI Bot
Changes v7:
- Rework to double PHY implementation
(suggested by Rob)
Now the clk driver expose a PHY for Serdes port
USB PHY driver selects it
- Rebase on top of linux-next
Changes v6:
- Fix kernel test robot (sparse warning)
Changes v5:
- Add Ack and Review tag from Connor
- Implement Ethernet support in the USB driver (testing support for this Serdes on a special reference board)
- Use an7581 prefix for USB PHY driver
Changes v4:
- Rename PCIe and USB PHY to AN7581
- Drop airoha,scu (handled directly in driver)
- Drop dt-bindings for monitor clock in favor of raw values
- Better describe the usage of airoha,usb3-serdes
- Simplify values of dt-bindings SSR SERDES
Changes v3:
- Drop clk changes
- Drop SSR driver
- Rename property in Documentation
- Simplify PHY handling
- Move SSR handling inside the PHY driver
Changes v2:
- Drop changes for simple-mfd
- Rework PHY node structure to single node
- Drop port-id property in favor of serdes-port and usb2-monitor-clock-sel
- Make the SSR driver probe from the clock driver
Christian Marangi (3):
dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
phy: move and rename Airoha PCIe PHY driver to dedicated directory
phy: airoha: Add support for Airoha AN7581 USB PHY
.../bindings/phy/airoha,an7581-usb-phy.yaml | 62 ++
MAINTAINERS | 11 +-
drivers/phy/Kconfig | 11 +-
drivers/phy/Makefile | 4 +-
drivers/phy/airoha/Kconfig | 24 +
drivers/phy/airoha/Makefile | 4 +
.../phy-an7581-pcie-regs.h} | 2 +-
.../phy-an7581-pcie.c} | 6 +-
drivers/phy/airoha/phy-an7581-usb.c | 559 ++++++++++++++++++
9 files changed, 665 insertions(+), 18 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
create mode 100644 drivers/phy/airoha/Kconfig
create mode 100644 drivers/phy/airoha/Makefile
rename drivers/phy/{phy-airoha-pcie-regs.h => airoha/phy-an7581-pcie-regs.h} (99%)
rename drivers/phy/{phy-airoha-pcie.c => airoha/phy-an7581-pcie.c} (99%)
create mode 100644 drivers/phy/airoha/phy-an7581-usb.cSignature · 1 line
2.53.0
PATCH v11 1/3 dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7581 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.
--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN7581 SoC USB PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: > + The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller. + + Airoha AN7581 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. + +properties: + compatible: + const: airoha,an7581-usb-phy + + reg: + maxItems: 1 + + 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] + + phys: + items: + - description: phandle to Serdes PHY. Optional if USB 3.0 is not used. + + '#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: + - compatible + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/soc/airoha,scu-ssr.h> + + phy@1fac0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x1fac0000 0x10000>; + + airoha,usb2-monitor-clk-sel = <1>; + phys = <&scu AIROHA_SCU_SERDES_USB1>; + + #phy-cells = <1>; + }; +
MAINTAINERS +6 -0
@@ -777,6 +777,12 @@ S: Maintained F: Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml F: drivers/spi/spi-airoha-snfi.c +AIROHA USB PHY DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml + AIRSPY MEDIA DRIVER L: [email protected] S: Orphan
Signature · 1 line
2.53.0
Rob Herring (Arm)
maintainerRe: [PATCH v11 1/3] dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
Quoted 20 lines · Christian Marangi
Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7581 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.
Quoted 8 lines
Signed-off-by Christian Marangi <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.example.dts:18:18: fatal error: dt-bindings/soc/airoha,scu-ssr.h: No such file or directory
18 | #include <dt-bindings/soc/airoha,scu-ssr.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.dtbs:140: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1705: dt_binding_check] Error 2
make: *** [Makefile:248: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Manivannan Sadhasivam
reviewerRe: [PATCH v11 1/3] dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
In reply to Christian MarangiQuoted 75 lines · Christian Marangi
Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7581 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.
Signed-off-by Christian Marangi <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yamlDocumentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +41
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN7581 SoC USB PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: > + The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller. + + Airoha AN7581 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. + +properties: + compatible: + const: airoha,an7581-usb-phy + + reg: + maxItems: 1 + + 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] + + phys: + items: + - description: phandle to Serdes PHY. Optional if USB 3.0 is not used. + + '#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:
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +10
-0+ - compatible + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/soc/airoha,scu-ssr.h>
Rob's bot triggered compilation error due to this missing header.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH v11 2/3 phy: move and rename Airoha PCIe PHY driver to dedicated directory
In reply to Christian MarangiTo keep the generic PHY directory tidy, move the PCIe PHY driver for Airoha AN7581 SoC to a dedicated directory.
Also rename the driver and add the relevant SoC name to the .c and .h file in preparation for support of PCIe and USB PHY driver for Airoha AN7583 SoC that use a completely different implementation and calibration for PHYs and will have their own dedicated drivers.
The rename permits to better identify the specific usage of the driver in the future once the airoha PHY directory will have multiple driver for multiple SoC.
The config is changed from PHY_AIROHA_PCIE to PHY_AIROHA_AN7581_PCIE.
---
MAINTAINERS | 4 ++--
drivers/phy/Kconfig | 11 +----------
drivers/phy/Makefile | 4 ++--
drivers/phy/airoha/Kconfig | 13 +++++++++++++
drivers/phy/airoha/Makefile | 3 +++
.../phy-an7581-pcie-regs.h} | 2 +-
.../{phy-airoha-pcie.c => airoha/phy-an7581-pcie.c} | 6 +++---
7 files changed, 25 insertions(+), 18 deletions(-)
create mode 100644 drivers/phy/airoha/Kconfig
create mode 100644 drivers/phy/airoha/Makefile
rename drivers/phy/{phy-airoha-pcie-regs.h => airoha/phy-an7581-pcie-regs.h} (99%)
rename drivers/phy/{phy-airoha-pcie.c => airoha/phy-an7581-pcie.c} (99%)MAINTAINERS +2 -2
@@ -765,8 +765,8 @@ M: Lorenzo Bianconi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml -F: drivers/phy/phy-airoha-pcie-regs.h -F: drivers/phy/phy-airoha-pcie.c +F: drivers/phy/airoha/phy-an7581-pcie-regs.h +F: drivers/phy/airoha/phy-an7581-pcie.c AIROHA SPI SNFI DRIVER M: Lorenzo Bianconi <[email protected]>
drivers/phy/Kconfig +1 -10
@@ -46,16 +46,6 @@ config GENERIC_PHY_MIPI_DPHY Provides a number of helpers a core functions for MIPI D-PHY drivers to us. -config PHY_AIROHA_PCIE - tristate "Airoha PCIe-PHY Driver" - depends on ARCH_AIROHA || COMPILE_TEST - depends on OF - select GENERIC_PHY - help - Say Y here to add support for Airoha PCIe PHY driver. - This driver create the basic PHY instance and provides initialize - callback for PCIe GEN3 port. - config PHY_CAN_TRANSCEIVER tristate "CAN transceiver PHY" select GENERIC_PHY
@@ -168,6 +158,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 -2
@@ -7,7 +7,6 @@ obj-$(CONFIG_PHY_COMMON_PROPS) += phy-common-props.o obj-$(CONFIG_PHY_COMMON_PROPS_TEST) += phy-common-props-test.o obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o -obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o obj-$(CONFIG_PHY_CAN_TRANSCEIVER) += phy-can-transceiver.o obj-$(CONFIG_PHY_ECONET_PCIE) += phy-econet-pcie.o obj-$(CONFIG_PHY_EYEQ5_ETH) += phy-eyeq5-eth.o
@@ -20,7 +19,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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Airoha devices +# +config PHY_AIROHA_AN7581_PCIE + tristate "Airoha AN7581 PCIe-PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Say Y here to add support for Airoha AN7581 PCIe PHY driver. + This driver create the basic PHY instance and provides initialize + callback for PCIe GEN3 port.
drivers/phy/airoha/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE) += phy-an7581-pcie.o
drivers/phy/airoha/phy-an7581-pcie-regs.h renamed from drivers/phy/phy-airoha-pcie-regs.h +1 -1
@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2024 AIROHA Inc * Author: Lorenzo Bianconi <[email protected]>
drivers/phy/airoha/phy-an7581-pcie.c renamed from drivers/phy/phy-airoha-pcie.c +3 -3
@@ -13,7 +13,7 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "phy-airoha-pcie-regs.h" +#include "phy-an7581-pcie-regs.h" #define LEQ_LEN_CTRL_MAX_VAL 7#define FREQ_LOCK_MAX_ATTEMPT 10
@@ -1279,12 +1279,12 @@ MODULE_DEVICE_TABLE(of, airoha_pcie_phy_of_match);static struct platform_driver airoha_pcie_phy_driver = { .probe = airoha_pcie_phy_probe, .driver = { - .name ="airoha-pcie-phy" , + .name ="airoha-an7581-pcie-phy" , .of_match_table = airoha_pcie_phy_of_match, }, };module_platform_driver (airoha_pcie_phy_driver); -MODULE_DESCRIPTION ("Airoha PCIe PHY driver" ); +MODULE_DESCRIPTION ("Airoha AN7581 PCIe PHY driver" );MODULE_AUTHOR ("Lorenzo Bianconi <[email protected]>" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v11 2/3] phy: move and rename Airoha PCIe PHY driver to dedicated directory
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The newly added drivers/phy/airoha/Kconfig and drivers/phy/airoha/Makefile are not covered by the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly added drivers/phy/airoha/Kconfig and drivers/phy/airoha/Makefile are not covered by the MAINTAINERS entry. --
--- Patch [2]: [PATCH v11 2/3] phy: move and rename Airoha PCIe PHY driver to dedicated directory --- commit 83a3c170a5f0894b166822d36bf49798d65f73e9
Author: Christian Marangi <[email protected]>
phy: move and rename Airoha PCIe PHY driver to dedicated directory
This commit moves the Airoha PCIe PHY driver to a dedicated directory and renames the files to specifically reference the AN7581 SoC. It also adds a new Kconfig and Makefile to the newly created drivers/phy/airoha/ directory to support future drivers for different SoCs.
MAINTAINERS M: Lorenzo Bianconi <[email protected]> · line 769
Quoted 12 lines
MAINTAINERS +2
-2@@ -765,8 +765,8 @@ M: Lorenzo Bianconi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml -F: drivers/phy/phy-airoha-pcie-regs.h -F: drivers/phy/phy-airoha-pcie.c +F: drivers/phy/airoha/phy-an7581-pcie-regs.h +F: drivers/phy/airoha/phy-an7581-pcie.c
[Severity: Low]
This isn't a bug, but should the newly created drivers/phy/airoha/Kconfig and drivers/phy/airoha/Makefile files also be included in this entry?
Currently, get_maintainer.pl might not automatically include the Airoha PCIe PHY driver maintainers for patches modifying those build files. Could this entry be simplified to cover the new files by using a directory match like "F: drivers/phy/airoha/" instead?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Manivannan Sadhasivam
reviewerRe: [PATCH v11 2/3] phy: move and rename Airoha PCIe PHY driver to dedicated directory
In reply to Christian MarangiQuoted 132 lines · Christian Marangi
To keep the generic PHY directory tidy, move the PCIe PHY driver for Airoha AN7581 SoC to a dedicated directory.
Also rename the driver and add the relevant SoC name to the .c and .h file in preparation for support of PCIe and USB PHY driver for Airoha AN7583 SoC that use a completely different implementation and calibration for PHYs and will have their own dedicated drivers.
The rename permits to better identify the specific usage of the driver in the future once the airoha PHY directory will have multiple driver for multiple SoC.
The config is changed from
PHY_AIROHA_PCIEtoPHY_AIROHA_AN7581_PCIE.Signed-off-by Christian Marangi <[email protected]>Acked-by Lorenzo Bianconi <[email protected]>--- MAINTAINERS | 4 ++-- drivers/phy/Kconfig | 11 +---------- drivers/phy/Makefile | 4 ++-- drivers/phy/airoha/Kconfig | 13 +++++++++++++ drivers/phy/airoha/Makefile | 3 +++ .../phy-an7581-pcie-regs.h} | 2 +- .../{phy-airoha-pcie.c => airoha/phy-an7581-pcie.c} | 6 +++--- 7 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile rename drivers/phy/{phy-airoha-pcie-regs.h => airoha/phy-an7581-pcie-regs.h} (99%) rename drivers/phy/{phy-airoha-pcie.c => airoha/phy-an7581-pcie.c} (99%)MAINTAINERS +2
-2@@ -765,8 +765,8 @@ M: Lorenzo Bianconi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml -F: drivers/phy/phy-airoha-pcie-regs.h -F: drivers/phy/phy-airoha-pcie.c +F: drivers/phy/airoha/phy-an7581-pcie-regs.h +F: drivers/phy/airoha/phy-an7581-pcie.c AIROHA SPI SNFI DRIVER M: Lorenzo Bianconi <[email protected]>drivers/phy/Kconfig +1
-10@@ -46,16 +46,6 @@ config GENERIC_PHY_MIPI_DPHY Provides a number of helpers a core functions for MIPI D-PHY drivers to us. -config PHY_AIROHA_PCIE - tristate "Airoha PCIe-PHY Driver" - depends on ARCH_AIROHA || COMPILE_TEST - depends on OF - select GENERIC_PHY - help - Say Y here to add support for Airoha PCIe PHY driver. - This driver create the basic PHY instance and provides initialize - callback for PCIe GEN3 port. - config PHY_CAN_TRANSCEIVER tristate "CAN transceiver PHY" select GENERIC_PHY@@ -168,6 +158,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
-2@@ -7,7 +7,6 @@ obj-$(CONFIG_PHY_COMMON_PROPS) += phy-common-props.o obj-$(CONFIG_PHY_COMMON_PROPS_TEST) += phy-common-props-test.o obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o -obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o obj-$(CONFIG_PHY_CAN_TRANSCEIVER) += phy-can-transceiver.o obj-$(CONFIG_PHY_ECONET_PCIE) += phy-econet-pcie.o obj-$(CONFIG_PHY_EYEQ5_ETH) += phy-eyeq5-eth.o@@ -20,7 +19,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 +13
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Airoha devices +# +config PHY_AIROHA_AN7581_PCIE + tristate "Airoha AN7581 PCIe-PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Say Y here to add support for Airoha AN7581 PCIe PHY driver. + This driver create the basic PHY instance and provides initialize + callback for PCIe GEN3 port.drivers/phy/airoha/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE) += phy-an7581-pcie.odrivers/phy/airoha/phy-an7581-pcie-regs.h renamed from drivers/phy/phy-airoha-pcie-regs.h +0
-0
drivers/phy/airoha/phy-an7581-pcie-regs.h line 1
Quoted 2 lines
drivers/phy/airoha/phy-an7581-pcie-regs.h renamed from drivers/phy/phy-airoha-pcie-regs.h +1
-1@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ +// SPDX-License-Identifier: GPL-2.0-only
As per Documentation/process/license-rules.rst, the existing license header was the correct one. So this change should be dropped.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH v11 3/3 phy: airoha: Add support for Airoha AN7581 USB PHY
In reply to Christian MarangiAdd support for Airoha AN7581 USB PHY driver. AN7581 supports up to 2 USB port with USB 2.0 mode always supported and USB 3.0 mode available only if the Serdes port is correctly configured for USB 3.0.
If the USB 3.0 mode is not configured, the modes needs to be also disabled in the xHCI node or the driver will report unsable clock and fail probe.
For USB 2.0 Slew Rate calibration, airoha,usb2-monitor-clk-sel is mandatory and is used to select the monitor clock for calibration.
Normally it's 1 for USB port 1 and 2 for USB port 2.
--- MAINTAINERS | 1 + drivers/phy/airoha/Kconfig | 11 + drivers/phy/airoha/Makefile | 1 + drivers/phy/airoha/phy-an7581-usb.c | 559 ++++++++++++++++++++++++++++ 4 files changed, 572 insertions(+) create mode 100644 drivers/phy/airoha/phy-an7581-usb.c
MAINTAINERS +1 -0
@@ -782,6 +782,7 @@ M: Christian Marangi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml +F: drivers/phy/airoha/phy-an7581-usb.c AIRSPY MEDIA DRIVER L: [email protected]
drivers/phy/airoha/Kconfig +11 -0
@@ -11,3 +11,14 @@ config PHY_AIROHA_AN7581_PCIE Say Y here to add support for Airoha AN7581 PCIe PHY driver. This driver create the basic PHY instance and provides initialize callback for PCIe GEN3 port. + +config PHY_AIROHA_AN7581_USB + tristate "Airoha AN7581 USB PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + select REGMAP_MMIO + help + Say 'Y' here to add support for Airoha AN7581 USB PHY driver. + This driver create the basic PHY instance and provides initialize + callback for USB port.
drivers/phy/airoha/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE) += phy-an7581-pcie.o +obj-$(CONFIG_PHY_AIROHA_AN7581_USB) += phy-an7581-usb.o
drivers/phy/airoha/phy-an7581-usb.c new file +559 -0
559 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v11 3/3] phy: airoha: Add support for Airoha AN7581 USB PHY
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Missing PHY Initialization for SerDes PHY (API Violation) - [High] Incorrect Register Update using…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Missing PHY Initialization for SerDes PHY (API Violation)
- [High] Incorrect Register Update using regmap_set_bits with a multi-bit mask
- [Medium] Semantic Mismatch: Hardcoding SerDes PHY to DEVICE mode ignores HOST controller capability
- [Low] Missing Header Files for Core Kernel APIs
--
--- Patch [3]: [PATCH v11 3/3] phy: airoha: Add support for Airoha AN7581 USB PHY --- commit 22b1a55f0db8cf42614375aa158b5f25ac5f97d6
Author: Christian Marangi <[email protected]>
Subject: phy: airoha: Add support for Airoha AN7581 USB PHY
This commit adds support for the Airoha AN7581 USB PHY driver, which supports up to 2 USB ports. USB 2.0 is always supported, while USB 3.0 mode is only available if the Serdes port is correctly configured. The driver includes slew rate calibration logic using a selectable monitor clock.
Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +4
-0@@ -0,0 +1,559 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Author: Christian Marangi <[email protected]> +*/
drivers/phy/airoha/phy-an7581-usb.c line 14
Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +10
-0+ +#include <dt-bindings/phy/phy.h> +#include <dt-bindings/soc/airoha,scu-ssr.h> +#include <linux/bitfield.h> +#include <linux/math.h> +#include <linux/module.h> +#include <linux/mfd/syscon.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h>
[Severity: Low]
Does this file need to include linux/delay.h for usleep_range(), linux/of.h for of_property_read_u32(), and linux/err.h for PTR_ERR_OR_ZERO() to avoid potential build breaks on other architectures if implicit inclusions change?
[ ... ]
Quoted 2 lines
drivers/phy/airoha/phy-an7581-usb.c new file +2
-0+static void an7581_usb_phy_u3_init (struct an7581_usb_phy_priv *priv) +{
[ ... ]
drivers/phy/airoha/phy-an7581-usb.c line 260
Quoted 6 lines
drivers/phy/airoha/phy-an7581-usb.c new file +6
-0+regmap_update_bits (priv->regmap,AIROHA_USB_PHY_U3_PHYA_REG0 , +AIROHA_USB_PHY_SSUSB_BG_DIV , +AIROHA_USB_PHY_SSUSB_BG_DIV_4 ); + +regmap_set_bits (priv->regmap,AIROHA_USB_PHY_U3_PHYA_REG1 , +FIELD_PREP (AIROHA_USB_PHY_SSUSB_XTAL_TOP_RESERVE ,0x600 ));
[Severity: High]
Is it intentional to use regmap_set_bits() here with a multi-bit mask? This performs a logical OR, which sets the desired bits but will not clear any pre-existing bits in the mask from the bootloader. Should this be regmap_update_bits() instead to ensure a clean state?
Quoted 8 lines
drivers/phy/airoha/phy-an7581-usb.c new file +8
-0+ +regmap_update_bits (priv->regmap,AIROHA_USB_PHY_U3_PHYA_DA_REG19 , +AIROHA_USB_PHY_SSUSB_PLL_SSC_DELTA1_U3 , +FIELD_PREP (AIROHA_USB_PHY_SSUSB_PLL_SSC_DELTA1_U3 ,0x43 )); +} + +static int an7581_usb_phy_init (struct phy *phy) +{
drivers/phy/airoha/phy-an7581-usb.c line 278
Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +10
-0+struct an7581_usb_phy_instance *instance =phy_get_drvdata (phy); +struct an7581_usb_phy_priv *priv =dev_get_drvdata (phy->dev.parent); +int ret; + +switch (instance->type) { +case PHY_TYPE_USB2 : +an7581_usb_phy_u2_init (priv); +break ; +case PHY_TYPE_USB3 : + ret =phy_set_mode (priv->serdes_phy,PHY_MODE_USB_DEVICE_SS );
[Severity: High]
This calls phy_set_mode() on priv->serdes_phy, but does the underlying serdes PHY hardware ever get initialized? It appears phy_init() is missing before this call, which could leave the serdes PHY in an uninitialized state.
[Severity: Medium]
Additionally, is it correct to hardcode the serdes PHY mode to PHY_MODE_USB_DEVICE_SS here? The commit message mentions xHCI which is a host controller, so forcing device mode might cause initialization failures if the serdes PHY driver distinguishes between host and device operational modes.
Quoted 11 lines
drivers/phy/airoha/phy-an7581-usb.c new file +11
-0+if (ret) +return ret; + +an7581_usb_phy_u3_init (priv); +break ; +default : +return -EINVAL ; + } + +return 0 ; +}
[ ... ]
drivers/phy/airoha/phy-an7581-usb.c line 324
Quoted 11 lines
drivers/phy/airoha/phy-an7581-usb.c new file +11
-0+static int an7581_usb_phy_power_on (struct phy *phy) +{ +struct an7581_usb_phy_instance *instance =phy_get_drvdata (phy); +struct an7581_usb_phy_priv *priv =dev_get_drvdata (phy->dev.parent); + +switch (instance->type) { +case PHY_TYPE_USB2 : +an7581_usb_phy_u2_power_on (priv); +break ; +case PHY_TYPE_USB3 : +an7581_usb_phy_u3_power_on (priv);
[Severity: High]
Does priv->serdes_phy need to be powered on here as well? The wrapper powers on its USB3 instance, but it looks like phy_power_on(priv->serdes_phy) is never called.
Quoted 7 lines
drivers/phy/airoha/phy-an7581-usb.c new file +7
-0+break ; +default : +return -EINVAL ; + } + +return 0 ; +}
[ ... ]
drivers/phy/airoha/phy-an7581-usb.c line 414
Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +10
-0+static int an7581_usb_phy_set_mode (struct phy *phy,enum phy_mode mode,int submode) +{ +struct an7581_usb_phy_instance *instance =phy_get_drvdata (phy); +struct an7581_usb_phy_priv *priv =dev_get_drvdata (phy->dev.parent); + +switch (instance->type) { +case PHY_TYPE_USB2 : +return an7581_usb_phy_u2_set_mode (priv, mode); +default : +return 0 ;
[Severity: Medium]
Does this code silently ignore the consumer's requested mode for PHY_TYPE_USB3? Since an7581_usb_phy_init() forces PHY_MODE_USB_DEVICE_SS, should this function handle propagating the requested mode to the serdes PHY instead of hardcoding it during initialization?
Quoted 2 lines
drivers/phy/airoha/phy-an7581-usb.c new file +2
-0+ } +}
[ ... ]
drivers/phy/airoha/phy-an7581-usb.c line 462
Quoted 7 lines
drivers/phy/airoha/phy-an7581-usb.c new file +7
-0+static const struct phy_ops airoha_phy = { + .init = an7581_usb_phy_init, + .power_on = an7581_usb_phy_power_on, + .power_off = an7581_usb_phy_power_off, + .set_mode = an7581_usb_phy_set_mode, + .owner =THIS_MODULE , +};
[Severity: High]
Is the .exit callback intentionally omitted here? Without an .exit hook, there doesn't seem to be a way to call phy_exit() on the serdes PHY, which might lead to resource leaks when the PHY is released.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Manivannan Sadhasivam
reviewerRe: [PATCH v11 3/3] phy: airoha: Add support for Airoha AN7581 USB PHY
Quoted 5 lines · On Fri, Jul 24, 2026 at 07:01:35PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Missing PHY Initialization for SerDes PHY (API Violation)
- [High] Incorrect Register Update usingregmap_set_bitswith a multi-bit mask
- [Medium] Semantic Mismatch: Hardcoding SerDes PHY to DEVICE mode ignores HOST controller capability
- [Low] Missing Header Files for Core Kernel APIs
Please respond to these issues.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்