blob: f97c73bd14f8f6427534ebee8e8b502f7b527299 [file] [log] [blame]
Rakesh Iyer11f5b302011-01-19 23:38:47 -08001/*
2 * Keyboard class input driver for the NVIDIA Tegra SoC internal matrix
3 * keyboard controller
4 *
5 * Copyright (c) 2009-2011, NVIDIA Corporation.
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 as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
Rakesh Iyer3f277572011-07-30 12:01:48 -070022#include <linux/kernel.h>
Rakesh Iyer11f5b302011-01-19 23:38:47 -080023#include <linux/module.h>
24#include <linux/input.h>
25#include <linux/platform_device.h>
26#include <linux/delay.h>
27#include <linux/io.h>
28#include <linux/interrupt.h>
Olof Johanssona445c7f2011-12-29 09:58:16 -080029#include <linux/of.h>
Laxman Dewangane10af9e2013-03-31 00:41:12 -070030#include <linux/of_device.h>
Rakesh Iyer11f5b302011-01-19 23:38:47 -080031#include <linux/clk.h>
32#include <linux/slab.h>
Stephen Warren9eee07d2013-02-15 17:04:12 -080033#include <linux/input/matrix_keypad.h>
Stephen Warrenfe6b0df2013-11-06 16:48:16 -070034#include <linux/reset.h>
Sachin Kamatba52a7f2013-03-17 21:30:05 -070035#include <linux/err.h>
Rakesh Iyer11f5b302011-01-19 23:38:47 -080036
Stephen Warren9eee07d2013-02-15 17:04:12 -080037#define KBC_MAX_KPENT 8
38
Laxman Dewangane10af9e2013-03-31 00:41:12 -070039/* Maximum row/column supported by Tegra KBC yet is 16x8 */
40#define KBC_MAX_GPIO 24
41/* Maximum keys supported by Tegra KBC yet is 16 x 8*/
42#define KBC_MAX_KEY (16 * 8)
Stephen Warren9eee07d2013-02-15 17:04:12 -080043
Rakesh Iyer11f5b302011-01-19 23:38:47 -080044#define KBC_MAX_DEBOUNCE_CNT 0x3ffu
45
46/* KBC row scan time and delay for beginning the row scan. */
47#define KBC_ROW_SCAN_TIME 16
48#define KBC_ROW_SCAN_DLY 5
49
50/* KBC uses a 32KHz clock so a cycle = 1/32Khz */
Rakesh Iyer3f277572011-07-30 12:01:48 -070051#define KBC_CYCLE_MS 32
Rakesh Iyer11f5b302011-01-19 23:38:47 -080052
53/* KBC Registers */
54
55/* KBC Control Register */
56#define KBC_CONTROL_0 0x0
57#define KBC_FIFO_TH_CNT_SHIFT(cnt) (cnt << 14)
58#define KBC_DEBOUNCE_CNT_SHIFT(cnt) (cnt << 4)
59#define KBC_CONTROL_FIFO_CNT_INT_EN (1 << 3)
Rakesh Iyerb6834b02012-01-22 23:27:54 -080060#define KBC_CONTROL_KEYPRESS_INT_EN (1 << 1)
Rakesh Iyer11f5b302011-01-19 23:38:47 -080061#define KBC_CONTROL_KBC_EN (1 << 0)
62
63/* KBC Interrupt Register */
64#define KBC_INT_0 0x4
65#define KBC_INT_FIFO_CNT_INT_STATUS (1 << 2)
Rakesh Iyerfd0fc212011-12-29 19:27:44 -080066#define KBC_INT_KEYPRESS_INT_STATUS (1 << 0)
Rakesh Iyer11f5b302011-01-19 23:38:47 -080067
68#define KBC_ROW_CFG0_0 0x8
69#define KBC_COL_CFG0_0 0x18
Rakesh Iyerd0d150e2011-09-08 15:34:11 -070070#define KBC_TO_CNT_0 0x24
Rakesh Iyer11f5b302011-01-19 23:38:47 -080071#define KBC_INIT_DLY_0 0x28
72#define KBC_RPT_DLY_0 0x2c
73#define KBC_KP_ENT0_0 0x30
74#define KBC_KP_ENT1_0 0x34
75#define KBC_ROW0_MASK_0 0x38
76
77#define KBC_ROW_SHIFT 3
78
Stephen Warren9eee07d2013-02-15 17:04:12 -080079enum tegra_pin_type {
80 PIN_CFG_IGNORE,
81 PIN_CFG_COL,
82 PIN_CFG_ROW,
83};
84
Laxman Dewangane10af9e2013-03-31 00:41:12 -070085/* Tegra KBC hw support */
86struct tegra_kbc_hw_support {
87 int max_rows;
88 int max_columns;
89};
90
Stephen Warren9eee07d2013-02-15 17:04:12 -080091struct tegra_kbc_pin_cfg {
92 enum tegra_pin_type type;
93 unsigned char num;
94};
95
Rakesh Iyer11f5b302011-01-19 23:38:47 -080096struct tegra_kbc {
Stephen Warren9eee07d2013-02-15 17:04:12 -080097 struct device *dev;
98 unsigned int debounce_cnt;
99 unsigned int repeat_cnt;
100 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO];
101 const struct matrix_keymap_data *keymap_data;
102 bool wakeup;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800103 void __iomem *mmio;
104 struct input_dev *idev;
Stephen Warren9eee07d2013-02-15 17:04:12 -0800105 int irq;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800106 spinlock_t lock;
107 unsigned int repoll_dly;
108 unsigned long cp_dly_jiffies;
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700109 unsigned int cp_to_wkup_dly;
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800110 bool use_fn_map;
Rakesh Iyer34abeeb2011-04-27 23:18:15 -0700111 bool use_ghost_filter;
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800112 bool keypress_caused_wake;
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800113 unsigned short keycode[KBC_MAX_KEY * 2];
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800114 unsigned short current_keys[KBC_MAX_KPENT];
115 unsigned int num_pressed_keys;
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800116 u32 wakeup_key;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800117 struct timer_list timer;
118 struct clk *clk;
Stephen Warrenfe6b0df2013-11-06 16:48:16 -0700119 struct reset_control *rst;
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700120 const struct tegra_kbc_hw_support *hw_support;
121 int max_keys;
122 int num_rows_and_columns;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800123};
124
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800125static void tegra_kbc_report_released_keys(struct input_dev *input,
126 unsigned short old_keycodes[],
127 unsigned int old_num_keys,
128 unsigned short new_keycodes[],
129 unsigned int new_num_keys)
130{
131 unsigned int i, j;
132
133 for (i = 0; i < old_num_keys; i++) {
134 for (j = 0; j < new_num_keys; j++)
135 if (old_keycodes[i] == new_keycodes[j])
136 break;
137
138 if (j == new_num_keys)
139 input_report_key(input, old_keycodes[i], 0);
140 }
141}
142
143static void tegra_kbc_report_pressed_keys(struct input_dev *input,
144 unsigned char scancodes[],
145 unsigned short keycodes[],
146 unsigned int num_pressed_keys)
147{
148 unsigned int i;
149
150 for (i = 0; i < num_pressed_keys; i++) {
151 input_event(input, EV_MSC, MSC_SCAN, scancodes[i]);
152 input_report_key(input, keycodes[i], 1);
153 }
154}
155
156static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
157{
158 unsigned char scancodes[KBC_MAX_KPENT];
159 unsigned short keycodes[KBC_MAX_KPENT];
160 u32 val = 0;
161 unsigned int i;
162 unsigned int num_down = 0;
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800163 bool fn_keypress = false;
Rakesh Iyer34abeeb2011-04-27 23:18:15 -0700164 bool key_in_same_row = false;
165 bool key_in_same_col = false;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800166
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800167 for (i = 0; i < KBC_MAX_KPENT; i++) {
168 if ((i % 4) == 0)
169 val = readl(kbc->mmio + KBC_KP_ENT0_0 + i);
170
171 if (val & 0x80) {
172 unsigned int col = val & 0x07;
173 unsigned int row = (val >> 3) & 0x0f;
174 unsigned char scancode =
175 MATRIX_SCAN_CODE(row, col, KBC_ROW_SHIFT);
176
177 scancodes[num_down] = scancode;
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800178 keycodes[num_down] = kbc->keycode[scancode];
179 /* If driver uses Fn map, do not report the Fn key. */
180 if ((keycodes[num_down] == KEY_FN) && kbc->use_fn_map)
181 fn_keypress = true;
182 else
183 num_down++;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800184 }
185
186 val >>= 8;
187 }
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800188
189 /*
Rakesh Iyer34abeeb2011-04-27 23:18:15 -0700190 * Matrix keyboard designs are prone to keyboard ghosting.
191 * Ghosting occurs if there are 3 keys such that -
192 * any 2 of the 3 keys share a row, and any 2 of them share a column.
193 * If so ignore the key presses for this iteration.
194 */
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700195 if (kbc->use_ghost_filter && num_down >= 3) {
Rakesh Iyer34abeeb2011-04-27 23:18:15 -0700196 for (i = 0; i < num_down; i++) {
197 unsigned int j;
198 u8 curr_col = scancodes[i] & 0x07;
199 u8 curr_row = scancodes[i] >> KBC_ROW_SHIFT;
200
201 /*
202 * Find 2 keys such that one key is in the same row
203 * and the other is in the same column as the i-th key.
204 */
205 for (j = i + 1; j < num_down; j++) {
206 u8 col = scancodes[j] & 0x07;
207 u8 row = scancodes[j] >> KBC_ROW_SHIFT;
208
209 if (col == curr_col)
210 key_in_same_col = true;
211 if (row == curr_row)
212 key_in_same_row = true;
213 }
214 }
215 }
216
217 /*
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800218 * If the platform uses Fn keymaps, translate keys on a Fn keypress.
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700219 * Function keycodes are max_keys apart from the plain keycodes.
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800220 */
221 if (fn_keypress) {
222 for (i = 0; i < num_down; i++) {
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700223 scancodes[i] += kbc->max_keys;
Rakesh Iyer4e8b65f2011-02-18 08:38:02 -0800224 keycodes[i] = kbc->keycode[scancodes[i]];
225 }
226 }
227
Rakesh Iyer34abeeb2011-04-27 23:18:15 -0700228 /* Ignore the key presses for this iteration? */
229 if (key_in_same_col && key_in_same_row)
230 return;
231
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800232 tegra_kbc_report_released_keys(kbc->idev,
233 kbc->current_keys, kbc->num_pressed_keys,
234 keycodes, num_down);
235 tegra_kbc_report_pressed_keys(kbc->idev, scancodes, keycodes, num_down);
236 input_sync(kbc->idev);
237
238 memcpy(kbc->current_keys, keycodes, sizeof(kbc->current_keys));
239 kbc->num_pressed_keys = num_down;
240}
241
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700242static void tegra_kbc_set_fifo_interrupt(struct tegra_kbc *kbc, bool enable)
243{
244 u32 val;
245
246 val = readl(kbc->mmio + KBC_CONTROL_0);
247 if (enable)
248 val |= KBC_CONTROL_FIFO_CNT_INT_EN;
249 else
250 val &= ~KBC_CONTROL_FIFO_CNT_INT_EN;
251 writel(val, kbc->mmio + KBC_CONTROL_0);
252}
253
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800254static void tegra_kbc_keypress_timer(unsigned long data)
255{
256 struct tegra_kbc *kbc = (struct tegra_kbc *)data;
257 unsigned long flags;
258 u32 val;
259 unsigned int i;
260
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700261 spin_lock_irqsave(&kbc->lock, flags);
262
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800263 val = (readl(kbc->mmio + KBC_INT_0) >> 4) & 0xf;
264 if (val) {
265 unsigned long dly;
266
267 tegra_kbc_report_keys(kbc);
268
269 /*
270 * If more than one keys are pressed we need not wait
271 * for the repoll delay.
272 */
273 dly = (val == 1) ? kbc->repoll_dly : 1;
274 mod_timer(&kbc->timer, jiffies + msecs_to_jiffies(dly));
275 } else {
276 /* Release any pressed keys and exit the polling loop */
277 for (i = 0; i < kbc->num_pressed_keys; i++)
278 input_report_key(kbc->idev, kbc->current_keys[i], 0);
279 input_sync(kbc->idev);
280
281 kbc->num_pressed_keys = 0;
282
283 /* All keys are released so enable the keypress interrupt */
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700284 tegra_kbc_set_fifo_interrupt(kbc, true);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800285 }
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700286
287 spin_unlock_irqrestore(&kbc->lock, flags);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800288}
289
290static irqreturn_t tegra_kbc_isr(int irq, void *args)
291{
292 struct tegra_kbc *kbc = args;
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700293 unsigned long flags;
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700294 u32 val;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800295
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700296 spin_lock_irqsave(&kbc->lock, flags);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800297
298 /*
299 * Quickly bail out & reenable interrupts if the fifo threshold
300 * count interrupt wasn't the interrupt source
301 */
302 val = readl(kbc->mmio + KBC_INT_0);
303 writel(val, kbc->mmio + KBC_INT_0);
304
305 if (val & KBC_INT_FIFO_CNT_INT_STATUS) {
306 /*
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700307 * Until all keys are released, defer further processing to
308 * the polling loop in tegra_kbc_keypress_timer.
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800309 */
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700310 tegra_kbc_set_fifo_interrupt(kbc, false);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800311 mod_timer(&kbc->timer, jiffies + kbc->cp_dly_jiffies);
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800312 } else if (val & KBC_INT_KEYPRESS_INT_STATUS) {
313 /* We can be here only through system resume path */
314 kbc->keypress_caused_wake = true;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800315 }
316
Dmitry Torokhov95439cb2011-09-09 09:24:20 -0700317 spin_unlock_irqrestore(&kbc->lock, flags);
318
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800319 return IRQ_HANDLED;
320}
321
322static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter)
323{
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800324 int i;
325 unsigned int rst_val;
326
Rakesh Iyerbaafb432011-05-11 14:24:10 -0700327 /* Either mask all keys or none. */
Stephen Warren9eee07d2013-02-15 17:04:12 -0800328 rst_val = (filter && !kbc->wakeup) ? ~0 : 0;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800329
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700330 for (i = 0; i < kbc->hw_support->max_rows; i++)
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800331 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800332}
333
334static void tegra_kbc_config_pins(struct tegra_kbc *kbc)
335{
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800336 int i;
337
338 for (i = 0; i < KBC_MAX_GPIO; i++) {
339 u32 r_shft = 5 * (i % 6);
340 u32 c_shft = 4 * (i % 8);
Rakesh Iyer7530c4a2011-01-28 22:05:14 -0800341 u32 r_mask = 0x1f << r_shft;
342 u32 c_mask = 0x0f << c_shft;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800343 u32 r_offs = (i / 6) * 4 + KBC_ROW_CFG0_0;
344 u32 c_offs = (i / 8) * 4 + KBC_COL_CFG0_0;
345 u32 row_cfg = readl(kbc->mmio + r_offs);
346 u32 col_cfg = readl(kbc->mmio + c_offs);
347
348 row_cfg &= ~r_mask;
349 col_cfg &= ~c_mask;
350
Stephen Warren9eee07d2013-02-15 17:04:12 -0800351 switch (kbc->pin_cfg[i].type) {
Shridhar Rasal023cea02012-02-03 00:27:30 -0800352 case PIN_CFG_ROW:
Stephen Warren9eee07d2013-02-15 17:04:12 -0800353 row_cfg |= ((kbc->pin_cfg[i].num << 1) | 1) << r_shft;
Shridhar Rasal023cea02012-02-03 00:27:30 -0800354 break;
355
356 case PIN_CFG_COL:
Stephen Warren9eee07d2013-02-15 17:04:12 -0800357 col_cfg |= ((kbc->pin_cfg[i].num << 1) | 1) << c_shft;
Shridhar Rasal023cea02012-02-03 00:27:30 -0800358 break;
359
360 case PIN_CFG_IGNORE:
361 break;
362 }
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800363
364 writel(row_cfg, kbc->mmio + r_offs);
365 writel(col_cfg, kbc->mmio + c_offs);
366 }
367}
368
369static int tegra_kbc_start(struct tegra_kbc *kbc)
370{
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800371 unsigned int debounce_cnt;
372 u32 val = 0;
373
Prashant Gaikwadf7624702012-06-05 09:59:39 +0530374 clk_prepare_enable(kbc->clk);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800375
376 /* Reset the KBC controller to clear all previous status.*/
Stephen Warrenfe6b0df2013-11-06 16:48:16 -0700377 reset_control_assert(kbc->rst);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800378 udelay(100);
Stephen Warrenfe6b0df2013-11-06 16:48:16 -0700379 reset_control_assert(kbc->rst);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800380 udelay(100);
381
382 tegra_kbc_config_pins(kbc);
383 tegra_kbc_setup_wakekeys(kbc, false);
384
Stephen Warren9eee07d2013-02-15 17:04:12 -0800385 writel(kbc->repeat_cnt, kbc->mmio + KBC_RPT_DLY_0);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800386
387 /* Keyboard debounce count is maximum of 12 bits. */
Stephen Warren9eee07d2013-02-15 17:04:12 -0800388 debounce_cnt = min(kbc->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800389 val = KBC_DEBOUNCE_CNT_SHIFT(debounce_cnt);
390 val |= KBC_FIFO_TH_CNT_SHIFT(1); /* set fifo interrupt threshold to 1 */
391 val |= KBC_CONTROL_FIFO_CNT_INT_EN; /* interrupt on FIFO threshold */
392 val |= KBC_CONTROL_KBC_EN; /* enable */
393 writel(val, kbc->mmio + KBC_CONTROL_0);
394
395 /*
396 * Compute the delay(ns) from interrupt mode to continuous polling
397 * mode so the timer routine is scheduled appropriately.
398 */
399 val = readl(kbc->mmio + KBC_INIT_DLY_0);
400 kbc->cp_dly_jiffies = usecs_to_jiffies((val & 0xfffff) * 32);
401
402 kbc->num_pressed_keys = 0;
403
404 /*
405 * Atomically clear out any remaining entries in the key FIFO
406 * and enable keyboard interrupts.
407 */
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800408 while (1) {
409 val = readl(kbc->mmio + KBC_INT_0);
410 val >>= 4;
411 if (!val)
412 break;
413
414 val = readl(kbc->mmio + KBC_KP_ENT0_0);
415 val = readl(kbc->mmio + KBC_KP_ENT1_0);
416 }
417 writel(0x7, kbc->mmio + KBC_INT_0);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800418
419 enable_irq(kbc->irq);
420
421 return 0;
422}
423
424static void tegra_kbc_stop(struct tegra_kbc *kbc)
425{
426 unsigned long flags;
427 u32 val;
428
429 spin_lock_irqsave(&kbc->lock, flags);
430 val = readl(kbc->mmio + KBC_CONTROL_0);
431 val &= ~1;
432 writel(val, kbc->mmio + KBC_CONTROL_0);
433 spin_unlock_irqrestore(&kbc->lock, flags);
434
435 disable_irq(kbc->irq);
436 del_timer_sync(&kbc->timer);
437
Prashant Gaikwadf7624702012-06-05 09:59:39 +0530438 clk_disable_unprepare(kbc->clk);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800439}
440
441static int tegra_kbc_open(struct input_dev *dev)
442{
443 struct tegra_kbc *kbc = input_get_drvdata(dev);
444
445 return tegra_kbc_start(kbc);
446}
447
448static void tegra_kbc_close(struct input_dev *dev)
449{
450 struct tegra_kbc *kbc = input_get_drvdata(dev);
451
452 return tegra_kbc_stop(kbc);
453}
454
Stephen Warren9eee07d2013-02-15 17:04:12 -0800455static bool tegra_kbc_check_pin_cfg(const struct tegra_kbc *kbc,
456 unsigned int *num_rows)
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800457{
458 int i;
459
460 *num_rows = 0;
461
462 for (i = 0; i < KBC_MAX_GPIO; i++) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800463 const struct tegra_kbc_pin_cfg *pin_cfg = &kbc->pin_cfg[i];
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800464
Shridhar Rasal023cea02012-02-03 00:27:30 -0800465 switch (pin_cfg->type) {
466 case PIN_CFG_ROW:
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700467 if (pin_cfg->num >= kbc->hw_support->max_rows) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800468 dev_err(kbc->dev,
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800469 "pin_cfg[%d]: invalid row number %d\n",
470 i, pin_cfg->num);
471 return false;
472 }
473 (*num_rows)++;
Shridhar Rasal023cea02012-02-03 00:27:30 -0800474 break;
475
476 case PIN_CFG_COL:
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700477 if (pin_cfg->num >= kbc->hw_support->max_columns) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800478 dev_err(kbc->dev,
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800479 "pin_cfg[%d]: invalid column number %d\n",
480 i, pin_cfg->num);
481 return false;
482 }
Shridhar Rasal023cea02012-02-03 00:27:30 -0800483 break;
484
485 case PIN_CFG_IGNORE:
486 break;
487
488 default:
Stephen Warren9eee07d2013-02-15 17:04:12 -0800489 dev_err(kbc->dev,
Shridhar Rasal023cea02012-02-03 00:27:30 -0800490 "pin_cfg[%d]: invalid entry type %d\n",
491 pin_cfg->type, pin_cfg->num);
492 return false;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800493 }
494 }
495
496 return true;
497}
498
Stephen Warren9eee07d2013-02-15 17:04:12 -0800499static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)
Olof Johanssona445c7f2011-12-29 09:58:16 -0800500{
Stephen Warren9eee07d2013-02-15 17:04:12 -0800501 struct device_node *np = kbc->dev->of_node;
Olof Johansson145e9732012-03-13 21:36:29 -0700502 u32 prop;
503 int i;
Laxman Dewangan88390242013-01-06 18:32:22 -0800504 u32 num_rows = 0;
505 u32 num_cols = 0;
506 u32 cols_cfg[KBC_MAX_GPIO];
507 u32 rows_cfg[KBC_MAX_GPIO];
508 int proplen;
509 int ret;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800510
Olof Johansson145e9732012-03-13 21:36:29 -0700511 if (!of_property_read_u32(np, "nvidia,debounce-delay-ms", &prop))
Stephen Warren9eee07d2013-02-15 17:04:12 -0800512 kbc->debounce_cnt = prop;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800513
Olof Johansson145e9732012-03-13 21:36:29 -0700514 if (!of_property_read_u32(np, "nvidia,repeat-delay-ms", &prop))
Stephen Warren9eee07d2013-02-15 17:04:12 -0800515 kbc->repeat_cnt = prop;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800516
Olof Johansson145e9732012-03-13 21:36:29 -0700517 if (of_find_property(np, "nvidia,needs-ghost-filter", NULL))
Stephen Warren9eee07d2013-02-15 17:04:12 -0800518 kbc->use_ghost_filter = true;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800519
Olof Johansson145e9732012-03-13 21:36:29 -0700520 if (of_find_property(np, "nvidia,wakeup-source", NULL))
Stephen Warren9eee07d2013-02-15 17:04:12 -0800521 kbc->wakeup = true;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800522
Laxman Dewangan88390242013-01-06 18:32:22 -0800523 if (!of_get_property(np, "nvidia,kbc-row-pins", &proplen)) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800524 dev_err(kbc->dev, "property nvidia,kbc-row-pins not found\n");
525 return -ENOENT;
Laxman Dewangan88390242013-01-06 18:32:22 -0800526 }
527 num_rows = proplen / sizeof(u32);
528
529 if (!of_get_property(np, "nvidia,kbc-col-pins", &proplen)) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800530 dev_err(kbc->dev, "property nvidia,kbc-col-pins not found\n");
531 return -ENOENT;
Laxman Dewangan88390242013-01-06 18:32:22 -0800532 }
533 num_cols = proplen / sizeof(u32);
534
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700535 if (num_rows > kbc->hw_support->max_rows) {
536 dev_err(kbc->dev,
537 "Number of rows is more than supported by hardware\n");
538 return -EINVAL;
539 }
540
541 if (num_cols > kbc->hw_support->max_columns) {
542 dev_err(kbc->dev,
543 "Number of cols is more than supported by hardware\n");
544 return -EINVAL;
545 }
546
Laxman Dewangan88390242013-01-06 18:32:22 -0800547 if (!of_get_property(np, "linux,keymap", &proplen)) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800548 dev_err(kbc->dev, "property linux,keymap not found\n");
549 return -ENOENT;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800550 }
551
Laxman Dewangan88390242013-01-06 18:32:22 -0800552 if (!num_rows || !num_cols || ((num_rows + num_cols) > KBC_MAX_GPIO)) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800553 dev_err(kbc->dev,
Laxman Dewangan88390242013-01-06 18:32:22 -0800554 "keypad rows/columns not porperly specified\n");
Stephen Warren9eee07d2013-02-15 17:04:12 -0800555 return -EINVAL;
Laxman Dewangan88390242013-01-06 18:32:22 -0800556 }
557
558 /* Set all pins as non-configured */
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700559 for (i = 0; i < kbc->num_rows_and_columns; i++)
Stephen Warren9eee07d2013-02-15 17:04:12 -0800560 kbc->pin_cfg[i].type = PIN_CFG_IGNORE;
Laxman Dewangan88390242013-01-06 18:32:22 -0800561
562 ret = of_property_read_u32_array(np, "nvidia,kbc-row-pins",
563 rows_cfg, num_rows);
564 if (ret < 0) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800565 dev_err(kbc->dev, "Rows configurations are not proper\n");
566 return -EINVAL;
Laxman Dewangan88390242013-01-06 18:32:22 -0800567 }
568
569 ret = of_property_read_u32_array(np, "nvidia,kbc-col-pins",
570 cols_cfg, num_cols);
571 if (ret < 0) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800572 dev_err(kbc->dev, "Cols configurations are not proper\n");
573 return -EINVAL;
Laxman Dewangan88390242013-01-06 18:32:22 -0800574 }
575
576 for (i = 0; i < num_rows; i++) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800577 kbc->pin_cfg[rows_cfg[i]].type = PIN_CFG_ROW;
578 kbc->pin_cfg[rows_cfg[i]].num = i;
Laxman Dewangan88390242013-01-06 18:32:22 -0800579 }
580
581 for (i = 0; i < num_cols; i++) {
Stephen Warren9eee07d2013-02-15 17:04:12 -0800582 kbc->pin_cfg[cols_cfg[i]].type = PIN_CFG_COL;
583 kbc->pin_cfg[cols_cfg[i]].num = i;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800584 }
585
Stephen Warren9eee07d2013-02-15 17:04:12 -0800586 return 0;
Olof Johanssona445c7f2011-12-29 09:58:16 -0800587}
Olof Johanssona445c7f2011-12-29 09:58:16 -0800588
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700589static const struct tegra_kbc_hw_support tegra20_kbc_hw_support = {
590 .max_rows = 16,
591 .max_columns = 8,
592};
593
594static const struct tegra_kbc_hw_support tegra11_kbc_hw_support = {
595 .max_rows = 11,
596 .max_columns = 8,
597};
598
599static const struct of_device_id tegra_kbc_of_match[] = {
600 { .compatible = "nvidia,tegra114-kbc", .data = &tegra11_kbc_hw_support},
601 { .compatible = "nvidia,tegra30-kbc", .data = &tegra20_kbc_hw_support},
602 { .compatible = "nvidia,tegra20-kbc", .data = &tegra20_kbc_hw_support},
603 { },
604};
605MODULE_DEVICE_TABLE(of, tegra_kbc_of_match);
606
Bill Pemberton5298cc42012-11-23 21:38:25 -0800607static int tegra_kbc_probe(struct platform_device *pdev)
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800608{
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800609 struct tegra_kbc *kbc;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800610 struct resource *res;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800611 int err;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800612 int num_rows = 0;
613 unsigned int debounce_cnt;
614 unsigned int scan_time_rows;
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700615 unsigned int keymap_rows;
616 const struct of_device_id *match;
617
Sachin Kamat3cbd04f2013-10-06 00:50:31 -0700618 match = of_match_device(tegra_kbc_of_match, &pdev->dev);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800619
Stephen Warren9eee07d2013-02-15 17:04:12 -0800620 kbc = devm_kzalloc(&pdev->dev, sizeof(*kbc), GFP_KERNEL);
621 if (!kbc) {
622 dev_err(&pdev->dev, "failed to alloc memory for kbc\n");
623 return -ENOMEM;
624 }
Olof Johanssona445c7f2011-12-29 09:58:16 -0800625
Stephen Warren9eee07d2013-02-15 17:04:12 -0800626 kbc->dev = &pdev->dev;
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700627 kbc->hw_support = match->data;
628 kbc->max_keys = kbc->hw_support->max_rows *
629 kbc->hw_support->max_columns;
630 kbc->num_rows_and_columns = kbc->hw_support->max_rows +
631 kbc->hw_support->max_columns;
632 keymap_rows = kbc->max_keys;
Stephen Warren9eee07d2013-02-15 17:04:12 -0800633 spin_lock_init(&kbc->lock);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800634
Stephen Warren9eee07d2013-02-15 17:04:12 -0800635 err = tegra_kbc_parse_dt(kbc);
636 if (err)
637 return err;
638
639 if (!tegra_kbc_check_pin_cfg(kbc, &num_rows))
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800640 return -EINVAL;
641
Stephen Warren9eee07d2013-02-15 17:04:12 -0800642 kbc->irq = platform_get_irq(pdev, 0);
643 if (kbc->irq < 0) {
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800644 dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800645 return -ENXIO;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800646 }
647
Stephen Warren9eee07d2013-02-15 17:04:12 -0800648 kbc->idev = devm_input_allocate_device(&pdev->dev);
649 if (!kbc->idev) {
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800650 dev_err(&pdev->dev, "failed to allocate input device\n");
651 return -ENOMEM;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800652 }
653
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800654 setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
655
Julia Lawalleacd0c42013-08-15 00:07:43 -0700656 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Sachin Kamatba52a7f2013-03-17 21:30:05 -0700657 kbc->mmio = devm_ioremap_resource(&pdev->dev, res);
658 if (IS_ERR(kbc->mmio))
659 return PTR_ERR(kbc->mmio);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800660
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800661 kbc->clk = devm_clk_get(&pdev->dev, NULL);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800662 if (IS_ERR(kbc->clk)) {
663 dev_err(&pdev->dev, "failed to get keyboard clock\n");
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800664 return PTR_ERR(kbc->clk);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800665 }
666
Stephen Warrenfe6b0df2013-11-06 16:48:16 -0700667 kbc->rst = devm_reset_control_get(&pdev->dev, "kbc");
668 if (IS_ERR(kbc->rst)) {
669 dev_err(&pdev->dev, "failed to get keyboard reset\n");
670 return PTR_ERR(kbc->rst);
671 }
672
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800673 /*
674 * The time delay between two consecutive reads of the FIFO is
675 * the sum of the repeat time and the time taken for scanning
676 * the rows. There is an additional delay before the row scanning
677 * starts. The repoll delay is computed in milliseconds.
678 */
Stephen Warren9eee07d2013-02-15 17:04:12 -0800679 debounce_cnt = min(kbc->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800680 scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
Stephen Warren9eee07d2013-02-15 17:04:12 -0800681 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + kbc->repeat_cnt;
Rakesh Iyer3f277572011-07-30 12:01:48 -0700682 kbc->repoll_dly = DIV_ROUND_UP(kbc->repoll_dly, KBC_CYCLE_MS);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800683
Stephen Warren9eee07d2013-02-15 17:04:12 -0800684 kbc->idev->name = pdev->name;
685 kbc->idev->id.bustype = BUS_HOST;
686 kbc->idev->dev.parent = &pdev->dev;
687 kbc->idev->open = tegra_kbc_open;
688 kbc->idev->close = tegra_kbc_close;
Dmitry Torokhov19328112012-05-10 22:37:08 -0700689
Stephen Warren9eee07d2013-02-15 17:04:12 -0800690 if (kbc->keymap_data && kbc->use_fn_map)
Laxman Dewangan914e5972013-01-06 18:34:48 -0800691 keymap_rows *= 2;
692
Stephen Warren9eee07d2013-02-15 17:04:12 -0800693 err = matrix_keypad_build_keymap(kbc->keymap_data, NULL,
Laxman Dewangane10af9e2013-03-31 00:41:12 -0700694 keymap_rows,
695 kbc->hw_support->max_columns,
Stephen Warren9eee07d2013-02-15 17:04:12 -0800696 kbc->keycode, kbc->idev);
Dmitry Torokhov19328112012-05-10 22:37:08 -0700697 if (err) {
Dmitry Torokhovb45c8f32012-05-10 22:37:15 -0700698 dev_err(&pdev->dev, "failed to setup keymap\n");
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800699 return err;
Dmitry Torokhov19328112012-05-10 22:37:08 -0700700 }
701
Stephen Warren9eee07d2013-02-15 17:04:12 -0800702 __set_bit(EV_REP, kbc->idev->evbit);
703 input_set_capability(kbc->idev, EV_MSC, MSC_SCAN);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800704
Stephen Warren9eee07d2013-02-15 17:04:12 -0800705 input_set_drvdata(kbc->idev, kbc);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800706
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800707 err = devm_request_irq(&pdev->dev, kbc->irq, tegra_kbc_isr,
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800708 IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800709 if (err) {
710 dev_err(&pdev->dev, "failed to request keyboard IRQ\n");
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800711 return err;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800712 }
713
714 disable_irq(kbc->irq);
715
716 err = input_register_device(kbc->idev);
717 if (err) {
718 dev_err(&pdev->dev, "failed to register input device\n");
Laxman Dewangan00eb81e2013-01-06 18:31:20 -0800719 return err;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800720 }
721
722 platform_set_drvdata(pdev, kbc);
Stephen Warren9eee07d2013-02-15 17:04:12 -0800723 device_init_wakeup(&pdev->dev, kbc->wakeup);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800724
725 return 0;
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800726}
727
728#ifdef CONFIG_PM_SLEEP
Laxman Dewangan1c407a12013-01-06 18:30:21 -0800729static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable)
730{
731 u32 val;
732
733 val = readl(kbc->mmio + KBC_CONTROL_0);
734 if (enable)
735 val |= KBC_CONTROL_KEYPRESS_INT_EN;
736 else
737 val &= ~KBC_CONTROL_KEYPRESS_INT_EN;
738 writel(val, kbc->mmio + KBC_CONTROL_0);
739}
740
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800741static int tegra_kbc_suspend(struct device *dev)
742{
743 struct platform_device *pdev = to_platform_device(dev);
744 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
745
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700746 mutex_lock(&kbc->idev->mutex);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800747 if (device_may_wakeup(&pdev->dev)) {
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700748 disable_irq(kbc->irq);
749 del_timer_sync(&kbc->timer);
750 tegra_kbc_set_fifo_interrupt(kbc, false);
751
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800752 /* Forcefully clear the interrupt status */
753 writel(0x7, kbc->mmio + KBC_INT_0);
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700754 /*
755 * Store the previous resident time of continuous polling mode.
756 * Force the keyboard into interrupt mode.
757 */
758 kbc->cp_to_wkup_dly = readl(kbc->mmio + KBC_TO_CNT_0);
759 writel(0, kbc->mmio + KBC_TO_CNT_0);
760
761 tegra_kbc_setup_wakekeys(kbc, true);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800762 msleep(30);
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700763
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800764 kbc->keypress_caused_wake = false;
Rakesh Iyerb6834b02012-01-22 23:27:54 -0800765 /* Enable keypress interrupt before going into suspend. */
766 tegra_kbc_set_keypress_interrupt(kbc, true);
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800767 enable_irq(kbc->irq);
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700768 enable_irq_wake(kbc->irq);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800769 } else {
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800770 if (kbc->idev->users)
771 tegra_kbc_stop(kbc);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800772 }
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700773 mutex_unlock(&kbc->idev->mutex);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800774
775 return 0;
776}
777
778static int tegra_kbc_resume(struct device *dev)
779{
780 struct platform_device *pdev = to_platform_device(dev);
781 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
782 int err = 0;
783
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700784 mutex_lock(&kbc->idev->mutex);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800785 if (device_may_wakeup(&pdev->dev)) {
786 disable_irq_wake(kbc->irq);
787 tegra_kbc_setup_wakekeys(kbc, false);
Rakesh Iyerb6834b02012-01-22 23:27:54 -0800788 /* We will use fifo interrupts for key detection. */
789 tegra_kbc_set_keypress_interrupt(kbc, false);
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700790
791 /* Restore the resident time of continuous polling mode. */
792 writel(kbc->cp_to_wkup_dly, kbc->mmio + KBC_TO_CNT_0);
793
794 tegra_kbc_set_fifo_interrupt(kbc, true);
795
Rakesh Iyerfd0fc212011-12-29 19:27:44 -0800796 if (kbc->keypress_caused_wake && kbc->wakeup_key) {
797 /*
798 * We can't report events directly from the ISR
799 * because timekeeping is stopped when processing
800 * wakeup request and we get a nasty warning when
801 * we try to call do_gettimeofday() in evdev
802 * handler.
803 */
804 input_report_key(kbc->idev, kbc->wakeup_key, 1);
805 input_sync(kbc->idev);
806 input_report_key(kbc->idev, kbc->wakeup_key, 0);
807 input_sync(kbc->idev);
808 }
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800809 } else {
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800810 if (kbc->idev->users)
811 err = tegra_kbc_start(kbc);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800812 }
Rakesh Iyerd0d150e2011-09-08 15:34:11 -0700813 mutex_unlock(&kbc->idev->mutex);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800814
815 return err;
816}
817#endif
818
819static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume);
820
821static struct platform_driver tegra_kbc_driver = {
822 .probe = tegra_kbc_probe,
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800823 .driver = {
824 .name = "tegra-kbc",
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800825 .pm = &tegra_kbc_pm_ops,
Olof Johanssona445c7f2011-12-29 09:58:16 -0800826 .of_match_table = tegra_kbc_of_match,
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800827 },
828};
JJ Ding5146c842011-11-29 11:08:39 -0800829module_platform_driver(tegra_kbc_driver);
Rakesh Iyer11f5b302011-01-19 23:38:47 -0800830
831MODULE_LICENSE("GPL");
832MODULE_AUTHOR("Rakesh Iyer <riyer@nvidia.com>");
833MODULE_DESCRIPTION("Tegra matrix keyboard controller driver");
834MODULE_ALIAS("platform:tegra-kbc");