[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e9e653d1-6360-ffaf-6b47-eb33c0d867df@microchip.com>
Date: Wed, 3 Jul 2019 16:52:35 +0000
From: <Codrin.Ciubotariu@...rochip.com>
To: <tzungbi@...gle.com>
CC: <alsa-devel@...a-project.org>, <linux-kernel@...r.kernel.org>,
<lars@...afoo.de>, <tiwai@...e.com>, <lgirdwood@...il.com>,
<broonie@...nel.org>
Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: codecs: ad193x: Group register
initialization at probe
On 03.07.2019 10:39, Tzung-Bi Shih wrote:
> On Thu, Jun 27, 2019 at 8:05 PM Codrin Ciubotariu
> <codrin.ciubotariu@...rochip.com> wrote:
>> +struct ad193x_reg_default {
>> + unsigned int reg;
>> + unsigned int val;
>> +};
> You probably don't need to define this. There is a struct
> reg_sequence in regmap.h.
>
>> +
>> +/* codec register values to set after reset */
>> +static void ad193x_reg_default_init(struct ad193x_priv *ad193x)
>> +{
>> + const struct ad193x_reg_default reg_init[] = {
>> + { 0, 0x99 }, /* PLL_CLK_CTRL0: pll input: mclki/xi 12.288Mhz */
>> + { 1, 0x04 }, /* PLL_CLK_CTRL1: no on-chip Vref */
>> + { 2, 0x40 }, /* DAC_CTRL0: TDM mode */
>> + { 4, 0x1A }, /* DAC_CTRL2: 48kHz de-emphasis, unmute dac */
>> + { 5, 0x00 }, /* DAC_CHNL_MUTE: unmute DAC channels */
>> + };
>> + const struct ad193x_reg_default reg_adc_init[] = {
>> + { 14, 0x03 }, /* ADC_CTRL0: high-pass filter enable */
>> + { 15, 0x43 }, /* ADC_CTRL1: sata delay=1, adc aux mode */
>> + };
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(reg_init); i++)
>> + regmap_write(ad193x->regmap, reg_init[i].reg, reg_init[i].val);
>> +
>> + if (ad193x_has_adc(ad193x)) {
>> + for (i = 0; i < ARRAY_SIZE(reg_adc_init); i++) {
>> + regmap_write(ad193x->regmap, reg_adc_init[i].reg,
>> + reg_adc_init[i].val);
>> + }
>> + }
> And you could use regmap_multi_reg_write( ) to substitute the two for-loops.
>
> See https://mailman.alsa-project.org/pipermail/alsa-devel/2019-June/151090.html
> as an example. It also has some reg initializations in component
> probe( ).
>
Your solution is certainly more elegant. I will make a patch and switch
to regmap_multi_reg_write().
Thank you for your review.
Best regards,
Codrin
Powered by blists - more mailing lists