From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: linux-kernel@vger.kernel.org
Cc: Tony Lindgren <tony@atomide.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
j-keerthy@ti.com, linux-omap@vger.kernel.org
Subject: [PATCH v2 2/2] regulator: tps65910: Allow supply references to the same chip
Date: Tue, 13 Jun 2017 16:41:58 +0200 [thread overview]
Message-ID: <053529c206a2afc453b52e2c0f024acd85341a83.1497364762.git.mirq-linux@rere.qmqm.pl> (raw)
In-Reply-To: <f2aee03834d8cdcc7195b9272982617d93f978dc.1497364762.git.mirq-linux@rere.qmqm.pl>
This allows for (acyclic) references from tps6591x supplies to
its outputs.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2:
- no changes
drivers/regulator/tps65910-regulator.c | 39 ++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 81672a58fcc23..f7987168ba4ed 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1082,7 +1082,8 @@ static int tps65910_probe(struct platform_device *pdev)
struct tps65910_reg *pmic;
struct tps65910_board *pmic_plat_data;
struct of_regulator_match *tps65910_reg_matches = NULL;
- int i, err;
+ bool made_progress;
+ int i, err, pending;
pmic_plat_data = dev_get_platdata(tps65910->dev);
if (!pmic_plat_data && tps65910->dev->of_node)
@@ -1146,6 +1147,7 @@ static int tps65910_probe(struct platform_device *pdev)
if (!pmic->rdev)
return -ENOMEM;
+ /* prepare regulator description */
for (i = 0; i < pmic->num_regulators; i++, info++) {
/* Register the regulators */
pmic->info[i] = info;
@@ -1196,18 +1198,32 @@ static int tps65910_probe(struct platform_device *pdev)
pmic->desc[i].owner = THIS_MODULE;
pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i);
pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
+ }
+
+ /* Register regulators - loop, as one regulator's output
+ * might be anothers input */
+
+ config.dev = pmic->mfd->dev;
+ config.driver_data = pmic;
+ config.regmap = pmic->mfd->regmap;
+ pending = pmic->num_regulators;
+
+reg_retry:
+ made_progress = false;
+ for (i = 0; i < pmic->num_regulators; i++) {
+ if (pmic->rdev[i])
+ continue;
- config.dev = tps65910->dev;
config.init_data = pmic_plat_data->tps65910_pmic_init_data[i];
- config.driver_data = pmic;
- config.regmap = tps65910->regmap;
-
if (tps65910_reg_matches)
config.of_node = tps65910_reg_matches[i].of_node;
rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i],
&config);
if (IS_ERR(rdev)) {
+ if (PTR_ERR(rdev) == -EPROBE_DEFER)
+ continue;
+
dev_err(tps65910->dev,
"failed to register %s regulator\n",
pdev->name);
@@ -1216,8 +1232,19 @@ static int tps65910_probe(struct platform_device *pdev)
/* Save regulator for cleanup */
pmic->rdev[i] = rdev;
+
+ made_progress = true;
+ --pending;
}
- return 0;
+
+ /* all done? */
+ if (!pending)
+ return 0;
+
+ if (made_progress)
+ goto reg_retry;
+
+ return -EPROBE_DEFER;
}
static void tps65910_shutdown(struct platform_device *pdev)
--
2.11.0
next prev parent reply other threads:[~2017-06-13 14:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 13:58 [PATCH 1/2] regulator: tps65910: check TPS65910_NUM_REGS at build time Michał Mirosław
2017-06-13 13:58 ` [PATCH 2/2] regulator: tps65910: Allow supply references to the same chip Michał Mirosław
2017-06-13 14:01 ` [PATCH 1/2] regulator: tps65910: check TPS65910_NUM_REGS at build time Keerthy
2017-06-13 14:35 ` Michał Mirosław
2017-06-13 14:41 ` [PATCH v2 " Michał Mirosław
2017-06-13 14:41 ` Michał Mirosław [this message]
2017-06-13 17:46 ` [PATCH v2 2/2] regulator: tps65910: Allow supply references to the same chip Mark Brown
2017-06-13 20:22 ` Michał Mirosław
2017-06-13 20:42 ` Mark Brown
2017-06-14 7:56 ` Javier Martinez Canillas
2017-06-14 12:14 ` Michał Mirosław
2017-06-13 17:44 ` [PATCH v2 1/2] regulator: tps65910: check TPS65910_NUM_REGS at build time Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=053529c206a2afc453b52e2c0f024acd85341a83.1497364762.git.mirq-linux@rere.qmqm.pl \
--to=mirq-linux@rere.qmqm.pl \
--cc=broonie@kernel.org \
--cc=j-keerthy@ti.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).