Skip to contentSkip to conversation

twl4030 dumps revision info

PATCH In review David Brownell 3 participants 5 messages Oct 16, 2008 – Oct 17, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 twl4030 dumps revision info

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(+)
drivers/mfd/twl4030-core.c +62 -0
@@ -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();
 
#1 lore raw
Quoted 16 lines

Sent: Wednesday, October 15, 2008 11:24 PM
To: [email protected]
Subject: [patch FYI] twl4030 dumps revision info

---
drivers/mfd/twl4030-core.c | 62 +++++++++++++++++++++++++++++++++++++++++++

1 file changed, 62 insertions(+)
drivers/mfd/twl4030-core.c +7 -0
+};
+
+static u32 twl_id(struct device *dev)
+{
+	const u32 mask = ((1 << 16) - 1) << 12;
+	union { u8 bytes[4]; u32 word; } idcode;
+	int status;

drivers/mfd/twl4030-core.c static int twl4030_remove(struct i2c_cli · line 783

Quoted 10 lines
drivers/mfd/twl4030-core.c +10 -0
+	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),

End of line should be ;
Hope you are not using , operator :-)

Quoted 43 lines
drivers/mfd/twl4030-core.c +27 -0
+	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)

drivers/mfd/twl4030-core.c +2 -1
@@ -795,6 +855,8 @@ twl4030_probe(struct i2c_client *client,
 
 	if(0)dumpit();
 
+	twl_id(&client->dev);
+
 	/* setup clock framework */
 	clocks_init();
 
--

To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to David Brownell

Dave

Quoted 7 lines

Sent: Wednesday, October 15, 2008 11:24 PM
To: [email protected]
Subject: [patch FYI] twl4030 dumps revision info

This is a diagnostic patch, dumping the IDCODE of the TWL4030/TWL5030/... family chips.

Quoted 8 lines

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.

As per TRM,
the idcode for TWL5030 should be: 0x0009802F

is it not what you are observing? Or was it the , bug !!

Quoted 89 lines

- Dave

---
drivers/mfd/twl4030-core.c | 62 +++++++++++++++++++++++++++++++++++++++++++

1 file changed, 62 insertions(+)
drivers/mfd/twl4030-core.c +60 -0
@@ -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)

drivers/mfd/twl4030-core.c +2 -1
@@ -795,6 +855,8 @@ twl4030_probe(struct i2c_client *client,
 
 	if(0)dumpit();
 
+	twl_id(&client->dev);
+
 	/* setup clock framework */
 	clocks_init();
 
--

To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 8 lines · Vikram
Quoted 3 lines

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.

As per TRM,
the idcode for TWL5030 should be: 0x0009802F

is it not what you are observing? Or was it the , bug !!

On one part labeled tps65950, it was 00009002F.
On one labeled as a twl5030, ditto.

On one labeled as a twl4030, it was 5009002f.

Ergo the observation that the TWL5030 ES1.0
parts seem to mis-identify themselves.

- Dave

#4 lore raw
Quoted 3 lines

Ergo the observation that the TWL5030 ES1.0
parts seem to mis-identify themselves.

The delta TRM between TWL4030 and TWL5030 has a note, which says, "The part code number is meaning less when accessed through the I2C"; which means, over JTAG, the ID code should reflect 0x0009802F. I have not verified the same though.

As of now I2C read will give the ID code for TWL5030 as TWL4030 ES1.0.