summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keeping <jkeeping@inmusicbrands.com>2024-07-09 10:24:54 +0100
committerTom Rini <trini@konsulko.com>2024-09-05 21:06:17 -0600
commita5d990854f2c67a8e9aa3d9ab3a11b2baff3285c (patch)
treee6a5158d675edb55f30f1faa679966742f195471
parent07c12525bbee102969fe7d2fce21a09f12fa0ae7 (diff)
regulator: fixed: fix regulator-fixed-clock
For regulator-fixed-clock, the device's private data is never set so in fixed_clock_regulator_set_enable() is null and the function cannot complete successfully. Rename the _plat structure to _priv to better represent its role and set this as the private data. As shown by the set_enable() function and by using the same .of_to_plat hook as regulator-fixed, the platform data is regulator_common_plat so also set .plat_auto correctly. Finally, set up the private data by adding a .probe function to look up the clock and set the member variable. Fixes: f3b5100aff3 ("regulator: fixed: add possibility to enable by clock") Signed-off-by: John Keeping <jkeeping@inmusicbrands.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/power/regulator/fixed.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 98c89bf2aff..996da41546a 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -17,7 +17,7 @@
#include "regulator_common.h"
-struct fixed_clock_regulator_plat {
+struct fixed_clock_regulator_priv {
struct clk *enable_clock;
unsigned int clk_enable_counter;
};
@@ -83,14 +83,14 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
static int fixed_clock_regulator_get_enable(struct udevice *dev)
{
- struct fixed_clock_regulator_plat *priv = dev_get_priv(dev);
+ struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
return priv->clk_enable_counter > 0;
}
static int fixed_clock_regulator_set_enable(struct udevice *dev, bool enable)
{
- struct fixed_clock_regulator_plat *priv = dev_get_priv(dev);
+ struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
struct regulator_common_plat *plat = dev_get_plat(dev);
int ret = 0;
@@ -113,6 +113,17 @@ static int fixed_clock_regulator_set_enable(struct udevice *dev, bool enable)
return ret;
}
+static int fixed_clock_regulator_probe(struct udevice *dev)
+{
+ struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
+
+ priv->enable_clock = devm_clk_get(dev, NULL);
+ if (IS_ERR(priv->enable_clock))
+ return PTR_ERR(priv->enable_clock);
+
+ return 0;
+}
+
static const struct dm_regulator_ops fixed_regulator_ops = {
.get_value = fixed_regulator_get_value,
.get_current = fixed_regulator_get_current,
@@ -149,6 +160,8 @@ U_BOOT_DRIVER(regulator_fixed_clock) = {
.id = UCLASS_REGULATOR,
.ops = &fixed_clock_regulator_ops,
.of_match = fixed_clock_regulator_ids,
+ .probe = fixed_clock_regulator_probe,
.of_to_plat = fixed_regulator_of_to_plat,
- .plat_auto = sizeof(struct fixed_clock_regulator_plat),
+ .plat_auto = sizeof(struct regulator_common_plat),
+ .priv_auto = sizeof(struct fixed_clock_regulator_priv),
};