aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2015-09-30 02:39:46 -0400
committerMark Brown <broonie@kernel.org>2015-10-05 10:05:29 -0400
commit7118f19c4c7cc95ad1513729b83f9db789970152 (patch)
tree8e60a5bf3c6bc9e8956b4ed50f9962e535675950
parent8a29f6c3da0b56fa20c94edde98f53a5582e71a3 (diff)
regulator: axp20x: set supply names for AXP22X DC1SW/DC5LDO internally
The DC1SW and DC5LDO regulators in the AXP22X are internally chained to DCDC1 and DCDC5, hence the names. The original bindings used the parent regulator names for the supply regulator property. Since they are internally connected, the relationship should not be represented in the device tree, but handled internally by the driver. This patch has the driver remember the regulator names for the parent DCDC1/DCDC5, and use them as supply names for DC1SW/DC5LDO. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/axp20x-regulator.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 01bf3476a791..56a0805e6494 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -196,10 +196,10 @@ static const struct regulator_desc axp22x_regulators[] = {
196 AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50, 196 AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
197 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)), 197 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
198 /* secondary switchable output of DCDC1 */ 198 /* secondary switchable output of DCDC1 */
199 AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100, 199 AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", NULL, 1600, 3400, 100,
200 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)), 200 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
201 /* LDO regulator internally chained to DCDC5 */ 201 /* LDO regulator internally chained to DCDC5 */
202 AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100, 202 AXP_DESC(AXP22X, DC5LDO, "dc5ldo", NULL, 700, 1400, 100,
203 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)), 203 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
204 AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 204 AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
205 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)), 205 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
@@ -350,6 +350,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
350 }; 350 };
351 int ret, i, nregulators; 351 int ret, i, nregulators;
352 u32 workmode; 352 u32 workmode;
353 const char *axp22x_dc1_name = axp22x_regulators[AXP22X_DCDC1].name;
354 const char *axp22x_dc5_name = axp22x_regulators[AXP22X_DCDC5].name;
353 355
354 switch (axp20x->variant) { 356 switch (axp20x->variant) {
355 case AXP202_ID: 357 case AXP202_ID:
@@ -371,8 +373,37 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
371 axp20x_regulator_parse_dt(pdev); 373 axp20x_regulator_parse_dt(pdev);
372 374
373 for (i = 0; i < nregulators; i++) { 375 for (i = 0; i < nregulators; i++) {
374 rdev = devm_regulator_register(&pdev->dev, &regulators[i], 376 const struct regulator_desc *desc = &regulators[i];
375 &config); 377 struct regulator_desc *new_desc;
378
379 /*
380 * Regulators DC1SW and DC5LDO are connected internally,
381 * so we have to handle their supply names separately.
382 *
383 * We always register the regulators in proper sequence,
384 * so the supply names are correctly read. See the last
385 * part of this loop to see where we save the DT defined
386 * name.
387 */
388 if (regulators == axp22x_regulators) {
389 if (i == AXP22X_DC1SW) {
390 new_desc = devm_kzalloc(&pdev->dev,
391 sizeof(*desc),
392 GFP_KERNEL);
393 *new_desc = regulators[i];
394 new_desc->supply_name = axp22x_dc1_name;
395 desc = new_desc;
396 } else if (i == AXP22X_DC5LDO) {
397 new_desc = devm_kzalloc(&pdev->dev,
398 sizeof(*desc),
399 GFP_KERNEL);
400 *new_desc = regulators[i];
401 new_desc->supply_name = axp22x_dc5_name;
402 desc = new_desc;
403 }
404 }
405
406 rdev = devm_regulator_register(&pdev->dev, desc, &config);
376 if (IS_ERR(rdev)) { 407 if (IS_ERR(rdev)) {
377 dev_err(&pdev->dev, "Failed to register %s\n", 408 dev_err(&pdev->dev, "Failed to register %s\n",
378 regulators[i].name); 409 regulators[i].name);
@@ -388,6 +419,21 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
388 dev_err(&pdev->dev, "Failed to set workmode on %s\n", 419 dev_err(&pdev->dev, "Failed to set workmode on %s\n",
389 rdev->desc->name); 420 rdev->desc->name);
390 } 421 }
422
423 /*
424 * Save AXP22X DCDC1 / DCDC5 regulator names for later.
425 */
426 if (regulators == axp22x_regulators) {
427 /* Can we use rdev->constraints->name instead? */
428 if (i == AXP22X_DCDC1)
429 of_property_read_string(rdev->dev.of_node,
430 "regulator-name",
431 &axp22x_dc1_name);
432 else if (i == AXP22X_DCDC5)
433 of_property_read_string(rdev->dev.of_node,
434 "regulator-name",
435 &axp22x_dc5_name);
436 }
391 } 437 }
392 438
393 return 0; 439 return 0;