A few dozen steps closer to a working frame buffer.
[linux-on-qualcomm-s-msm:experimental-linux-msm-lg-incite.git] / arch / arm / mach-msm / msm-gpio-keys.c
1 /* linux/arch/arm/mach-msm/gpio-keys.c
2  *
3  * Copyright (C) 2009 HUSSON Pierre-Hugues <phhusson@free.fr>
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20
21 #include <asm/mach-types.h>
22 #include <mach/gpio.h>
23 #include <mach/io.h>
24 #include <linux/delay.h>
25 #include <linux/gpio_keys.h>
26
27 #define MODULE_NAME "msm_gpio_keys"
28 #ifdef CONFIG_ANDROID_PMEM
29 #define PWRK    KEY_HOME
30 #else
31 #define PWRK    KEY_POWER
32 #endif
33
34 //add incite
35
36 static struct gpio_keys_button lgincite_button_table[] = {
37         /*KEY                   GPIO    ACTIVE_LOW DESCRIPTION          type            wakeup  debounce*/
38         {KEY_VOLUMEUP,          246,            1, "Volume Up",         EV_KEY,         0,      0},
39         {KEY_VOLUMEDOWN,        245,            1, "Volume Down",       EV_KEY,         0,      0},
40         {KEY_PHONE,             244,            1, "Call Button",       EV_KEY,         0,      0},
41         {KEY_SCREENLOCK,        242,            1, "Lock button",       EV_KEY,         0,      0},
42         {PWRK,                  83,             1, "Power button",      EV_KEY,         1,      0},
43 };
44
45
46 static struct gpio_keys_button blackstone_button_table[] = {
47         /*KEY                   GPIO    ACTIVE_LOW DESCRIPTION          type            wakeup  debounce*/
48         {KEY_VOLUMEUP,          39,             1, "Volume Up",         EV_KEY,         0,      0},
49         {KEY_VOLUMEDOWN,        40,             1, "Volume Down",       EV_KEY,         0,      0},
50         {PWRK,                  83,             1, "Power button",      EV_KEY,         1,      0},
51 };
52
53 static struct gpio_keys_button raph_button_table[] = {
54         /*KEY                   GPIO    ACTIVE_LOW DESCRIPTION          type            wakeup  debounce*/
55         {PWRK,                  83,             1, "Power button",      EV_KEY,         1,      0},
56 };
57
58 static struct gpio_keys_button topaz_button_table[] = {
59         /*KEY                   GPIO    ACTIVE_LOW DESCRIPTION          type            wakeup  debounce*/
60         {PWRK,                  83,             1, "Power button",      EV_KEY,         1,      0},
61 };
62
63 static struct gpio_keys_button rhodium_button_table[] = {
64         /*KEY                   GPIO    ACTIVE_LOW DESCRIPTION          type            wakeup  debounce*/
65         {PWRK,                  83,             0, "Power button",      EV_KEY,         1,      0},
66         {KEY_UP,                39,             0, "Up button",         EV_KEY,         0,      0},
67         {KEY_DOWN,              40,             0, "Down button",       EV_KEY,         0,      0},
68 };
69
70 static struct gpio_keys_platform_data gpio_keys_data;
71
72 static struct platform_device gpio_keys = {
73         .name = "gpio-keys",
74         .dev  = {
75                 .platform_data = &gpio_keys_data,
76         },
77         .id   = -1,
78 };
79
80 static struct platform_device *devices[] __initdata = {
81         &gpio_keys,
82 };
83
84 static void __init msm_gpio_keys_init(void) {
85         if(machine_is_lgeincitephone()) {
86                 gpio_keys_data.buttons=lgincite_button_table;
87                 gpio_keys_data.nbuttons=ARRAY_SIZE(lgincite_button_table);
88         } else if(machine_is_htcblackstone()) {
89                 gpio_keys_data.buttons=blackstone_button_table;
90                 gpio_keys_data.nbuttons=ARRAY_SIZE(blackstone_button_table);
91         } else if(machine_is_htcraphael() || machine_is_htcraphael_cdma() || machine_is_htcraphael_cdma500() ||
92                         machine_is_htcdiamond() || machine_is_htcdiamond_cdma()) {
93                 gpio_keys_data.buttons=raph_button_table;
94                 gpio_keys_data.nbuttons=ARRAY_SIZE(raph_button_table);
95         } else if(machine_is_htctopaz()) {
96                 gpio_keys_data.buttons=topaz_button_table;
97                 gpio_keys_data.nbuttons=ARRAY_SIZE(topaz_button_table);
98         } else if(machine_is_htcrhodium()) {
99                 gpio_keys_data.buttons=rhodium_button_table;
100                 gpio_keys_data.nbuttons=ARRAY_SIZE(rhodium_button_table);
101         } else {
102                 printk(KERN_INFO "Callled msm_gpio_keys on unsupported device!");
103                 return;
104         }
105         platform_add_devices(devices, ARRAY_SIZE(devices));
106
107 }
108
109 module_init(msm_gpio_keys_init);
110
111 MODULE_DESCRIPTION("MSM WinCE gpio keys driver");
112 MODULE_AUTHOR("HUSSON Pierre-Hugues <phhusson@free.fr>");
113 MODULE_LICENSE("GPL");