From aaf27f232634dfbb8ddbcbccb4df6c25bb1e684d Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Wed, 22 Jun 2011 12:15:56 -0500 Subject: OMAP4: PM: TPS: provide a read-modify-write for TWL6030 We will be flipping a few bits to enable/disable groups in later patches, so, we provide a helper to do a read modify write function which wraps around the standard TWL6030 read/write functions. Acked-by: Ambresh K Signed-off-by: Nishanth Menon --- arch/arm/mach-omap2/omap_tps6236x.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-omap2/omap_tps6236x.c b/arch/arm/mach-omap2/omap_tps6236x.c index 808d05c..24aa6cd 100644 --- a/arch/arm/mach-omap2/omap_tps6236x.c +++ b/arch/arm/mach-omap2/omap_tps6236x.c @@ -194,6 +194,30 @@ static struct omap_voltdm_pmic omap4_mpu_pmic = { }; /** + * _twl_i2c_rmw_u8() - Tiny helper function to do a read modify write for twl + * @mod_no: module number + * @mask: mask for the val + * @value: value to write + * @reg: register to write to + */ +static int __init _twl_i2c_rmw_u8(u8 mod_no, u8 mask, u8 value, u8 reg) +{ + int ret; + u8 val; + + ret = twl_i2c_read_u8(mod_no, &val, reg); + if (ret) + goto out; + + val &= ~mask; + val |= (value & mask); + + ret = twl_i2c_write_u8(mod_no, val, reg); +out: + return ret; +} + +/** * omap4_twl_tps62361_enable() - Enable tps chip * * This function enables TPS chip by associating SYSEN signal @@ -245,14 +269,9 @@ static int __init omap4_twl_tps62361_enable(struct voltagedomain *voltdm) /* if we have to work with TWL */ #ifdef CONFIG_TWL4030_CORE - ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, &val, - TWL6030_REG_SYSEN_CFG_GRP); - if (ret) - goto out; - - val |= TWL6030_BIT_APE_GRP; - ret = twl_i2c_write_u8(TWL6030_MODULE_ID0, val, - TWL6030_REG_SYSEN_CFG_GRP); + /* Map up SYSEN on TWL core to control TPS */ + ret = _twl_i2c_rmw_u8(TWL6030_MODULE_ID0, TWL6030_BIT_APE_GRP, + TWL6030_BIT_APE_GRP, TWL6030_REG_SYSEN_CFG_GRP); #endif out: -- cgit v1.1