Lines Matching full:adg
3 // Helper routines for R-Car sound ADG.
25 .name = "adg",
47 #define for_each_rsnd_clk(pos, adg, i) \ argument
50 ((pos) = adg->clk[i]); \
52 #define for_each_rsnd_clkout(pos, adg, i) \ argument
55 ((pos) = adg->clkout[i]); \
57 #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)
113 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in __rsnd_adg_get_timesel_ratio() local
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()
214 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_set_cmd_timsel_gen2() local
215 struct rsnd_mod *adg_mod = rsnd_mod_get(adg); in rsnd_adg_set_cmd_timsel_gen2()
239 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_set_src_timesel_gen2() local
240 struct rsnd_mod *adg_mod = rsnd_mod_get(adg); in rsnd_adg_set_src_timesel_gen2()
268 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_set_ssi_clk() local
269 struct rsnd_mod *adg_mod = rsnd_mod_get(adg); in rsnd_adg_set_ssi_clk()
280 * SSI 8 is not connected to ADG. in rsnd_adg_set_ssi_clk()
293 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_clk_query() local
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()
332 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_ssi_clk_try_start() local
334 struct rsnd_mod *adg_mod = rsnd_mod_get(adg); in rsnd_adg_ssi_clk_try_start()
344 if (rsnd_flags_has(adg, LRCLK_ASYNC)) { in rsnd_adg_ssi_clk_try_start()
345 if (rsnd_flags_has(adg, AUDIO_OUT_48)) in rsnd_adg_ssi_clk_try_start()
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()
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()
366 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_clk_control() local
370 for_each_rsnd_clk(clk, adg, i) { in rsnd_adg_clk_control()
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() local
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() local
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() local
438 adg->clk[i] = clk; in rsnd_adg_get_clkin()
444 dev_err(dev, "adg clock IN get failed\n"); in rsnd_adg_get_clkin()
453 struct rsnd_adg *adg = priv->adg; in rsnd_adg_unregister_clkout() local
457 for_each_rsnd_clkout(clk, adg, i) in rsnd_adg_unregister_clkout()
463 struct rsnd_adg *adg = priv->adg; in rsnd_adg_get_clkout() local
494 * ADG supports BRRA/BRRB output only in rsnd_adg_get_clkout()
518 rsnd_flags_set(adg, AUDIO_OUT_48); in rsnd_adg_get_clkout()
521 rsnd_flags_set(adg, LRCLK_ASYNC); 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()
534 for_each_rsnd_clk(clk, adg, i) { 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()
551 !rsnd_flags_has(adg, AUDIO_OUT_48)) 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()
567 rsnd_flags_has(adg, AUDIO_OUT_48)) in rsnd_adg_get_clkout()
574 * ADG supports BRRA/BRRB output only. 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()
618 dev_err(dev, "adg clock OUT get failed\n"); in rsnd_adg_get_clkout()
645 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); in rsnd_adg_clk_dbg_info() local
650 for_each_rsnd_clk(clk, adg, i) in rsnd_adg_clk_dbg_info()
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()
663 for_each_rsnd_clkout(clk, adg, i) in rsnd_adg_clk_dbg_info()
673 struct rsnd_adg *adg; in rsnd_adg_probe() local
677 adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL); in rsnd_adg_probe()
678 if (!adg) 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()