Skip to content

Commit cda323d

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: bcm2835: Make sure the channel is enabled after pwm_request()
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: e5a06dc ("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>
1 parent a5d51e0 commit cda323d

1 file changed

Lines changed: 3 additions & 25 deletions

File tree

drivers/pwm/pwm-bcm2835.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,6 @@ static inline struct bcm2835_pwm *to_bcm2835_pwm(struct pwm_chip *chip)
3434
return pwmchip_get_drvdata(chip);
3535
}
3636

37-
static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
38-
{
39-
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
40-
u32 value;
41-
42-
value = readl(pc->base + PWM_CONTROL);
43-
value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
44-
value |= (PWM_MODE << PWM_CONTROL_SHIFT(pwm->hwpwm));
45-
writel(value, pc->base + PWM_CONTROL);
46-
47-
return 0;
48-
}
49-
50-
static void bcm2835_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
51-
{
52-
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
53-
u32 value;
54-
55-
value = readl(pc->base + PWM_CONTROL);
56-
value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
57-
writel(value, pc->base + PWM_CONTROL);
58-
}
59-
6037
static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
6138
const struct pwm_state *state)
6239
{
@@ -102,6 +79,9 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
10279
/* set polarity */
10380
val = readl(pc->base + PWM_CONTROL);
10481

82+
val &= ~(PWM_CONTROL_MASK << PWM_CONTROL_SHIFT(pwm->hwpwm));
83+
val |= PWM_MODE << PWM_CONTROL_SHIFT(pwm->hwpwm);
84+
10585
if (state->polarity == PWM_POLARITY_NORMAL)
10686
val &= ~(PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm));
10787
else
@@ -119,8 +99,6 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
11999
}
120100

121101
static const struct pwm_ops bcm2835_pwm_ops = {
122-
.request = bcm2835_pwm_request,
123-
.free = bcm2835_pwm_free,
124102
.apply = bcm2835_pwm_apply,
125103
};
126104

0 commit comments

Comments
 (0)