diff options
Diffstat (limited to 'arch/arm/mach-tegra/board-whistler-kbc.c')
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-kbc.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-whistler-kbc.c b/arch/arm/mach-tegra/board-whistler-kbc.c new file mode 100644 index 00000000000..0dbcbbcdc31 --- /dev/null +++ b/arch/arm/mach-tegra/board-whistler-kbc.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010-2011 NVIDIA, Inc. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
16 | * 02111-1307, USA | ||
17 | */ | ||
18 | |||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/input.h> | ||
23 | #include <linux/device.h> | ||
24 | |||
25 | #include <mach/clk.h> | ||
26 | #include <mach/iomap.h> | ||
27 | #include <mach/irqs.h> | ||
28 | #include <mach/pinmux.h> | ||
29 | #include <mach/iomap.h> | ||
30 | #include <mach/io.h> | ||
31 | #include <mach/kbc.h> | ||
32 | |||
33 | #include <asm/mach-types.h> | ||
34 | #include <asm/mach/arch.h> | ||
35 | |||
36 | /* | ||
37 | * Scrollwheel is connected to KBC pins but has it's own | ||
38 | * driver using those pins as gpio. | ||
39 | * In case of using scrollwheel Row3 and Col3/4/5 | ||
40 | * should NOT be configured as KBC | ||
41 | */ | ||
42 | #ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL | ||
43 | #define WHISTLER_ROW_COUNT 3 | ||
44 | #define WHISTLER_COL_COUNT 2 | ||
45 | #else | ||
46 | #define WHISTLER_ROW_COUNT 4 | ||
47 | #define WHISTLER_COL_COUNT 2 | ||
48 | #endif | ||
49 | |||
50 | #ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL | ||
51 | static const u32 whistler_keymap[] = { | ||
52 | KEY(0, 0, KEY_POWER), | ||
53 | KEY(0, 1, KEY_RESERVED), | ||
54 | KEY(1, 0, KEY_HOME), | ||
55 | KEY(1, 1, KEY_BACK), | ||
56 | KEY(2, 0, KEY_RESERVED), | ||
57 | KEY(2, 1, KEY_MENU), | ||
58 | }; | ||
59 | #else | ||
60 | static const u32 whistler_keymap[] = { | ||
61 | KEY(0, 0, KEY_POWER), | ||
62 | KEY(0, 1, KEY_RESERVED), | ||
63 | KEY(1, 0, KEY_HOME), | ||
64 | KEY(1, 1, KEY_BACK), | ||
65 | KEY(2, 0, KEY_RESERVED), | ||
66 | KEY(2, 1, KEY_MENU), | ||
67 | KEY(3, 0, KEY_RESERVED), | ||
68 | KEY(3, 1, KEY_RESERVED), | ||
69 | }; | ||
70 | #endif | ||
71 | |||
72 | static const struct matrix_keymap_data whistler_keymap_data = { | ||
73 | .keymap = whistler_keymap, | ||
74 | .keymap_size = ARRAY_SIZE(whistler_keymap), | ||
75 | }; | ||
76 | |||
77 | static struct tegra_kbc_wake_key whistler_wake_cfg[] = { | ||
78 | [0] = { | ||
79 | .row = 0, | ||
80 | .col = 0, | ||
81 | }, | ||
82 | }; | ||
83 | |||
84 | static struct tegra_kbc_platform_data whistler_kbc_platform_data = { | ||
85 | .debounce_cnt = 20, | ||
86 | .repeat_cnt = 50 * 32, | ||
87 | .wake_cnt = 1, | ||
88 | .wake_cfg = &whistler_wake_cfg[0], | ||
89 | .keymap_data = &whistler_keymap_data, | ||
90 | .use_fn_map = false, | ||
91 | .wakeup = true, | ||
92 | #ifdef CONFIG_ANDROID | ||
93 | .disable_ev_rep = true, | ||
94 | #endif | ||
95 | }; | ||
96 | |||
97 | static struct resource whistler_kbc_resources[] = { | ||
98 | [0] = { | ||
99 | .start = TEGRA_KBC_BASE, | ||
100 | .end = TEGRA_KBC_BASE + TEGRA_KBC_SIZE - 1, | ||
101 | .flags = IORESOURCE_MEM, | ||
102 | }, | ||
103 | [1] = { | ||
104 | .start = INT_KBC, | ||
105 | .end = INT_KBC, | ||
106 | .flags = IORESOURCE_IRQ, | ||
107 | }, | ||
108 | }; | ||
109 | |||
110 | struct platform_device whistler_kbc_device = { | ||
111 | .name = "tegra-kbc", | ||
112 | .id = -1, | ||
113 | .dev = { | ||
114 | .platform_data = &whistler_kbc_platform_data, | ||
115 | }, | ||
116 | .resource = whistler_kbc_resources, | ||
117 | .num_resources = ARRAY_SIZE(whistler_kbc_resources), | ||
118 | }; | ||
119 | |||
120 | int __init whistler_kbc_init(void) | ||
121 | { | ||
122 | struct tegra_kbc_platform_data *data = &whistler_kbc_platform_data; | ||
123 | int i; | ||
124 | |||
125 | pr_info("KBC: whistler_kbc_init\n"); | ||
126 | for (i = 0; i < WHISTLER_ROW_COUNT; i++) { | ||
127 | data->pin_cfg[i].num = i; | ||
128 | data->pin_cfg[i].is_row = true; | ||
129 | data->pin_cfg[i].en = true; | ||
130 | } | ||
131 | for (i = 0; i < WHISTLER_COL_COUNT; i++) { | ||
132 | data->pin_cfg[i + KBC_PIN_GPIO_16].num = i; | ||
133 | data->pin_cfg[i + KBC_PIN_GPIO_16].en = true; | ||
134 | } | ||
135 | |||
136 | platform_device_register(&whistler_kbc_device); | ||
137 | return 0; | ||
138 | } | ||