]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pwm: bcm2835: Make sure the channel is enabled after pwm_request()
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Tue, 18 Nov 2025 17:43:02 +0000 (18:43 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:31 +0000 (13:09 +0100)
[ Upstream commit cda323dbda76600bf9761970d58517648f0de67d ]

The .free callback cleared among others the enable bit PWENx in the
control register. When the PWM is requested later again this bit isn't
restored but the core assumes the PWM is enabled and thus skips a
request to configure the same state as before.

To fix that don't touch the hardware configuration in .free(). For
symmetry also drop .request() and configure the mode completely in
.apply().

Fixes: e5a06dc5ac1f ("pwm: Add BCM2835 PWM driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251118174303.1761577-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pwm/pwm-bcm2835.c

index 50b8594be31d829fc991c7345aeca3e9d4927886..4541d63d57c40b04a0dbff03a8c42621a32a59e6 100644 (file)
@@ -35,29 +35,6 @@ static inline struct bcm2835_pwm *to_bcm2835_pwm(struct pwm_chip *chip)
        return container_of(chip, struct bcm2835_pwm, chip);
 }
 
-static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-       struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
-       u32 value;
-
-       value = readl(pc->base + PWM_CONTROL);
-       value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
-       value |= (PWM_MODE << PWM_CONTROL_SHIFT(pwm->hwpwm));
-       writel(value, pc->base + PWM_CONTROL);
-
-       return 0;
-}
-
-static void bcm2835_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-       struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
-       u32 value;
-
-       value = readl(pc->base + PWM_CONTROL);
-       value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
-       writel(value, pc->base + PWM_CONTROL);
-}
-
 static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                             const struct pwm_state *state)
 {
@@ -109,6 +86,9 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
        /* set polarity */
        val = readl(pc->base + PWM_CONTROL);
 
+       val &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
+       val |= PWM_MODE << PWM_CONTROL_SHIFT(pwm->hwpwm);
+
        if (state->polarity == PWM_POLARITY_NORMAL)
                val &= ~(PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm));
        else
@@ -126,8 +106,6 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 }
 
 static const struct pwm_ops bcm2835_pwm_ops = {
-       .request = bcm2835_pwm_request,
-       .free = bcm2835_pwm_free,
        .apply = bcm2835_pwm_apply,
        .owner = THIS_MODULE,
 };