Lines Matching +full:rcar +full:- +full:gen3 +full:- +full:usb2 +full:- +full:clock +full:- +full:sel
1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas R-Car USB2.0 clock selector
7 * Based on renesas-cpg-mssr.c
13 #include <linux/clk-provider.h>
32 { .id = "hs-usb-if", },
47 u16 val = readw(priv->base + USB20_CLKSET0); in usb2_clock_sel_enable_extal_only()
50 priv->extal, priv->xtal, val); in usb2_clock_sel_enable_extal_only()
52 if (priv->extal && !priv->xtal && val != CLKSET0_EXTAL_ONLY) in usb2_clock_sel_enable_extal_only()
53 writew(CLKSET0_EXTAL_ONLY, priv->base + USB20_CLKSET0); in usb2_clock_sel_enable_extal_only()
58 if (priv->extal && !priv->xtal) in usb2_clock_sel_disable_extal_only()
59 writew(CLKSET0_PRIVATE, priv->base + USB20_CLKSET0); in usb2_clock_sel_disable_extal_only()
67 ret = reset_control_deassert(priv->rsts); in usb2_clock_sel_enable()
71 ret = clk_bulk_prepare_enable(ARRAY_SIZE(priv->clks), priv->clks); in usb2_clock_sel_enable()
73 reset_control_assert(priv->rsts); in usb2_clock_sel_enable()
88 clk_bulk_disable_unprepare(ARRAY_SIZE(priv->clks), priv->clks); in usb2_clock_sel_disable()
89 reset_control_assert(priv->rsts); in usb2_clock_sel_disable()
95 * If this driver acts as a gate, ehci/ohci-platform drivers don't need
104 { .compatible = "renesas,rcar-gen3-usb2-clock-sel" },
130 struct device *dev = &pdev->dev; in rcar_usb2_clock_sel_remove()
132 of_clk_del_provider(dev->of_node); in rcar_usb2_clock_sel_remove()
141 struct device *dev = &pdev->dev; in rcar_usb2_clock_sel_probe()
142 struct device_node *np = dev->of_node; in rcar_usb2_clock_sel_probe()
150 return -ENOMEM; in rcar_usb2_clock_sel_probe()
152 priv->base = devm_platform_ioremap_resource(pdev, 0); in rcar_usb2_clock_sel_probe()
153 if (IS_ERR(priv->base)) in rcar_usb2_clock_sel_probe()
154 return PTR_ERR(priv->base); in rcar_usb2_clock_sel_probe()
156 memcpy(priv->clks, rcar_usb2_clocks, sizeof(priv->clks)); in rcar_usb2_clock_sel_probe()
157 ret = devm_clk_bulk_get(dev, ARRAY_SIZE(priv->clks), priv->clks); in rcar_usb2_clock_sel_probe()
161 priv->rsts = devm_reset_control_array_get_shared(dev); in rcar_usb2_clock_sel_probe()
162 if (IS_ERR(priv->rsts)) in rcar_usb2_clock_sel_probe()
163 return PTR_ERR(priv->rsts); in rcar_usb2_clock_sel_probe()
167 priv->extal = !!clk_get_rate(clk); in rcar_usb2_clock_sel_probe()
172 priv->xtal = !!clk_get_rate(clk); in rcar_usb2_clock_sel_probe()
176 if (!priv->extal && !priv->xtal) { in rcar_usb2_clock_sel_probe()
178 return -ENOENT; in rcar_usb2_clock_sel_probe()
188 priv->hw.init = &init; in rcar_usb2_clock_sel_probe()
190 ret = devm_clk_hw_register(dev, &priv->hw); in rcar_usb2_clock_sel_probe()
194 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &priv->hw); in rcar_usb2_clock_sel_probe()
213 .name = "rcar-usb2-clock-sel",
222 MODULE_DESCRIPTION("Renesas R-Car USB2 clock selector Driver");