cb798e951c1790cdf62aa29f0cf6d054c8b11331
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-kbc.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-kbc.c
3  * KBC configuration for Nvidia tegra3 cardhu platform.
4  *
5  * Copyright (C) 2011 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/device.h>
26
27 #include <mach/irqs.h>
28 #include <mach/io.h>
29 #include <mach/iomap.h>
30 #include <mach/kbc.h>
31
32 #define CARDHU_ROW_COUNT        2
33 #define CARDHU_COL_COUNT        4
34
35 static int plain_kbd_keycode[] = {
36         KEY_WAKEUP, KEY_RESERVED, KEY_VOLUMEDOWN, KEY_VOLUMEUP,
37         KEY_HOME,   KEY_MENU,     KEY_BACK,       KEY_SEARCH};
38
39 static struct tegra_kbc_wake_key cardhu_wake_cfg[] = {
40         [0] = {
41                 .row = 0,
42                 .col = 0,
43         },
44 };
45
46 static struct tegra_kbc_platform_data cardhu_kbc_platform_data = {
47         .debounce_cnt = 20,
48         .repeat_cnt = 50 * 32,
49         .scan_timeout_cnt = 3000 * 32,
50         .plain_keycode = plain_kbd_keycode,
51         .fn_keycode = NULL,
52         .is_filter_keys = false,
53         .is_wake_on_any_key = false,
54         .wake_key_cnt = 1,
55         .wake_cfg = &cardhu_wake_cfg[0],
56 };
57
58 static struct resource cardhu_kbc_resources[] = {
59         [0] = {
60                 .start = TEGRA_KBC_BASE,
61                 .end   = TEGRA_KBC_BASE + TEGRA_KBC_SIZE - 1,
62                 .flags = IORESOURCE_MEM,
63         },
64         [1] = {
65                 .start = INT_KBC,
66                 .end   = INT_KBC,
67                 .flags = IORESOURCE_IRQ,
68         },
69 };
70
71
72 struct platform_device cardhu_kbc_device = {
73         .name = "tegra-kbc",
74         .id = -1,
75         .dev = {
76                 .platform_data = &cardhu_kbc_platform_data,
77         },
78         .resource = cardhu_kbc_resources,
79         .num_resources = ARRAY_SIZE(cardhu_kbc_resources),
80 };
81
82 int __init cardhu_kbc_init(void)
83 {
84         struct tegra_kbc_platform_data *data = &cardhu_kbc_platform_data;
85         int i;
86
87         pr_info("KBC: cardhu_kbc_init\n");
88
89          /* Setup the pin configuration information. */
90         for (i = 0; i < KBC_MAX_GPIO; i++) {
91                 data->pin_cfg[i].num = 0;
92                 data->pin_cfg[i].pin_type = kbc_pin_unused;
93         }
94         for (i = 0; i < CARDHU_ROW_COUNT; i++) {
95                 data->pin_cfg[i].num = i;
96                 data->pin_cfg[i].pin_type = kbc_pin_row;
97         }
98
99         for (i = 0; i < CARDHU_COL_COUNT; i++) {
100                 data->pin_cfg[i + CARDHU_ROW_COUNT].num = i;
101                 data->pin_cfg[i + CARDHU_ROW_COUNT].pin_type = kbc_pin_col;
102         }
103         platform_device_register(&cardhu_kbc_device);
104         return 0;
105 }