From: Fabio Estevam <festevam@gmail.com>
To: broonie@kernel.org
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
alsa-devel@alsa-project.org, lars@metafoo.de,
matt@genesi-usa.com, eric.nelson@boundarydevices.com,
troy.kisky@boundarydevices.com
Subject: [PATCH v5 1/2] ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()
Date: Thu, 9 May 2013 21:15:46 -0300 [thread overview]
Message-ID: <1368144947-23775-1-git-send-email-festevam@gmail.com> (raw)
From: Fabio Estevam <fabio.estevam@freescale.com>
The usual place for reading chip ID is inside i2c_probe, so move it there and
also convert it to regmap.
sgtl5000_enable_regulators() needs to read the chip revision, so keep the
revision check there.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v4:
- Just introduced in this version.
sound/soc/codecs/sgtl5000.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 327b443..af0c8aa 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)
{
- u16 reg;
+ int reg;
int ret;
int rev;
int i;
@@ -1303,23 +1303,17 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
/* wait for all power rails bring up */
udelay(10);
- /* 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
*/
+
+ ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®);
+ if (ret)
+ goto err_regulator_disable;
+
+ rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
+
if (external_vddd && rev >= 0x11) {
/* disable all regulator first */
regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
@@ -1478,7 +1472,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct sgtl5000_priv *sgtl5000;
- int ret;
+ int ret, reg, rev;
sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv),
GFP_KERNEL);
@@ -1492,6 +1486,21 @@ 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);
ret = snd_soc_register_codec(&client->dev,
--
1.7.9.5
next reply other threads:[~2013-05-10 0:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-10 0:15 Fabio Estevam [this message]
2013-05-10 0:15 ` [PATCH v5 2/2] ASoC: sgtl5000: Fix driver probe after reset Fabio Estevam
2013-05-10 1:17 ` Troy Kisky
2013-05-10 2:12 ` Fabio Estevam
[not found] ` <CAKGA1bnhE3dZe8P+aJm+cps+Rp4abSGOMmPckGw_0fCnh9e6+A@mail.gmail.com>
2013-05-10 17:31 ` Fabio Estevam
2013-05-10 19:11 ` Troy Kisky
2013-05-10 19:16 ` Troy Kisky
2013-05-10 19:18 ` Fabio Estevam
2013-05-10 19:39 ` Fabio Estevam
2013-05-10 20:56 ` Mark Brown
2013-05-10 20:58 ` Mark Brown
2013-05-10 20:13 ` Troy Kisky
2013-05-10 19:23 ` Fabio Estevam
2013-05-10 9:16 ` Mark Brown
2013-05-10 16:38 ` Eric Nelson
2013-05-10 20:59 ` Mark Brown
2013-05-10 9:15 ` [PATCH v5 1/2] ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe() Mark Brown
2013-05-10 16:37 ` Eric Nelson
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=1368144947-23775-1-git-send-email-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=eric.nelson@boundarydevices.com \
--cc=fabio.estevam@freescale.com \
--cc=lars@metafoo.de \
--cc=matt@genesi-usa.com \
--cc=troy.kisky@boundarydevices.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