Skip to content

Commit 3b64ea4

Browse files
Xu Yangvinodkoul
authored andcommitted
phy: fsl-imx8mq-usb: support alternate reference clock
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> Link: https://patch.msgid.link/20251118071947.2504789-2-xu.yang_2@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 0e8fe19 commit 3b64ea4

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

drivers/phy/freescale/phy-fsl-imx8mq-usb.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define PHY_CTRL0_REF_SSP_EN BIT(2)
1717
#define PHY_CTRL0_FSEL_MASK GENMASK(10, 5)
1818
#define PHY_CTRL0_FSEL_24M 0x2a
19+
#define PHY_CTRL0_FSEL_100M 0x27
1920

2021
#define PHY_CTRL1 0x4
2122
#define PHY_CTRL1_RESET BIT(0)
@@ -108,6 +109,7 @@ struct tca_blk {
108109
struct imx8mq_usb_phy {
109110
struct phy *phy;
110111
struct clk *clk;
112+
struct clk *alt_clk;
111113
void __iomem *base;
112114
struct regulator *vbus;
113115
struct tca_blk *tca;
@@ -582,7 +584,8 @@ static int imx8mp_usb_phy_init(struct phy *phy)
582584
/* USB3.0 PHY signal fsel for 24M ref */
583585
value = readl(imx_phy->base + PHY_CTRL0);
584586
value &= ~PHY_CTRL0_FSEL_MASK;
585-
value |= FIELD_PREP(PHY_CTRL0_FSEL_MASK, PHY_CTRL0_FSEL_24M);
587+
value |= FIELD_PREP(PHY_CTRL0_FSEL_MASK, imx_phy->alt_clk ?
588+
PHY_CTRL0_FSEL_100M : PHY_CTRL0_FSEL_24M);
586589
writel(value, imx_phy->base + PHY_CTRL0);
587590

588591
/* Disable alt_clk_en and use internal MPLL clocks */
@@ -626,13 +629,24 @@ static int imx8mq_phy_power_on(struct phy *phy)
626629
if (ret)
627630
return ret;
628631

629-
return clk_prepare_enable(imx_phy->clk);
632+
ret = clk_prepare_enable(imx_phy->clk);
633+
if (ret)
634+
return ret;
635+
636+
ret = clk_prepare_enable(imx_phy->alt_clk);
637+
if (ret) {
638+
clk_disable_unprepare(imx_phy->clk);
639+
return ret;
640+
}
641+
642+
return ret;
630643
}
631644

632645
static int imx8mq_phy_power_off(struct phy *phy)
633646
{
634647
struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
635648

649+
clk_disable_unprepare(imx_phy->alt_clk);
636650
clk_disable_unprepare(imx_phy->clk);
637651
regulator_disable(imx_phy->vbus);
638652

@@ -681,6 +695,11 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
681695
return PTR_ERR(imx_phy->clk);
682696
}
683697

698+
imx_phy->alt_clk = devm_clk_get_optional(dev, "alt");
699+
if (IS_ERR(imx_phy->alt_clk))
700+
return dev_err_probe(dev, PTR_ERR(imx_phy->alt_clk),
701+
"Failed to get alt clk\n");
702+
684703
imx_phy->base = devm_platform_ioremap_resource(pdev, 0);
685704
if (IS_ERR(imx_phy->base))
686705
return PTR_ERR(imx_phy->base);

0 commit comments

Comments
 (0)