* [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
@ 2013-05-28 14:04 Fabio Estevam
2013-05-28 14:32 ` Mark Brown
0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2013-05-28 14:04 UTC (permalink / raw)
To: broonie; +Cc: Fabio Estevam, alsa-devel
Commit b871f1ad (ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()) placed
the code for reading the codec revision prior to turning on the power supplies.
Even though this works on some systems that always have the codec power supplies
enabled, this is not correct, so revert this commit.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
sound/soc/codecs/sgtl5000.c | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 1c3b20f..788af6c 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1275,7 +1275,7 @@ static int sgtl5000_replace_vddd_with_ldo(struct snd_soc_codec *codec)
static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
{
- int reg;
+ u16 reg;
int ret;
int rev;
int i;
@@ -1303,17 +1303,23 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
/* wait for all power rails bring up */
udelay(10);
- /*
- * workaround for revision 0x11 and later,
- * roll back to use internal LDO
- */
-
- ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®);
- if (ret)
+ /* read chip information */
+ reg = snd_soc_read(codec, SGTL5000_CHIP_ID);
+ if (((reg & SGTL5000_PARTID_MASK) >> SGTL5000_PARTID_SHIFT) !=
+ SGTL5000_PARTID_PART_ID) {
+ dev_err(codec->dev,
+ "Device with ID register %x is not a sgtl5000\n", reg);
+ ret = -ENODEV;
goto err_regulator_disable;
+ }
rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
+ dev_info(codec->dev, "sgtl5000 revision 0x%x\n", rev);
+ /*
+ * workaround for revision 0x11 and later,
+ * roll back to use internal LDO
+ */
if (external_vddd && rev >= 0x11) {
/* disable all regulator first */
regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
@@ -1497,7 +1503,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct sgtl5000_priv *sgtl5000;
- int ret, reg, rev;
+ int ret;
sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv),
GFP_KERNEL);
@@ -1511,21 +1517,6 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
return ret;
}
- /* read chip information */
- ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®);
- if (ret)
- return ret;
-
- if (((reg & SGTL5000_PARTID_MASK) >> SGTL5000_PARTID_SHIFT) !=
- SGTL5000_PARTID_PART_ID) {
- dev_err(&client->dev,
- "Device with ID register %x is not a sgtl5000\n", reg);
- return -ENODEV;
- }
-
- rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
- dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev);
-
i2c_set_clientdata(client, sgtl5000);
/* Ensure sgtl5000 will start with sane register values */
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-28 14:04 [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies Fabio Estevam
@ 2013-05-28 14:32 ` Mark Brown
2013-05-30 22:36 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2013-05-28 14:32 UTC (permalink / raw)
To: Fabio Estevam; +Cc: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 482 bytes --]
On Tue, May 28, 2013 at 11:04:18AM -0300, Fabio Estevam wrote:
> Commit b871f1ad (ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()) placed
> the code for reading the codec revision prior to turning on the power supplies.
>
> Even though this works on some systems that always have the codec power supplies
> enabled, this is not correct, so revert this commit.
It seems like a better fix for this is to just enable the supplies while
doing the device identification?
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-28 14:32 ` Mark Brown
@ 2013-05-30 22:36 ` Marek Vasut
2013-05-31 5:09 ` Estevam Fabio-R49496
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2013-05-30 22:36 UTC (permalink / raw)
To: alsa-devel; +Cc: Fabio Estevam, Mark Brown
Hi Mark, Fabio,
> On Tue, May 28, 2013 at 11:04:18AM -0300, Fabio Estevam wrote:
> > Commit b871f1ad (ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe())
> > placed the code for reading the codec revision prior to turning on the
> > power supplies.
> >
> > Even though this works on some systems that always have the codec power
> > supplies enabled, this is not correct, so revert this commit.
>
> It seems like a better fix for this is to just enable the supplies while
> doing the device identification?
This patch does kinda fix it for me, but the system takes quite some time to
init the soundcard now (a few seconds). After reverting these two patches, the
soundcard works just fine (like before):
ASoC: sgtl5000: Fix driver probe after reset
ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-30 22:36 ` Marek Vasut
@ 2013-05-31 5:09 ` Estevam Fabio-R49496
2013-05-31 15:32 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Estevam Fabio-R49496 @ 2013-05-31 5:09 UTC (permalink / raw)
To: Marek Vasut, alsa-devel@alsa-project.org; +Cc: Mark Brown, festevam@gmail.com
Hi Marek,
(Sorry for the top-posting here)
There is a delay of 23 seconds, which is 1 second for each sgtl500- register write.
This is an I2C issue and we have already talked about this on the linux-arm-kernel list.
Alexandre Belloni also sees this 1 second on another I2C device connected to mx28.
Regards,
Fabio Estevam
________________________________________
From: Marek Vasut [marex@denx.de]
Sent: Thursday, May 30, 2013 5:36 PM
To: alsa-devel@alsa-project.org
Cc: Mark Brown; Estevam Fabio-R49496
Subject: Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
Hi Mark, Fabio,
> On Tue, May 28, 2013 at 11:04:18AM -0300, Fabio Estevam wrote:
> > Commit b871f1ad (ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe())
> > placed the code for reading the codec revision prior to turning on the
> > power supplies.
> >
> > Even though this works on some systems that always have the codec power
> > supplies enabled, this is not correct, so revert this commit.
>
> It seems like a better fix for this is to just enable the supplies while
> doing the device identification?
This patch does kinda fix it for me, but the system takes quite some time to
init the soundcard now (a few seconds). After reverting these two patches, the
soundcard works just fine (like before):
ASoC: sgtl5000: Fix driver probe after reset
ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-31 5:09 ` Estevam Fabio-R49496
@ 2013-05-31 15:32 ` Marek Vasut
2013-05-31 15:36 ` Fabio Estevam
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2013-05-31 15:32 UTC (permalink / raw)
To: Estevam Fabio-R49496
Cc: alsa-devel@alsa-project.org, Mark Brown, festevam@gmail.com
Hello Fabio,
> Hi Marek,
>
> (Sorry for the top-posting here)
>
> There is a delay of 23 seconds, which is 1 second for each sgtl500-
> register write.
>
> This is an I2C issue and we have already talked about this on the
> linux-arm-kernel list.
>
> Alexandre Belloni also sees this 1 second on another I2C device connected
> to mx28.
There was no problem without these patches though. With your patches, I see NAK
happening on the I2C lines upon first 2-byte write.
> Regards,
>
> Fabio Estevam
> ________________________________________
> From: Marek Vasut [marex@denx.de]
> Sent: Thursday, May 30, 2013 5:36 PM
> To: alsa-devel@alsa-project.org
> Cc: Mark Brown; Estevam Fabio-R49496
> Subject: Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Do not read registers
> prior to turning on the supplies
>
> Hi Mark, Fabio,
>
> > On Tue, May 28, 2013 at 11:04:18AM -0300, Fabio Estevam wrote:
> > > Commit b871f1ad (ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe())
> > > placed the code for reading the codec revision prior to turning on the
> > > power supplies.
> > >
> > > Even though this works on some systems that always have the codec power
> > > supplies enabled, this is not correct, so revert this commit.
> >
> > It seems like a better fix for this is to just enable the supplies while
> > doing the device identification?
>
> This patch does kinda fix it for me, but the system takes quite some time
> to init the soundcard now (a few seconds). After reverting these two
> patches, the soundcard works just fine (like before):
>
> ASoC: sgtl5000: Fix driver probe after reset
> ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()
>
> Best regards,
> Marek Vasut
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-31 15:32 ` Marek Vasut
@ 2013-05-31 15:36 ` Fabio Estevam
2013-05-31 15:45 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2013-05-31 15:36 UTC (permalink / raw)
To: Marek Vasut; +Cc: Estevam Fabio-R49496, alsa-devel@alsa-project.org, Mark Brown
On Fri, May 31, 2013 at 12:32 PM, Marek Vasut <marex@denx.de> wrote:
> There was no problem without these patches though. With your patches, I see NAK
> happening on the I2C lines upon first 2-byte write.
Yes, but prior to these patches there were no register writes in sgtl5000.
These addditional writes does work and solve the reset issues on
mx6qsabrelite/mx51evk.
It is only on mx28evk that we have this timeout issue.
I think we need to turn on the SAIF clock (that connects to the
sgtl5000 MCLK) prior to doing the I2C writes.
Regards,
Fabio Estevam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-31 15:36 ` Fabio Estevam
@ 2013-05-31 15:45 ` Marek Vasut
2013-05-31 15:52 ` Fabio Estevam
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2013-05-31 15:45 UTC (permalink / raw)
To: Fabio Estevam
Cc: Estevam Fabio-R49496, alsa-devel@alsa-project.org, Mark Brown
Hi Fabio,
> On Fri, May 31, 2013 at 12:32 PM, Marek Vasut <marex@denx.de> wrote:
> > There was no problem without these patches though. With your patches, I
> > see NAK happening on the I2C lines upon first 2-byte write.
>
> Yes, but prior to these patches there were no register writes in sgtl5000.
How would volume adjustment work with no writes ? ;-)
> These addditional writes does work and solve the reset issues on
> mx6qsabrelite/mx51evk.
>
> It is only on mx28evk that we have this timeout issue.
>
> I think we need to turn on the SAIF clock (that connects to the
> sgtl5000 MCLK) prior to doing the I2C writes.
Ah, that's _very_ likely. I think the chip will NAK I2C communication without
having clock supplied to it. I did look into this stuff with an LA yesterday
night and I saw the 2-byte write followed by I2C NAK.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-31 15:45 ` Marek Vasut
@ 2013-05-31 15:52 ` Fabio Estevam
2013-05-31 17:20 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2013-05-31 15:52 UTC (permalink / raw)
To: Marek Vasut; +Cc: Estevam Fabio-R49496, alsa-devel@alsa-project.org, Mark Brown
On Fri, May 31, 2013 at 12:45 PM, Marek Vasut <marex@denx.de> wrote:
> Ah, that's _very_ likely. I think the chip will NAK I2C communication without
> having clock supplied to it. I did look into this stuff with an LA yesterday
> night and I saw the 2-byte write followed by I2C NAK.
Yes, I haven't had a chance to try enabling the saif clock earlier and
I am currently out of office.
Thanks,
Fabio Estevam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies
2013-05-31 15:52 ` Fabio Estevam
@ 2013-05-31 17:20 ` Marek Vasut
0 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2013-05-31 17:20 UTC (permalink / raw)
To: Fabio Estevam
Cc: Estevam Fabio-R49496, alsa-devel@alsa-project.org, Mark Brown
Hi Fabio,
> On Fri, May 31, 2013 at 12:45 PM, Marek Vasut <marex@denx.de> wrote:
> > Ah, that's _very_ likely. I think the chip will NAK I2C communication
> > without having clock supplied to it. I did look into this stuff with an
> > LA yesterday night and I saw the 2-byte write followed by I2C NAK.
>
> Yes, I haven't had a chance to try enabling the saif clock earlier and
> I am currently out of office.
Send me a patch if you have time and I'll test it.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-05-31 17:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28 14:04 [PATCH] ASoC: sgtl5000: Do not read registers prior to turning on the supplies Fabio Estevam
2013-05-28 14:32 ` Mark Brown
2013-05-30 22:36 ` Marek Vasut
2013-05-31 5:09 ` Estevam Fabio-R49496
2013-05-31 15:32 ` Marek Vasut
2013-05-31 15:36 ` Fabio Estevam
2013-05-31 15:45 ` Marek Vasut
2013-05-31 15:52 ` Fabio Estevam
2013-05-31 17:20 ` Marek Vasut
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.