]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: adp5585: Enable oscillator during probe
authorNuno Sá <nuno.sa@analog.com>
Tue, 1 Jul 2025 14:31:58 +0000 (15:31 +0100)
committerLee Jones <lee@kernel.org>
Tue, 1 Jul 2025 20:50:50 +0000 (21:50 +0100)
Make sure to enable the oscillator in the top device. This will allow to
not control this in the child PWM device as that would not work with
future support for keyboard matrix where the oscillator needs to be
always enabled (and so cannot be disabled by disabling PWM).

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-3-b1fcfe9e9826@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/adp5585.c
drivers/pwm/pwm-adp5585.c

index 53a46734f2d022ec54b3efc2ebbf389357f8d85a..e4a75ae9b2696d5ca8dfe7882660ed08bcd5ba2d 100644 (file)
@@ -137,6 +137,13 @@ static int adp5585_add_devices(struct device *dev)
        return 0;
 }
 
+static void adp5585_osc_disable(void *data)
+{
+       const struct adp5585_dev *adp5585 = data;
+
+       regmap_write(adp5585->regmap, ADP5585_GENERAL_CFG, 0);
+}
+
 static int adp5585_i2c_probe(struct i2c_client *i2c)
 {
        const struct regmap_config *regmap_config;
@@ -165,6 +172,18 @@ static int adp5585_i2c_probe(struct i2c_client *i2c)
                return dev_err_probe(&i2c->dev, -ENODEV,
                                     "Invalid device ID 0x%02x\n", id);
 
+       /*
+        * Enable the internal oscillator, as it's shared between multiple
+        * functions.
+        */
+       ret = regmap_set_bits(adp5585->regmap, ADP5585_GENERAL_CFG, ADP5585_OSC_EN);
+       if (ret)
+               return ret;
+
+       ret = devm_add_action_or_reset(&i2c->dev, adp5585_osc_disable, adp5585);
+       if (ret)
+               return ret;
+
        return adp5585_add_devices(&i2c->dev);
 }
 
index d79106d121810595b605ea185c34bd9778f974af..add36bc7d2216c9f06cb8801192b10318c748186 100644 (file)
@@ -63,7 +63,6 @@ static int pwm_adp5585_apply(struct pwm_chip *chip,
        int ret;
 
        if (!state->enabled) {
-               regmap_clear_bits(regmap, ADP5585_GENERAL_CFG, ADP5585_OSC_EN);
                regmap_clear_bits(regmap, ADP5585_PWM_CFG, ADP5585_PWM_EN);
                return 0;
        }
@@ -101,10 +100,6 @@ static int pwm_adp5585_apply(struct pwm_chip *chip,
        if (ret)
                return ret;
 
-       ret = regmap_set_bits(regmap, ADP5585_GENERAL_CFG, ADP5585_OSC_EN);
-       if (ret)
-               return ret;
-
        return regmap_set_bits(regmap, ADP5585_PWM_CFG, ADP5585_PWM_EN);
 }