Lines Matching +full:clkout +full:- +full:fmt

1 // SPDX-License-Identifier: GPL-2.0
3 // Helper routines for R-Car sound ADG.
6 #include <linux/clk-provider.h>
16 #define CLKOUT 0 macro
30 struct clk *clkout[CLKOUTMAX]; member
50 ((pos) = adg->clk[i]); \
55 ((pos) = adg->clkout[i]); \
57 #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)
73 for (i = 3; i >= 0; i--) { in rsnd_adg_calculate_rbgx()
76 return (u32)((i << 8) | ((div / ratio) - 1)); in rsnd_adg_calculate_rbgx()
119 adg->clk_rate[CLKA], /* 0000: CLKA */ in __rsnd_adg_get_timesel_ratio()
120 adg->clk_rate[CLKB], /* 0001: CLKB */ in __rsnd_adg_get_timesel_ratio()
121 adg->clk_rate[CLKC], /* 0010: CLKC */ in __rsnd_adg_get_timesel_ratio()
122 adg->rbga_rate_for_441khz, /* 0011: RBGA */ in __rsnd_adg_get_timesel_ratio()
123 adg->rbgb_rate_for_48khz, /* 0100: RBGB */ in __rsnd_adg_get_timesel_ratio()
138 diff = abs(target_rate - sel_rate[sel] / div); in __rsnd_adg_get_timesel_ratio()
189 if (runtime->rate != in_rate) { in rsnd_adg_get_timesel_ratio()
192 } else if (runtime->rate != out_rate) { in rsnd_adg_get_timesel_ratio()
307 if (rate == adg->clk_rate[i]) in rsnd_adg_clk_query()
313 if (rate == adg->rbga_rate_for_441khz) in rsnd_adg_clk_query()
316 if (rate == adg->rbgb_rate_for_48khz) in rsnd_adg_clk_query()
319 return -EIO; in rsnd_adg_clk_query()
352 rsnd_mod_bset(adg_mod, BRGCKR, 0x80770000, adg->ckr | ckr); in rsnd_adg_ssi_clk_try_start()
353 rsnd_mod_write(adg_mod, BRRA, adg->rbga); in rsnd_adg_ssi_clk_try_start()
354 rsnd_mod_write(adg_mod, BRRB, adg->rbgb); in rsnd_adg_ssi_clk_try_start()
356 dev_dbg(dev, "CLKOUT is based on BRG%c (= %dHz)\n", in rsnd_adg_ssi_clk_try_start()
358 (ckr) ? adg->rbgb_rate_for_48khz : in rsnd_adg_ssi_clk_try_start()
359 adg->rbga_rate_for_441khz); in rsnd_adg_ssi_clk_try_start()
379 adg->clk_rate[i] = clk_get_rate(clk); in rsnd_adg_clk_control()
404 struct rsnd_adg *adg = priv->adg; in rsnd_adg_null_clk_get()
406 if (!adg->null_clk) { in rsnd_adg_null_clk_get()
409 adg->null_clk = rsnd_adg_create_null_clk(priv, name, NULL); in rsnd_adg_null_clk_get()
412 return adg->null_clk; in rsnd_adg_null_clk_get()
417 struct rsnd_adg *adg = priv->adg; in rsnd_adg_null_clk_clean()
419 if (adg->null_clk) in rsnd_adg_null_clk_clean()
420 clk_unregister_fixed_rate(adg->null_clk); in rsnd_adg_null_clk_clean()
425 struct rsnd_adg *adg = priv->adg; in rsnd_adg_get_clkin()
438 adg->clk[i] = clk; in rsnd_adg_get_clkin()
448 return -EIO; in rsnd_adg_get_clkin()
453 struct rsnd_adg *adg = priv->adg; in rsnd_adg_unregister_clkout()
463 struct rsnd_adg *adg = priv->adg; in rsnd_adg_get_clkout()
466 struct device_node *np = dev->of_node; in rsnd_adg_get_clkout()
477 [CLKOUT] = "audio_clkout", in rsnd_adg_get_clkout()
497 prop = of_find_property(np, "clock-frequency", NULL); in rsnd_adg_get_clkout()
501 req_size = prop->length / sizeof(u32); in rsnd_adg_get_clkout()
503 dev_err(dev, "too many clock-frequency\n"); in rsnd_adg_get_clkout()
504 return -EINVAL; in rsnd_adg_get_clkout()
507 of_property_read_u32_array(np, "clock-frequency", req_rate, req_size); in rsnd_adg_get_clkout()
520 if (of_get_property(np, "clkout-lr-asynchronous", NULL)) in rsnd_adg_get_clkout()
527 * SSI itself can divide parent clock by 1/1 - 1/16 in rsnd_adg_get_clkout()
532 adg->rbga_rate_for_441khz = 0; in rsnd_adg_get_clkout()
533 adg->rbgb_rate_for_48khz = 0; in rsnd_adg_get_clkout()
541 if (!adg->rbga_rate_for_441khz && (0 == rate % 44100)) { in rsnd_adg_get_clkout()
548 adg->rbga_rate_for_441khz = rate / div; in rsnd_adg_get_clkout()
557 if (!adg->rbgb_rate_for_48khz && (0 == rate % 48000)) { in rsnd_adg_get_clkout()
564 adg->rbgb_rate_for_48khz = rate / div; in rsnd_adg_get_clkout()
578 of_property_read_u32(np, "#clock-cells", &count); in rsnd_adg_get_clkout()
580 * for clkout in rsnd_adg_get_clkout()
583 clk = clk_register_fixed_rate(dev, clkout_name[CLKOUT], in rsnd_adg_get_clkout()
588 adg->clkout[CLKOUT] = clk; in rsnd_adg_get_clkout()
602 adg->clkout[i] = clk; in rsnd_adg_get_clkout()
604 adg->onecell.clks = adg->clkout; in rsnd_adg_get_clkout()
605 adg->onecell.clk_num = CLKOUTMAX; in rsnd_adg_get_clkout()
607 &adg->onecell); in rsnd_adg_get_clkout()
611 adg->ckr = ckr; in rsnd_adg_get_clkout()
612 adg->rbga = rbga; in rsnd_adg_get_clkout()
613 adg->rbgb = rbgb; in rsnd_adg_get_clkout()
622 return -EIO; in rsnd_adg_get_clkout()
628 const char *fmt, ...) in dbg_msg() argument
633 va_start(args, fmt); in dbg_msg()
634 vsnprintf(msg, sizeof(msg), fmt, args); in dbg_msg()
655 adg->ckr, adg->rbga, adg->rbgb); in rsnd_adg_clk_dbg_info()
656 dbg_msg(dev, m, "BRGA (for 44100 base) = %d\n", adg->rbga_rate_for_441khz); in rsnd_adg_clk_dbg_info()
657 dbg_msg(dev, m, "BRGB (for 48000 base) = %d\n", adg->rbgb_rate_for_48khz); in rsnd_adg_clk_dbg_info()
660 * Actual CLKOUT will be exchanged in rsnd_adg_ssi_clk_try_start() in rsnd_adg_clk_dbg_info()
664 dbg_msg(dev, m, "clkout %d : %pa : %ld\n", i, in rsnd_adg_clk_dbg_info()
679 return -ENOMEM; in rsnd_adg_probe()
681 ret = rsnd_mod_init(priv, &adg->mod, &adg_ops, in rsnd_adg_probe()
686 priv->adg = adg; in rsnd_adg_probe()
705 struct device_node *np = dev->of_node; in rsnd_adg_remove()