Skip to content

Commit 80cf67d

Browse files
shimodaygeertu
authored andcommitted
clk: renesas: rcar-usb2-clock-sel: Add multiple clocks management
This hardware needs to enable clocks of both host and peripheral. So, this patch adds multiple clocks management. Signed-off-by: Yoshihiro Shimoda <[email protected]> Link: https://lore.kernel.org/r/1583304137-28482-4-git-send-email-yoshihiro.shimoda.uh@renesas.com Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent f70ae8e commit 80cf67d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/clk/renesas/rcar-usb2-clock-sel.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@
2626
#define CLKSET0_PRIVATE BIT(0)
2727
#define CLKSET0_EXTAL_ONLY (CLKSET0_INTCLK_EN | CLKSET0_PRIVATE)
2828

29+
static const struct clk_bulk_data rcar_usb2_clocks[] = {
30+
{ .id = "ehci_ohci", },
31+
{ .id = "hs-usb-if", },
32+
};
33+
2934
struct usb2_clock_sel_priv {
3035
void __iomem *base;
3136
struct clk_hw hw;
37+
struct clk_bulk_data clks[ARRAY_SIZE(rcar_usb2_clocks)];
3238
bool extal;
3339
bool xtal;
3440
};
@@ -53,14 +59,25 @@ static void usb2_clock_sel_disable_extal_only(struct usb2_clock_sel_priv *priv)
5359

5460
static int usb2_clock_sel_enable(struct clk_hw *hw)
5561
{
56-
usb2_clock_sel_enable_extal_only(to_priv(hw));
62+
struct usb2_clock_sel_priv *priv = to_priv(hw);
63+
int ret;
64+
65+
ret = clk_bulk_prepare_enable(ARRAY_SIZE(priv->clks), priv->clks);
66+
if (ret)
67+
return ret;
68+
69+
usb2_clock_sel_enable_extal_only(priv);
5770

5871
return 0;
5972
}
6073

6174
static void usb2_clock_sel_disable(struct clk_hw *hw)
6275
{
63-
usb2_clock_sel_disable_extal_only(to_priv(hw));
76+
struct usb2_clock_sel_priv *priv = to_priv(hw);
77+
78+
usb2_clock_sel_disable_extal_only(priv);
79+
80+
clk_bulk_disable_unprepare(ARRAY_SIZE(priv->clks), priv->clks);
6481
}
6582

6683
/*
@@ -119,6 +136,7 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
119136
struct usb2_clock_sel_priv *priv;
120137
struct clk *clk;
121138
struct clk_init_data init;
139+
int ret;
122140

123141
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
124142
if (!priv)
@@ -128,6 +146,11 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
128146
if (IS_ERR(priv->base))
129147
return PTR_ERR(priv->base);
130148

149+
memcpy(priv->clks, rcar_usb2_clocks, sizeof(priv->clks));
150+
ret = devm_clk_bulk_get(dev, ARRAY_SIZE(priv->clks), priv->clks);
151+
if (ret < 0)
152+
return ret;
153+
131154
pm_runtime_enable(dev);
132155
pm_runtime_get_sync(dev);
133156

0 commit comments

Comments
 (0)