• Home
  • Raw
  • Download

Lines Matching +full:data +full:- +full:clock +full:- +full:ratio

1 // SPDX-License-Identifier: GPL-2.0
3 * CS2000 -- CIRRUS LOGIC Fractional-N Clock Synthesizer & Clock Multiplier
8 #include <linux/clk-provider.h>
24 #define Ratio_Val(x, nth) ((x >> (24 - (8 * nth))) & 0xFF)
25 #define Val_Ratio(x, nth) ((x & 0xFF) << (24 - (8 * nth)))
67 #define priv_to_client(priv) (priv->client)
68 #define priv_to_dev(priv) (&(priv_to_client(priv)->dev))
86 { .compatible = "cirrus,cs2000-cp", },
92 { "cs2000-cp", },
104 s32 data; in cs2000_bset() local
106 data = cs2000_read(priv, addr); in cs2000_bset()
107 if (data < 0) in cs2000_bset()
108 return data; in cs2000_bset()
110 data &= ~mask; in cs2000_bset()
111 data |= (val & mask); in cs2000_bset()
113 return cs2000_write(priv, addr, data); in cs2000_bset()
135 /* FIXME: for Static ratio mode */ in cs2000_enable_dev_config()
156 return -EINVAL; in cs2000_clk_in_bound_rate()
180 return -ETIMEDOUT; in cs2000_wait_pll_lock()
194 u64 ratio; in cs2000_rate_to_ratio() local
197 * ratio = rate_out / rate_in * 2^20 in cs2000_rate_to_ratio()
202 ratio = (u64)rate_out << 20; in cs2000_rate_to_ratio()
203 do_div(ratio, rate_in); in cs2000_rate_to_ratio()
205 return ratio; in cs2000_rate_to_ratio()
208 static unsigned long cs2000_ratio_to_rate(u32 ratio, u32 rate_in) in cs2000_ratio_to_rate() argument
213 * ratio = rate_out / rate_in * 2^20 in cs2000_ratio_to_rate()
219 rate_out = (u64)ratio * rate_in; in cs2000_ratio_to_rate()
231 return -EINVAL; in cs2000_ratio_set()
268 return -EINVAL; in cs2000_ratio_select()
273 * this driver supports static ratio mode only at this point. in cs2000_ratio_select()
293 u32 ratio; in cs2000_recalc_rate() local
295 ratio = cs2000_ratio_get(priv, ch); in cs2000_recalc_rate()
297 return cs2000_ratio_to_rate(ratio, parent_rate); in cs2000_recalc_rate()
303 u32 ratio; in cs2000_round_rate() local
305 ratio = cs2000_rate_to_ratio(*parent_rate, rate); in cs2000_round_rate()
307 return cs2000_ratio_to_rate(ratio, *parent_rate); in cs2000_round_rate()
328 priv->saved_rate = rate; in __cs2000_set_rate()
329 priv->saved_parent_rate = parent_rate; in __cs2000_set_rate()
348 priv->saved_rate, in cs2000_set_saved_rate()
349 priv->saved_parent_rate); in cs2000_set_saved_rate()
404 return -EPROBE_DEFER; in cs2000_clk_get()
409 return -EPROBE_DEFER; in cs2000_clk_get()
411 priv->clk_in = clk_in; in cs2000_clk_get()
412 priv->ref_clk = ref_clk; in cs2000_clk_get()
420 struct device_node *np = dev->of_node; in cs2000_clk_register()
422 const char *name = np->name; in cs2000_clk_register()
428 of_property_read_string(np, "clock-output-names", &name); in cs2000_clk_register()
432 * otherwise .set_rate which setup ratio in cs2000_clk_register()
435 rate = clk_get_rate(priv->ref_clk); in cs2000_clk_register()
440 parent_names[CLK_IN] = __clk_get_name(priv->clk_in); in cs2000_clk_register()
441 parent_names[REF_CLK] = __clk_get_name(priv->ref_clk); in cs2000_clk_register()
449 priv->hw.init = &init; in cs2000_clk_register()
451 ret = clk_hw_register(dev, &priv->hw); in cs2000_clk_register()
455 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &priv->hw); in cs2000_clk_register()
457 clk_hw_unregister(&priv->hw); in cs2000_clk_register()
476 return -EIO; in cs2000_version_print()
486 return -EIO; in cs2000_version_print()
489 dev_info(dev, "revision - %s\n", revision); in cs2000_version_print()
498 struct device_node *np = dev->of_node; in cs2000_remove()
502 clk_hw_unregister(&priv->hw); in cs2000_remove()
511 struct device *dev = &client->dev; in cs2000_probe()
516 return -ENOMEM; in cs2000_probe()
518 priv->client = client; in cs2000_probe()
554 .name = "cs2000-cp",
565 MODULE_DESCRIPTION("CS2000-CP driver");