regulator: tps51632: add register property for regmap
Subsystems (2)
PATCH v2 1/2 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.
---
Changes from V1:
- No code change.
- Rebase in linux-next 20121224
drivers/regulator/tps51632-regulator.c | 41 ++++++++++++++++++++++++++++---- 1 files changed, 36 insertions(+), 5 deletions(-)
drivers/regulator/tps51632-regulator.c +36 -5
@@ -205,18 +205,49 @@ skip_pwm_config:return ret; } -static bool rd_wr_reg (struct device *dev,unsigned int reg) +static bool is_volatile_reg (struct device *dev,unsigned int reg) { -if ((reg >=0x8 ) && (reg <=0x10 )) +switch (reg) { +case TPS51632_OFFSET_REG : +case TPS51632_FAULT_REG : +case TPS51632_IMON_REG : +return true; +default :return false; -return true; + } +} + +static bool is_read_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { + case 0x08 ... 0x0F: +return false; +default : +return true; + } +} + +static bool is_write_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { +case TPS51632_VOLTAGE_SELECT_REG : +case TPS51632_VOLTAGE_BASE_REG : +case TPS51632_VMAX_REG : +case TPS51632_DVFS_CONTROL_REG : +case TPS51632_POWER_STATE_REG : +case TPS51632_SLEW_REGS : +return true; +default : +return false; + } }static const struct regmap_config tps51632_regmap_config = { .reg_bits =8 , .val_bits =8 , - .writeable_reg = rd_wr_reg, - .readable_reg = rd_wr_reg, + .writeable_reg = is_write_reg, + .readable_reg = is_read_reg, + .volatile_reg = is_volatile_reg, .max_register =TPS51632_MAX_REG -1 , .cache_type =REGCACHE_RBTREE , };
Signature · 1 line
1.7.1.1
PATCH v2 2/2 regulator: tps51632: add DT support
Add DT support for the TI TPS51632. Add device binding document also.
---
Changes from V1:
- Fix compilation error which was not cought in earlier patch.
- Rebased to linux-next 20121224
.../bindings/regulator/tps51632-regulator.txt | 27 +++++++++ drivers/regulator/tps51632-regulator.c | 59 ++++++++++++++++++++ 2 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/tps51632-regulator.txt
Documentation/devicetree/bindings/regulator/tps51632-regulator.txt new file +27 -0
@@ -0,0 +1,27 @@ +TPS51632 Voltage regulators + +Required properties: +- compatible: Must be "ti,tps51632" +- reg: I2C slave address + +Optional properties: +- ti,enable-pwm-dvfs: Enable the DVFS voltage control through the PWM interface. +- ti,dvfs-step-20mV: The 20mV step voltage when PWM DVFS enabled. Missing this + will set 10mV step voltage in PWM DVFS mode. In normal mode, the voltage + step is 10mV as per datasheet. + +Any property defined as part of the core regulator binding, defined in +regulator.txt, can also be used. + +Example: + + tps51632 { + compatible = "ti,tps51632"; + reg = <0x43>; + regulator-name = "tps51632-vout"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1500000>; + regulator-boot-on; + ti,enable-pwm-dvfs; + ti,dvfs-step-20mV; + };
drivers/regulator/tps51632-regulator.c +59 -0
88 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Mark Brown
AppliedQuoted 2 lines · Laxman Dewangan
All TPS51632 registers are not readable/writable and non-volatiles.
Applied both, thanks, but you might wish to consider...
drivers/regulator/tps51632-regulator.c skip_pwm_config: · line 228
Quoted 9 lines
drivers/regulator/tps51632-regulator.c +9
-0+static bool is_read_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { + case 0x08 ... 0x0F: +return false; +default : +return true; + } +}
...using the new table based stuff for the access checks, at least this one seems to map on nicely.