Skip to content

Commit 15de15c

Browse files
Chunfeng Yunkishon
authored andcommitted
phy: phy-mt65xx-usb3: move clock from phy node into port nodes
each port has its own reference clock, the HighSpeed port is 48M, and the SuperSpeed port is usually 26M, put them into port node for flexibility, this can close clock if the port is not used. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
1 parent 04466ef commit 15de15c

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/phy/phy-mt65xx-usb3.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ struct mt65xx_phy_pdata {
153153
struct mt65xx_phy_instance {
154154
struct phy *phy;
155155
void __iomem *port_base;
156+
struct clk *ref_clk; /* reference clock of anolog phy */
156157
u32 index;
157158
u8 type;
158159
};
159160

160161
struct mt65xx_u3phy {
161162
struct device *dev;
162163
void __iomem *sif_base; /* only shared sif */
164+
/* deprecated, use @ref_clk instead in phy instance */
163165
struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */
164166
const struct mt65xx_phy_pdata *pdata;
165167
struct mt65xx_phy_instance **phys;
@@ -455,6 +457,12 @@ static int mt65xx_phy_init(struct phy *phy)
455457
return ret;
456458
}
457459

460+
ret = clk_prepare_enable(instance->ref_clk);
461+
if (ret) {
462+
dev_err(u3phy->dev, "failed to enable ref_clk\n");
463+
return ret;
464+
}
465+
458466
if (instance->type == PHY_TYPE_USB2)
459467
phy_instance_init(u3phy, instance);
460468
else
@@ -494,6 +502,7 @@ static int mt65xx_phy_exit(struct phy *phy)
494502
if (instance->type == PHY_TYPE_USB2)
495503
phy_instance_exit(u3phy, instance);
496504

505+
clk_disable_unprepare(instance->ref_clk);
497506
clk_disable_unprepare(u3phy->u3phya_ref);
498507
return 0;
499508
}
@@ -594,10 +603,13 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev)
594603
return PTR_ERR(u3phy->sif_base);
595604
}
596605

606+
/* it's deprecated, make it optional for backward compatibility */
597607
u3phy->u3phya_ref = devm_clk_get(dev, "u3phya_ref");
598608
if (IS_ERR(u3phy->u3phya_ref)) {
599-
dev_err(dev, "error to get u3phya_ref\n");
600-
return PTR_ERR(u3phy->u3phya_ref);
609+
if (PTR_ERR(u3phy->u3phya_ref) == -EPROBE_DEFER)
610+
return -EPROBE_DEFER;
611+
612+
u3phy->u3phya_ref = NULL;
601613
}
602614

603615
port = 0;
@@ -638,6 +650,17 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev)
638650
instance->index = port;
639651
phy_set_drvdata(phy, instance);
640652
port++;
653+
654+
/* if deprecated clock is provided, ignore instance's one */
655+
if (u3phy->u3phya_ref)
656+
continue;
657+
658+
instance->ref_clk = devm_clk_get(&phy->dev, "ref");
659+
if (IS_ERR(instance->ref_clk)) {
660+
dev_err(dev, "failed to get ref_clk(id-%d)\n", port);
661+
retval = PTR_ERR(instance->ref_clk);
662+
goto put_child;
663+
}
641664
}
642665

643666
provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate);

0 commit comments

Comments
 (0)