diff options
author | Anson Huang <b20788@freescale.com> | 2013-01-31 11:23:53 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-31 01:40:49 -0500 |
commit | 9ee417c07479b9a87d0808dd3c8b4ce3925983f1 (patch) | |
tree | 639728c1c15217843d2d4641cdf13c5146d39aa8 /drivers/regulator/anatop-regulator.c | |
parent | 949db153b6466c6f7cad5a427ecea94985927311 (diff) |
regulators: anatop: add set_voltage_time_sel interface
some of anatop's regulators(cpu, vddpu and vddsoc) have
register settings about LDO's step time, which will impact
the LDO ramp up speed, need to use set_voltage_time_sel
interface to add necessary delay everytime LDOs' voltage
is increased.
offset 0x170:
bit [24-25]: cpu
bit [26-27]: vddpu
bit [28-29]: vddsoc
field definition:
0'b00: 64 cycles of 24M clock;
0'b01: 128 cycles of 24M clock;
0'b02: 256 cycles of 24M clock;
0'b03: 512 cycles of 24M clock;
Signed-off-by: Anson Huang <b20788@freescale.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 8f39cac661d2..0df9c6a97604 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -31,12 +31,18 @@ | |||
31 | #include <linux/regulator/driver.h> | 31 | #include <linux/regulator/driver.h> |
32 | #include <linux/regulator/of_regulator.h> | 32 | #include <linux/regulator/of_regulator.h> |
33 | 33 | ||
34 | #define LDO_RAMP_UP_UNIT_IN_CYCLES 64 /* 64 cycles per step */ | ||
35 | #define LDO_RAMP_UP_FREQ_IN_MHZ 24 /* cycle based on 24M OSC */ | ||
36 | |||
34 | struct anatop_regulator { | 37 | struct anatop_regulator { |
35 | const char *name; | 38 | const char *name; |
36 | u32 control_reg; | 39 | u32 control_reg; |
37 | struct regmap *anatop; | 40 | struct regmap *anatop; |
38 | int vol_bit_shift; | 41 | int vol_bit_shift; |
39 | int vol_bit_width; | 42 | int vol_bit_width; |
43 | u32 delay_reg; | ||
44 | int delay_bit_shift; | ||
45 | int delay_bit_width; | ||
40 | int min_bit_val; | 46 | int min_bit_val; |
41 | int min_voltage; | 47 | int min_voltage; |
42 | int max_voltage; | 48 | int max_voltage; |
@@ -55,6 +61,32 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, | |||
55 | return regulator_set_voltage_sel_regmap(reg, selector); | 61 | return regulator_set_voltage_sel_regmap(reg, selector); |
56 | } | 62 | } |
57 | 63 | ||
64 | static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg, | ||
65 | unsigned int old_sel, | ||
66 | unsigned int new_sel) | ||
67 | { | ||
68 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | ||
69 | u32 val; | ||
70 | int ret = 0; | ||
71 | |||
72 | /* check whether need to care about LDO ramp up speed */ | ||
73 | if (anatop_reg->delay_bit_width && new_sel > old_sel) { | ||
74 | /* | ||
75 | * the delay for LDO ramp up time is | ||
76 | * based on the register setting, we need | ||
77 | * to calculate how many steps LDO need to | ||
78 | * ramp up, and how much delay needed. (us) | ||
79 | */ | ||
80 | regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val); | ||
81 | val = (val >> anatop_reg->delay_bit_shift) & | ||
82 | ((1 << anatop_reg->delay_bit_width) - 1); | ||
83 | ret = (new_sel - old_sel) * ((LDO_RAMP_UP_UNIT_IN_CYCLES << | ||
84 | val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1); | ||
85 | } | ||
86 | |||
87 | return ret; | ||
88 | } | ||
89 | |||
58 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | 90 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) |
59 | { | 91 | { |
60 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 92 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
@@ -67,6 +99,7 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | |||
67 | 99 | ||
68 | static struct regulator_ops anatop_rops = { | 100 | static struct regulator_ops anatop_rops = { |
69 | .set_voltage_sel = anatop_regmap_set_voltage_sel, | 101 | .set_voltage_sel = anatop_regmap_set_voltage_sel, |
102 | .set_voltage_time_sel = anatop_regmap_set_voltage_time_sel, | ||
70 | .get_voltage_sel = anatop_regmap_get_voltage_sel, | 103 | .get_voltage_sel = anatop_regmap_get_voltage_sel, |
71 | .list_voltage = regulator_list_voltage_linear, | 104 | .list_voltage = regulator_list_voltage_linear, |
72 | .map_voltage = regulator_map_voltage_linear, | 105 | .map_voltage = regulator_map_voltage_linear, |
@@ -143,6 +176,14 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
143 | goto anatop_probe_end; | 176 | goto anatop_probe_end; |
144 | } | 177 | } |
145 | 178 | ||
179 | /* read LDO ramp up setting, only for core reg */ | ||
180 | of_property_read_u32(np, "anatop-delay-reg-offset", | ||
181 | &sreg->delay_reg); | ||
182 | of_property_read_u32(np, "anatop-delay-bit-width", | ||
183 | &sreg->delay_bit_width); | ||
184 | of_property_read_u32(np, "anatop-delay-bit-shift", | ||
185 | &sreg->delay_bit_shift); | ||
186 | |||
146 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 | 187 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
147 | + sreg->min_bit_val; | 188 | + sreg->min_bit_val; |
148 | rdesc->min_uV = sreg->min_voltage; | 189 | rdesc->min_uV = sreg->min_voltage; |