aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/axp20x-regulator.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 441ae01123dd..e4331f5e5d7d 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -152,22 +152,6 @@ static const struct regulator_desc axp20x_regulators[] = {
152 AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), 152 AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
153}; 153};
154 154
155#define AXP_MATCH(_name, _id) \
156 [AXP20X_##_id] = { \
157 .name = #_name, \
158 .driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \
159 }
160
161static struct of_regulator_match axp20x_matches[] = {
162 AXP_MATCH(dcdc2, DCDC2),
163 AXP_MATCH(dcdc3, DCDC3),
164 AXP_MATCH(ldo1, LDO1),
165 AXP_MATCH(ldo2, LDO2),
166 AXP_MATCH(ldo3, LDO3),
167 AXP_MATCH(ldo4, LDO4),
168 AXP_MATCH(ldo5, LDO5),
169};
170
171static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) 155static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
172{ 156{
173 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 157 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@@ -202,13 +186,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
202 if (!regulators) { 186 if (!regulators) {
203 dev_warn(&pdev->dev, "regulators node not found\n"); 187 dev_warn(&pdev->dev, "regulators node not found\n");
204 } else { 188 } else {
205 ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches,
206 ARRAY_SIZE(axp20x_matches));
207 if (ret < 0) {
208 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
209 return ret;
210 }
211
212 dcdcfreq = 1500; 189 dcdcfreq = 1500;
213 of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); 190 of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
214 ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); 191 ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
@@ -242,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
242{ 219{
243 struct regulator_dev *rdev; 220 struct regulator_dev *rdev;
244 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 221 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
245 struct regulator_config config = { }; 222 struct regulator_config config = {
246 struct regulator_init_data *init_data; 223 .dev = pdev->dev.parent,
224 .regmap = axp20x->regmap,
225 };
247 int ret, i; 226 int ret, i;
248 u32 workmode; 227 u32 workmode;
249 228
250 ret = axp20x_regulator_parse_dt(pdev); 229 /* This only sets the dcdc freq. Ignore any errors */
251 if (ret) 230 axp20x_regulator_parse_dt(pdev);
252 return ret;
253 231
254 for (i = 0; i < AXP20X_REG_ID_MAX; i++) { 232 for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
255 init_data = axp20x_matches[i].init_data;
256
257 config.dev = pdev->dev.parent;
258 config.init_data = init_data;
259 config.regmap = axp20x->regmap;
260 config.of_node = axp20x_matches[i].of_node;
261
262 rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], 233 rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
263 &config); 234 &config);
264 if (IS_ERR(rdev)) { 235 if (IS_ERR(rdev)) {
@@ -268,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
268 return PTR_ERR(rdev); 239 return PTR_ERR(rdev);
269 } 240 }
270 241
271 ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", 242 ret = of_property_read_u32(rdev->dev.of_node,
243 "x-powers,dcdc-workmode",
272 &workmode); 244 &workmode);
273 if (!ret) { 245 if (!ret) {
274 if (axp20x_set_dcdc_workmode(rdev, i, workmode)) 246 if (axp20x_set_dcdc_workmode(rdev, i, workmode))