8 #include <linux/module.h>
14 #include <linux/input.h>
15 #include <linux/slab.h>
20 static const u16 per_cnt[] = {
39 static void report_key_event(
struct input_dev *
input,
int keycode)
42 input_report_key(input, keycode, 1);
44 input_report_key(input, keycode, 0);
48 static void report_rotary_event(
struct bfin_rot *rotary,
int delta)
53 report_key_event(input,
56 input_report_rel(input, rotary->
rel_code, delta);
64 struct bfin_rot *rotary = platform_get_drvdata(pdev);
76 report_rotary_event(rotary, delta);
97 struct input_dev *
input;
108 dev_err(&pdev->
dev,
"requesting peripherals failed\n");
113 input = input_allocate_device();
114 if (!rotary || !input) {
130 input->name = pdev->
name;
131 input->phys =
"bfin-rotary/input0";
132 input->dev.parent = &pdev->
dev;
134 input_set_drvdata(input, rotary);
137 input->id.vendor = 0x0001;
138 input->id.product = 0x0001;
139 input->id.version = 0x0100;
156 0, dev_name(&pdev->
dev), pdev);
159 "unable to claim irq %d; error %d\n",
164 error = input_register_device(input);
167 "unable to register input device (%d)\n", error);
184 platform_set_drvdata(pdev, rotary);
192 input_free_device(input);
201 struct bfin_rot *rotary = platform_get_drvdata(pdev);
207 input_unregister_device(rotary->
input);
211 platform_set_drvdata(pdev,
NULL);
217 static int bfin_rotary_suspend(
struct device *
dev)
220 struct bfin_rot *rotary = platform_get_drvdata(pdev);
226 if (device_may_wakeup(&pdev->
dev))
227 enable_irq_wake(rotary->
irq);
232 static int bfin_rotary_resume(
struct device *dev)
235 struct bfin_rot *rotary = platform_get_drvdata(pdev);
241 if (device_may_wakeup(&pdev->
dev))
242 disable_irq_wake(rotary->
irq);
250 static const struct dev_pm_ops bfin_rotary_pm_ops = {
251 .
suspend = bfin_rotary_suspend,
252 .resume = bfin_rotary_resume,
257 .probe = bfin_rotary_probe,
260 .name =
"bfin-rotary",
263 .pm = &bfin_rotary_pm_ops,