diff options
author | Chen-Yu Tsai <wens@csie.org> | 2016-02-02 05:27:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-02-03 12:15:08 -0500 |
commit | 13d57e64352a5d3457d7782bc2f8b576e12b05f3 (patch) | |
tree | dce9306bb52b66a8dc70e1310bd5b9595e77b0c4 | |
parent | 94c39041ae0c0e83d10bc1a56974a2eefd9386c8 (diff) |
regulator: axp20x: Use linear voltage ranges for AXP20X LDO4
AXP20X datasheet lists the possible voltage settings for LDO4, so
it was implemented using a voltage table. Upon closer examination,
the valid voltages can be mapped into 3 linear ranges.
Move AXP20X LDO4 to use linear ranges. The supporting code can be
reused with later AXP8xx PMICs, which have a number of regulators
that have 2 linear ranges.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/axp20x-regulator.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index fafaaa8eb8b3..7d29893f833c 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c | |||
@@ -106,8 +106,8 @@ | |||
106 | .ops = &axp20x_ops_fixed \ | 106 | .ops = &axp20x_ops_fixed \ |
107 | } | 107 | } |
108 | 108 | ||
109 | #define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask, \ | 109 | #define AXP_DESC_RANGES(_family, _id, _match, _supply, _ranges, _n_voltages, \ |
110 | _ereg, _emask) \ | 110 | _vreg, _vmask, _ereg, _emask) \ |
111 | [_family##_##_id] = { \ | 111 | [_family##_##_id] = { \ |
112 | .name = #_id, \ | 112 | .name = #_id, \ |
113 | .supply_name = (_supply), \ | 113 | .supply_name = (_supply), \ |
@@ -115,30 +115,25 @@ | |||
115 | .regulators_node = of_match_ptr("regulators"), \ | 115 | .regulators_node = of_match_ptr("regulators"), \ |
116 | .type = REGULATOR_VOLTAGE, \ | 116 | .type = REGULATOR_VOLTAGE, \ |
117 | .id = _family##_##_id, \ | 117 | .id = _family##_##_id, \ |
118 | .n_voltages = ARRAY_SIZE(_table), \ | 118 | .n_voltages = (_n_voltages), \ |
119 | .owner = THIS_MODULE, \ | 119 | .owner = THIS_MODULE, \ |
120 | .vsel_reg = (_vreg), \ | 120 | .vsel_reg = (_vreg), \ |
121 | .vsel_mask = (_vmask), \ | 121 | .vsel_mask = (_vmask), \ |
122 | .enable_reg = (_ereg), \ | 122 | .enable_reg = (_ereg), \ |
123 | .enable_mask = (_emask), \ | 123 | .enable_mask = (_emask), \ |
124 | .volt_table = (_table), \ | 124 | .linear_ranges = (_ranges), \ |
125 | .ops = &axp20x_ops_table, \ | 125 | .n_linear_ranges = ARRAY_SIZE(_ranges), \ |
126 | .ops = &axp20x_ops_range, \ | ||
126 | } | 127 | } |
127 | 128 | ||
128 | static const int axp20x_ldo4_data[] = { 1250000, 1300000, 1400000, 1500000, 1600000, | ||
129 | 1700000, 1800000, 1900000, 2000000, 2500000, | ||
130 | 2700000, 2800000, 3000000, 3100000, 3200000, | ||
131 | 3300000 }; | ||
132 | |||
133 | static struct regulator_ops axp20x_ops_fixed = { | 129 | static struct regulator_ops axp20x_ops_fixed = { |
134 | .list_voltage = regulator_list_voltage_linear, | 130 | .list_voltage = regulator_list_voltage_linear, |
135 | }; | 131 | }; |
136 | 132 | ||
137 | static struct regulator_ops axp20x_ops_table = { | 133 | static struct regulator_ops axp20x_ops_range = { |
138 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 134 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
139 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 135 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
140 | .list_voltage = regulator_list_voltage_table, | 136 | .list_voltage = regulator_list_voltage_linear_range, |
141 | .map_voltage = regulator_map_voltage_ascend, | ||
142 | .enable = regulator_enable_regmap, | 137 | .enable = regulator_enable_regmap, |
143 | .disable = regulator_disable_regmap, | 138 | .disable = regulator_disable_regmap, |
144 | .is_enabled = regulator_is_enabled_regmap, | 139 | .is_enabled = regulator_is_enabled_regmap, |
@@ -159,6 +154,12 @@ static struct regulator_ops axp20x_ops_sw = { | |||
159 | .is_enabled = regulator_is_enabled_regmap, | 154 | .is_enabled = regulator_is_enabled_regmap, |
160 | }; | 155 | }; |
161 | 156 | ||
157 | static const struct regulator_linear_range axp20x_ldo4_ranges[] = { | ||
158 | REGULATOR_LINEAR_RANGE(1250000, 0x0, 0x0, 0), | ||
159 | REGULATOR_LINEAR_RANGE(1300000, 0x1, 0x8, 100000), | ||
160 | REGULATOR_LINEAR_RANGE(2500000, 0x9, 0xf, 100000), | ||
161 | }; | ||
162 | |||
162 | static const struct regulator_desc axp20x_regulators[] = { | 163 | static const struct regulator_desc axp20x_regulators[] = { |
163 | AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25, | 164 | AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25, |
164 | AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10), | 165 | AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10), |
@@ -169,8 +170,9 @@ static const struct regulator_desc axp20x_regulators[] = { | |||
169 | AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04), | 170 | AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04), |
170 | AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25, | 171 | AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25, |
171 | AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40), | 172 | AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40), |
172 | AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data, | 173 | AXP_DESC_RANGES(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_ranges, |
173 | AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08), | 174 | 16, AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, |
175 | 0x08), | ||
174 | AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100, | 176 | AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100, |
175 | AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07, | 177 | AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07, |
176 | AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), | 178 | AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), |