Skip to content

Commit eaace6d

Browse files
Robert Delienraysiudak
Robert Delien
authored andcommitted
PWM beeper forcing PWM to inactive statr
When disabling, some PWM hardware IP leaves the pin in the state it happens to be in at that very moment. To make sure it is in the inactive state, the duty cycle is now set to 0 first, before PWM is being disabled. Solves: EMP-628
1 parent 9d3942c commit eaace6d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/input/misc/pwm-beeper.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@ static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)
6767

6868
static void pwm_beeper_off(struct pwm_beeper *beeper)
6969
{
70+
struct pwm_state state;
71+
7072
if (beeper->amplifier_on) {
7173
regulator_disable(beeper->amplifier);
7274
beeper->amplifier_on = false;
7375
}
7476

77+
/*
78+
* When disabling, some PWM hardware IP leaves the pin in the state it
79+
* happens to be in. To make sure it is in the inactive state, set the
80+
* duty cycle to 0 first.
81+
*/
82+
pwm_get_state(beeper->pwm, &state);
83+
state.duty_cycle = 0;
84+
pwm_apply_state(beeper->pwm, &state);
85+
7586
pwm_disable(beeper->pwm);
7687
}
7788

0 commit comments

Comments
 (0)