2 * arch/arm/mach-tegra/board-cardhu-kbc.c
3 * Keys configuration for Nvidia tegra3 cardhu platform.
5 * Copyright (C) 2011 NVIDIA, Inc.
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.
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.
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
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/gpio_scrollwheel.h>
30 #include <mach/irqs.h>
32 #include <mach/iomap.h>
35 #include "board-cardhu.h"
37 #include "gpio-names.h"
39 #ifdef CONFIG_KEYBOARD_TEGRA
40 #ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL
41 #define CARDHU_ROW_COUNT 3
42 #define CARDHU_COL_COUNT 2
44 #define CARDHU_ROW_COUNT 4
45 #define CARDHU_COL_COUNT 6
48 #ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL
49 static int plain_kbd_keycode[] = {
50 KEY_POWER, KEY_RESERVED,
52 KEY_RESERVED, KEY_RESERVED,
55 static int plain_kbd_keycode[] = {
56 KEY_POWER, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
57 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
58 KEY_HOME, KEY_BACK, KEY_RESERVED, KEY_RESERVED,
59 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
60 KEY_CAMERA, KEY_CAMERA, KEY_RESERVED, KEY_RESERVED,
61 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
62 KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_RESERVED, KEY_RESERVED,
63 KEY_RESERVED, KEY_RESERVED, KEY_PAUSE,
64 KEY_END, KEY_BACK, KEY_RESERVED, KEY_RESERVED,
65 KEY_RESERVED, KEY_PLAY, KEY_PHONE,
68 static struct tegra_kbc_wake_key cardhu_wake_cfg[] = {
75 static struct tegra_kbc_platform_data cardhu_kbc_platform_data = {
77 .repeat_cnt = 50 * 32,
78 .scan_timeout_cnt = 3000 * 32,
79 .plain_keycode = plain_kbd_keycode,
81 .is_filter_keys = false,
82 .is_wake_on_any_key = false,
84 .wake_cfg = &cardhu_wake_cfg[0],
87 static struct resource cardhu_kbc_resources[] = {
89 .start = TEGRA_KBC_BASE,
90 .end = TEGRA_KBC_BASE + TEGRA_KBC_SIZE - 1,
91 .flags = IORESOURCE_MEM,
96 .flags = IORESOURCE_IRQ,
101 struct platform_device cardhu_kbc_device = {
105 .platform_data = &cardhu_kbc_platform_data,
107 .resource = cardhu_kbc_resources,
108 .num_resources = ARRAY_SIZE(cardhu_kbc_resources),
111 int __init cardhu_kbc_init(void)
113 struct tegra_kbc_platform_data *data = &cardhu_kbc_platform_data;
115 struct board_info board_info;
117 tegra_get_board_info(&board_info);
118 if ((board_info.board_id == BOARD_E1198) ||
119 (board_info.board_id == BOARD_E1291))
122 pr_info("Registering tegra-kbc\n");
123 /* Setup the pin configuration information. */
124 for (i = 0; i < KBC_MAX_GPIO; i++) {
125 data->pin_cfg[i].num = 0;
126 data->pin_cfg[i].pin_type = kbc_pin_unused;
128 for (i = 0; i < CARDHU_ROW_COUNT; i++) {
129 data->pin_cfg[i].num = i;
130 data->pin_cfg[i].pin_type = kbc_pin_row;
133 for (i = 0; i < CARDHU_COL_COUNT; i++) {
134 data->pin_cfg[i + CARDHU_ROW_COUNT].num = i;
135 data->pin_cfg[i + CARDHU_ROW_COUNT].pin_type = kbc_pin_col;
137 platform_device_register(&cardhu_kbc_device);
141 int __init cardhu_kbc_init(void)
146 #ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL
147 #define GPIO_SCROLL(_pinaction, _gpio, _desc) \
149 .pinaction = GPIO_SCROLLWHEEL_PIN_##_pinaction, \
150 .gpio = TEGRA_GPIO_##_gpio, \
153 .debounce_interval = 2, \
156 static struct gpio_scrollwheel_button scroll_keys[] = {
157 [0] = GPIO_SCROLL(ONOFF, PR3, "sw_onoff"),
158 [1] = GPIO_SCROLL(PRESS, PQ5, "sw_press"),
159 [2] = GPIO_SCROLL(ROT1, PQ3, "sw_rot1"),
160 [3] = GPIO_SCROLL(ROT2, PQ4, "sw_rot2"),
163 static struct gpio_scrollwheel_platform_data cardhu_scroll_platform_data = {
164 .buttons = scroll_keys,
165 .nbuttons = ARRAY_SIZE(scroll_keys),
168 static struct platform_device cardhu_scroll_device = {
169 .name = "alps-gpio-scrollwheel",
172 .platform_data = &cardhu_scroll_platform_data,
176 int __init cardhu_scroll_init(void)
179 struct board_info board_info;
181 tegra_get_board_info(&board_info);
182 if ((board_info.board_id == BOARD_E1198) ||
183 (board_info.board_id == BOARD_E1291))
186 pr_info("Registering alps scroll wheel\n");
188 /* Setting pins to gpio mode */
189 for (i = 0; i < ARRAY_SIZE(scroll_keys); i++)
190 tegra_gpio_enable(scroll_keys[i].gpio);
192 platform_device_register(&cardhu_scroll_device);
196 int __init cardhu_scroll_init(void)
202 #ifdef CONFIG_KEYBOARD_GPIO
203 #define GPIO_KEY(_id, _gpio, _iswake) \
206 .gpio = TEGRA_GPIO_##_gpio, \
211 .debounce_interval = 10, \
214 static struct gpio_keys_button cardhu_keys_e1198[] = {
215 [0] = GPIO_KEY(KEY_HOME, PQ0, 0),
216 [1] = GPIO_KEY(KEY_BACK, PQ1, 0),
217 [2] = GPIO_KEY(KEY_MENU, PQ2, 0),
218 [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0),
219 [4] = GPIO_KEY(KEY_VOLUMEUP, PR0, 0),
220 [5] = GPIO_KEY(KEY_VOLUMEDOWN, PR1, 0),
221 [6] = GPIO_KEY(KEY_POWER, PV0, 1),
224 static struct gpio_keys_platform_data cardhu_keys_e1198_platform_data = {
225 .buttons = cardhu_keys_e1198,
226 .nbuttons = ARRAY_SIZE(cardhu_keys_e1198),
229 static struct platform_device cardhu_keys_e1198_device = {
233 .platform_data = &cardhu_keys_e1198_platform_data,
237 static struct gpio_keys_button cardhu_keys_e1291[] = {
238 [0] = GPIO_KEY(KEY_MENU, PR0, 0),
239 [1] = GPIO_KEY(KEY_BACK, PR1, 0),
240 [2] = GPIO_KEY(KEY_HOME, PR2, 0),
241 [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0),
242 [4] = GPIO_KEY(KEY_VOLUMEUP, PQ0, 0),
243 [5] = GPIO_KEY(KEY_VOLUMEDOWN, PQ1, 0),
246 static struct gpio_keys_platform_data cardhu_keys_e1291_platform_data = {
247 .buttons = cardhu_keys_e1291,
248 .nbuttons = ARRAY_SIZE(cardhu_keys_e1291),
251 static struct platform_device cardhu_keys_e1291_device = {
255 .platform_data = &cardhu_keys_e1291_platform_data,
259 int __init cardhu_keys_init(void)
263 struct board_info board_info;
265 tegra_get_board_info(&board_info);
266 if (!((board_info.board_id == BOARD_E1198) ||
267 (board_info.board_id == BOARD_E1291)))
270 pr_info("Registering gpio keys\n");
272 if (board_info.board_id == BOARD_E1291) {
273 /* Enable gpio mode for other pins */
274 for (i = 0; i < ARRAY_SIZE(cardhu_keys_e1291); i++)
275 tegra_gpio_enable(cardhu_keys_e1291[i].gpio);
277 platform_device_register(&cardhu_keys_e1291_device);
282 for (i = 0; i < ARRAY_SIZE(cardhu_keys_e1198); i++)
283 tegra_gpio_enable(cardhu_keys_e1198[i].gpio);
285 platform_device_register(&cardhu_keys_e1198_device);
289 int __init cardhu_keys_init(void)