Lines Matching +full:g12a +full:- +full:mdio +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/clk-provider.h>
13 #include <linux/mdio-mux.h>
75 val = readl(pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_recalc_rate()
85 u32 val = readl(pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_enable()
89 writel(val, pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_enable()
93 writel(val, pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_enable()
100 return readl_poll_timeout(pll->base + ETH_PLL_CTL0, val, in g12a_ephy_pll_enable()
109 val = readl(pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_disable()
112 writel(val, pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_disable()
120 val = readl(pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_is_enabled()
130 writel(0x29c0040a, pll->base + ETH_PLL_CTL0); in g12a_ephy_pll_init()
131 writel(0x927e0000, pll->base + ETH_PLL_CTL1); in g12a_ephy_pll_init()
132 writel(0xac5f49e5, pll->base + ETH_PLL_CTL2); in g12a_ephy_pll_init()
133 writel(0x00000000, pll->base + ETH_PLL_CTL3); in g12a_ephy_pll_init()
134 writel(0x00000000, pll->base + ETH_PLL_CTL4); in g12a_ephy_pll_init()
135 writel(0x20200000, pll->base + ETH_PLL_CTL5); in g12a_ephy_pll_init()
136 writel(0x0000c002, pll->base + ETH_PLL_CTL6); in g12a_ephy_pll_init()
137 writel(0x00000023, pll->base + ETH_PLL_CTL7); in g12a_ephy_pll_init()
156 if (!__clk_is_enabled(priv->pll)) { in g12a_enable_internal_mdio()
157 ret = clk_prepare_enable(priv->pll); in g12a_enable_internal_mdio()
163 writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0); in g12a_enable_internal_mdio()
165 /* Make sure we get a 0 -> 1 transition on the enable bit */ in g12a_enable_internal_mdio()
171 writel(value, priv->regs + ETH_PHY_CNTL1); in g12a_enable_internal_mdio()
175 priv->regs + ETH_PHY_CNTL2); in g12a_enable_internal_mdio()
178 writel(value, priv->regs + ETH_PHY_CNTL1); in g12a_enable_internal_mdio()
188 /* Reset the mdio bus mux */ in g12a_enable_external_mdio()
189 writel_relaxed(0x0, priv->regs + ETH_PHY_CNTL2); in g12a_enable_external_mdio()
192 if (__clk_is_enabled(priv->pll)) in g12a_enable_external_mdio()
193 clk_disable_unprepare(priv->pll); in g12a_enable_external_mdio()
212 return -EINVAL; in g12a_mdio_switch_fn()
217 { .compatible = "amlogic,g12a-mdio-mux", },
228 struct clk_mux *mux; in g12a_ephy_glue_clk_register() local
233 /* get the mux parents */ in g12a_ephy_glue_clk_register()
246 /* create the input mux */ in g12a_ephy_glue_clk_register()
247 mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL); in g12a_ephy_glue_clk_register()
248 if (!mux) in g12a_ephy_glue_clk_register()
249 return -ENOMEM; in g12a_ephy_glue_clk_register()
251 name = kasprintf(GFP_KERNEL, "%s#mux", dev_name(dev)); in g12a_ephy_glue_clk_register()
253 return -ENOMEM; in g12a_ephy_glue_clk_register()
261 mux->reg = priv->regs + ETH_PLL_CTL0; in g12a_ephy_glue_clk_register()
262 mux->shift = __ffs(PLL_CTL0_SEL); in g12a_ephy_glue_clk_register()
263 mux->mask = PLL_CTL0_SEL >> mux->shift; in g12a_ephy_glue_clk_register()
264 mux->hw.init = &init; in g12a_ephy_glue_clk_register()
266 clk = devm_clk_register(dev, &mux->hw); in g12a_ephy_glue_clk_register()
269 dev_err(dev, "failed to register input mux\n"); in g12a_ephy_glue_clk_register()
276 return -ENOMEM; in g12a_ephy_glue_clk_register()
280 return -ENOMEM; in g12a_ephy_glue_clk_register()
289 pll->base = priv->regs; in g12a_ephy_glue_clk_register()
290 pll->hw.init = &init; in g12a_ephy_glue_clk_register()
292 clk = devm_clk_register(dev, &pll->hw); in g12a_ephy_glue_clk_register()
295 dev_err(dev, "failed to register input mux\n"); in g12a_ephy_glue_clk_register()
299 priv->pll = clk; in g12a_ephy_glue_clk_register()
306 struct device *dev = &pdev->dev; in g12a_mdio_mux_probe()
313 return -ENOMEM; in g12a_mdio_mux_probe()
317 priv->regs = devm_platform_ioremap_resource(pdev, 0); in g12a_mdio_mux_probe()
318 if (IS_ERR(priv->regs)) in g12a_mdio_mux_probe()
319 return PTR_ERR(priv->regs); in g12a_mdio_mux_probe()
331 ret = mdio_mux_init(dev, dev->of_node, g12a_mdio_switch_fn, in g12a_mdio_mux_probe()
332 &priv->mux_handle, dev, NULL); in g12a_mdio_mux_probe()
334 dev_err_probe(dev, ret, "mdio multiplexer init failed\n"); in g12a_mdio_mux_probe()
343 mdio_mux_uninit(priv->mux_handle); in g12a_mdio_mux_remove()
345 if (__clk_is_enabled(priv->pll)) in g12a_mdio_mux_remove()
346 clk_disable_unprepare(priv->pll); in g12a_mdio_mux_remove()
353 .name = "g12a-mdio_mux",
359 MODULE_DESCRIPTION("Amlogic G12a MDIO multiplexer driver");