2 * Copyright (C) ST-Ericsson SA 2010
4 * License Terms: GNU General Public License v2
6 * Keypad layouts for various boards
10 #include <linux/gpio.h>
11 #include <linux/interrupt.h>
12 #include <linux/platform_device.h>
13 #include <linux/mfd/stmpe.h>
14 #include <linux/mfd/tc3589x.h>
15 #include <linux/input/matrix_keypad.h>
17 #include <plat/pincfg.h>
20 #include <mach/devices.h>
21 #include <mach/hardware.h>
23 #include "devices-db8500.h"
24 #include "board-mop500.h"
26 /* STMPE/SKE keypad use this key layout */
27 static const unsigned int mop500_keymap
[] = {
30 KEY(3, 5, KEY_VOLUMEDOWN
),
44 KEY(4, 2, KEY_VOLUMEUP
),
50 static const struct matrix_keymap_data mop500_keymap_data
= {
51 .keymap
= mop500_keymap
,
52 .keymap_size
= ARRAY_SIZE(mop500_keymap
),
58 #define ROW_PIN_I0 164
59 #define ROW_PIN_I1 163
60 #define ROW_PIN_I2 162
61 #define ROW_PIN_I3 161
62 #define ROW_PIN_I4 156
63 #define ROW_PIN_I5 155
64 #define ROW_PIN_I6 154
65 #define ROW_PIN_I7 153
66 #define COL_PIN_O0 168
67 #define COL_PIN_O1 167
68 #define COL_PIN_O2 166
69 #define COL_PIN_O3 165
70 #define COL_PIN_O4 160
71 #define COL_PIN_O5 159
72 #define COL_PIN_O6 158
73 #define COL_PIN_O7 157
75 #define SKE_KPD_MAX_ROWS 8
76 #define SKE_KPD_MAX_COLS 8
78 static int ske_kp_rows
[] = {
79 ROW_PIN_I0
, ROW_PIN_I1
, ROW_PIN_I2
, ROW_PIN_I3
,
80 ROW_PIN_I4
, ROW_PIN_I5
, ROW_PIN_I6
, ROW_PIN_I7
,
84 * ske_set_gpio_row: request and set gpio rows
86 static int ske_set_gpio_row(int gpio
)
90 ret
= gpio_request(gpio
, "ske-kp");
92 pr_err("ske_set_gpio_row: gpio request failed\n");
96 ret
= gpio_direction_output(gpio
, 1);
98 pr_err("ske_set_gpio_row: gpio direction failed\n");
106 * ske_kp_init - enable the gpio configuration
108 static int ske_kp_init(void)
112 for (i
= 0; i
< SKE_KPD_MAX_ROWS
; i
++) {
113 ret
= ske_set_gpio_row(ske_kp_rows
[i
]);
115 pr_err("ske_kp_init: failed init\n");
123 static struct ske_keypad_platform_data ske_keypad_board
= {
125 .keymap_data
= &mop500_keymap_data
,
126 .no_autorepeat
= true,
127 .krow
= SKE_KPD_MAX_ROWS
, /* 8x8 matrix */
128 .kcol
= SKE_KPD_MAX_COLS
,
129 .debounce_ms
= 40, /* in millisecs */
135 static struct stmpe_keypad_platform_data stmpe1601_keypad_data
= {
138 .no_autorepeat
= true,
139 .keymap_data
= &mop500_keymap_data
,
142 static struct stmpe_platform_data stmpe1601_data
= {
144 .blocks
= STMPE_BLOCK_KEYPAD
,
145 .irq_trigger
= IRQF_TRIGGER_FALLING
,
146 .irq_base
= MOP500_STMPE1601_IRQ(0),
147 .keypad
= &stmpe1601_keypad_data
,
149 .autosleep_timeout
= 1024,
152 static struct i2c_board_info mop500_i2c0_devices_stuib
[] = {
154 I2C_BOARD_INFO("stmpe1601", 0x40),
155 .irq
= NOMADIK_GPIO_TO_IRQ(218),
156 .platform_data
= &stmpe1601_data
,
157 .flags
= I2C_CLIENT_WAKE
,
165 static const unsigned int uib_keymap
[] = {
167 KEY(4, 1, KEY_POWER
),
168 KEY(6, 4, KEY_VOLUMEDOWN
),
169 KEY(4, 2, KEY_EMAIL
),
170 KEY(3, 3, KEY_RIGHT
),
171 KEY(2, 5, KEY_BACKSPACE
),
174 KEY(5, 0, KEY_ENTER
),
182 KEY(6, 2, KEY_VOLUMEUP
),
183 KEY(1, 3, KEY_SPACE
),
185 KEY(5, 5, KEY_SEARCH
),
188 static struct matrix_keymap_data uib_keymap_data
= {
189 .keymap
= uib_keymap
,
190 .keymap_size
= ARRAY_SIZE(uib_keymap
),
193 static struct tc3589x_keypad_platform_data tc35893_data
= {
195 .kcol
= TC_KPD_COLUMNS
,
196 .debounce_period
= TC_KPD_DEBOUNCE_PERIOD
,
197 .settle_time
= TC_KPD_SETTLE_TIME
,
198 .irqtype
= IRQF_TRIGGER_FALLING
,
199 .enable_wakeup
= true,
200 .keymap_data
= &uib_keymap_data
,
201 .no_autorepeat
= true,
204 static struct tc3589x_platform_data tc3589x_keypad_data
= {
205 .block
= TC3589x_BLOCK_KEYPAD
,
206 .keypad
= &tc35893_data
,
207 .irq_base
= MOP500_EGPIO_IRQ_BASE
,
210 static struct i2c_board_info mop500_i2c0_devices_uib
[] = {
212 I2C_BOARD_INFO("tc3589x", 0x44),
213 .platform_data
= &tc3589x_keypad_data
,
214 .irq
= NOMADIK_GPIO_TO_IRQ(218),
215 .flags
= I2C_CLIENT_WAKE
,
219 void mop500_keypad_init(void)
221 db8500_add_ske_keypad(&ske_keypad_board
);
223 i2c_register_board_info(0, mop500_i2c0_devices_stuib
,
224 ARRAY_SIZE(mop500_i2c0_devices_stuib
));
226 i2c_register_board_info(0, mop500_i2c0_devices_uib
,
227 ARRAY_SIZE(mop500_i2c0_devices_uib
));