Lines Matching refs:beeper

31 static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)  in pwm_beeper_on()  argument
36 pwm_get_state(beeper->pwm, &state); in pwm_beeper_on()
42 error = pwm_apply_might_sleep(beeper->pwm, &state); in pwm_beeper_on()
46 if (!beeper->amplifier_on) { in pwm_beeper_on()
47 error = regulator_enable(beeper->amplifier); in pwm_beeper_on()
49 pwm_disable(beeper->pwm); in pwm_beeper_on()
53 beeper->amplifier_on = true; in pwm_beeper_on()
59 static void pwm_beeper_off(struct pwm_beeper *beeper) in pwm_beeper_off() argument
61 if (beeper->amplifier_on) { in pwm_beeper_off()
62 regulator_disable(beeper->amplifier); in pwm_beeper_off()
63 beeper->amplifier_on = false; in pwm_beeper_off()
66 pwm_disable(beeper->pwm); in pwm_beeper_off()
71 struct pwm_beeper *beeper = container_of(work, struct pwm_beeper, work); in pwm_beeper_work() local
72 unsigned long period = READ_ONCE(beeper->period); in pwm_beeper_work()
75 pwm_beeper_on(beeper, period); in pwm_beeper_work()
77 pwm_beeper_off(beeper); in pwm_beeper_work()
83 struct pwm_beeper *beeper = input_get_drvdata(input); in pwm_beeper_event() local
90 value = value ? beeper->bell_frequency : 0; in pwm_beeper_event()
99 beeper->period = 0; in pwm_beeper_event()
101 beeper->period = HZ_TO_NANOSECONDS(value); in pwm_beeper_event()
103 if (!beeper->suspended) in pwm_beeper_event()
104 schedule_work(&beeper->work); in pwm_beeper_event()
109 static void pwm_beeper_stop(struct pwm_beeper *beeper) in pwm_beeper_stop() argument
111 cancel_work_sync(&beeper->work); in pwm_beeper_stop()
112 pwm_beeper_off(beeper); in pwm_beeper_stop()
117 struct pwm_beeper *beeper = input_get_drvdata(input); in pwm_beeper_close() local
119 pwm_beeper_stop(beeper); in pwm_beeper_close()
125 struct pwm_beeper *beeper; in pwm_beeper_probe() local
130 beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); in pwm_beeper_probe()
131 if (!beeper) in pwm_beeper_probe()
134 beeper->pwm = devm_pwm_get(dev, NULL); in pwm_beeper_probe()
135 if (IS_ERR(beeper->pwm)) in pwm_beeper_probe()
136 return dev_err_probe(dev, PTR_ERR(beeper->pwm), "Failed to request PWM device\n"); in pwm_beeper_probe()
139 pwm_init_state(beeper->pwm, &state); in pwm_beeper_probe()
141 error = pwm_apply_might_sleep(beeper->pwm, &state); in pwm_beeper_probe()
148 beeper->amplifier = devm_regulator_get(dev, "amp"); in pwm_beeper_probe()
149 if (IS_ERR(beeper->amplifier)) in pwm_beeper_probe()
150 return dev_err_probe(dev, PTR_ERR(beeper->amplifier), in pwm_beeper_probe()
153 INIT_WORK(&beeper->work, pwm_beeper_work); in pwm_beeper_probe()
163 beeper->bell_frequency = bell_frequency; in pwm_beeper_probe()
165 beeper->input = devm_input_allocate_device(dev); in pwm_beeper_probe()
166 if (!beeper->input) { in pwm_beeper_probe()
171 beeper->input->name = "pwm-beeper"; in pwm_beeper_probe()
172 beeper->input->phys = "pwm/input0"; in pwm_beeper_probe()
173 beeper->input->id.bustype = BUS_HOST; in pwm_beeper_probe()
174 beeper->input->id.vendor = 0x001f; in pwm_beeper_probe()
175 beeper->input->id.product = 0x0001; in pwm_beeper_probe()
176 beeper->input->id.version = 0x0100; in pwm_beeper_probe()
178 input_set_capability(beeper->input, EV_SND, SND_TONE); in pwm_beeper_probe()
179 input_set_capability(beeper->input, EV_SND, SND_BELL); in pwm_beeper_probe()
181 beeper->input->event = pwm_beeper_event; in pwm_beeper_probe()
182 beeper->input->close = pwm_beeper_close; in pwm_beeper_probe()
184 input_set_drvdata(beeper->input, beeper); in pwm_beeper_probe()
186 error = input_register_device(beeper->input); in pwm_beeper_probe()
192 platform_set_drvdata(pdev, beeper); in pwm_beeper_probe()
199 struct pwm_beeper *beeper = dev_get_drvdata(dev); in pwm_beeper_suspend() local
206 spin_lock_irq(&beeper->input->event_lock); in pwm_beeper_suspend()
207 beeper->suspended = true; in pwm_beeper_suspend()
208 spin_unlock_irq(&beeper->input->event_lock); in pwm_beeper_suspend()
210 pwm_beeper_stop(beeper); in pwm_beeper_suspend()
217 struct pwm_beeper *beeper = dev_get_drvdata(dev); in pwm_beeper_resume() local
219 spin_lock_irq(&beeper->input->event_lock); in pwm_beeper_resume()
220 beeper->suspended = false; in pwm_beeper_resume()
221 spin_unlock_irq(&beeper->input->event_lock); in pwm_beeper_resume()
224 schedule_work(&beeper->work); in pwm_beeper_resume()