]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/arm/mach-tegra/board-pluto-kbc.c
ARM: tegra: fix regulator_get() return value check
[linux-3.10.git] / arch / arm / mach-tegra / board-pluto-kbc.c
1 /*
2  * arch/arm/mach-tegra/board-pluto-kbc.c
3  * Keys configuration for Nvidia tegra3 pluto 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/input/tegra_kbc.h>
26 #include <linux/gpio.h>
27 #include <linux/gpio_keys.h>
28
29 #include "board.h"
30 #include "board-pluto.h"
31 #include "devices.h"
32
33 #define PLUTO_ROW_COUNT 3
34 #define PLUTO_COL_COUNT 3
35
36 static const u32 kbd_keymap[] = {
37         KEY(0, 0, KEY_POWER),
38         KEY(0, 1, KEY_VOLUMEUP),
39         KEY(0, 2, KEY_VOLUMEDOWN),
40
41         KEY(1, 0, KEY_SEARCH),
42         KEY(1, 1, KEY_CAMERA),
43         KEY(1, 2, KEY_CAMERA_FOCUS),
44
45         KEY(2, 0, KEY_HOME),
46         KEY(2, 1, KEY_BACK),
47         KEY(2, 2, KEY_MENU),
48 };
49
50 static const struct matrix_keymap_data keymap_data = {
51         .keymap         = kbd_keymap,
52         .keymap_size    = ARRAY_SIZE(kbd_keymap),
53 };
54
55 static struct tegra_kbc_wake_key pluto_wake_cfg[] = {
56         [0] = {
57                 .row = 0,
58                 .col = 0,
59         },
60         [1] = {
61                 .row = 0,
62                 .col = 1,
63         },
64         [2] = {
65                 .row = 0,
66                 .col = 2,
67         },
68 };
69
70 static struct tegra_kbc_platform_data pluto_kbc_platform_data = {
71         .debounce_cnt = 20 * 32, /* 20 ms debaunce time */
72         .repeat_cnt = 1,
73         .scan_count = 30,
74         .wakeup = true,
75         .keymap_data = &keymap_data,
76         .wake_cnt = 3,
77         .wake_cfg = &pluto_wake_cfg[0],
78         .wakeup_key = KEY_POWER,
79 #ifdef CONFIG_ANDROID
80         .disable_ev_rep = true,
81 #endif
82 };
83
84 static struct gpio_keys_button pluto_keys[] = {
85         [0] = {
86                 .code = KEY_MUTE,
87                 .gpio = TEGRA_GPIO_PI5,
88                 .irq = -1,
89                 .type = EV_KEY,
90                 .desc = "RINGER",
91                 .active_low = 0,
92                 .wakeup = 0,
93                 .debounce_interval = 100,
94         },
95 };
96
97 static struct gpio_keys_platform_data pluto_keys_pdata = {
98         .buttons        = pluto_keys,
99         .nbuttons       = ARRAY_SIZE(pluto_keys),
100 };
101
102 static struct platform_device pluto_keys_device = {
103         .name   = "gpio-keys",
104         .id     = 0,
105         .dev    = {
106                 .platform_data  = &pluto_keys_pdata,
107         },
108 };
109
110 int __init pluto_kbc_init(void)
111 {
112         struct tegra_kbc_platform_data *data = &pluto_kbc_platform_data;
113         int i;
114
115         tegra_kbc_device.dev.platform_data = &pluto_kbc_platform_data;
116         pr_info("Registering tegra-kbc\n");
117
118         BUG_ON((KBC_MAX_ROW + KBC_MAX_COL) > KBC_MAX_GPIO);
119         for (i = 0; i < PLUTO_ROW_COUNT; i++) {
120                 data->pin_cfg[i].num = i;
121                 data->pin_cfg[i].type = PIN_CFG_ROW;
122         }
123         for (i = 0; i < PLUTO_COL_COUNT; i++) {
124                 data->pin_cfg[i + KBC_PIN_GPIO_11].num = i;
125                 data->pin_cfg[i + KBC_PIN_GPIO_11].type = PIN_CFG_COL;
126         }
127
128         platform_device_register(&tegra_kbc_device);
129         pr_info("Registering successful tegra-kbc\n");
130
131         platform_device_register(&pluto_keys_device);
132         pr_info("Registering successful gpio-keys\n");
133
134         return 0;
135 }
136