22 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/errno.h>
26 #include <linux/input.h>
30 #include <linux/sched.h>
31 #include <linux/slab.h>
34 struct input_dev *
pwr;
36 #define MC13783_PWRB_B1_POL_INVERT (1 << 0)
37 #define MC13783_PWRB_B2_POL_INVERT (1 << 1)
38 #define MC13783_PWRB_B3_POL_INVERT (1 << 2)
43 #define MC13783_REG_INTERRUPT_SENSE_1 5
44 #define MC13783_IRQSENSE1_ONOFD1S (1 << 3)
45 #define MC13783_IRQSENSE1_ONOFD2S (1 << 4)
46 #define MC13783_IRQSENSE1_ONOFD3S (1 << 5)
48 #define MC13783_REG_POWER_CONTROL_2 15
49 #define MC13783_POWER_CONTROL_2_ON1BDBNC 4
50 #define MC13783_POWER_CONTROL_2_ON2BDBNC 6
51 #define MC13783_POWER_CONTROL_2_ON3BDBNC 8
52 #define MC13783_POWER_CONTROL_2_ON1BRSTEN (1 << 1)
53 #define MC13783_POWER_CONTROL_2_ON2BRSTEN (1 << 2)
54 #define MC13783_POWER_CONTROL_2_ON3BRSTEN (1 << 3)
69 input_report_key(priv->
pwr, priv->
keymap[0], val);
76 input_report_key(priv->
pwr, priv->
keymap[1], val);
83 input_report_key(priv->
pwr, priv->
keymap[2], val);
87 input_sync(priv->
pwr);
96 struct input_dev *pwr;
101 pdata = dev_get_platdata(&pdev->
dev);
103 dev_err(&pdev->
dev,
"missing platform data\n");
107 pwr = input_allocate_device();
109 dev_dbg(&pdev->
dev,
"Can't allocate power button\n");
116 dev_dbg(&pdev->
dev,
"Can't allocate power button\n");
141 button_irq,
"b1on", priv);
160 button_irq,
"b2on", priv);
179 button_irq,
"b3on", priv);
181 dev_dbg(&pdev->
dev,
"Can't request irq: %d\n", err);
190 pwr->name =
"mc13783_pwrbutton";
191 pwr->phys =
"mc13783_pwrbutton/input0";
192 pwr->dev.parent = &pdev->
dev;
194 pwr->keycode = priv->
keymap;
196 pwr->keycodesize =
sizeof(priv->
keymap[0]);
199 err = input_register_device(pwr);
201 dev_dbg(&pdev->
dev,
"Can't register power button: %d\n", err);
205 platform_set_drvdata(pdev, priv);
228 input_free_device(pwr);
238 pdata = dev_get_platdata(&pdev->
dev);
251 input_unregister_device(priv->
pwr);
253 platform_set_drvdata(pdev,
NULL);
259 .probe = mc13783_pwrbutton_probe,
262 .name =
"mc13783-pwrbutton",