diff options
Diffstat (limited to 'arch/arm/mach-tegra/board-kai-kbc.c')
-rw-r--r-- | arch/arm/mach-tegra/board-kai-kbc.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-kai-kbc.c b/arch/arm/mach-tegra/board-kai-kbc.c new file mode 100644 index 00000000000..5c528640279 --- /dev/null +++ b/arch/arm/mach-tegra/board-kai-kbc.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/board-kai-kbc.c | ||
3 | * Keys configuration for Nvidia tegra3 kai platform. | ||
4 | * | ||
5 | * Copyright (C) 2012 NVIDIA, Inc. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
19 | * 02111-1307, USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/input.h> | ||
25 | #include <linux/device.h> | ||
26 | #include <linux/gpio.h> | ||
27 | #include <linux/gpio_keys.h> | ||
28 | #include <linux/mfd/max77663-core.h> | ||
29 | #include <linux/gpio_scrollwheel.h> | ||
30 | |||
31 | #include <mach/irqs.h> | ||
32 | #include <mach/io.h> | ||
33 | #include <mach/iomap.h> | ||
34 | #include <mach/kbc.h> | ||
35 | #include "board.h" | ||
36 | #include "board-kai.h" | ||
37 | |||
38 | #include "gpio-names.h" | ||
39 | #include "devices.h" | ||
40 | |||
41 | #define GPIO_KEY(_id, _gpio, _iswake) \ | ||
42 | { \ | ||
43 | .code = _id, \ | ||
44 | .gpio = TEGRA_GPIO_##_gpio, \ | ||
45 | .active_low = 1, \ | ||
46 | .desc = #_id, \ | ||
47 | .type = EV_KEY, \ | ||
48 | .wakeup = _iswake, \ | ||
49 | .debounce_interval = 10, \ | ||
50 | } | ||
51 | |||
52 | #define GPIO_IKEY(_id, _irq, _iswake, _deb) \ | ||
53 | { \ | ||
54 | .code = _id, \ | ||
55 | .gpio = -1, \ | ||
56 | .irq = _irq, \ | ||
57 | .desc = #_id, \ | ||
58 | .type = EV_KEY, \ | ||
59 | .wakeup = _iswake, \ | ||
60 | .debounce_interval = _deb, \ | ||
61 | } | ||
62 | |||
63 | static struct gpio_keys_button kai_keys[] = { | ||
64 | [0] = GPIO_KEY(KEY_MENU, PR2, 0), | ||
65 | [1] = GPIO_KEY(KEY_BACK, PQ1, 0), | ||
66 | [2] = GPIO_KEY(KEY_HOME, PQ0, 0), | ||
67 | [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0), | ||
68 | [4] = GPIO_KEY(KEY_VOLUMEUP, PR1, 0), | ||
69 | [5] = GPIO_KEY(KEY_VOLUMEDOWN, PR0, 0), | ||
70 | [6] = GPIO_IKEY(KEY_POWER, MAX77663_IRQ_BASE + MAX77663_IRQ_ONOFF_EN0_FALLING, 1, 100), | ||
71 | [7] = GPIO_IKEY(KEY_POWER, MAX77663_IRQ_BASE + MAX77663_IRQ_ONOFF_EN0_1SEC, 1, 3000), | ||
72 | }; | ||
73 | |||
74 | static struct gpio_keys_platform_data kai_keys_platform_data = { | ||
75 | .buttons = kai_keys, | ||
76 | .nbuttons = ARRAY_SIZE(kai_keys), | ||
77 | }; | ||
78 | |||
79 | static struct platform_device kai_keys_device = { | ||
80 | .name = "gpio-keys", | ||
81 | .id = 0, | ||
82 | .dev = { | ||
83 | .platform_data = &kai_keys_platform_data, | ||
84 | }, | ||
85 | }; | ||
86 | |||
87 | int __init kai_keys_init(void) | ||
88 | { | ||
89 | int i; | ||
90 | |||
91 | pr_info("Registering gpio keys\n"); | ||
92 | |||
93 | /* Enable gpio mode for other pins */ | ||
94 | for (i = 0; i < kai_keys_platform_data.nbuttons; i++) { | ||
95 | if (kai_keys_platform_data.buttons[i].gpio < 0) | ||
96 | continue; | ||
97 | tegra_gpio_enable(kai_keys_platform_data.buttons[i].gpio); | ||
98 | } | ||
99 | |||
100 | platform_device_register(&kai_keys_device); | ||
101 | |||
102 | return 0; | ||
103 | } | ||