From: Brian Austin <brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Brian Austin
<brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Subject: Re: [PATCH 1/2] ASoC: Add support for CS35L32 Boosted Amplifier
Date: Thu, 31 Jul 2014 15:27:13 -0500 [thread overview]
Message-ID: <alpine.DEB.2.02.1407311520490.7394@heelrod> (raw)
In-Reply-To: <20140731200729.GW17528-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
On Thu, 31 Jul 2014, Mark Brown wrote:
> On Tue, Jul 29, 2014 at 03:02:42PM -0500, Brian Austin wrote:
>
> > + case CS35L32_LED_STATUS:
> > + case CS35L32_FLASH_MODE:
> > + case CS35L32_MOVIE_MODE:
> > + case CS35L32_FLASH_TIMER:
> > + case CS35L32_FLASH_INHIBIT:
>
> Should this be an MFD? Can always be refactored later if required
> though.
Well.... It _might_ turn into one at a later time but since it really
just ships as an AMP I haven't had the time to do the LED part yet.
>
> > +static bool cs35l32_volatile_register(struct device *dev, unsigned int reg)
> > +{
> > + switch (reg) {
> > + case CS35L32_DEVID_AB:
> > + case CS35L32_DEVID_CD:
> > + case CS35L32_DEVID_E:
> > + case CS35L32_FAB_ID:
> > + case CS35L32_REV_ID:
> > + return 1;
> > + default:
> > + return 0;
> > + }
> > +}
>
> Should the interrupt and LED status registers not also be volatile?
Sure. I guess precious doesn't have any effect on cache then?
>
> > +static const struct snd_kcontrol_new cs35l32_snd_controls[] = {
> > + SOC_SINGLE_TLV("SPK Amp Volume", CS35L32_CLASSD_CTL,
> > + 3, 0x04, 1, classd_ctl_tlv),
>
> Speaker Volume.
>
> > + SOC_SINGLE("Gain Zero Cross", CS35L32_CLASSD_CTL, 2, 1, 0),
>
> Zero Cross Switch perhaps (if it's an on/off control it should be called
> Switch)?
>
> > +static int int_clear(struct snd_soc_dapm_widget *w,
> > + struct snd_kcontrol *kcontrol, int event)
> > +{
> > + struct snd_soc_codec *codec = w->codec;
> > +
> > + if (SND_SOC_DAPM_EVENT_ON(event)) {
> > + snd_soc_read(codec, CS35L32_INT_STATUS_1);
> > + snd_soc_read(codec, CS35L32_INT_STATUS_2);
> > + } else {
> > + return 0;
> > + }
> > + return 0;
> > +}
>
> This seems... icky. Shouldn't there be an interrupt handler doing
> this?
>
Yeah, I'm gonna scrap this whole thing...
> > +static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec,
> > + int clk_id, int source, unsigned int freq, int dir)
> > +{
> > +
> > + switch (freq) {
>
> > + case CS35L32_MCLK_6144MHZ:
>
> Not sure these defines add anything over just using the numbers and it
> avoids ickyness with the fact that I bet this isn't really 6.144GHz.
>
I was trying to avoid using numbers, but if it is OK I can do that.
> > +static int cs35l32_probe(struct snd_soc_codec *codec)
> > +{
> > + /* Power down the AMP */
> > + snd_soc_update_bits(codec, CS35L32_PWRCTL1, CS35L32_PDN_AMP,
> > + CS35L32_PDN_AMP);
> > +
> > + /* Clear MCLK Error Bit since we don't have the clock yet */
> > + snd_soc_read(codec, CS35L32_INT_STATUS_1);
> > +
> > + return 0;
> > +}
>
> Any reason not to do these in the device level probe()?
Nope
>
> > +static int cs35l32_remove(struct snd_soc_codec *codec)
> > +{
> > + struct cs35l32_private *cs35l32 = snd_soc_codec_get_drvdata(codec);
> > +
> > + regulator_bulk_free(ARRAY_SIZE(cs35l32->supplies), cs35l32->supplies);
> > + return 0;
> > +}
>
> The regulators should be being acquired and released in the device level
> probe(), though this could be dropped entirely with devm.
>
OK.
> > + ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch,
> > + ARRAY_SIZE(cs35l32_monitor_patch));
>
> Should either pay attention to the return value or not assign ret
> (better to pay attention but it's not like it'd be the first CODEC to
> ignore it).
>
I should bail out here if this fails.
> > + /* initialize codec */
> > + ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, ®);
> > + devid = (reg & 0xFF) << 12;
> > +
> > + ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_CD, ®);
> > + devid |= (reg & 0xFF) << 4;
> > +
> > + ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_E, ®);
> > + devid |= (reg & 0xF0) >> 4;
> > +
> > + if (devid != CS35L32_CHIP_ID) {
> > + ret = -ENODEV;
> > + dev_err(&i2c_client->dev,
> > + "CS35L32 Device ID (%X). Expected %X\n",
> > + devid, CS35L32_CHIP_ID);
> > + return ret;
> > + }
>
> Should the ID check not be done before we register the patch in case
> it's the wrong device and we do something bad to it by writing to it?
>
Yeah, that's a good idea.
Thanks Mark
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-07-31 20:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 20:02 [PATCH 1/2] ASoC: Add support for CS35L32 Boosted Amplifier Brian Austin
[not found] ` <1406664163-10506-1-git-send-email-brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
2014-07-29 20:02 ` [PATCH 2/2] Documentation: dt: bindings: sound: Add bindings file for CS35L32 Brian Austin
[not found] ` <1406664163-10506-2-git-send-email-brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
2014-07-31 20:21 ` Mark Brown
[not found] ` <20140731202149.GX17528-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-07-31 20:40 ` Brian Austin
2014-07-31 21:18 ` Mark Brown
[not found] ` <20140731211828.GA17528-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-07-31 21:28 ` Brian Austin
2014-07-31 20:07 ` [PATCH 1/2] ASoC: Add support for CS35L32 Boosted Amplifier Mark Brown
[not found] ` <20140731200729.GW17528-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-07-31 20:27 ` Brian Austin [this message]
2014-07-31 20:27 ` Mark Brown
2014-07-30 21:02 ` Dinh Nguyen
2014-07-31 14:37 ` Brian Austin
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=alpine.DEB.2.02.1407311520490.7394@heelrod \
--to=brian.austin-jgc1dhjmkg3qt0dzr+alfa@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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