Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: <Codrin.Ciubotariu@microchip.com>
To: tzungbi@google.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	lars@metafoo.de, tiwai@suse.com, lgirdwood@gmail.com,
	broonie@kernel.org
Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: codecs: ad193x: Group register initialization at probe
Date: Wed, 3 Jul 2019 16:52:35 +0000	[thread overview]
Message-ID: <e9e653d1-6360-ffaf-6b47-eb33c0d867df@microchip.com> (raw)
In-Reply-To: <CA+Px+wXBBgeWbjZ5uQmwJgn+d=ZE-N0aehitog7==ak3GDxMsQ@mail.gmail.com>

On 03.07.2019 10:39, Tzung-Bi Shih wrote:
> On Thu, Jun 27, 2019 at 8:05 PM Codrin Ciubotariu
> <codrin.ciubotariu@microchip.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

      reply	other threads:[~2019-07-03 16:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27 12:02 [PATCH 1/2] ASoC: codecs: ad193x: Group register initialization at probe Codrin Ciubotariu
2019-06-27 12:02 ` [PATCH 2/2] ASoC: codecs: ad193x: Reset used registers " Codrin Ciubotariu
2019-06-28 16:56   ` Applied "ASoC: codecs: ad193x: Reset used registers at probe" to the asoc tree Mark Brown
2019-06-28 16:56 ` Applied "ASoC: codecs: ad193x: Group register initialization " Mark Brown
2019-07-03  7:39 ` [alsa-devel] [PATCH 1/2] ASoC: codecs: ad193x: Group register initialization at probe Tzung-Bi Shih
2019-07-03 16:52   ` Codrin.Ciubotariu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9e653d1-6360-ffaf-6b47-eb33c0d867df@microchip.com \
    --to=codrin.ciubotariu@microchip.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=tzungbi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox