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/mfd/tps6591x.h>
29 #include <linux/mfd/max77663-core.h>
30 #include <linux/interrupt_keys.h>
31 #include <linux/gpio_scrollwheel.h>
33 #include <mach/irqs.h>
35 #include <mach/iomap.h>
38 #include "board-cardhu.h"
40 #include "gpio-names.h"
43 #define CARDHU_PM269_ROW_COUNT 2
44 #define CARDHU_PM269_COL_COUNT 4
46 static const u32 kbd_keymap[] = {
48 KEY(0, 1, KEY_RESERVED),
49 KEY(0, 2, KEY_VOLUMEUP),
50 KEY(0, 3, KEY_VOLUMEDOWN),
55 KEY(1, 3, KEY_SEARCH),
57 static const struct matrix_keymap_data keymap_data = {
59 .keymap_size = ARRAY_SIZE(kbd_keymap),
62 static struct tegra_kbc_wake_key cardhu_wake_cfg[] = {
69 static struct tegra_kbc_platform_data cardhu_kbc_platform_data = {
70 .debounce_cnt = 20 * 32, /* 20ms debounce time */
74 .keymap_data = &keymap_data,
76 .wake_cfg = &cardhu_wake_cfg[0],
78 .disable_ev_rep = true,
82 int __init cardhu_kbc_init(void)
84 struct tegra_kbc_platform_data *data = &cardhu_kbc_platform_data;
86 struct board_info board_info;
88 tegra_get_board_info(&board_info);
89 if ((board_info.board_id == BOARD_E1198) ||
90 (board_info.board_id == BOARD_E1291))
93 pr_info("Registering tegra-kbc\n");
94 tegra_kbc_device.dev.platform_data = &cardhu_kbc_platform_data;
96 for (i = 0; i < CARDHU_PM269_ROW_COUNT; i++) {
97 data->pin_cfg[i].num = i;
98 data->pin_cfg[i].is_row = true;
99 data->pin_cfg[i].en = true;
101 for (i = 0; i < CARDHU_PM269_COL_COUNT; i++) {
102 data->pin_cfg[i + KBC_PIN_GPIO_16].num = i;
103 data->pin_cfg[i + KBC_PIN_GPIO_16].en = true;
106 platform_device_register(&tegra_kbc_device);
110 int __init cardhu_scroll_init(void)
115 #define GPIO_KEY(_id, _gpio, _iswake) \
118 .gpio = TEGRA_GPIO_##_gpio, \
123 .debounce_interval = 10, \
126 static struct gpio_keys_button cardhu_keys_e1198[] = {
127 [0] = GPIO_KEY(KEY_HOME, PQ0, 0),
128 [1] = GPIO_KEY(KEY_BACK, PQ1, 0),
129 [2] = GPIO_KEY(KEY_MENU, PQ2, 0),
130 [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0),
131 [4] = GPIO_KEY(KEY_VOLUMEUP, PR0, 0),
132 [5] = GPIO_KEY(KEY_VOLUMEDOWN, PR1, 0),
133 [6] = GPIO_KEY(KEY_POWER, PV0, 1),
136 static struct gpio_keys_platform_data cardhu_keys_e1198_platform_data = {
137 .buttons = cardhu_keys_e1198,
138 .nbuttons = ARRAY_SIZE(cardhu_keys_e1198),
141 static struct platform_device cardhu_keys_e1198_device = {
145 .platform_data = &cardhu_keys_e1198_platform_data,
149 static struct gpio_keys_button cardhu_keys_e1291[] = {
150 [0] = GPIO_KEY(KEY_MENU, PR0, 0),
151 [1] = GPIO_KEY(KEY_BACK, PR1, 0),
152 [2] = GPIO_KEY(KEY_HOME, PR2, 0),
153 [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0),
154 [4] = GPIO_KEY(KEY_VOLUMEUP, PQ0, 0),
155 [5] = GPIO_KEY(KEY_VOLUMEDOWN, PQ1, 0),
158 static struct gpio_keys_button cardhu_keys_e1291_a04[] = {
159 [0] = GPIO_KEY(KEY_MENU, PR0, 0),
160 [1] = GPIO_KEY(KEY_BACK, PR1, 0),
161 [2] = GPIO_KEY(KEY_HOME, PQ2, 0),
162 [3] = GPIO_KEY(KEY_SEARCH, PQ3, 0),
163 [4] = GPIO_KEY(KEY_VOLUMEUP, PQ0, 0),
164 [5] = GPIO_KEY(KEY_VOLUMEDOWN, PQ1, 0),
167 static struct gpio_keys_platform_data cardhu_keys_e1291_platform_data = {
168 .buttons = cardhu_keys_e1291,
169 .nbuttons = ARRAY_SIZE(cardhu_keys_e1291),
172 static struct platform_device cardhu_keys_e1291_device = {
176 .platform_data = &cardhu_keys_e1291_platform_data,
180 #define INT_KEY(_id, _irq, _iswake, _deb_int) \
188 .debounce_interval = _deb_int, \
190 static struct interrupt_keys_button cardhu_int_keys[] = {
191 [0] = INT_KEY(KEY_POWER, TPS6591X_IRQ_BASE + TPS6591X_INT_PWRON, 1, 100),
194 static struct interrupt_keys_button cardhu_pm298_int_keys[] = {
195 [0] = INT_KEY(KEY_POWER, MAX77663_IRQ_BASE + MAX77663_IRQ_ONOFF_EN0_FALLING, 1, 100),
196 [1] = INT_KEY(KEY_POWER, MAX77663_IRQ_BASE + MAX77663_IRQ_ONOFF_EN0_1SEC, 1, 3000),
199 static struct interrupt_keys_button cardhu_pm299_int_keys[] = {
200 [0] = INT_KEY(KEY_POWER, RICOH583_IRQ_BASE + RICOH583_IRQ_ONKEY, 1, 100),
203 static struct interrupt_keys_platform_data cardhu_int_keys_pdata = {
204 .int_buttons = cardhu_int_keys,
205 .nbuttons = ARRAY_SIZE(cardhu_int_keys),
208 static struct platform_device cardhu_int_keys_device = {
209 .name = "interrupt-keys",
212 .platform_data = &cardhu_int_keys_pdata,
216 int __init cardhu_keys_init(void)
219 struct board_info board_info;
220 struct board_info pmu_board_info;
222 tegra_get_board_info(&board_info);
223 if (!((board_info.board_id == BOARD_E1198) ||
224 (board_info.board_id == BOARD_E1291) ||
225 (board_info.board_id == BOARD_E1186) ||
226 (board_info.board_id == BOARD_E1257) ||
227 (board_info.board_id == BOARD_PM305) ||
228 (board_info.board_id == BOARD_PM311) ||
229 (board_info.board_id == BOARD_PM269)))
232 pr_info("Registering gpio keys\n");
234 if (board_info.board_id == BOARD_E1291) {
235 if (board_info.fab >= BOARD_FAB_A04) {
236 cardhu_keys_e1291_platform_data.buttons =
237 cardhu_keys_e1291_a04;
238 cardhu_keys_e1291_platform_data.nbuttons =
239 ARRAY_SIZE(cardhu_keys_e1291_a04);
242 /* Enable gpio mode for other pins */
243 for (i = 0; i < cardhu_keys_e1291_platform_data.nbuttons; i++)
244 tegra_gpio_enable(cardhu_keys_e1291_platform_data.
247 platform_device_register(&cardhu_keys_e1291_device);
248 } else if (board_info.board_id == BOARD_E1198) {
250 for (i = 0; i < ARRAY_SIZE(cardhu_keys_e1198); i++)
251 tegra_gpio_enable(cardhu_keys_e1198[i].gpio);
253 platform_device_register(&cardhu_keys_e1198_device);
256 /* Register on-key through pmu interrupt */
257 tegra_get_pmu_board_info(&pmu_board_info);
259 if (pmu_board_info.board_id == BOARD_PMU_PM298) {
260 cardhu_int_keys_pdata.int_buttons = cardhu_pm298_int_keys;
261 cardhu_int_keys_pdata.nbuttons =
262 ARRAY_SIZE(cardhu_pm298_int_keys);
265 if (pmu_board_info.board_id == BOARD_PMU_PM299) {
266 cardhu_int_keys_pdata.int_buttons = cardhu_pm299_int_keys;
267 cardhu_int_keys_pdata.nbuttons =
268 ARRAY_SIZE(cardhu_pm299_int_keys);
271 if ((board_info.board_id == BOARD_E1291) ||
272 (board_info.board_id == BOARD_E1198) ||
273 (board_info.board_id == BOARD_E1257) ||
274 (board_info.board_id == BOARD_E1186) ||
275 (board_info.board_id == BOARD_PM305) ||
276 (board_info.board_id == BOARD_PM311) ||
277 (board_info.board_id == BOARD_PM269))
278 platform_device_register(&cardhu_int_keys_device);