diff options
author | Nishanth Menon <nm@ti.com> | 2013-05-01 09:38:12 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-12 08:04:16 -0400 |
commit | fc31d6f55908759530462998d0464a9f124b1c32 (patch) | |
tree | e46590fd7da690fc5f3229975a470e1db4b268e4 /drivers/cpufreq | |
parent | d96038e0fa00f42a5d6711884bef0a725cdc70bb (diff) |
cpufreq: cpufreq-cpu0: defer probe when regulator is not ready
With commit 1e4b545, regulator_get will now return -EPROBE_DEFER
when the cpu0-supply node is present, but the regulator is not yet
registered.
It is possible for this to occur when the regulator registration
by itself might be defered due to some dependent interface not yet
instantiated. For example: an regulator which uses I2C and GPIO might
need both systems available before proceeding, in this case, the
regulator might defer it's registration.
However, the cpufreq-cpu0 driver assumes that any un-successful
return result is equivalent of failure.
When the regulator_get returns failure other than -EPROBE_DEFER, it
makes sense to assume that supply node is not present and proceed
with the assumption that only clock control is necessary in the
platform.
With this change, we can now handle the following conditions:
a) cpu0-supply binding is not present, regulator_get will return
appropriate error result, resulting in cpufreq-cpu0 driver
controlling just the clock.
b) cpu0-supply binding is present, regulator_get returns
-EPROBE_DEFER, we retry resulting in cpufreq-cpu0 driver
registering later once the regulator is available.
c) cpu0-supply binding is present, regulator_get returns
-EPROBE_DEFER, however, regulator never registers, we retry until
cpufreq-cpu0 driver fails to register pointing at device tree
information bug. However, in this case, the fact that
cpufreq-cpu0 operates with clock only when the DT binding clearly
indicates need of a supply is a bug of it's own.
d) cpu0-supply gets an regulator at probe - cpufreq-cpu0 driver
controls both the clock and regulator
Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq-cpu0.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index 3ab8294eab04..ecd8af900432 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
@@ -195,6 +195,22 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
195 | cpu_dev = &pdev->dev; | 195 | cpu_dev = &pdev->dev; |
196 | cpu_dev->of_node = np; | 196 | cpu_dev->of_node = np; |
197 | 197 | ||
198 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); | ||
199 | if (IS_ERR(cpu_reg)) { | ||
200 | /* | ||
201 | * If cpu0 regulator supply node is present, but regulator is | ||
202 | * not yet registered, we should try defering probe. | ||
203 | */ | ||
204 | if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { | ||
205 | dev_err(cpu_dev, "cpu0 regulator not ready, retry\n"); | ||
206 | ret = -EPROBE_DEFER; | ||
207 | goto out_put_node; | ||
208 | } | ||
209 | pr_warn("failed to get cpu0 regulator: %ld\n", | ||
210 | PTR_ERR(cpu_reg)); | ||
211 | cpu_reg = NULL; | ||
212 | } | ||
213 | |||
198 | cpu_clk = devm_clk_get(cpu_dev, NULL); | 214 | cpu_clk = devm_clk_get(cpu_dev, NULL); |
199 | if (IS_ERR(cpu_clk)) { | 215 | if (IS_ERR(cpu_clk)) { |
200 | ret = PTR_ERR(cpu_clk); | 216 | ret = PTR_ERR(cpu_clk); |
@@ -202,12 +218,6 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
202 | goto out_put_node; | 218 | goto out_put_node; |
203 | } | 219 | } |
204 | 220 | ||
205 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); | ||
206 | if (IS_ERR(cpu_reg)) { | ||
207 | pr_warn("failed to get cpu0 regulator\n"); | ||
208 | cpu_reg = NULL; | ||
209 | } | ||
210 | |||
211 | ret = of_init_opp_table(cpu_dev); | 221 | ret = of_init_opp_table(cpu_dev); |
212 | if (ret) { | 222 | if (ret) { |
213 | pr_err("failed to init OPP table: %d\n", ret); | 223 | pr_err("failed to init OPP table: %d\n", ret); |