Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock
@ 2025-11-18  7:19 Xu Yang
  2025-11-18  7:19 ` [PATCH v4 2/2] phy: fsl-imx8mq-usb: support " Xu Yang
  2025-11-20 17:12 ` [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add " Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Xu Yang @ 2025-11-18  7:19 UTC (permalink / raw)
  To: vkoul, kishon, robh, krzk+dt, conor+dt, shawnguo, s.hauer, kernel,
	festevam, jun.li, Frank.Li, linux-phy, devicetree, imx,
	linux-arm-kernel, linux-kernel

Beside default 24MHz clock input, there is an optional additional 100Mhz
clock input 'alt' for USB PHY reference clock.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
 - improve commit message
Changes in v3:
 - no changes
Changes in v4:
 - no changes
---
 .../devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
index f9cffbb2df07..8a00a6c58edd 100644
--- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
@@ -27,11 +27,16 @@ properties:
     const: 0
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    items:
+      - description: PHY configuration clock
+      - description: Alternate PHY reference clock
 
   clock-names:
+    minItems: 1
     items:
       - const: phy
+      - const: alt
 
   power-domains:
     maxItems: 1
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v4 2/2] phy: fsl-imx8mq-usb: support alternate reference clock
  2025-11-18  7:19 [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock Xu Yang
@ 2025-11-18  7:19 ` Xu Yang
  2025-11-20 17:12 ` [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add " Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Xu Yang @ 2025-11-18  7:19 UTC (permalink / raw)
  To: vkoul, kishon, robh, krzk+dt, conor+dt, shawnguo, s.hauer, kernel,
	festevam, jun.li, Frank.Li, linux-phy, devicetree, imx,
	linux-arm-kernel, linux-kernel

This phy supports both 24MHz and 100MHz clock inputs. By default it's
using XTAL 24MHz and the 100MHz clock is a alternate reference clock.
Add supports to use alternate reference clock in case 24MHz clock
can't work well.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
 - add Rb tag
Changes in v3:
 - no changes
Changes in v4:
 - no changes
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index b94f242420fc..ad8a55012e42 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -16,6 +16,7 @@
 #define PHY_CTRL0_REF_SSP_EN		BIT(2)
 #define PHY_CTRL0_FSEL_MASK		GENMASK(10, 5)
 #define PHY_CTRL0_FSEL_24M		0x2a
+#define PHY_CTRL0_FSEL_100M		0x27
 
 #define PHY_CTRL1			0x4
 #define PHY_CTRL1_RESET			BIT(0)
@@ -108,6 +109,7 @@ struct tca_blk {
 struct imx8mq_usb_phy {
 	struct phy *phy;
 	struct clk *clk;
+	struct clk *alt_clk;
 	void __iomem *base;
 	struct regulator *vbus;
 	struct tca_blk *tca;
@@ -582,7 +584,8 @@ static int imx8mp_usb_phy_init(struct phy *phy)
 	/* USB3.0 PHY signal fsel for 24M ref */
 	value = readl(imx_phy->base + PHY_CTRL0);
 	value &= ~PHY_CTRL0_FSEL_MASK;
-	value |= FIELD_PREP(PHY_CTRL0_FSEL_MASK, PHY_CTRL0_FSEL_24M);
+	value |= FIELD_PREP(PHY_CTRL0_FSEL_MASK, imx_phy->alt_clk ?
+			    PHY_CTRL0_FSEL_100M : PHY_CTRL0_FSEL_24M);
 	writel(value, imx_phy->base + PHY_CTRL0);
 
 	/* Disable alt_clk_en and use internal MPLL clocks */
@@ -626,13 +629,24 @@ static int imx8mq_phy_power_on(struct phy *phy)
 	if (ret)
 		return ret;
 
-	return clk_prepare_enable(imx_phy->clk);
+	ret = clk_prepare_enable(imx_phy->clk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(imx_phy->alt_clk);
+	if (ret) {
+		clk_disable_unprepare(imx_phy->clk);
+		return ret;
+	}
+
+	return ret;
 }
 
 static int imx8mq_phy_power_off(struct phy *phy)
 {
 	struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
 
+	clk_disable_unprepare(imx_phy->alt_clk);
 	clk_disable_unprepare(imx_phy->clk);
 	regulator_disable(imx_phy->vbus);
 
@@ -681,6 +695,11 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(imx_phy->clk);
 	}
 
+	imx_phy->alt_clk = devm_clk_get_optional(dev, "alt");
+	if (IS_ERR(imx_phy->alt_clk))
+		return dev_err_probe(dev, PTR_ERR(imx_phy->alt_clk),
+				    "Failed to get alt clk\n");
+
 	imx_phy->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(imx_phy->base))
 		return PTR_ERR(imx_phy->base);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock
  2025-11-18  7:19 [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock Xu Yang
  2025-11-18  7:19 ` [PATCH v4 2/2] phy: fsl-imx8mq-usb: support " Xu Yang
@ 2025-11-20 17:12 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-11-20 17:12 UTC (permalink / raw)
  To: kishon, robh, krzk+dt, conor+dt, shawnguo, s.hauer, kernel,
	festevam, jun.li, Frank.Li, linux-phy, devicetree, imx,
	linux-arm-kernel, linux-kernel, Xu Yang


On Tue, 18 Nov 2025 15:19:46 +0800, Xu Yang wrote:
> Beside default 24MHz clock input, there is an optional additional 100Mhz
> clock input 'alt' for USB PHY reference clock.
> 
> 

Applied, thanks!

[1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock
      commit: 0e8fe19c0292d9912460b25043292227d5f1fdb2
[2/2] phy: fsl-imx8mq-usb: support alternate reference clock
      commit: 3b64ea4768e7e64b2d9ae5833dbcac19f6212145

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-20 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18  7:19 [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add alternate reference clock Xu Yang
2025-11-18  7:19 ` [PATCH v4 2/2] phy: fsl-imx8mq-usb: support " Xu Yang
2025-11-20 17:12 ` [PATCH v4 1/2] dt-bindings: phy: imx8mq-usb: add " Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox