]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap2evm.c
OMAP2EVM TWL4030 keypad update
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-omap2evm.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap2evm.c
3  *
4  * Copyright (C) 2008 Mistral Solutions Pvt Ltd
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
17 #include <linux/err.h>
18 #include <linux/clk.h>
19 #include <linux/io.h>
20 #include <linux/input.h>
21 #include <linux/i2c/twl4030.h>
22
23 #include <mach/hardware.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27
28 #include <mach/gpio.h>
29 #include <mach/board.h>
30 #include <mach/common.h>
31 #include <mach/hsmmc.h>
32 #include <mach/keypad.h>
33
34 static struct resource omap2evm_smc911x_resources[] = {
35         [0] =   {
36                 .start  = OMAP2EVM_ETHR_START,
37                 .end    = (OMAP2EVM_ETHR_START + OMAP2EVM_ETHR_SIZE - 1),
38                 .flags  = IORESOURCE_MEM,
39         },
40         [1] =   {
41                 .start  = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
42                 .end    = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
43                 .flags  = IORESOURCE_IRQ,
44         },
45 };
46
47 static struct platform_device omap2evm_smc911x_device = {
48         .name       = "smc911x",
49         .id     = -1,
50         .num_resources  = ARRAY_SIZE(omap2evm_smc911x_resources),
51         .resource   = &omap2evm_smc911x_resources [0],
52 };
53
54 static inline void __init omap2evm_init_smc911x(void)
55 {
56         int gpio = OMAP2EVM_ETHR_GPIO_IRQ;
57         int ret;
58
59         ret = gpio_request(gpio, "smc911x IRQ");
60         if (ret < 0) {
61                 printk(KERN_ERR "Failed to request GPIO %d for smc911x IRQ\n",
62                                 gpio);
63                 return;
64         }
65         gpio_direction_input(gpio);
66
67 }
68
69 static struct platform_device omap2_evm_lcd_device = {
70         .name           = "omap2evm_lcd",
71         .id             = -1,
72 };
73
74 static struct omap_lcd_config omap2_evm_lcd_config __initdata = {
75         .ctrl_name      = "internal",
76 };
77
78 static int omap2evm_keymap[] = {
79         KEY(0, 0, KEY_LEFT),
80         KEY(0, 1, KEY_RIGHT),
81         KEY(0, 2, KEY_A),
82         KEY(0, 3, KEY_B),
83         KEY(1, 0, KEY_DOWN),
84         KEY(1, 1, KEY_UP),
85         KEY(1, 2, KEY_E),
86         KEY(1, 3, KEY_F),
87         KEY(2, 0, KEY_ENTER),
88         KEY(2, 1, KEY_I),
89         KEY(2, 2, KEY_J),
90         KEY(2, 3, KEY_K),
91         KEY(3, 0, KEY_M),
92         KEY(3, 1, KEY_N),
93         KEY(3, 2, KEY_O),
94         KEY(3, 3, KEY_P)
95 };
96
97 static struct omap_kp_platform_data omap2evm_kp_data = {
98         .rows           = 4,
99         .cols           = 4,
100         .keymap         = omap2evm_keymap,
101         .keymapsize     = ARRAY_SIZE(omap2evm_keymap),
102         .rep            = 1,
103         .irq            = TWL4030_MODIRQ_KEYPAD,
104 };
105
106 static struct platform_device omap2evm_kp_device = {
107         .name           = "omap_twl4030keypad",
108         .id             = -1,
109         .dev            = {
110                                 .platform_data = &omap2evm_kp_data,
111                         },
112 };
113
114 static void __init omap2_evm_init_irq(void)
115 {
116         omap2_init_common_hw(NULL);
117         omap_init_irq();
118         omap_gpio_init();
119         omap2evm_init_smc911x();
120 }
121
122 static struct omap_uart_config omap2_evm_uart_config __initdata = {
123         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
124 };
125
126 static struct omap_mmc_config omap2_evm_mmc_config __initdata = {
127         .mmc [0] = {
128                 .enabled        = 1,
129                 .wire4          = 1,
130         },
131 };
132
133 static struct omap_board_config_kernel omap2_evm_config[] __initdata = {
134         { OMAP_TAG_UART,        &omap2_evm_uart_config },
135         { OMAP_TAG_LCD,         &omap2_evm_lcd_config },
136         { OMAP_TAG_MMC,         &omap2_evm_mmc_config },
137 };
138
139 static int __init omap2_evm_i2c_init(void)
140 {
141         /*
142          * Registering bus 2 first to avoid twl4030 misbehaving as OMAP2EVM
143          * has twl4030 on bus 2
144          */
145         omap_register_i2c_bus(2, 2600, NULL, 0);
146         omap_register_i2c_bus(1, 400, NULL, 0);
147         return 0;
148 }
149
150 static struct platform_device *omap2_evm_devices[] __initdata = {
151         &omap2_evm_lcd_device,
152         &omap2evm_smc911x_device,
153         &omap2evm_kp_device,
154 };
155
156 static void __init omap2_evm_init(void)
157 {
158         platform_add_devices(omap2_evm_devices, ARRAY_SIZE(omap2_evm_devices));
159         omap_board_config = omap2_evm_config;
160         omap_board_config_size = ARRAY_SIZE(omap2_evm_config);
161         omap_serial_init();
162         hsmmc_init();
163 }
164
165 static void __init omap2_evm_map_io(void)
166 {
167         omap2_set_globals_243x();
168         omap2_map_common_io();
169 }
170
171 arch_initcall(omap2_evm_i2c_init);
172
173 MACHINE_START(OMAP2EVM, "OMAP2EVM Board")
174         /* Maintainer:  Arun KS <arunks@mistralsolutions.com> */
175         .phys_io        = 0x48000000,
176         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
177         .boot_params    = 0x80000100,
178         .map_io         = omap2_evm_map_io,
179         .init_irq       = omap2_evm_init_irq,
180         .init_machine   = omap2_evm_init,
181         .timer          = &omap_timer,
182 MACHINE_END