From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: zhaoming.zeng@freescale.com
Cc: alsa-devel@alsa-project.org, s.hauer@pengutronix.de,
timur.tabi@gmail.com, zengzm.kernel@gmail.com,
xiao-lizhang@freescale.com, linuxzsc@gmail.com,
arnaud.patard@rtp-net.org, lrg@slimlogic.co.uk
Subject: Re: [PATCH v5] ASoC: Add Freescale SGTL5000 codec support
Date: Fri, 25 Feb 2011 12:09:06 +0000 [thread overview]
Message-ID: <20110225120906.GE28980@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1298484501-3993-1-git-send-email-zhaoming.zeng@freescale.com>
On Thu, Feb 24, 2011 at 02:08:21AM +0800, zhaoming.zeng@freescale.com wrote:
This is mostly good, there's a few issues around the regulator usage
though. I've applied the patch but please send incremental patches to
fix the issues below and also the issue Liam raised with the controls.
> + .constraints = {
> + .min_uV = 850000,
> + .max_uV = 1600000,
> + .valid_modes_mask = REGULATOR_MODE_NORMAL,
> + .valid_ops_mask = REGULATOR_CHANGE_STATUS,
> + },
This regulator supports a range of voltages but does not support
changing the voltage.
> + /* set regulator value firstly */
> + reg = (1600 - ldo->voltage / 1000) / 50;
> + reg = clamp(reg, 0x0, 0xf);
> +
> + /* amend the voltage value, unit: uV */
> + ldo->voltage = (1600 - reg * 50) * 1000;
> +
> + /* set voltage to register */
> + snd_soc_update_bits(codec, SGTL5000_CHIP_LINREG_CTRL,
> + (0x1 << 4) - 1, reg);
This looks like it should be in a regulator set_voltage() operation not
here:
> +
> + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
> + SGTL5000_LINEREG_D_POWERUP,
> + SGTL5000_LINEREG_D_POWERUP);
You have a separate enable bit which is probably the only thing you need
to deal with here. If the hardware needs this better to explain why.
> + vdda = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer);
> + vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer);
> + vddd = regulator_get_voltage(sgtl5000->supplies[VDDD].consumer);
> +
> + vdda = vdda / 1000;
> + vddio = vddio / 1000;
> + vddd = vddd / 1000;
> +
> + if (vdda <= 0 || vddio <= 0 || vddd < 0) {
> + dev_err(codec->dev, "regulator voltage not set correctly\n");
> +
> + return -EINVAL;
> + }
This is going to fail on systems without voltage readback capabilities,
including systems which have the regulator API disabled and stubbed out.
> + /*
> + * copy DAP default values to default value array.
> + * sgtl5000 register space has a big hole, merge it
> + * at init phase makes life easy.
> + * FIXME: should we drop 'const' of sgtl5000_regs?
> + */
> + memcpy((void *)(&sgtl5000_regs[0] + (SGTL5000_DAP_REG_OFFSET >> 1)),
> + sgtl5000_dap_regs,
> + SGTL5000_MAX_REG_OFFSET - SGTL5000_DAP_REG_OFFSET);
As has been pointed out on previous revisions of the patch there is no
need to cast away from void in C and it can be actively harmful.
next prev parent reply other threads:[~2011-02-25 12:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-23 18:08 [PATCH v5] ASoC: Add Freescale SGTL5000 codec support zhaoming.zeng
2011-02-25 9:13 ` Liam Girdwood
2011-02-25 12:09 ` Mark Brown [this message]
[not found] ` <AANLkTikpBB5vVKj+Y2EfbjfC=6aigeCjaqZ9mz9+qWuF@mail.gmail.com>
2011-02-25 16:13 ` Timur Tabi
2011-02-25 23:01 ` Timur Tabi
2011-02-28 14:45 ` Mark Brown
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=20110225120906.GE28980@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.patard@rtp-net.org \
--cc=linuxzsc@gmail.com \
--cc=lrg@slimlogic.co.uk \
--cc=s.hauer@pengutronix.de \
--cc=timur.tabi@gmail.com \
--cc=xiao-lizhang@freescale.com \
--cc=zengzm.kernel@gmail.com \
--cc=zhaoming.zeng@freescale.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;
as well as URLs for NNTP newsgroup(s).