* [PATCH 1/2] mfd: TWL6030: Add support for version detection
2011-03-03 12:58 [PATCH 0/2] mfd: TWL6030: add version check for errata handling Balaji T K
@ 2011-03-03 12:58 ` Balaji T K
2011-03-03 12:58 ` [PATCH 2/2] mfd: TWL6030: Fix buggy burst read in TWL6030 ES1.0 Balaji T K
1 sibling, 0 replies; 3+ messages in thread
From: Balaji T K @ 2011-03-03 12:58 UTC (permalink / raw)
To: sameo, linux-omap; +Cc: leslyam, paul, Balaji T K
Print chip version at bootup
pack product id and version id in a way similar to Triton TWL5030
so that twl_get_si_type and twl_get_si_version can be used for TWL6030
Use this to set flags for errata based on particular chip version.
Signed-off-by: Balaji T K <balajitk@ti.com>
---
drivers/mfd/twl-core.c | 43 +++++++++++++++++++++++++++++++++++++++++++
include/linux/i2c/twl.h | 10 ++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 5e706d7..cd0ce54 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1036,6 +1036,48 @@ int twl4030_init_chip_irq(const char *chip);
int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
int twl6030_exit_irq(void);
+static void __devinit twl6030_check_version(void)
+{
+ int ret;
+ u8 es_id = 0;
+ u8 prd_lsb = 0;
+ u8 prd_msb = 0;
+ char es_version[8];
+
+ ret = twl_i2c_read_u8(TWL6030_MODULE_ID2, &es_id, TWL6030_JTAGVERNUM);
+ if (ret < 0) {
+ pr_err("TWL6030 failed to read version register %d\n", ret);
+ return;
+ }
+ ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &prd_lsb,
+ TWL6030_USB_PRODUCT_ID_LSB);
+ if (ret < 0) {
+ pr_err("TWL6030 failed to read product lsb register %d\n", ret);
+ return;
+ }
+ ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &prd_msb,
+ TWL6030_USB_PRODUCT_ID_MSB);
+ if (ret < 0) {
+ pr_err("TWL6030 failed to read product msb register %d\n", ret);
+ return;
+ }
+
+ switch (es_id) {
+ case 0:
+ sprintf(es_version, "%s", "1.0");
+ break;
+ case 1:
+ default:
+ sprintf(es_version, "%s", "2.0");
+ break;
+ }
+ twl_idcode = (es_id << 24) | (prd_msb << 8) | prd_lsb;
+
+ pr_info("TWL6030 version ES%s\n", es_version);
+
+ return;
+}
+
static int twl_remove(struct i2c_client *client)
{
unsigned i;
@@ -1106,6 +1148,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
if ((id->driver_data) & TWL6030_CLASS) {
twl_id = TWL6030_CLASS_ID;
twl_map = &twl6030_map[0];
+ twl6030_check_version();
} else {
twl_id = TWL4030_CLASS_ID;
twl_map = &twl4030_map[0];
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index ff1f1e0..470dd97 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -793,4 +793,14 @@ static inline int twl4030charger_usb_en(int enable) { return 0; }
/* INTERNAL LDOs */
#define TWL6030_REG_VRTC 47
+/* TWL6030 - Register offset for i2c slave address 0x48 */
+
+/* TWL6030 - Register offset for i2c slave address 0x49 */
+#define TWL6030_USB_PRODUCT_ID_LSB 0x02
+#define TWL6030_USB_PRODUCT_ID_MSB 0x03
+
+/* TWL6030 - Register offset for i2c slave address 0x4A */
+#define TWL6030_JTAGVERNUM 0x87
+#define TWL6030_EPROM_REV 0xD7
+
#endif /* End of __TWL4030_H */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] mfd: TWL6030: Fix buggy burst read in TWL6030 ES1.0
2011-03-03 12:58 [PATCH 0/2] mfd: TWL6030: add version check for errata handling Balaji T K
2011-03-03 12:58 ` [PATCH 1/2] mfd: TWL6030: Add support for version detection Balaji T K
@ 2011-03-03 12:58 ` Balaji T K
1 sibling, 0 replies; 3+ messages in thread
From: Balaji T K @ 2011-03-03 12:58 UTC (permalink / raw)
To: sameo, linux-omap; +Cc: leslyam, paul, Balaji T K
Convert multi byte i2c read to several single byte i2c read as workaround.
Signed-off-by: Balaji T K <balajitk@ti.com>
---
drivers/mfd/twl-core.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index cd0ce54..b4cfba3 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -224,6 +224,9 @@
#define TWL5031 BIT(2) /* twl5031 has different registers */
#define TWL6030_CLASS BIT(3) /* TWL6030 class */
+static int errata;
+#define ERRATA_107890 (1 << 0) /* Buggy burst read at 400 KHz */
+
/*----------------------------------------------------------------------*/
/* is driver active, bound to a chip? */
@@ -405,7 +408,7 @@ EXPORT_SYMBOL(twl_i2c_write);
*
* Returns result of operation - num_bytes is success else failure.
*/
-int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
+static int twl_i2c_read_burst(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
{
int ret;
u8 val;
@@ -453,6 +456,29 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
return 0;
}
}
+
+int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
+{
+ int ret = 0, i = 0;
+
+ /*
+ * Glitch in the I2C Data line when the I2C controller
+ * performs a Burst Read at I2C bus speed of 400KHz
+ * This glitch causes burst read to fail in Phoenix TWL6030 ES1.0
+ * Convert multi byte read to byte read if burst read is buggy
+ */
+ if (errata & ERRATA_107890) {
+ for (i = 0; i < num_bytes; i++)
+ ret = twl_i2c_read_burst(mod_no, value + i,
+ reg + i, 1);
+ if (ret)
+ return ret;
+ } else {
+ ret = twl_i2c_read_burst(mod_no, value, reg, num_bytes);
+ }
+
+ return ret;
+}
EXPORT_SYMBOL(twl_i2c_read);
/**
@@ -484,7 +510,7 @@ EXPORT_SYMBOL(twl_i2c_write_u8);
*/
int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
{
- return twl_i2c_read(mod_no, value, reg, 1);
+ return twl_i2c_read_burst(mod_no, value, reg, 1);
}
EXPORT_SYMBOL(twl_i2c_read_u8);
@@ -1065,6 +1091,7 @@ static void __devinit twl6030_check_version(void)
switch (es_id) {
case 0:
sprintf(es_version, "%s", "1.0");
+ errata = ERRATA_107890;
break;
case 1:
default:
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread