From 94d03c2a7a54ae82ca34729919e683a1b5474fc1 Mon Sep 17 00:00:00 2001 From: Oleksandr Dmytryshyn Date: Wed, 28 Mar 2012 09:45:30 +0300 Subject: OMAP4: Regulator: Perform additional check for some LDOs For TWL6032 revision < ES1.1 with EEPROM revision < rev56.0 LDO6 and LDOLN must be always ON because of the hardware bug in the TWL6032. For TWL6032 revision >= ES1.1 with EEPROM revision >= rev56.0 those LDOs can be off in sleep-mode. If LDO6 or LDOLN is always on then SYSEN must be always on. This patch performs additional checks. Change-Id: I81e8e1a9dfdb628849277f4c3b4363bd0146cac4 Signed-off-by: Oleksandr Dmytryshyn --- drivers/mfd/twl-core.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index af3cd409d7d..3bf9a8d87a1 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -248,6 +248,10 @@ /* need to access USB_PRODUCT_ID_LSB to identify which 6030 varient we are */ #define USB_PRODUCT_ID_LSB 0x02 +/* need to check eeprom revision and jtagver number */ +#define TWL6030_REG_EPROM_REV 0xdf +#define TWL6030_REG_JTAGVERNUM 0x87 + /*----------------------------------------------------------------------*/ /* is driver active, bound to a chip? */ @@ -659,6 +663,9 @@ add_regulator(int num, struct regulator_init_data *pdata, return add_regulator_linked(num, pdata, NULL, 0, features); } +#define SET_LDO_STATE_MEM(ldo, state) \ + ldo->constraints.state_mem.disabled = state + /* * NOTE: We know the first 8 IRQs after pdata->base_irq are * for the PIH, and the next are for the PWR_INT SIH, since @@ -670,6 +677,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) { struct device *child; unsigned sub_chip_id; + u8 eepromrev = 0; + u8 twlrev = 0; if (twl_has_gpio() && pdata->gpio) { child = add_child(SUB_CHIP_ID1, "twl4030_gpio", @@ -970,6 +979,32 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) return PTR_ERR(child); } + if (twl_has_regulator() && twl_class_is_6030()) { + /* + * For TWL6032 revision < ES1.1 with EEPROM revision < rev56.0 + * LDO6 and LDOLN must be always ON + * if LDO6 or LDOLN is always on then SYSEN must be always on + * for TWL6030 or TWL6032 revision >= ES1.1 with EEPROM + * revision >= rev56.0 those LDOs can be off in sleep-mode + */ + if (features & TWL6032_SUBCLASS) { + twl_i2c_read_u8(TWL6030_MODULE_ID2, &eepromrev, + TWL6030_REG_EPROM_REV); + + twl_i2c_read_u8(TWL6030_MODULE_ID2, &twlrev, + TWL6030_REG_JTAGVERNUM); + + if ((eepromrev < 56) && (twlrev < 1)) { + SET_LDO_STATE_MEM(pdata->ldo6, false); + SET_LDO_STATE_MEM(pdata->ldoln, false); + SET_LDO_STATE_MEM(pdata->sysen, false); + WARN(1, "This TWL6032 is an older revision that " + "does not support low power " + "measurements\n"); + } + } + } + /* twl6030 regulators */ if (twl_has_regulator() && twl_class_is_6030() && !(features & TWL6032_SUBCLASS)) { -- cgit v1.2.3