]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
usb: xhci-mtk: add an optional xhci_ck clock
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Fri, 23 Aug 2019 06:40:25 +0000 (14:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Aug 2019 20:50:25 +0000 (22:50 +0200)
Some SoCs may have an optional clock xhci_ck (125M or 200M), it
usually uses the same PLL as sys_ck, so support it.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1566542425-20082-2-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mtk.c
drivers/usb/host/xhci-mtk.h

index 026fe18972d3e5b30232c2507105ff6f9542ef4d..b18a6baef204a60b1ac5071a55fdb25b0280aea5 100644 (file)
@@ -216,6 +216,10 @@ static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
                return PTR_ERR(mtk->sys_clk);
        }
 
+       mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck");
+       if (IS_ERR(mtk->xhci_clk))
+               return PTR_ERR(mtk->xhci_clk);
+
        mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck");
        if (IS_ERR(mtk->ref_clk))
                return PTR_ERR(mtk->ref_clk);
@@ -244,6 +248,12 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
                goto sys_clk_err;
        }
 
+       ret = clk_prepare_enable(mtk->xhci_clk);
+       if (ret) {
+               dev_err(mtk->dev, "failed to enable xhci_clk\n");
+               goto xhci_clk_err;
+       }
+
        ret = clk_prepare_enable(mtk->mcu_clk);
        if (ret) {
                dev_err(mtk->dev, "failed to enable mcu_clk\n");
@@ -261,6 +271,8 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
 dma_clk_err:
        clk_disable_unprepare(mtk->mcu_clk);
 mcu_clk_err:
+       clk_disable_unprepare(mtk->xhci_clk);
+xhci_clk_err:
        clk_disable_unprepare(mtk->sys_clk);
 sys_clk_err:
        clk_disable_unprepare(mtk->ref_clk);
@@ -272,6 +284,7 @@ static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
 {
        clk_disable_unprepare(mtk->dma_clk);
        clk_disable_unprepare(mtk->mcu_clk);
+       clk_disable_unprepare(mtk->xhci_clk);
        clk_disable_unprepare(mtk->sys_clk);
        clk_disable_unprepare(mtk->ref_clk);
 }
index 8be8c5f7ff626f01dc115de8ee592318564a8473..5ac458b7d2e0efa406e5db2ca57dfe3dde59e550 100644 (file)
@@ -139,6 +139,7 @@ struct xhci_hcd_mtk {
        struct regulator *vusb33;
        struct regulator *vbus;
        struct clk *sys_clk;    /* sys and mac clock */
+       struct clk *xhci_clk;
        struct clk *ref_clk;
        struct clk *mcu_clk;
        struct clk *dma_clk;