phy: airoha: add support for AN7583 PCIe PHY driver
Subsystems (2)
v5 cover phy: airoha: add support for AN7583 PCIe PHY driver
This small series introduce support for Airoha AN7583 Gen3 PCIe PHY.
It's not possible to reuse the EN7581 code as the register changed between the 2 SoC and also the setup method changed (different calibration logic)
Putting the PHY in a dedicated directory is also needed for other series current pending that will add USB PHY support.
Also a dedicated schema is added as the register names is entirely different compared to EN7581.
Changes v5:
- Rebase on top of phy/next
- Add Review tag
Changes v4:
- Add REGMAP_MMIO to kconfig
- Better handle exit
- Add additional info on QPHY usage
Changes v3:
- Improve example for Documentation patch
- Deinit G3 PHY on QPHY error
Changes v2:
- Drop move patch (handled in different series)
- Rework to regmap implementation
- Rename files to more specific name
- Add .exit logic
- Drop QPHY in favor of external PHY handling
- Update schema with new requirement and improve example
Christian Marangi (2):
dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
.../phy/airoha,an7583-pcie-gen3-phy.yaml | 65 ++ MAINTAINERS | 8 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 3 +- drivers/phy/airoha/Kconfig | 14 + drivers/phy/airoha/Makefile | 2 + drivers/phy/airoha/phy-an7583-pcie-regs.h | 377 ++++++++ drivers/phy/airoha/phy-an7583-pcie.c | 823 ++++++++++++++++++ 8 files changed, 1292 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-an7583-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-an7583-pcie.c
Signature · 1 line
2.55.0
PATCH v5 1/2 dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
Document support for AN7583 PCIe PHY used to make the Gen3 PCIe port work. Add the required register to configure the PCIe PHY and provide an example for it.
The PHY link to another PHY (the QPHY as described in the YAML) to correctly handle Gen2 speed and mode. It's mandatory to have this PHY configured for correct functionality of PCIe. The QPHY is a unified PHY that both handle USB and PCIe PHY.
It's also mondatory that the QPHY setup is done in the PCIe PHY setup and calibration phase or calibration might fail.
--- .../phy/airoha,an7583-pcie-gen3-phy.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +65 -0
@@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/airoha,an7583-pcie-gen3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN7583 PCI-Express PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: + The PCIe PHY supports physical layer functionality for PCIe Gen2/Gen3 port. + +properties: + compatible: + const: airoha,an7583-pcie-gen3-phy + + reg: + items: + - description: PCIE G3 analog base address + - description: PCIE G3 PMA base address + - description: PCIE detection time base address + - description: PCIE Rx AEQ base address + + reg-names: + items: + - const: g3-ana + - const: g3-pma + - const: xr-dtime + - const: rx-aeq + + phys: + items: + - description: phandle to QPHY phy for Gen2 support + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - reg-names + - phys + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/phy/phy.h> + + phy@1fc7f000 { + compatible = "airoha,an7583-pcie-gen3-phy"; + reg = <0x1fc7f000 0x1000>, + <0x1fc7e000 0x1000>, + <0x1fc30044 0x4>, + <0x1fc35030 0x4>; + reg-names = "g3-ana", "g3-pma", + "xr-dtime", "rx-aeq"; + + phys = <&pcie1_phy PHY_TYPE_PCIE>; + + #phy-cells = <0>; + };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v5 1/2] dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] dt-bindings: phy: airoha: Gen2 QPHY modeled as sub-PHY of Gen3 PHY - [Medium] dt-bindings: phy…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: phy: airoha: Gen2 QPHY modeled as sub-PHY of Gen3 PHY
- [Medium] dt-bindings: phy: airoha: single 4-byte registers modeled as reg blocks --
commit e8f61fa61bb7ae6492d5b28847c5a694f3cca2ec
Author: Christian Marangi <[email protected]>
dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
This commit adds the Device Tree binding schema for the Airoha AN7583 Gen3 PCIe PHY, defining its register regions and QPHY phandle link.
Quoted 6 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +0
-0@@ -0,0 +1,65 @@
[ ... ]
Quoted 32 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +32
-0+ reg: + items: + - description: PCIE G3 analog base address + - description: PCIE G3 PMA base address + - description: PCIE detection time base address + - description: PCIE Rx AEQ base address + + reg-names: + items: + - const: g3-ana + - const: g3-pma + - const: xr-dtime + - const: rx-aeq + + phys: + items: + - description: phandle to QPHY phy for Gen2 support + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - reg-names + - phys + - "#phy-cells" + +additionalProperties: false + +examples: + - |
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml line 60
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +10
-0+ #include <dt-bindings/phy/phy.h> + + phy@1fc7f000 { + compatible = "airoha,an7583-pcie-gen3-phy"; + reg = <0x1fc7f000 0x1000>, + <0x1fc7e000 0x1000>, + <0x1fc30044 0x4>, + <0x1fc35030 0x4>; + reg-names = "g3-ana", "g3-pma", + "xr-dtime", "rx-aeq";
[Severity: Medium]
As reported by Krzysztof Kozlowski on v2 [1], should the reg and reg-names properties describe the enclosing hardware register blocks rather than mapping two individual 4-byte registers for xr-dtime (0x1fc30044, size 0x4) and rx-aeq (0x1fc35030, size 0x4)?
In the companion driver header drivers/phy/airoha/phy-an7583-pcie-regs.h, these regions are accessed at offset 0x0 via REG_PCIE_PEXTP_DIG_GLB44 and REG_PCIE_PEXTP_DIG_LN_RX30:
/* Stone Portrait XR DTIME */
#define REG_PCIE_PEXTP_DIG_GLB44 0x0
/* Stone Portrait RX AEQ */
#define REG_PCIE_PEXTP_DIG_LN_RX30 0x0Consistent with the MediaTek and Airoha PEXTP register layout in drivers/phy/mediatek/phy-mtk-pcie-sphy.c and drivers/phy/phy-airoha-pcie-regs.h, 0x1fc30044 is offset 0x44 within the PEXTP_DIG_GLB block at 0x1fc30000, and 0x1fc35030 is offset 0x30 within the PEXTP_DIG_LN_RX block at 0x1fc35000 (offset 0x5030 from 0x1fc30000).
Mapping only 4 bytes per register in the binding prevents accessing any other registers in those PEXTP blocks without changing the binding ABI.
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
Quoted 2 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +2
-0+ + phys = <&pcie1_phy PHY_TYPE_PCIE>;
[Severity: Medium]
As reported by Rob Herring on v3 [2], why is the Gen2 QPHY linked as a required phys property on the Gen3 PHY node instead of referencing both the Gen2 and Gen3 PHYs from the PCIe host controller?
The commit message states that QPHY setup must be done in the PCIe PHY setup and calibration phase or calibration might fail. However, looking at an7583_pcie_phy_init() and an7583_pcie_phy_exit() in the companion driver (drivers/phy/airoha/phy-an7583-pcie.c), there is no interleaved register access or cross-calibration between the two PHYs:
static int an7583_pcie_phy_init(struct phy *phy)
{
...
an7583_pcie_phy_init_default(pcie_phy);
...
setbits(pcie_phy->g3_pma + REG_SS_DA_XPON_PWDB_0,
G3_PMA_DA_XPON_CDR_PR_PWDB);
ret = phy_init(pcie_phy->qp_phy);
if (ret)
return ret;
msleep(PHY_HW_INIT_TIME_MS);
return 0;
}
static int an7583_pcie_phy_exit(struct phy *phy)
{
...
ret = phy_exit(pcie_phy->qp_phy);
if (ret)
return ret;
an7583_pcie_phy_deinit(pcie_phy);
return 0;
}In addition, an7583_pcie_phy_probe() retrieves qp_phy using devm_phy_optional_get() even though phys is marked required in this binding schema. Could both PHYs be linked directly to the PCIe host controller instead of nesting phys inside the Gen3 PHY binding?
[1] https://lore.kernel.org/r/20260831-elastic-turquoise-puma-f032fc@quoll
[2] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v5 1/2] dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
In reply to Christian MarangiQuoted 9 lines · Christian Marangi
Document support for AN7583 PCIe PHY used to make the Gen3 PCIe port work. Add the required register to configure the PCIe PHY and provide an example for it.
The PHY link to another PHY (the QPHY as described in the YAML) to correctly handle Gen2 speed and mode. It's mandatory to have this PHY configured for correct functionality of PCIe. The QPHY is a unified PHY that both handle USB and PCIe PHY.
Quoted 9 lines
It's also mondatory that the QPHY setup is done in the PCIe PHY setup and calibration phase or calibration might fail.
Signed-off-by Christian Marangi <[email protected]>--- .../phy/airoha,an7583-pcie-gen3-phy.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
You forgot my tag...
PATCH v5 2/2 phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
In reply to Christian MarangiAdd support for AN7583 PCIe PHY driver. This is required to make the Gen3 PCIe port present on the Airoha AN7583 SoC correctly work.
A different setup is needed compared to Airoha EN7581 where the calibration process and the register map greatly changed.
--- MAINTAINERS | 8 + drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 3 +- drivers/phy/airoha/Kconfig | 14 + drivers/phy/airoha/Makefile | 2 + drivers/phy/airoha/phy-an7583-pcie-regs.h | 377 ++++++++++ drivers/phy/airoha/phy-an7583-pcie.c | 823 ++++++++++++++++++++++ 7 files changed, 1227 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-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-an7583-pcie.c
MAINTAINERS +8 -0
@@ -788,6 +788,14 @@ 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 +AIROHA AN7583 PCIE PHY DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml +F: drivers/phy/airoha/phy-an7583-pcie-regs.h +F: drivers/phy/airoha/phy-an7583-pcie.c + AIROHA SOUND DRIVER M: Christian Marangi <[email protected]> L: [email protected]
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/ \ aspeed/ \
drivers/phy/airoha/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Airoha platforms +# +config PHY_AIROHA_AN7583_PCIE + tristate "Airoha AN7583 PCIe-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 AN7583 PCIe PHY driver. + This driver create the basic PHY instance and provides initialize + callback for PCIe GEN3 port.
drivers/phy/airoha/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_PHY_AIROHA_AN7583_PCIE) += phy-an7583-pcie.o
drivers/phy/airoha/phy-an7583-pcie-regs.h new file +377 -0
377 lines not on this page · raw message
drivers/phy/airoha/phy-an7583-pcie.c new file +823 -0
823 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v5 2/2] phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] phy: airoha: use of devm_phy_optional_get() for required qp_phy - [Medium] phy: airoha…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] phy: airoha: use of devm_phy_optional_get() for required qp_phy
- [Medium] phy: airoha: G3_ANA_PXP_JCPLL_SSC_EN not cleared on init or deinit
- [Low] phy: airoha: misuse of dev_err_probe() in an7583_pcie_phy_init()
- [Low] phy: airoha: unused FREQ_LOCK_MAX_ATTEMPT macro and MAINTAINERS order --
commit 2954f920d212f21a88edba191990e99091d7cd13
Author: Christian Marangi <[email protected]>
phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
This commit adds a new PHY driver for the Gen3 PCIe port on the Airoha AN7583 SoC, implementing its register map and calibration sequence.
Quoted 19 lines
MAINTAINERS +8
-0@@ -788,6 +788,14 @@ 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 +AIROHA AN7583 PCIE PHY DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml +F: drivers/phy/airoha/phy-an7583-pcie-regs.h +F: drivers/phy/airoha/phy-an7583-pcie.c + AIROHA SOUND DRIVER M: Christian Marangi <[email protected]> L: [email protected]
[ ... ]
Quoted 6 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +0
-0@@ -0,0 +1,823 @@
[ ... ]
drivers/phy/airoha/phy-an7583-pcie.c line 19
Quoted 3 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +3
-0+#include "phy-an7583-pcie-regs.h" + +#define FREQ_LOCK_MAX_ATTEMPT 50
[Severity: Low]
This isn't a bug, but FREQ_LOCK_MAX_ATTEMPT is defined in drivers/phy/airoha/phy-an7583-pcie.c without being referenced anywhere in the driver. Also, in MAINTAINERS, AIROHA AN7583 PCIE PHY DRIVER is placed after AIROHA PCIE PHY DRIVER; should FREQ_LOCK_MAX_ATTEMPT be dropped and the MAINTAINERS entry be placed in alphabetical order before AIROHA ETHERNET DRIVER?
[ ... ]
Quoted 24 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +24
-0+static void an7583_pcie_phy_init_jcpll (struct an7583_pcie_phy *pcie_phy) +{ +regmap_set_bits (pcie_phy->g3_pma,REG_FORCE_DA_PXP_JCPLL_CKOUT_EN , +G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN ); +regmap_clear_bits (pcie_phy->g3_pma,REG_FORCE_DA_PXP_JCPLL_CKOUT_EN , +G3_PMA_FORCE_DA_PXP_JCPLL_EN ); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SPARE_H , +G3_ANA_PXP_JCPLL_SPARE_L , +FIELD_PREP (G3_ANA_PXP_JCPLL_SPARE_L ,0x20 )); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_RST_DLY , +G3_ANA_PXP_JCPLL_PLL_RSTB ); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_DELTA , +G3_ANA_PXP_JCPLL_SSC_DELTA , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_DELTA ,0x0 )); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_TRI_EN , +G3_ANA_PXP_JCPLL_SSC_DELTA1 , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_DELTA1 ,0x0 )); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_DELTA , +G3_ANA_PXP_JCPLL_SSC_PERIOD , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_PERIOD ,0x0 )); +regmap_clear_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_VCO_TCLVAR , +G3_ANA_PXP_JCPLL_SSC_PHASE_INI ); +regmap_clear_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_TRI_EN , +G3_ANA_PXP_JCPLL_SSC_TRI_EN );
[ ... ]
Quoted 24 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +24
-0+static void an7583_pcie_phy_init_ssc_jcpll (struct an7583_pcie_phy *pcie_phy) +{ +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_DELTA , +G3_ANA_PXP_JCPLL_SSC_DELTA , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_DELTA ,0x106 )); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_TRI_EN , +G3_ANA_PXP_JCPLL_SSC_DELTA1 , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_DELTA1 ,0x106 )); +regmap_update_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_DELTA , +G3_ANA_PXP_JCPLL_SSC_PERIOD , +FIELD_PREP (G3_ANA_PXP_JCPLL_SSC_PERIOD ,0x31B )); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_VCO_TCLVAR , +G3_ANA_PXP_JCPLL_SSC_PHASE_INI ); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_VCO_TCLVAR , +G3_ANA_PXP_JCPLL_SSC_EN ); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SDM_IFM , +G3_ANA_PXP_JCPLL_SDM_IFM ); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SDM_HREN , +G3_ANA_PXP_JCPLL_SDM_HREN ); +regmap_clear_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_RST_DLY , +G3_ANA_PXP_JCPLL_SDM_DI_EN ); +regmap_set_bits (pcie_phy->g3_ana,REG_PXP_JCPLL_SSC_TRI_EN , +G3_ANA_PXP_JCPLL_SSC_TRI_EN ); +}
[ ... ]
Quoted 28 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +28
-0+static int an7583_pcie_phy_deinit (struct an7583_pcie_phy *pcie_phy) +{ +/* Disable RX CDR/PR */ +regmap_clear_bits (pcie_phy->g3_pma,REG_SS_DA_XPON_PWDB_0 , +G3_PMA_DA_XPON_CDR_PR_PWDB ); + +/* Disable TX PLL output/enable */ +regmap_clear_bits (pcie_phy->g3_pma,REG_FORCE_DA_PXP_TXPLL_CKOUT_EN , +G3_PMA_FORCE_DA_PXP_TXPLL_CKOUT_EN | +G3_PMA_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN | +G3_PMA_FORCE_SEL_DA_PXP_TXPLL_EN | +G3_PMA_FORCE_DA_PXP_TXPLL_EN ); + +/* Disable JCPLL output/enable */ +regmap_clear_bits (pcie_phy->g3_pma,REG_FORCE_DA_PXP_JCPLL_CKOUT_EN , +G3_PMA_FORCE_DA_PXP_JCPLL_CKOUT_EN | +G3_PMA_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN | +G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN | +G3_PMA_FORCE_DA_PXP_JCPLL_EN ); + +/* Assert PHY resets */ + regmap_clear_bits(pcie_phy->g3_pma, REG_SW_RST_SET, + G3_PMA_SW_TX_FIFO_RST_N | + G3_PMA_SW_ALLPCS_RST_N | + G3_PMA_SW_PMA_RST_N | + G3_PMA_SW_TX_RST_N | + G3_PMA_SW_RX_FIFO_RST_N | + G3_PMA_SW_XFI_RXPCS_RST_N |
drivers/phy/airoha/phy-an7583-pcie.c line 635
Quoted 10 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +10
-0+G3_PMA_SW_REF_RST_N | + G3_PMA_SW_RX_RST_N); + +/* Disable TX analog blocks */ +regmap_clear_bits (pcie_phy->g3_ana,REG_PXP_TX_CKLDO_EN , +G3_ANA_PXP_TX_CKLDO_EN | +G3_ANA_PXP_TX_DMEDGEGEN_EN ); + +return 0 ; +}
[Severity: Medium]
When an7583_pcie_phy_init() runs, an7583_pcie_phy_init_ssc_jcpll() enables JCPLL spread-spectrum clocking by setting G3_ANA_PXP_JCPLL_SSC_PHASE_INI and G3_ANA_PXP_JCPLL_SSC_EN in REG_PXP_JCPLL_VCO_TCLVAR, and G3_ANA_PXP_JCPLL_SSC_TRI_EN in REG_PXP_JCPLL_SSC_TRI_EN.
However, an7583_pcie_phy_deinit() does not clear these JCPLL SSC bits (in contrast to airoha_pcie_phy_exit() in drivers/phy/phy-airoha-pcie.c, which clears CSR_2L_PXP_JCPLL_SSC_PHASE_INI | CSR_2L_PXP_JCPLL_SSC_TRI_EN | CSR_2L_PXP_JCPLL_SSC_EN), and Phase 1 in an7583_pcie_phy_init_jcpll() only clears G3_ANA_PXP_JCPLL_SSC_PHASE_INI and G3_ANA_PXP_JCPLL_SSC_TRI_EN without clearing G3_ANA_PXP_JCPLL_SSC_EN.
If the PHY is re-initialized after phy_exit() or after a failed phy_init() attempt (or if the bootloader left JCPLL SSC enabled), will G3_ANA_PXP_JCPLL_SSC_EN remain set during Phase 1 JCPLL and TXPLL configuration when SSC is supposed to be disabled?
Quoted 3 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +3
-0+ +static int an7583_pcie_phy_init (struct phy *phy) +{
[ ... ]
drivers/phy/airoha/phy-an7583-pcie.c line 711
Quoted 6 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +6
-0+ ret =phy_init (pcie_phy->qp_phy); +if (ret) { +an7583_pcie_phy_deinit (pcie_phy); + +return dev_err_probe (pcie_phy->dev, ret,"failed to initialize QP phy\n" ); + }
[Severity: Low]
Is dev_err_probe() appropriate inside the phy_ops .init callback an7583_pcie_phy_init()?
Because an7583_pcie_phy_init() runs when a consumer PCIe controller driver calls phy_init() after an7583_pcie_phy_probe() has already bound pcie_phy->dev, calling dev_err_probe(pcie_phy->dev, ret, ...) will suppress error messages completely if ret is -ENOMEM, or downgrade the message to dev_dbg() and allocate pcie_phy->dev->p->deferred_probe_reason on an already-bound device if ret is -EPROBE_DEFER. Should this use dev_err() instead?
[ ... ]
Quoted 9 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +9
-0+static int an7583_pcie_phy_probe (struct platform_device *pdev) +{ +struct an7583_pcie_phy *pcie_phy; +struct device *dev = &pdev->dev; +struct phy_provider *provider; + + pcie_phy =devm_kzalloc (dev,sizeof (*pcie_phy),GFP_KERNEL ); +if (!pcie_phy) +return -ENOMEM ;
drivers/phy/airoha/phy-an7583-pcie.c line 773
Quoted 10 lines
drivers/phy/airoha/phy-an7583-pcie.c new file +10
-0+ + pcie_phy->g3_ana =an7583_pcie_phy_regmap_init (pdev,"g3-ana" ); +if (IS_ERR (pcie_phy->g3_ana)) +return dev_err_probe (dev,PTR_ERR (pcie_phy->g3_ana), +"Failed to initialize g3 ANA regmap\n" ); + + pcie_phy->qp_phy =devm_phy_optional_get (dev,NULL ); +if (IS_ERR (pcie_phy->qp_phy)) +return dev_err_probe (dev,PTR_ERR (pcie_phy->qp_phy), +"Failed to get QP PCIe phy\n" );
[Severity: Medium]
Should an7583_pcie_phy_probe() use devm_phy_get() instead of devm_phy_optional_get() for pcie_phy->qp_phy?
In Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml, phys is a required property because QPHY configuration is needed during the PCIe PHY setup and calibration phase. With devm_phy_optional_get(dev, NULL), a missing phys property or a disabled QPHY node in DeviceTree causes _of_phy_get() to return ERR_PTR(-ENODEV), which devm_phy_optional_get() turns into NULL. Both an7583_pcie_phy_probe() and phy_init(pcie_phy->qp_phy) in an7583_pcie_phy_init() will then succeed silently without initializing the required QPHY.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2