16 #include <linux/input.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
21 #include <linux/slab.h>
29 #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x))
31 static int pwm_beeper_event(
struct input_dev *
input,
35 struct pwm_beeper *beeper = input_get_drvdata(input);
38 if (type !=
EV_SND || value < 0)
43 value = value ? 1000 : 0;
70 unsigned long pwm_id = (
unsigned long)pdev->
dev.platform_data;
80 if (IS_ERR(beeper->pwm)) {
81 error = PTR_ERR(beeper->pwm);
86 beeper->input = input_allocate_device();
88 dev_err(&pdev->
dev,
"Failed to allocate input device\n");
92 beeper->input->dev.parent = &pdev->
dev;
94 beeper->input->name =
"pwm-beeper";
95 beeper->input->phys =
"pwm/input0";
96 beeper->input->id.bustype =
BUS_HOST;
97 beeper->input->id.vendor = 0x001f;
98 beeper->input->id.product = 0x0001;
99 beeper->input->id.version = 0x0100;
104 beeper->input->event = pwm_beeper_event;
106 input_set_drvdata(beeper->input, beeper);
108 error = input_register_device(beeper->input);
114 platform_set_drvdata(pdev, beeper);
119 input_free_device(beeper->input);
130 struct pwm_beeper *beeper = platform_get_drvdata(pdev);
132 platform_set_drvdata(pdev,
NULL);
133 input_unregister_device(beeper->
input);
144 static int pwm_beeper_suspend(
struct device *
dev)
154 static int pwm_beeper_resume(
struct device *dev)
167 pwm_beeper_suspend, pwm_beeper_resume);
169 #define PWM_BEEPER_PM_OPS (&pwm_beeper_pm_ops)
171 #define PWM_BEEPER_PM_OPS NULL
175 .probe = pwm_beeper_probe,
178 .name =
"pwm-beeper",