aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-12-25 10:05:59 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-27 12:30:45 -0500
commitfaa3b2d57964e3c3e974e1d0bea8e047bd8e5edd (patch)
tree22467ce29c024f9886dc0f694b67883d046c613e
parenta49f0d1ea3ec94fc7cf33a7c36a16343b74bd565 (diff)
regulator: tps51632: add register property for regmap
All TPS51632 registers are not readable/writable and non-volatiles. Add property of the registers whether it is readable/writable or volatile for regmap framework. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/tps51632-regulator.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c
index ab21133e6784..b96fb0e15a82 100644
--- a/drivers/regulator/tps51632-regulator.c
+++ b/drivers/regulator/tps51632-regulator.c
@@ -205,18 +205,49 @@ skip_pwm_config:
205 return ret; 205 return ret;
206} 206}
207 207
208static bool rd_wr_reg(struct device *dev, unsigned int reg) 208static bool is_volatile_reg(struct device *dev, unsigned int reg)
209{ 209{
210 if ((reg >= 0x8) && (reg <= 0x10)) 210 switch (reg) {
211 case TPS51632_OFFSET_REG:
212 case TPS51632_FAULT_REG:
213 case TPS51632_IMON_REG:
214 return true;
215 default:
211 return false; 216 return false;
212 return true; 217 }
218}
219
220static bool is_read_reg(struct device *dev, unsigned int reg)
221{
222 switch (reg) {
223 case 0x08 ... 0x0F:
224 return false;
225 default:
226 return true;
227 }
228}
229
230static bool is_write_reg(struct device *dev, unsigned int reg)
231{
232 switch (reg) {
233 case TPS51632_VOLTAGE_SELECT_REG:
234 case TPS51632_VOLTAGE_BASE_REG:
235 case TPS51632_VMAX_REG:
236 case TPS51632_DVFS_CONTROL_REG:
237 case TPS51632_POWER_STATE_REG:
238 case TPS51632_SLEW_REGS:
239 return true;
240 default:
241 return false;
242 }
213} 243}
214 244
215static const struct regmap_config tps51632_regmap_config = { 245static const struct regmap_config tps51632_regmap_config = {
216 .reg_bits = 8, 246 .reg_bits = 8,
217 .val_bits = 8, 247 .val_bits = 8,
218 .writeable_reg = rd_wr_reg, 248 .writeable_reg = is_write_reg,
219 .readable_reg = rd_wr_reg, 249 .readable_reg = is_read_reg,
250 .volatile_reg = is_volatile_reg,
220 .max_register = TPS51632_MAX_REG - 1, 251 .max_register = TPS51632_MAX_REG - 1,
221 .cache_type = REGCACHE_RBTREE, 252 .cache_type = REGCACHE_RBTREE,
222}; 253};