From: David Brownell <david-b@pacbell.net>
To: linux-omap@vger.kernel.org
Subject: [patch FYI] twl4030 dumps revision info
Date: Wed, 15 Oct 2008 21:23:42 -0700 [thread overview]
Message-ID: <200810152123.42459.david-b@pacbell.net> (raw)
This is a diagnostic patch, dumping the IDCODE of the
TWL4030/TWL5030/... family chips.
Not for merging, at least for now. Later this may be
useful to make sure the reduced-functionality catalog
parts (TPS series) don't go registering components that
don't exist, like the battery charger.
The main curiousity we've uncovered is that TWL5030 ES1.0
mis-identifies itself as TWL4030 ES1.0 ... unclear just now
whether that's also true of ES1.1 and later parts.
- Dave
---
drivers/mfd/twl4030-core.c | 62 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -748,6 +748,66 @@ static int twl4030_remove(struct i2c_cli
return 0;
}
+struct es_desc {
+ u8 nibble;
+ char name[4];
+};
+
+static const struct es_desc twl4030_es[] = {
+ { 0, "1.0", },
+ { 1, "2.x", },
+ { 4, "3.0", },
+ { 5, "3.1", },
+ { },
+};
+static const struct es_desc twl5030_es[] = {
+ { 0, "1.0", },
+ { 1, "1.1", },
+ { },
+};
+
+static u32 twl_id(struct device *dev)
+{
+ const u32 mask = ((1 << 16) - 1) << 12;
+ union { u8 bytes[4]; u32 word; } idcode;
+ int status;
+ u8 nibble;
+ char *chip;
+ const struct es_desc *desc;
+
+ status = twl4030_i2c_read(TWL4030_MODULE_INTBR,
+ idcode.bytes, 0, 4);
+ if (status < 0)
+ return 0;
+
+ idcode.word = le32_to_cpu(idcode.word),
+ nibble = idcode.word >> 28;
+
+ /* NOTE: TWL5030 / TPS65930 ES1.0 mis-identifies as TWL4030 */
+
+ if ((idcode.word & mask) == (0x0009002F & mask)) {
+ chip = "TWL4030";
+ desc = twl4030_es;
+ } else if ((idcode.word & mask) == (0x0009802F & mask)) {
+ chip = "TWL5030";
+ desc = twl5030_es;
+ } else {
+ chip = "unrecognized";
+ desc = NULL;
+ }
+
+ while (desc && desc->name[0]) {
+ if (desc->nibble == nibble) {
+ dev_info(dev, "%s ES %s; idcode %08x\n",
+ chip, desc->name, idcode.word);
+ return idcode.word;
+ }
+ desc++;
+ }
+ dev_info(dev, "%s; idcode %08x\n", chip, idcode.word);
+ return idcode.word;
+}
+
/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
static int
twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
@@ -795,6 +855,8 @@ twl4030_probe(struct i2c_client *client,
if(0)dumpit();
+ twl_id(&client->dev);
+
/* setup clock framework */
clocks_init();
next reply other threads:[~2008-10-16 4:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 4:23 David Brownell [this message]
2008-10-16 23:19 ` [patch FYI] twl4030 dumps revision info Pandita, Vikram
2008-10-16 23:27 ` Pandita, Vikram
2008-10-17 0:16 ` David Brownell
2008-10-17 8:31 ` Pakaravoor, Jagadeesh
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=200810152123.42459.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=linux-omap@vger.kernel.org \
/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