@@ -33,6 +33,7 @@
struct fixed_voltage_data {
struct regulator_desc desc;
struct regulator_dev *dev;
+ struct notifier_block nb;
struct clk *enable_clock;
unsigned int enable_counter;
@@ -105,6 +106,39 @@ static int reg_is_enabled(struct regulator_dev *rdev)
return priv->enable_counter > 0;
}
+static int reg_fixed_regulator_notifier(struct notifier_block *nb,
+ unsigned long event, void *data)
+{
+ struct fixed_voltage_data *priv =
+ container_of(nb, struct fixed_voltage_data, nb);
+ struct regulator_dev *rdev = priv->dev;
+
+ if (event != REGULATOR_EVENT_UNDER_VOLTAGE_WARN &&
+ event != REGULATOR_EVENT_UNDER_VOLTAGE)
+ return NOTIFY_OK;
+
+ regulator_notifier_call_chain(rdev, event, NULL);
+
+ return NOTIFY_OK;
+}
+
+static int reg_fixed_register_reg_notifier(struct fixed_voltage_data *priv,
+ struct device *dev)
+{
+ struct regulator_dev *rdev = priv->dev;
+ int ret;
+
+ if (!rdev->supply)
+ return 0;
+
+ priv->nb.notifier_call = reg_fixed_regulator_notifier;
+ ret = devm_regulator_register_notifier(rdev->supply, &priv->nb);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to register notifier\n");
+
+ return 0;
+}
+
static irqreturn_t reg_fixed_under_voltage_irq_handler(int irq, void *data)
{
struct fixed_voltage_data *priv = data;
@@ -327,7 +361,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
if (ret)
return ret;
- return 0;
+ return reg_fixed_register_reg_notifier(drvdata, dev);
}
#if defined(CONFIG_OF)
Add handler to forward under-voltage events. On systems for more or less complicated regulator chains we need to forward under-voltage events to actual driver which need to react on them. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> --- drivers/regulator/fixed.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)