[PATCH v5 3/3] phy: airoha: Add support for Airoha AN7583 USB PHY

sashiko-bot at kernel.org sashiko-bot at kernel.org
Tue Nov 24 14:50:36 PST 2026


Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] phy: airoha: broken 0-cell PCIe xlate and type check in
  an7583_usb_phy_xlate()
- [High] phy: airoha: broken USB host mode and SerDes init in
  an7583_usb_phy_init()
- [Medium] phy: airoha: unshifted AIROHA_USB_ANA_TX_RESERVE_8 write to
  register 0x28
- [Medium] phy: airoha: write RX_IMP_SEL to INTF_STS_9 in
  an7583_usb_phy_set_mode_eth()
--

commit 8d0f29ff8d877f4177177940f87f2d0a3776baf6
Author: Christian Marangi <ansuelsmth at gmail.com>

phy: airoha: Add support for Airoha AN7583 USB PHY

This commit adds a PHY driver for the Airoha AN7583 USB PHY (supporting two
USB 2.0 ports and one USB 3.0 port) and the AN7583 PCIe Gen2 PHY.

[Severity: Medium]
In drivers/phy/airoha/phy-an7583-usb.c at lines 225-228 and in
an7583_usb_phy_set_mode_eth() at lines 671-675, should
AIROHA_USB_PMA_RX_IMP_SEL_SEL and AIROHA_USB_PMA_RX_IMP_SEL_FORCE be written
to a PMA interface control register instead of AIROHA_USB_PMA_INTF_STS_9
(0x364)?

All other *_SEL and *_FORCE override pairs live in the INTF_CTRL_5..8 block
(0x314..0x320), whereas AIROHA_USB_PMA_INTF_STS_9 (0x364) is the status
register read for AIROHA_USB_PMA_ADDR_INTF_STS_PLL_VCOCAL during KBand
calibration.  Writing the RX impedance override to the status register leaves
RX impedance unconfigured in SGMII and 2500Base-X Ethernet modes.

[Severity: Medium]
In drivers/phy/airoha/phy-an7583-usb.c, inside an7583_usb_phy_u3_init() at
lines 1092-1093 and an7583_usb_phy_pcie_init() at lines 1378-1379, should
AIROHA_USB_ANA_TX_RESERVE_8 be wrapped in
FIELD_PREP(AIROHA_USB_QP_TX_RESERVE, ...) when updating
AIROHA_USB_ANA_QP_TX_MODE_16B_EN (0x28)?

At lines 157-160, AIROHA_USB_ANA_TX_RESERVE_8 (BIT(8)) is defined relative to
AIROHA_USB_QP_TX_RESERVE (GENMASK(31, 16)), and an7583_usb_phy_set_mode_eth()
at lines 726-729 shifts it with FIELD_PREP(AIROHA_USB_QP_TX_RESERVE, ...).
Passing raw AIROHA_USB_ANA_TX_RESERVE_8 to regmap_set_bits() sets bit 8 in the
lower half of register 0x28 instead of bit 24.

[Severity: High]
In drivers/phy/airoha/phy-an7583-usb.c, how are USB host modes and SerDes PHY
mode selection expected to work across an7583_usb_phy_init() (lines
1408-1429), an7583_usb_phy_u2_set_mode() (lines 1663-1699), and
an7583_usb_phy_u3_set_mode() (lines 1701-1731)?

There are three related issues in these paths:

1. During HCD registration, usb_add_hcd() calls
   usb_phy_roothub_set_mode(hcd->phy_roothub, PHY_MODE_USB_HOST_SS) and falls
   back to PHY_MODE_USB_HOST only if that call returns an error.
   an7583_usb_phy_u3_set_mode() only accepts PHY_MODE_ETHERNET and
   PHY_MODE_USB_DEVICE_SS, returning -EOPNOTSUPP for both host modes and
   causing usb_add_hcd() to fail when the USB3 PHY is enabled.  Even if host
   modes were allowed in the switch statement, forwarding PHY_MODE_USB_HOST_SS
   or PHY_MODE_USB_HOST to phy_set_mode_ext(instance->serdes_phy, mode,
   submode) will be rejected by en7581_serdes_phy_set_mode() in
   drivers/clk/clk-en7523.c, which only accepts PHY_MODE_USB_DEVICE and
   PHY_MODE_USB_DEVICE_SS for USB.

2. In an7583_usb_phy_u2_set_mode() at lines 1678-1690, PHY_MODE_USB_HOST_SS
   hits the default case and returns 0 without updating
   AIROHA_USB_PHY_U2PHYDTM1.  Because the PHY_MODE_USB_HOST_SS call succeeds
   on USB2 PHYs, usb_add_hcd() skips the fallback call with PHY_MODE_USB_HOST,
   leaving AIROHA_USB_PHY_FORCE_IDDIG unset.

3. Unlike an7581_usb_phy_init(), an7583_usb_phy_init() runs
   an7583_usb_phy_u3_init() and an7583_usb_phy_pcie_init() without configuring
   instance->serdes_phy.  Because usb_add_hcd() calls usb_phy_roothub_init()
   before usb_phy_roothub_set_mode(), USB3 setup and KBand PLL calibration run
   before instance->serdes_phy is switched to USB mode; and because
   mtk_pcie_enable_port() in drivers/pci/controller/pcie-mediatek.c only calls
   phy_init() and phy_power_on() without calling phy_set_mode(),
   instance->serdes_phy is never configured to PHY_MODE_PCIE.

[Severity: High]
In drivers/phy/airoha/phy-an7583-usb.c, does an7583_usb_phy_xlate() at lines
1775-1814 break lookups for airoha,an7583-pcie-gen2-phy and skip matching the
requested PHY type against instance->type?

an7583_usb_phy_probe() at line 1987 registers an7583_usb_phy_xlate() for both
airoha,an7583-usb-phy and airoha,an7583-pcie-gen2-phy.  However, the binding
in Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen2-phy.yaml
specifies #phy-cells = <0>, so args->args_count is 0 for PCIe and the check at
line 1786 (if (args->args_count != 1)) unconditionally fails with
ERR_PTR(-EINVAL).

In addition, when args->args_count == 1, lines 1806-1811 only check that
args->args[0] is one of PHY_TYPE_USB2, PHY_TYPE_USB3, or PHY_TYPE_PCIE rather
than verifying that args->args[0] matches the resolved PHY's instance->type.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124222452.219832-1-ansuelsmth@gmail.com?part=3



More information about the linux-phy mailing list