[alsa-devel] [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
Instead of checking the SGTL5000 chip revision, we should only check if the VDDD regulator exists and only call sgtl5000_replace_vddd_with_ldo if the regulator is missing. Otherwise, the user reads in the kernel log that the internal LDO is used, even though he did follow the NXP recommendation to use external VDDD and also specified VDDD-supply in the devicetree.
Also remove the comment, which incorrectly states that external VDDD is only supported for SGTL5000 chip revisions < 0x11. Official NXP documentation recommends using external VDDD and not the internal LDO due to the SGTL5000 erratum ER1. This also applies to revisions >= 0x11.
Tested on an i.MX6Q board with SGTL5000 rev 0x11 and external VDDD.
Signed-off-by: Clemens Gruber clemens.gruber@pqgruber.com --- sound/soc/codecs/sgtl5000.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 08b4046..fbad4fb 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1286,17 +1286,14 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) for (i = 0; i < ARRAY_SIZE(sgtl5000->supplies); i++) sgtl5000->supplies[i].supply = supply_names[i];
- /* External VDDD only works before revision 0x11 */ - if (sgtl5000->revision < 0x11) { - vddd = regulator_get_optional(codec->dev, "VDDD"); - if (IS_ERR(vddd)) { - /* See if it's just not registered yet */ - if (PTR_ERR(vddd) == -EPROBE_DEFER) - return -EPROBE_DEFER; - } else { - external_vddd = 1; - regulator_put(vddd); - } + vddd = regulator_get_optional(codec->dev, "VDDD"); + if (IS_ERR(vddd)) { + /* See if it's just not registered yet */ + if (PTR_ERR(vddd) == -EPROBE_DEFER) + return -EPROBE_DEFER; + } else { + external_vddd = 1; + regulator_put(vddd); }
if (!external_vddd) {
Hi Clemens,
On Thu, Jun 2, 2016 at 9:47 AM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
Instead of checking the SGTL5000 chip revision, we should only check if the VDDD regulator exists and only call sgtl5000_replace_vddd_with_ldo if the regulator is missing. Otherwise, the user reads in the kernel log that the internal LDO is used, even though he did follow the NXP recommendation to use external VDDD and also specified VDDD-supply in the devicetree.
Also remove the comment, which incorrectly states that external VDDD is only supported for SGTL5000 chip revisions < 0x11. Official NXP documentation recommends using external VDDD and not the internal LDO due to the SGTL5000 erratum ER1. This also applies to revisions >= 0x11.
Tested on an i.MX6Q board with SGTL5000 rev 0x11 and external VDDD.
Patch looks good to me.
Eric,
Sometime ago you were looking at this. What do you think about this patch?
Thanks
On Thu, Jun 02, 2016 at 12:48:15PM -0300, Fabio Estevam wrote:
Sometime ago you were looking at this. What do you think about this patch?
I'm rather concerned that the patches came from people working closely with Freescale already - are we *sure* that Freescale/NXP's public errata are accurate?
On Thu, Jun 02, 2016 at 05:56:51PM +0100, Mark Brown wrote:
On Thu, Jun 02, 2016 at 12:48:15PM -0300, Fabio Estevam wrote:
Sometime ago you were looking at this. What do you think about this patch?
I'm rather concerned that the patches came from people working closely with Freescale already - are we *sure* that Freescale/NXP's public errata are accurate?
This was confirmed by Freescale/NXP employees, the errata and the datasheet. First in the errata from 2012 and also in the second revision of the errata in 2013 and the latest datasheet from 2013. http://cache.freescale.com/files/analog/doc/errata/SGTL5000ER.pdf https://community.nxp.com/thread/352718#comment-506518 The latest datasheet from 2013 states: "An external VDDD is required for new designs"
So, the SGTL5000 rev 0x11 obviously can be used with external VDDD, this is what Freescale is recommending since 2012 and what people are doing.
The revision check was introduced in the first commit in 2011, so this was probably a mistake and was never corrected because it still works, but it shows a misleading message at boot and enables the internal LDO, which is not used. It's also confusing for everyone who reads the code.
Checking if there is a VDDD-supply regulator should be sufficient.
Thanks, Clemens
Hi Fabio,
On 06/02/2016 05:48 PM, Fabio Estevam wrote:
Hi Clemens,
On Thu, Jun 2, 2016 at 9:47 AM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
Instead of checking the SGTL5000 chip revision, we should only check if the VDDD regulator exists and only call sgtl5000_replace_vddd_with_ldo if the regulator is missing. Otherwise, the user reads in the kernel log that the internal LDO is used, even though he did follow the NXP recommendation to use external VDDD and also specified VDDD-supply in the devicetree.
Also remove the comment, which incorrectly states that external VDDD is only supported for SGTL5000 chip revisions < 0x11. Official NXP documentation recommends using external VDDD and not the internal LDO due to the SGTL5000 erratum ER1. This also applies to revisions >= 0x11.
Tested on an i.MX6Q board with SGTL5000 rev 0x11 and external VDDD.
Patch looks good to me.
Eric,
Sometime ago you were looking at this. What do you think about this patch?
Sorry. I'm traveling and haven't had a chance to review this, but it's on my to-do.
Hi Fabio and Clemens,
On 06/03/2016 06:23 PM, Eric Nelson wrote:
Hi Fabio,
On 06/02/2016 05:48 PM, Fabio Estevam wrote:
Hi Clemens,
On Thu, Jun 2, 2016 at 9:47 AM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
Instead of checking the SGTL5000 chip revision, we should only check if the VDDD regulator exists and only call sgtl5000_replace_vddd_with_ldo if the regulator is missing. Otherwise, the user reads in the kernel log that the internal LDO is used, even though he did follow the NXP recommendation to use external VDDD and also specified VDDD-supply in the devicetree.
Also remove the comment, which incorrectly states that external VDDD is only supported for SGTL5000 chip revisions < 0x11. Official NXP documentation recommends using external VDDD and not the internal LDO due to the SGTL5000 erratum ER1. This also applies to revisions >= 0x11.
Tested on an i.MX6Q board with SGTL5000 rev 0x11 and external VDDD.
Patch looks good to me.
Eric,
Sometime ago you were looking at this. What do you think about this patch?
Sorry. I'm traveling and haven't had a chance to review this, but it's on my to-do.
AFAIK, the SGTL5000 versions < 0x11 are like Sasquatch: I've seen no real proof of their existence. I tried to chase down when this code was introduced, but it seems to have been around since the dawn of the driver.
Clemens, if you're really trying to control an external regulator, I think you'll need lots more than this patch. There are some fundamental flaws in regulator handling and I put together some RFC patches to address them in February 2015: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/thread.ht...
The long and short of it is that at least one of the regulators would need to be initialized before the SGTL5000 probes.
Regards,
Eric
Hi Eric,
On Sat, Jun 04, 2016 at 07:18:28AM +0200, Eric Nelson wrote:
AFAIK, the SGTL5000 versions < 0x11 are like Sasquatch: I've seen no real proof of their existence. I tried to chase down when this code was introduced, but it seems to have been around since the dawn of the driver.
Clemens, if you're really trying to control an external regulator, I think you'll need lots more than this patch. There are some fundamental flaws in regulator handling and I put together some RFC patches to address them in February 2015: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/thread.ht...
The long and short of it is that at least one of the regulators would need to be initialized before the SGTL5000 probes.
Thank you very much for your input on this. So we can assume that no user of the sgtl5000 is controlling an external VDDD regulator, because this does not work without your patch series from Februar 2015.
As far as not enabling the internal LDO when using external VDDD and avoiding the misleading "Using internal LDO..." message at boot, do you think my patch would be OK?
Regards, Clemens
Hi Mark, Hi Fabio,
please don't merge the patch yet, I just observed a strange effect when resetting the board during playback / just after playback stops. At next boot time, sometimes the following error occurs: imx-sgtl5000 sound: ASoc: CODEC DAI sgtl5000 not registered imx-sgtl5000 sound: snd_soc_register_card failed (-517)
I'll have to investigate further and will report back. Until then, please hold off with the patch. I might have overlooked something.
Regards, Clemens
Hi Eric, Fabio, Mark,
On Sat, Jun 04, 2016 at 07:15:25PM +0200, Clemens Gruber wrote:
please don't merge the patch yet, I just observed a strange effect when resetting the board during playback / just after playback stops. At next boot time, sometimes the following error occurs: imx-sgtl5000 sound: ASoc: CODEC DAI sgtl5000 not registered imx-sgtl5000 sound: snd_soc_register_card failed (-517)
I looked into this today and discovered the following:
With my patch applied, if I reset the board just after playback, at the next boot, the sgtl5000_fill_defaults function does not succeed: Writing the default value 0x7060 to register 0x30 (CHIP_ANA_POWER) fails.
How did CHIP_ANA_POWER change with my patch: Before, only LINREG_SIMPLE_POWERUP was cleared as is recommended in the datasheet when using the internal LDO, now both LINREG_SIMPLE_POWERUP and STARTUP_POWERUP are cleared, as is recommended when using external VDDD.
But why does the SGTL5000 nack that default write to CHIP_ANA_POWER after a reboot, which interrupted the playback?
The following patch from Eric solved the problem; one write fails but it continues setting the other registers and thus even if resetting a board during playback, the sound still works after reboot: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088356.ht... Another workaround might be to not even write a default value to CHIP_ANA_POWER, as in this patch from Eric: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088355.ht...
What do you think we should do?
Regards, Clemens
Hi Clemens,
On Sun, Jun 5, 2016 at 8:16 PM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
I looked into this today and discovered the following:
With my patch applied, if I reset the board just after playback, at the next boot, the sgtl5000_fill_defaults function does not succeed: Writing the default value 0x7060 to register 0x30 (CHIP_ANA_POWER) fails.
How did CHIP_ANA_POWER change with my patch: Before, only LINREG_SIMPLE_POWERUP was cleared as is recommended in the datasheet when using the internal LDO, now both LINREG_SIMPLE_POWERUP and STARTUP_POWERUP are cleared, as is recommended when using external VDDD.
But why does the SGTL5000 nack that default write to CHIP_ANA_POWER after a reboot, which interrupted the playback?
The following patch from Eric solved the problem; one write fails but it continues setting the other registers and thus even if resetting a board during playback, the sound still works after reboot: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088356.ht... Another workaround might be to not even write a default value to CHIP_ANA_POWER, as in this patch from Eric: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088355.ht...
What do you think we should do?
Shouldn't both patches be applied?
Hi Fabio,
On Sun, Jun 05, 2016 at 10:22:55PM -0300, Fabio Estevam wrote:
Hi Clemens,
On Sun, Jun 5, 2016 at 8:16 PM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
I looked into this today and discovered the following:
With my patch applied, if I reset the board just after playback, at the next boot, the sgtl5000_fill_defaults function does not succeed: Writing the default value 0x7060 to register 0x30 (CHIP_ANA_POWER) fails.
How did CHIP_ANA_POWER change with my patch: Before, only LINREG_SIMPLE_POWERUP was cleared as is recommended in the datasheet when using the internal LDO, now both LINREG_SIMPLE_POWERUP and STARTUP_POWERUP are cleared, as is recommended when using external VDDD.
But why does the SGTL5000 nack that default write to CHIP_ANA_POWER after a reboot, which interrupted the playback?
The following patch from Eric solved the problem; one write fails but it continues setting the other registers and thus even if resetting a board during playback, the sound still works after reboot: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088356.ht... Another workaround might be to not even write a default value to CHIP_ANA_POWER, as in this patch from Eric: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/088355.ht...
What do you think we should do?
Shouldn't both patches be applied?
Yes, I think so too. However I am unsure if we should also remove SGTL5000_CHIP_LINREG_CTRL from the defaults as in Eric's patch 3/6 or only keep the parts of the patch dealing with SGTL5000_CHIP_ANA_POWER. What do you think?
Regards, Clemens
On Mon, Jun 6, 2016 at 1:45 PM, Clemens Gruber clemens.gruber@pqgruber.com wrote:
Yes, I think so too. However I am unsure if we should also remove SGTL5000_CHIP_LINREG_CTRL from the defaults as in Eric's patch 3/6 or only keep the parts of the patch dealing with SGTL5000_CHIP_ANA_POWER. What do you think?
I think the way Eric did in patch 3/6 is fine.
Thanks
On Thu, Jun 02, 2016 at 02:47:24PM +0200, Clemens Gruber wrote:
Instead of checking the SGTL5000 chip revision, we should only check if the VDDD regulator exists and only call sgtl5000_replace_vddd_with_ldo if the regulator is missing.
It looks like there's multiple patches needed here from the following discussion, please resubmit as a series with everything that's needed for review and testing.
participants (4)
-
Clemens Gruber
-
Eric Nelson
-
Fabio Estevam
-
Mark Brown