ar71xx: add support for TL-WR740N v1
[openwrt.git] / target / linux / omap24xx / patches-2.6.37 / 310-n8x0-gpioswitch-input.patch
1 ---
2 arch/arm/mach-omap2/board-n8x0.c | 73 +++++++++++++++++++++++++++++++++++++++
3 1 file changed, 73 insertions(+)
4
5 Index: linux-2.6.37-rc1/arch/arm/mach-omap2/board-n8x0.c
6 ===================================================================
7 --- linux-2.6.37-rc1.orig/arch/arm/mach-omap2/board-n8x0.c 2010-11-05 17:03:59.354999895 +0100
8 +++ linux-2.6.37-rc1/arch/arm/mach-omap2/board-n8x0.c 2010-11-05 17:04:41.040001926 +0100
9 @@ -794,6 +794,77 @@
10
11 extern void n8x0_usb_init(void);
12
13 +struct gpio_switch_input_dev {
14 + struct input_dev *idev;
15 + unsigned int swcode;
16 +};
17 +
18 +static struct gpio_switch_input_dev *slide_input;
19 +static struct gpio_switch_input_dev *kblock_input;
20 +
21 +static void n8x0_gpio_switch_input_notify(struct gpio_switch_input_dev *gdev,
22 + int state)
23 +{
24 + if (gdev) {
25 + input_report_switch(gdev->idev, gdev->swcode, state);
26 + input_sync(gdev->idev);
27 + }
28 +}
29 +
30 +static void n8x0_slide_notify(void *data, int state)
31 +{
32 + n8x0_gpio_switch_input_notify(slide_input, state);
33 +}
34 +
35 +static void n8x0_kb_lock_notify(void *data, int state)
36 +{
37 + n8x0_gpio_switch_input_notify(kblock_input, state);
38 +}
39 +
40 +static struct gpio_switch_input_dev * __init gpioswitch_input_init(
41 + const char *name,
42 + unsigned int swcode)
43 +{
44 + struct gpio_switch_input_dev *gdev;
45 + int err;
46 +
47 + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
48 + if (!gdev)
49 + goto error;
50 + gdev->swcode = swcode;
51 +
52 + gdev->idev = input_allocate_device();
53 + if (!gdev->idev)
54 + goto err_free;
55 +
56 + gdev->idev->evbit[0] = BIT_MASK(EV_SW);
57 + gdev->idev->swbit[BIT_WORD(swcode)] = BIT_MASK(swcode);
58 + gdev->idev->name = name;
59 +
60 + err = input_register_device(gdev->idev);
61 + if (err)
62 + goto err_free_idev;
63 +
64 + return gdev;
65 +
66 +err_free_idev:
67 + input_free_device(gdev->idev);
68 +err_free:
69 + kfree(gdev);
70 +error:
71 + return NULL;
72 +}
73 +
74 +static int __init n8x0_gpio_switches_input_init(void)
75 +{
76 + slide_input = gpioswitch_input_init("slide", SW_KEYPAD_SLIDE);
77 + kblock_input = gpioswitch_input_init("kb_lock", SW_LID);
78 + if (WARN_ON(!slide_input || !kblock_input))
79 + return -ENODEV;
80 + return 0;
81 +}
82 +late_initcall(n8x0_gpio_switches_input_init);
83 +
84 static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = {
85 {
86 .name = "headphone",
87 @@ -815,11 +886,13 @@
88 .gpio = -1,
89 .debounce_rising = 200,
90 .debounce_falling = 200,
91 + .notify = n8x0_slide_notify,
92 }, {
93 .name = "kb_lock",
94 .gpio = -1,
95 .debounce_rising = 200,
96 .debounce_falling = 200,
97 + .notify = n8x0_kb_lock_notify,
98 },
99 };
100
This page took 0.049543 seconds and 5 git commands to generate.