The patch

   regulator: pfuze100: add support to en-/disable switch regulators

has been applied to the regulator tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 9d2fd4f0ddfbc4aa1135000df34caebc02793a26 Mon Sep 17 00:00:00 2001
From: Marco Felsch <m.fel...@pengutronix.de>
Date: Mon, 23 Jul 2018 09:47:47 +0200
Subject: [PATCH] regulator: pfuze100: add support to en-/disable switch
 regulators

Add enable/disable support for switch regulators on pfuze100.

Based on commit 5fe156f1cab4 ("regulator: pfuze100: add enable/disable for
switch") which is reverted due to boot regressions by commit 464a5686e6c9
("regulator: Revert "regulator: pfuze100: add enable/disable for switch"").
Disabling the switch regulators will only be done if the user specifies
"fsl,pfuze-support-disable-sw" in its device tree to keep backward
compatibility with current dtb's [1].

[1] https://patchwork.kernel.org/patch/10490381/

Signed-off-by: Marco Felsch <m.fel...@pengutronix.de>
Signed-off-by: Mark Brown <broo...@kernel.org>
---
 drivers/regulator/pfuze100-regulator.c | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/regulator/pfuze100-regulator.c 
b/drivers/regulator/pfuze100-regulator.c
index cde6eda1d283..31c3a236120a 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/regmap.h>
 
+#define PFUZE_FLAG_DISABLE_SW  BIT(1)
+
 #define PFUZE_NUMREGS          128
 #define PFUZE100_VOL_OFFSET    0
 #define PFUZE100_STANDBY_OFFSET        1
@@ -50,10 +52,12 @@ struct pfuze_regulator {
        struct regulator_desc desc;
        unsigned char stby_reg;
        unsigned char stby_mask;
+       bool sw_reg;
 };
 
 struct pfuze_chip {
        int     chip_id;
+       int     flags;
        struct regmap *regmap;
        struct device *dev;
        struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
@@ -170,6 +174,17 @@ static const struct regulator_ops 
pfuze100_sw_regulator_ops = {
        .set_ramp_delay = pfuze100_set_ramp_delay,
 };
 
+static const struct regulator_ops pfuze100_sw_disable_regulator_ops = {
+       .enable = regulator_enable_regmap,
+       .disable = regulator_disable_regmap,
+       .is_enabled = regulator_is_enabled_regmap,
+       .list_voltage = regulator_list_voltage_linear,
+       .set_voltage_sel = regulator_set_voltage_sel_regmap,
+       .get_voltage_sel = regulator_get_voltage_sel_regmap,
+       .set_voltage_time_sel = regulator_set_voltage_time_sel,
+       .set_ramp_delay = pfuze100_set_ramp_delay,
+};
+
 static const struct regulator_ops pfuze100_swb_regulator_ops = {
        .enable = regulator_enable_regmap,
        .disable = regulator_disable_regmap,
@@ -209,9 +224,12 @@ static const struct regulator_ops 
pfuze100_swb_regulator_ops = {
                        .uV_step = (step),      \
                        .vsel_reg = (base) + PFUZE100_VOL_OFFSET,       \
                        .vsel_mask = 0x3f,      \
+                       .enable_reg = (base) + PFUZE100_MODE_OFFSET,    \
+                       .enable_mask = 0xf,     \
                },      \
                .stby_reg = (base) + PFUZE100_STANDBY_OFFSET,   \
                .stby_mask = 0x3f,      \
+               .sw_reg = true,         \
        }
 
 #define PFUZE100_SWB_REG(_chip, _name, base, mask, voltages)   \
@@ -471,6 +489,9 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip 
*chip)
        if (!np)
                return -EINVAL;
 
+       if (of_property_read_bool(np, "fsl,pfuze-support-disable-sw"))
+               chip->flags |= PFUZE_FLAG_DISABLE_SW;
+
        parent = of_get_child_by_name(np, "regulators");
        if (!parent) {
                dev_err(dev, "regulators node not found\n");
@@ -703,6 +724,21 @@ static int pfuze100_regulator_probe(struct i2c_client 
*client,
                        }
                }
 
+               /*
+                * Allow SW regulators to turn off. Checking it trough a flag is
+                * a workaround to keep the backward compatibility with existing
+                * old dtb's which may relay on the fact that we didn't disable
+                * the switched regulator till yet.
+                */
+               if (pfuze_chip->flags & PFUZE_FLAG_DISABLE_SW) {
+                       if (pfuze_chip->regulator_descs[i].sw_reg) {
+                               desc->ops = &pfuze100_sw_disable_regulator_ops;
+                               desc->enable_val = 0x8;
+                               desc->disable_val = 0x0;
+                               desc->enable_time = 500;
+                       }
+               }
+
                config.dev = &client->dev;
                config.init_data = init_data;
                config.driver_data = pfuze_chip;
-- 
2.18.0

Reply via email to