2 * arch/arm/mach-tegra/board-stingray-keypad.c
4 * Copyright (C) 2010 Google, Inc.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/platform_device.h>
18 #include <linux/input.h>
19 #include <linux/keyreset.h>
20 #include <linux/gpio_event.h>
21 #include <linux/gpio.h>
22 #include <asm/mach-types.h>
24 #include "board-stingray.h"
25 #include "gpio-names.h"
27 static unsigned int stingray_row_gpios[] = {
31 static unsigned int stingray_col_gpios[] = {
35 #define KEYMAP_INDEX(col, row) ((col)*ARRAY_SIZE(stingray_row_gpios) + (row))
37 static const unsigned short stingray_p3_keymap[ARRAY_SIZE(stingray_col_gpios) *
38 ARRAY_SIZE(stingray_row_gpios)] = {
39 [KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP,
40 [KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN
43 static struct gpio_event_matrix_info stingray_keypad_matrix_info = {
44 .info.func = gpio_event_matrix_func,
45 .keymap = stingray_p3_keymap,
46 .output_gpios = stingray_col_gpios,
47 .input_gpios = stingray_row_gpios,
48 .noutputs = ARRAY_SIZE(stingray_col_gpios),
49 .ninputs = ARRAY_SIZE(stingray_row_gpios),
50 .settle_time.tv.nsec = 40 * NSEC_PER_USEC,
51 .poll_time.tv.nsec = 20 * NSEC_PER_MSEC,
52 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_REMOVE_PHANTOM_KEYS |
53 GPIOKPF_PRINT_UNMAPPED_KEYS /*| GPIOKPF_PRINT_MAPPED_KEYS*/
56 static struct gpio_event_direct_entry stingray_keypad_switch_map[] = {
59 static struct gpio_event_input_info stingray_keypad_switch_info = {
60 .info.func = gpio_event_input_func,
63 .keymap = stingray_keypad_switch_map,
64 .keymap_size = ARRAY_SIZE(stingray_keypad_switch_map)
67 static struct gpio_event_info *stingray_keypad_info[] = {
68 &stingray_keypad_matrix_info.info,
69 &stingray_keypad_switch_info.info,
72 static struct gpio_event_platform_data stingray_keypad_data = {
73 .name = "stingray-keypad",
74 .info = stingray_keypad_info,
75 .info_count = ARRAY_SIZE(stingray_keypad_info)
78 static struct platform_device stingray_keypad_device = {
79 .name = GPIO_EVENT_DEV_NAME,
82 .platform_data = &stingray_keypad_data,
86 int stingray_log_reset(void)
88 pr_warn("Hard reset buttons pushed\n");
92 static struct keyreset_platform_data stingray_reset_keys_pdata = {
93 .reset_fn = stingray_log_reset,
101 struct platform_device stingray_keyreset_device = {
102 .name = KEYRESET_NAME,
104 .platform_data = &stingray_reset_keys_pdata,
109 int __init stingray_keypad_init(void)
111 tegra_gpio_enable(TEGRA_GPIO_PR0);
112 tegra_gpio_enable(TEGRA_GPIO_PR1);
113 tegra_gpio_enable(TEGRA_GPIO_PQ0);
114 platform_device_register(&stingray_keyreset_device);
115 return platform_device_register(&stingray_keypad_device);