regulator: db8500-prcmu: Convert to use simplified DT parsing

Use regulator core's simplified DT parsing code to simplify the driver
implementation.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Axel Lin 2019-04-12 09:54:20 +08:00 коммит произвёл Mark Brown
Родитель 1a18195a2c
Коммит 92722a8fac
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
1 изменённых файлов: 45 добавлений и 100 удалений

Просмотреть файл

@ -214,6 +214,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VAPE] = { [DB8500_REGULATOR_VAPE] = {
.desc = { .desc = {
.name = "db8500-vape", .name = "db8500-vape",
.of_match = of_match_ptr("db8500_vape"),
.id = DB8500_REGULATOR_VAPE, .id = DB8500_REGULATOR_VAPE,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -223,6 +224,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VARM] = { [DB8500_REGULATOR_VARM] = {
.desc = { .desc = {
.name = "db8500-varm", .name = "db8500-varm",
.of_match = of_match_ptr("db8500_varm"),
.id = DB8500_REGULATOR_VARM, .id = DB8500_REGULATOR_VARM,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -232,6 +234,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VMODEM] = { [DB8500_REGULATOR_VMODEM] = {
.desc = { .desc = {
.name = "db8500-vmodem", .name = "db8500-vmodem",
.of_match = of_match_ptr("db8500_vmodem"),
.id = DB8500_REGULATOR_VMODEM, .id = DB8500_REGULATOR_VMODEM,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -241,6 +244,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VPLL] = { [DB8500_REGULATOR_VPLL] = {
.desc = { .desc = {
.name = "db8500-vpll", .name = "db8500-vpll",
.of_match = of_match_ptr("db8500_vpll"),
.id = DB8500_REGULATOR_VPLL, .id = DB8500_REGULATOR_VPLL,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -250,6 +254,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS1] = { [DB8500_REGULATOR_VSMPS1] = {
.desc = { .desc = {
.name = "db8500-vsmps1", .name = "db8500-vsmps1",
.of_match = of_match_ptr("db8500_vsmps1"),
.id = DB8500_REGULATOR_VSMPS1, .id = DB8500_REGULATOR_VSMPS1,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -259,6 +264,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS2] = { [DB8500_REGULATOR_VSMPS2] = {
.desc = { .desc = {
.name = "db8500-vsmps2", .name = "db8500-vsmps2",
.of_match = of_match_ptr("db8500_vsmps2"),
.id = DB8500_REGULATOR_VSMPS2, .id = DB8500_REGULATOR_VSMPS2,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -271,6 +277,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS3] = { [DB8500_REGULATOR_VSMPS3] = {
.desc = { .desc = {
.name = "db8500-vsmps3", .name = "db8500-vsmps3",
.of_match = of_match_ptr("db8500_vsmps3"),
.id = DB8500_REGULATOR_VSMPS3, .id = DB8500_REGULATOR_VSMPS3,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -280,6 +287,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VRF1] = { [DB8500_REGULATOR_VRF1] = {
.desc = { .desc = {
.name = "db8500-vrf1", .name = "db8500-vrf1",
.of_match = of_match_ptr("db8500_vrf1"),
.id = DB8500_REGULATOR_VRF1, .id = DB8500_REGULATOR_VRF1,
.ops = &db8500_regulator_ops, .ops = &db8500_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -289,6 +297,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SVAMMDSP] = { [DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
.desc = { .desc = {
.name = "db8500-sva-mmdsp", .name = "db8500-sva-mmdsp",
.of_match = of_match_ptr("db8500_sva_mmdsp"),
.id = DB8500_REGULATOR_SWITCH_SVAMMDSP, .id = DB8500_REGULATOR_SWITCH_SVAMMDSP,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -299,6 +308,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = { [DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
.desc = { .desc = {
.name = "db8500-sva-mmdsp-ret", .name = "db8500-sva-mmdsp-ret",
.of_match = of_match_ptr("db8500_sva_mmdsp_ret"),
.id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET, .id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -310,6 +320,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SVAPIPE] = { [DB8500_REGULATOR_SWITCH_SVAPIPE] = {
.desc = { .desc = {
.name = "db8500-sva-pipe", .name = "db8500-sva-pipe",
.of_match = of_match_ptr("db8500_sva_pipe"),
.id = DB8500_REGULATOR_SWITCH_SVAPIPE, .id = DB8500_REGULATOR_SWITCH_SVAPIPE,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -320,6 +331,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SIAMMDSP] = { [DB8500_REGULATOR_SWITCH_SIAMMDSP] = {
.desc = { .desc = {
.name = "db8500-sia-mmdsp", .name = "db8500-sia-mmdsp",
.of_match = of_match_ptr("db8500_sia_mmdsp"),
.id = DB8500_REGULATOR_SWITCH_SIAMMDSP, .id = DB8500_REGULATOR_SWITCH_SIAMMDSP,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -330,6 +342,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = { [DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = {
.desc = { .desc = {
.name = "db8500-sia-mmdsp-ret", .name = "db8500-sia-mmdsp-ret",
.of_match = of_match_ptr("db8500_sia_mmdsp_ret"),
.id = DB8500_REGULATOR_SWITCH_SIAMMDSPRET, .id = DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -341,6 +354,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SIAPIPE] = { [DB8500_REGULATOR_SWITCH_SIAPIPE] = {
.desc = { .desc = {
.name = "db8500-sia-pipe", .name = "db8500-sia-pipe",
.of_match = of_match_ptr("db8500_sia_pipe"),
.id = DB8500_REGULATOR_SWITCH_SIAPIPE, .id = DB8500_REGULATOR_SWITCH_SIAPIPE,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -351,6 +365,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SGA] = { [DB8500_REGULATOR_SWITCH_SGA] = {
.desc = { .desc = {
.name = "db8500-sga", .name = "db8500-sga",
.of_match = of_match_ptr("db8500_sga"),
.id = DB8500_REGULATOR_SWITCH_SGA, .id = DB8500_REGULATOR_SWITCH_SGA,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -361,6 +376,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_B2R2_MCDE] = { [DB8500_REGULATOR_SWITCH_B2R2_MCDE] = {
.desc = { .desc = {
.name = "db8500-b2r2-mcde", .name = "db8500-b2r2-mcde",
.of_match = of_match_ptr("db8500_b2r2_mcde"),
.id = DB8500_REGULATOR_SWITCH_B2R2_MCDE, .id = DB8500_REGULATOR_SWITCH_B2R2_MCDE,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -371,6 +387,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_ESRAM12] = { [DB8500_REGULATOR_SWITCH_ESRAM12] = {
.desc = { .desc = {
.name = "db8500-esram12", .name = "db8500-esram12",
.of_match = of_match_ptr("db8500_esram12"),
.id = DB8500_REGULATOR_SWITCH_ESRAM12, .id = DB8500_REGULATOR_SWITCH_ESRAM12,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -382,6 +399,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_ESRAM12RET] = { [DB8500_REGULATOR_SWITCH_ESRAM12RET] = {
.desc = { .desc = {
.name = "db8500-esram12-ret", .name = "db8500-esram12-ret",
.of_match = of_match_ptr("db8500_esram12_ret"),
.id = DB8500_REGULATOR_SWITCH_ESRAM12RET, .id = DB8500_REGULATOR_SWITCH_ESRAM12RET,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -393,6 +411,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_ESRAM34] = { [DB8500_REGULATOR_SWITCH_ESRAM34] = {
.desc = { .desc = {
.name = "db8500-esram34", .name = "db8500-esram34",
.of_match = of_match_ptr("db8500_esram34"),
.id = DB8500_REGULATOR_SWITCH_ESRAM34, .id = DB8500_REGULATOR_SWITCH_ESRAM34,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -404,6 +423,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_ESRAM34RET] = { [DB8500_REGULATOR_SWITCH_ESRAM34RET] = {
.desc = { .desc = {
.name = "db8500-esram34-ret", .name = "db8500-esram34-ret",
.of_match = of_match_ptr("db8500_esram34_ret"),
.id = DB8500_REGULATOR_SWITCH_ESRAM34RET, .id = DB8500_REGULATOR_SWITCH_ESRAM34RET,
.ops = &db8500_regulator_switch_ops, .ops = &db8500_regulator_switch_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
@ -414,113 +434,38 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
}, },
}; };
static int db8500_regulator_register(struct platform_device *pdev,
struct regulator_init_data *init_data,
int id,
struct device_node *np)
{
struct dbx500_regulator_info *info;
struct regulator_config config = { };
int err;
/* assign per-regulator data */
info = &dbx500_regulator_info[id];
info->dev = &pdev->dev;
config.dev = &pdev->dev;
config.init_data = init_data;
config.driver_data = info;
config.of_node = np;
/* register with the regulator framework */
info->rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
if (IS_ERR(info->rdev)) {
err = PTR_ERR(info->rdev);
dev_err(&pdev->dev, "failed to register %s: err %i\n",
info->desc.name, err);
return err;
}
dev_dbg(rdev_get_dev(info->rdev),
"regulator-%s-probed\n", info->desc.name);
return 0;
}
static struct of_regulator_match db8500_regulator_matches[] = {
{ .name = "db8500_vape", .driver_data = (void *) DB8500_REGULATOR_VAPE, },
{ .name = "db8500_varm", .driver_data = (void *) DB8500_REGULATOR_VARM, },
{ .name = "db8500_vmodem", .driver_data = (void *) DB8500_REGULATOR_VMODEM, },
{ .name = "db8500_vpll", .driver_data = (void *) DB8500_REGULATOR_VPLL, },
{ .name = "db8500_vsmps1", .driver_data = (void *) DB8500_REGULATOR_VSMPS1, },
{ .name = "db8500_vsmps2", .driver_data = (void *) DB8500_REGULATOR_VSMPS2, },
{ .name = "db8500_vsmps3", .driver_data = (void *) DB8500_REGULATOR_VSMPS3, },
{ .name = "db8500_vrf1", .driver_data = (void *) DB8500_REGULATOR_VRF1, },
{ .name = "db8500_sva_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSP, },
{ .name = "db8500_sva_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSPRET, },
{ .name = "db8500_sva_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAPIPE, },
{ .name = "db8500_sia_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSP, },
{ .name = "db8500_sia_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSPRET, },
{ .name = "db8500_sia_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAPIPE, },
{ .name = "db8500_sga", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SGA, },
{ .name = "db8500_b2r2_mcde", .driver_data = (void *) DB8500_REGULATOR_SWITCH_B2R2_MCDE, },
{ .name = "db8500_esram12", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12, },
{ .name = "db8500_esram12_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12RET, },
{ .name = "db8500_esram34", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34, },
{ .name = "db8500_esram34_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, },
};
static int
db8500_regulator_of_probe(struct platform_device *pdev,
struct device_node *np)
{
int i, err;
for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
err = db8500_regulator_register(
pdev, db8500_regulator_matches[i].init_data,
i, db8500_regulator_matches[i].of_node);
if (err)
return err;
}
return 0;
}
static int db8500_regulator_probe(struct platform_device *pdev) static int db8500_regulator_probe(struct platform_device *pdev)
{ {
struct regulator_init_data *db8500_init_data = struct regulator_init_data *db8500_init_data;
dev_get_platdata(&pdev->dev); struct dbx500_regulator_info *info;
struct device_node *np = pdev->dev.of_node; struct regulator_config config = { };
int i, err; int err, i;
/* register all regulators */ db8500_init_data = dev_get_platdata(&pdev->dev);
if (np) {
err = of_regulator_match(&pdev->dev, np, for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
db8500_regulator_matches, /* assign per-regulator data */
ARRAY_SIZE(db8500_regulator_matches)); info = &dbx500_regulator_info[i];
if (err < 0) { info->dev = &pdev->dev;
dev_err(&pdev->dev,
"Error parsing regulator init data: %d\n", err); config.driver_data = info;
config.dev = &pdev->dev;
if (db8500_init_data)
config.init_data = &db8500_init_data[i];
info->rdev = devm_regulator_register(&pdev->dev, &info->desc,
&config);
if (IS_ERR(info->rdev)) {
err = PTR_ERR(info->rdev);
dev_err(&pdev->dev, "failed to register %s: err %i\n",
info->desc.name, err);
return err; return err;
} }
dev_dbg(&pdev->dev, "regulator-%s-probed\n", info->desc.name);
err = db8500_regulator_of_probe(pdev, np);
if (err)
return err;
} else {
for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
err = db8500_regulator_register(pdev,
&db8500_init_data[i],
i, NULL);
if (err)
return err;
}
} }
err = ux500_regulator_debug_init(pdev, ux500_regulator_debug_init(pdev, dbx500_regulator_info,
dbx500_regulator_info, ARRAY_SIZE(dbx500_regulator_info));
ARRAY_SIZE(dbx500_regulator_info));
return 0; return 0;
} }