Lines Matching +full:clk +full:- +full:phase +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 #include <linux/clk.h>
9 #include <linux/clk-provider.h>
15 #include "clk-factors.h"
18 * sun4i_a10_get_mod0_factors() - calculates m, n factors for MOD0-style clocks
29 if (req->rate > req->parent_rate) in sun4i_a10_get_mod0_factors()
30 req->rate = req->parent_rate; in sun4i_a10_get_mod0_factors()
32 div = DIV_ROUND_UP(req->parent_rate, req->rate); in sun4i_a10_get_mod0_factors()
45 req->rate = (req->parent_rate >> calcp) / calcm; in sun4i_a10_get_mod0_factors()
46 req->m = calcm - 1; in sun4i_a10_get_mod0_factors()
47 req->p = calcp; in sun4i_a10_get_mod0_factors()
75 * This happens with mod0 clk nodes instantiated through in sun4i_a10_mod0_setup()
85 CLK_OF_DECLARE_DRIVER(sun4i_a10_mod0, "allwinner,sun4i-a10-mod0-clk",
90 struct device_node *np = pdev->dev.of_node; in sun4i_a10_mod0_clk_probe()
95 return -ENODEV; in sun4i_a10_mod0_clk_probe()
98 reg = devm_ioremap_resource(&pdev->dev, r); in sun4i_a10_mod0_clk_probe()
108 { .compatible = "allwinner,sun4i-a10-mod0-clk" },
114 .name = "sun4i-a10-mod0-clk",
135 pr_err("Could not get registers for mod0-clk: %pOFn\n", in sun9i_a80_mod0_setup()
143 CLK_OF_DECLARE(sun9i_a80_mod0, "allwinner,sun9i-a80-mod0-clk", sun9i_a80_mod0_setup);
153 pr_err("Could not get registers for a13-mbus-clk\n"); in sun5i_a13_mbus_setup()
161 CLK_OF_DECLARE(sun5i_a13_mbus, "allwinner,sun5i-a13-mbus-clk", sun5i_a13_mbus_setup);
174 struct clk *mmc, *mmc_parent, *clk = hw->clk; in mmc_get_phase() local
175 struct mmc_phase *phase = to_mmc_phase(hw); in mmc_get_phase() local
181 value = readl(phase->reg); in mmc_get_phase()
182 delay = (value >> phase->offset) & 0x3; in mmc_get_phase()
188 mmc = clk_get_parent(clk); in mmc_get_phase()
190 return -EINVAL; in mmc_get_phase()
195 return -EINVAL; in mmc_get_phase()
200 return -EINVAL; in mmc_get_phase()
205 return -EINVAL; in mmc_get_phase()
216 struct clk *mmc, *mmc_parent, *clk = hw->clk; in mmc_set_phase() local
217 struct mmc_phase *phase = to_mmc_phase(hw); in mmc_set_phase() local
224 mmc = clk_get_parent(clk); in mmc_set_phase()
226 return -EINVAL; in mmc_set_phase()
231 return -EINVAL; in mmc_set_phase()
236 return -EINVAL; in mmc_set_phase()
241 return -EINVAL; in mmc_set_phase()
268 spin_lock_irqsave(phase->lock, flags); in mmc_set_phase()
269 value = readl(phase->reg); in mmc_set_phase()
270 value &= ~GENMASK(phase->offset + 3, phase->offset); in mmc_set_phase()
271 value |= delay << phase->offset; in mmc_set_phase()
272 writel(value, phase->reg); in mmc_set_phase()
273 spin_unlock_irqrestore(phase->lock, flags); in mmc_set_phase()
284 * sunxi_mmc_setup - Common setup function for mmc module clocks
288 * through struct factors_data. The phase clocks parts are identical.
309 clk_data->clks = kcalloc(3, sizeof(*clk_data->clks), GFP_KERNEL); in sunxi_mmc_setup()
310 if (!clk_data->clks) in sunxi_mmc_setup()
313 clk_data->clk_num = 3; in sunxi_mmc_setup()
314 clk_data->clks[0] = sunxi_factors_register(node, data, lock, reg); in sunxi_mmc_setup()
315 if (!clk_data->clks[0]) in sunxi_mmc_setup()
318 parent = __clk_get_name(clk_data->clks[0]); in sunxi_mmc_setup()
326 struct mmc_phase *phase; in sunxi_mmc_setup() local
328 phase = kmalloc(sizeof(*phase), GFP_KERNEL); in sunxi_mmc_setup()
329 if (!phase) in sunxi_mmc_setup()
332 phase->hw.init = &init; in sunxi_mmc_setup()
333 phase->reg = reg; in sunxi_mmc_setup()
334 phase->lock = lock; in sunxi_mmc_setup()
337 phase->offset = 8; in sunxi_mmc_setup()
339 phase->offset = 20; in sunxi_mmc_setup()
341 if (of_property_read_string_index(node, "clock-output-names", in sunxi_mmc_setup()
343 init.name = node->name; in sunxi_mmc_setup()
345 clk_data->clks[i] = clk_register(NULL, &phase->hw); in sunxi_mmc_setup()
346 if (IS_ERR(clk_data->clks[i])) { in sunxi_mmc_setup()
347 kfree(phase); in sunxi_mmc_setup()
357 kfree(clk_data->clks); in sunxi_mmc_setup()
368 CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup);
376 CLK_OF_DECLARE(sun9i_a80_mmc, "allwinner,sun9i-a80-mmc-clk", sun9i_a80_mmc_setup);