airoha: an7581: USB support
Subsystems (2)
v5 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 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 (4):
dt-bindings: soc: Add bindings for Airoha SCU Serdes lines
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 | 71 + MAINTAINERS | 11 +- drivers/phy/Kconfig | 11 +- drivers/phy/Makefile | 4 +- drivers/phy/airoha/Kconfig | 23 + drivers/phy/airoha/Makefile | 4 + drivers/phy/airoha/phy-an7581-pcie-regs.h | 494 +++++++ drivers/phy/airoha/phy-an7581-pcie.c | 1290 +++++++++++++++++ drivers/phy/airoha/phy-an7581-usb.c | 640 ++++++++ include/dt-bindings/soc/airoha,scu-ssr.h | 11 + 10 files changed, 2545 insertions(+), 14 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 create mode 100644 drivers/phy/airoha/phy-an7581-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-an7581-pcie.c create mode 100644 drivers/phy/airoha/phy-an7581-usb.c create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h
Signature · 1 line
2.51.0
PATCH v5 1/4 dt-bindings: soc: Add bindings for Airoha SCU Serdes lines
The Airoha AN7581 SoC can configure the SCU serdes lines for multiple purpose. For example the Serdes for the USB1 port can be both used for USB 3.0 operation or for Ethernet. Or the USB2 serdes can both used for USB 3.0 operation or for PCIe.
The PCIe Serdes can be both used for PCIe operation or for Ethernet.
Add bindings to permit correct reference of the different ports in DT, mostly to differentiate the different supported modes internally to the drivers.
--- include/dt-bindings/soc/airoha,scu-ssr.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h
include/dt-bindings/soc/airoha,scu-ssr.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +#ifndef __DT_BINDINGS_AIROHA_SCU_SSR_H +#define __DT_BINDINGS_AIROHA_SCU_SSR_H + +#define AIROHA_SCU_SERDES_PCIE1 0 +#define AIROHA_SCU_SERDES_PCIE2 1 +#define AIROHA_SCU_SERDES_USB1 0 +#define AIROHA_SCU_SERDES_USB2 1 + +#endif /* __DT_BINDINGS_AIROHA_SCU_SSR_H */
Signature · 1 line
2.51.0
PATCH v5 2/4 dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
In reply to Christian MarangiAdd 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, the "airoha,usb3-serdes" property is required. This can be either AIROHA_SCU_SERDES_USB1 or AIROHA_SCU_SERDES_USB2 and is used to identify what modes support the PHY and what register to use to setup the requested mode.
The first USB port on the SoC can be both used for USB 3.0 operation or Ethernet (HSGMII).
The second USB port on the SoC can be both used for USB 3.0 operation or for an additional PCIe line.
--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 71 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +71 -0
@@ -0,0 +1,71 @@ +# 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. + + The first USB port on the SoC can be both used for USB 3.0 operation or + Ethernet (HSGMII). + The second USB port on the SoC can be both used for USB 3.0 operation or + for an additional PCIe line. + +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] + + airoha,usb3-serdes: + description: Describe what Serdes line is attached to the USB 3.0 port. + Can be either AIROHA_SCU_SERDES_USB1 or AIROHA_SCU_SERDES_USB2 as + defined in dt-bindings/soc/airoha,scu-ssr.h + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 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: + - compatible + - reg + - airoha,usb2-monitor-clk-sel + - airoha,usb3-serdes + - '#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>; + airoha,usb3-serdes = <AIROHA_SCU_SERDES_USB1>; + + #phy-cells = <1>; + }; +
MAINTAINERS +6 -0
@@ -779,6 +779,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.51.0
PATCH v5 3/4 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 + drivers/phy/airoha/phy-an7581-pcie-regs.h | 494 ++++++++ drivers/phy/airoha/phy-an7581-pcie.c | 1290 +++++++++++++++++++++ 7 files changed, 1805 insertions(+), 14 deletions(-) create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-an7581-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-an7581-pcie.c
MAINTAINERS +2 -2
@@ -767,8 +767,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
@@ -133,6 +123,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_GOOGLE_USB) += phy-google-usb.o obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o
@@ -17,7 +16,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/ \ broadcom/ \
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 new file +494 -0
494 lines not on this page · raw message
drivers/phy/airoha/phy-an7581-pcie.c new file +1290 -0
1,290 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 4/4 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.
The first USB port on the SoC can be both used for USB 3.0 operation or Ethernet.
The second USB port on the SoC can be both used for USB 3.0 operation or PCIe.
Both port operation toggled by the SCU SSR register and configured by the USB PHY driver.
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 | 10 + drivers/phy/airoha/Makefile | 1 + drivers/phy/airoha/phy-an7581-usb.c | 640 ++++++++++++++++++++++++++++ 4 files changed, 652 insertions(+) create mode 100644 drivers/phy/airoha/phy-an7581-usb.c
MAINTAINERS +1 -0
@@ -784,6 +784,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 +10 -0
@@ -11,3 +11,13 @@ 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 + 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 +640 -0
640 lines not on this page · raw message
Signature · 1 line
2.51.0
kernel test robot
build botRe: [PATCH v5 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY
kernel test robot noticed the following build warnings:
Hi Christian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20260303]
[cannot apply to robh/for-next linus/master v7.0-rc2 v7.0-rc1 v6.19 v7.0-rc2] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-soc-Add-bindings-for-Airoha-SCU-Serdes-lines/20260304-090107 base: next-20260303 patch link: https://lore.kernel.org/r/20260304005843.2680-5-ansuelsmth%40gmail.com patch subject: [PATCH v5 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY config: powerpc64-randconfig-r131-20260305 (https://download.01.org/0day-ci/archive/20260305/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9a109fbb6e184ec9bcce10615949f598f4c974a9) sparse: v0.6.5-rc1 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/phy/airoha/phy-an7581-usb.c:569:14: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *base @@ got void [noderef] __iomem * @@ drivers/phy/airoha/phy-an7581-usb.c:569:14: sparse: expected void *base drivers/phy/airoha/phy-an7581-usb.c:569:14: sparse: got void [noderef] __iomem * >> drivers/phy/airoha/phy-an7581-usb.c:573:24: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected void [noderef] __iomem *regs @@ got void *base @@
drivers/phy/airoha/phy-an7581-usb.c:573:24: sparse: expected void [noderef] __iomem *regs
drivers/phy/airoha/phy-an7581-usb.c:573:24: sparse: got void *base
vim +569 drivers/phy/airoha/phy-an7581-usb.c
545
546 static int an7581_usb_phy_probe(struct platform_device *pdev)
547 {
548 struct phy_provider *phy_provider;
549 struct an7581_usb_phy_priv *priv;
550 struct device *dev = &pdev->dev;
551 unsigned int index;
552 void *base;
553 int ret;
554
555 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
556 if (!priv)
557 return -ENOMEM;
558
559 priv->dev = dev;
560
561 ret = of_property_read_u32(dev->of_node, "airoha,usb2-monitor-clk-sel",
562 &priv->monclk_sel);
563 if (ret)
564 return dev_err_probe(dev, ret, "Monitor clock selection is mandatory for USB PHY calibration\n");
565
566 if (priv->monclk_sel > 3)
567 return dev_err_probe(dev, -EINVAL, "only 4 Monitor clock are selectable on the SoC\n");
568
> 569 base = devm_platform_ioremap_resource(pdev, 0); 570 if (IS_ERR(base)) 571 return PTR_ERR(base); 572 > 573 priv->regmap = devm_regmap_init_mmio(dev, base, &an7581_usb_phy_regmap_config);
574 if (IS_ERR(priv->regmap))
575 return PTR_ERR(priv->regmap);
576
577 platform_set_drvdata(pdev, priv);
578
579 for (index = 0; index < AIROHA_PHY_USB_MAX; index++) {
580 enum an7581_usb_phy_instance_type phy_type;
581 struct an7581_usb_phy_instance *instance;
582
583 switch (index) {
584 case AIROHA_PHY_USB2:
585 phy_type = PHY_TYPE_USB2;
586 break;
587 case AIROHA_PHY_USB3:
588 phy_type = PHY_TYPE_USB3;
589 break;
590 }
591
592 if (phy_type == PHY_TYPE_USB3) {
593 ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
594 &priv->serdes_port);
595 if (ret)
596 return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
597
598 priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");
599 if (IS_ERR(priv->scu))
600 return dev_err_probe(dev, PTR_ERR(priv->scu), "failed to get SCU syscon\n");
601 }
602
603 instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
604 if (!instance)
605 return -ENOMEM;
606
607 instance->type = phy_type;
608 priv->phys[index] = instance;
609
610 instance->phy = devm_phy_create(dev, NULL, &airoha_phy);
611 if (IS_ERR(instance->phy))
612 return dev_err_probe(dev, PTR_ERR(instance->phy), "failed to create phy\n");
613
614 phy_set_drvdata(instance->phy, instance);
615 }
616
617 phy_provider = devm_of_phy_provider_register(&pdev->dev, an7581_usb_phy_xlate);
618
619 return PTR_ERR_OR_ZERO(phy_provider);
620 }
621
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki