Skip to content

Commit bd4cee2

Browse files
morimotobroonie
authored andcommitted
ASoC: rsnd: enable clk_i approximate rate usage
Basically Renesas sound ADG is assuming that it has accurately divisible input clock. But sometimes / some board might not have it. The clk_i from CPG is used for such case. It can't calculate accurate division, but can be used as approximate rate. This patch enable clk_i for such case. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Adnan Ali <adnan.ali@bp.renesas.com> Tested-by: Vincenzo De Michele <vincenzo.michele@davinci.de> Tested-by: Patrick Keil <patrick.keil@conti-engineering.com> Link: https://lore.kernel.org/r/87msyizlfd.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 220adc0 commit bd4cee2

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

sound/soc/sh/rcar/adg.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ static int rsnd_adg_get_clkout(struct rsnd_priv *priv)
491491
unsigned long req_Hz[ADG_HZ_SIZE];
492492
int clkout_size;
493493
int i, req_size;
494+
int approximate = 0;
494495
const char *parent_clk_name = NULL;
495496
const char * const *clkout_name;
496497
int brg_table[] = {
@@ -537,13 +538,37 @@ static int rsnd_adg_get_clkout(struct rsnd_priv *priv)
537538
* rsnd_adg_ssi_clk_try_start()
538539
* rsnd_ssi_master_clk_start()
539540
*/
541+
542+
/*
543+
* [APPROXIMATE]
544+
*
545+
* clk_i (internal clock) can't create accurate rate, it will be approximate rate.
546+
*
547+
* <Note>
548+
*
549+
* clk_i needs x2 of required maximum rate.
550+
* see
551+
* - Minimum division of BRRA/BRRB
552+
* - rsnd_ssi_clk_query()
553+
*
554+
* Sample Settings for TDM 8ch, 32bit width
555+
*
556+
* 8(ch) x 32(bit) x 44100(Hz) x 2<Note> = 22579200
557+
* 8(ch) x 32(bit) x 48000(Hz) x 2<Note> = 24576000
558+
*
559+
* clock-frequency = <22579200 24576000>;
560+
*/
540561
for_each_rsnd_clkin(clk, adg, i) {
541562
rate = clk_get_rate(clk);
542563

543564
if (0 == rate) /* not used */
544565
continue;
545566

546567
/* BRGA */
568+
569+
if (i == CLKI)
570+
/* see [APPROXIMATE] */
571+
rate = (clk_get_rate(clk) / req_Hz[ADG_HZ_441]) * req_Hz[ADG_HZ_441];
547572
if (!adg->brg_rate[ADG_HZ_441] && (0 == rate % 44100)) {
548573
div = 6;
549574
if (req_Hz[ADG_HZ_441])
@@ -555,10 +580,16 @@ static int rsnd_adg_get_clkout(struct rsnd_priv *priv)
555580
ckr |= brg_table[i] << 20;
556581
if (req_Hz[ADG_HZ_441])
557582
parent_clk_name = __clk_get_name(clk);
583+
if (i == CLKI)
584+
approximate = 1;
558585
}
559586
}
560587

561588
/* BRGB */
589+
590+
if (i == CLKI)
591+
/* see [APPROXIMATE] */
592+
rate = (clk_get_rate(clk) / req_Hz[ADG_HZ_48]) * req_Hz[ADG_HZ_48];
562593
if (!adg->brg_rate[ADG_HZ_48] && (0 == rate % 48000)) {
563594
div = 6;
564595
if (req_Hz[ADG_HZ_48])
@@ -570,10 +601,15 @@ static int rsnd_adg_get_clkout(struct rsnd_priv *priv)
570601
ckr |= brg_table[i] << 16;
571602
if (req_Hz[ADG_HZ_48])
572603
parent_clk_name = __clk_get_name(clk);
604+
if (i == CLKI)
605+
approximate = 1;
573606
}
574607
}
575608
}
576609

610+
if (approximate)
611+
dev_info(dev, "It uses CLK_I as approximate rate");
612+
577613
clkout_name = clkout_name_gen2;
578614
clkout_size = ARRAY_SIZE(clkout_name_gen2);
579615
if (rsnd_is_gen4(priv))

0 commit comments

Comments
 (0)