Skip to content

Commit 5dbe9ac

Browse files
Xu Yanggregkh
authored andcommitted
usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
Some platform using ChipIdea IP may keep 32KHz wakeup clock always on without usb driver intervention. And some may need driver to handle this clock. For now only i.MX93 needs this wakeup clock. This patch will get wakeup clock and keep it always on to make controller work properly. Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Acked-by: Peter Chen <peter.chen@kernel.org> Tested-by: Stefan Wahren <wahrenst@gmx.net> Link: https://lore.kernel.org/r/20231228110753.1755756-1-xu.yang_2@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 895ee5a commit 5dbe9ac

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
9696
struct usb_phy *phy;
9797
struct platform_device *ci_pdev;
9898
struct clk *clk;
99+
struct clk *clk_wakeup;
99100
struct imx_usbmisc_data *usbmisc_data;
100101
bool supports_runtime_pm;
101102
bool override_phy_control;
@@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
199200

200201
data->clk_ipg = devm_clk_get(dev, "ipg");
201202
if (IS_ERR(data->clk_ipg)) {
202-
/* If the platform only needs one clocks */
203+
/* If the platform only needs one primary clock */
203204
data->clk = devm_clk_get(dev, NULL);
204205
if (IS_ERR(data->clk)) {
205206
ret = PTR_ERR(data->clk);
@@ -208,6 +209,13 @@ static int imx_get_clks(struct device *dev)
208209
PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
209210
return ret;
210211
}
212+
/* Get wakeup clock. Not all of the platforms need to
213+
* handle this clock. So make it optional.
214+
*/
215+
data->clk_wakeup = devm_clk_get_optional(dev, "usb_wakeup_clk");
216+
if (IS_ERR(data->clk_wakeup))
217+
ret = dev_err_probe(dev, PTR_ERR(data->clk_wakeup),
218+
"Failed to get wakeup clk\n");
211219
return ret;
212220
}
213221

@@ -423,6 +431,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
423431
if (ret)
424432
goto disable_hsic_regulator;
425433

434+
ret = clk_prepare_enable(data->clk_wakeup);
435+
if (ret)
436+
goto err_wakeup_clk;
437+
426438
data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
427439
if (IS_ERR(data->phy)) {
428440
ret = PTR_ERR(data->phy);
@@ -504,6 +516,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
504516
disable_device:
505517
ci_hdrc_remove_device(data->ci_pdev);
506518
err_clk:
519+
clk_disable_unprepare(data->clk_wakeup);
520+
err_wakeup_clk:
507521
imx_disable_unprepare_clks(dev);
508522
disable_hsic_regulator:
509523
if (data->hsic_pad_regulator)
@@ -530,6 +544,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
530544
usb_phy_shutdown(data->phy);
531545
if (data->ci_pdev) {
532546
imx_disable_unprepare_clks(&pdev->dev);
547+
clk_disable_unprepare(data->clk_wakeup);
533548
if (data->plat_data->flags & CI_HDRC_PMQOS)
534549
cpu_latency_qos_remove_request(&data->pm_qos_req);
535550
if (data->hsic_pad_regulator)

0 commit comments

Comments
 (0)