linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
@ 2016-05-31 19:11 Clemens Gruber
  0 siblings, 0 replies; 9+ messages in thread
From: Clemens Gruber @ 2016-05-31 19:11 UTC (permalink / raw)
  To: linux-kernel, alsa-devel
  Cc: Mark Brown, Fabio Estevam, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Clemens Gruber

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) {
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-02 12:47 Clemens Gruber
  2016-06-02 15:48 ` Fabio Estevam
@ 2016-06-06 17:55 ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-06-06 17:55 UTC (permalink / raw)
  To: Clemens Gruber; +Cc: alsa-devel, Fabio Estevam, Eric Nelson, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-04  5:18     ` Eric Nelson
@ 2016-06-04  9:03       ` Clemens Gruber
  0 siblings, 0 replies; 9+ messages in thread
From: Clemens Gruber @ 2016-06-04  9:03 UTC (permalink / raw)
  To: Eric Nelson; +Cc: alsa-devel, Mark Brown, linux-kernel, Fabio Estevam

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.html#88353
> 
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-03 16:23   ` Eric Nelson
@ 2016-06-04  5:18     ` Eric Nelson
  2016-06-04  9:03       ` Clemens Gruber
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Nelson @ 2016-06-04  5:18 UTC (permalink / raw)
  To: Fabio Estevam, Clemens Gruber; +Cc: alsa-devel, Mark Brown, linux-kernel

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.html#88353

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-02 15:48 ` Fabio Estevam
  2016-06-02 16:56   ` Mark Brown
@ 2016-06-03 16:23   ` Eric Nelson
  2016-06-04  5:18     ` Eric Nelson
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Nelson @ 2016-06-03 16:23 UTC (permalink / raw)
  To: Fabio Estevam, Clemens Gruber; +Cc: alsa-devel, Mark Brown, linux-kernel

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-02 16:56   ` Mark Brown
@ 2016-06-03 15:52     ` Clemens Gruber
  0 siblings, 0 replies; 9+ messages in thread
From: Clemens Gruber @ 2016-06-03 15:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Eric Nelson, linux-kernel, Fabio Estevam

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-02 15:48 ` Fabio Estevam
@ 2016-06-02 16:56   ` Mark Brown
  2016-06-03 15:52     ` Clemens Gruber
  2016-06-03 16:23   ` Eric Nelson
  1 sibling, 1 reply; 9+ messages in thread
From: Mark Brown @ 2016-06-02 16:56 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Clemens Gruber, alsa-devel, Eric Nelson, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

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?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
  2016-06-02 12:47 Clemens Gruber
@ 2016-06-02 15:48 ` Fabio Estevam
  2016-06-02 16:56   ` Mark Brown
  2016-06-03 16:23   ` Eric Nelson
  2016-06-06 17:55 ` Mark Brown
  1 sibling, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2016-06-02 15:48 UTC (permalink / raw)
  To: Clemens Gruber; +Cc: alsa-devel, Mark Brown, Eric Nelson, linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision
@ 2016-06-02 12:47 Clemens Gruber
  2016-06-02 15:48 ` Fabio Estevam
  2016-06-06 17:55 ` Mark Brown
  0 siblings, 2 replies; 9+ messages in thread
From: Clemens Gruber @ 2016-06-02 12:47 UTC (permalink / raw)
  To: alsa-devel
  Cc: Mark Brown, Fabio Estevam, Eric Nelson, linux-kernel, Clemens Gruber

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) {
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-06 17:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 19:11 [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision Clemens Gruber
2016-06-02 12:47 Clemens Gruber
2016-06-02 15:48 ` Fabio Estevam
2016-06-02 16:56   ` Mark Brown
2016-06-03 15:52     ` Clemens Gruber
2016-06-03 16:23   ` Eric Nelson
2016-06-04  5:18     ` Eric Nelson
2016-06-04  9:03       ` Clemens Gruber
2016-06-06 17:55 ` Mark Brown

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).