mach-omap2: fix more arch_initcall() breakage
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap3evm.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3evm.c
3  *
4  * Copyright (C) 2008 Texas Instruments
5  *
6  * Modified from mach-omap2/board-3430sdp.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/input.h>
23 #include <linux/spi/spi.h>
24 #include <linux/spi/ads7846.h>
25
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <linux/io.h>
31 #include <linux/delay.h>
32
33 #include <mach/gpio.h>
34 #include <mach/keypad.h>
35 #include <mach/board.h>
36 #include <mach/hsmmc.h>
37 #include <mach/usb-musb.h>
38 #include <mach/usb-ehci.h>
39 #include <mach/common.h>
40 #include <mach/mcspi.h>
41
42 #include "sdram-micron-mt46h32m32lf-6.h"
43
44 static struct resource omap3evm_smc911x_resources[] = {
45         [0] =   {
46                 .start  = OMAP3EVM_ETHR_START,
47                 .end    = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
48                 .flags  = IORESOURCE_MEM,
49         },
50         [1] =   {
51                 .start  = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
52                 .end    = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
53                 .flags  = IORESOURCE_IRQ,
54         },
55 };
56
57 static struct platform_device omap3evm_smc911x_device = {
58         .name           = "smc911x",
59         .id             = -1,
60         .num_resources  = ARRAY_SIZE(omap3evm_smc911x_resources),
61         .resource       = &omap3evm_smc911x_resources [0],
62 };
63
64 static inline void __init omap3evm_init_smc911x(void)
65 {
66         int eth_cs;
67         struct clk *l3ck;
68         unsigned int rate;
69
70         eth_cs = OMAP3EVM_SMC911X_CS;
71
72         l3ck = clk_get(NULL, "l3_ck");
73         if (IS_ERR(l3ck))
74                 rate = 100000000;
75         else
76                 rate = clk_get_rate(l3ck);
77
78         if (omap_request_gpio(OMAP3EVM_ETHR_GPIO_IRQ) < 0) {
79                 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
80                         OMAP3EVM_ETHR_GPIO_IRQ);
81                 return;
82         }
83
84         omap_set_gpio_direction(OMAP3EVM_ETHR_GPIO_IRQ, 1);
85 }
86
87 static struct omap_uart_config omap3_evm_uart_config __initdata = {
88         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
89 };
90
91 static int __init omap3_evm_i2c_init(void)
92 {
93         omap_register_i2c_bus(1, 2600, NULL, 0);
94         omap_register_i2c_bus(2, 400, NULL, 0);
95         omap_register_i2c_bus(3, 400, NULL, 0);
96         return 0;
97 }
98
99 static struct platform_device omap3_evm_lcd_device = {
100         .name           = "omap3evm_lcd",
101         .id             = -1,
102 };
103
104 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
105         .ctrl_name      = "internal",
106 };
107
108 static struct platform_device omap3_evm_twl4030rtc_device = {
109         .name           = "twl4030_rtc",
110         .id             = -1,
111 };
112
113 static void ads7846_dev_init(void)
114 {
115         if (omap_request_gpio(OMAP3_EVM_TS_GPIO) < 0)
116                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
117
118         omap_set_gpio_direction(OMAP3_EVM_TS_GPIO, 1);
119
120         omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
121         omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
122 }
123
124 static int ads7846_get_pendown_state(void)
125 {
126         return !omap_get_gpio_datain(OMAP3_EVM_TS_GPIO);
127 }
128
129 struct ads7846_platform_data ads7846_config = {
130         .x_max                  = 0x0fff,
131         .y_max                  = 0x0fff,
132         .x_plate_ohms           = 180,
133         .pressure_max           = 255,
134         .debounce_max           = 10,
135         .debounce_tol           = 3,
136         .debounce_rep           = 1,
137         .get_pendown_state      = ads7846_get_pendown_state,
138         .keep_vref_on           = 1,
139         .settle_delay_usecs     = 150,
140 };
141
142 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
143         .turbo_mode     = 0,
144         .single_channel = 1,  /* 0: slave, 1: master */
145 };
146
147 struct spi_board_info omap3evm_spi_board_info[] = {
148         [0] = {
149                 .modalias               = "ads7846",
150                 .bus_num                = 1,
151                 .chip_select            = 0,
152                 .max_speed_hz           = 1500000,
153                 .controller_data        = &ads7846_mcspi_config,
154                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
155                 .platform_data          = &ads7846_config,
156         },
157 };
158
159 static int omap3evm_keymap[] = {
160         KEY(0, 0, KEY_LEFT),
161         KEY(0, 1, KEY_RIGHT),
162         KEY(0, 2, KEY_A),
163         KEY(0, 3, KEY_B),
164         KEY(1, 0, KEY_DOWN),
165         KEY(1, 1, KEY_UP),
166         KEY(1, 2, KEY_E),
167         KEY(1, 3, KEY_F),
168         KEY(2, 0, KEY_ENTER),
169         KEY(2, 1, KEY_I),
170         KEY(2, 2, KEY_J),
171         KEY(2, 3, KEY_K),
172         KEY(3, 0, KEY_M),
173         KEY(3, 1, KEY_N),
174         KEY(3, 2, KEY_O),
175         KEY(3, 3, KEY_P)
176 };
177
178 static struct omap_kp_platform_data omap3evm_kp_data = {
179         .rows           = 4,
180         .cols           = 4,
181         .keymap         = omap3evm_keymap,
182         .keymapsize     = ARRAY_SIZE(omap3evm_keymap),
183         .rep            = 1,
184 };
185
186 static struct platform_device omap3evm_kp_device = {
187         .name           = "omap_twl4030keypad",
188         .id             = -1,
189         .dev            = {
190                                 .platform_data = &omap3evm_kp_data,
191                         },
192 };
193
194 static void __init omap3_evm_init_irq(void)
195 {
196         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
197         omap_init_irq();
198         omap_gpio_init();
199         omap3evm_init_smc911x();
200 }
201
202 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
203         { OMAP_TAG_UART,        &omap3_evm_uart_config },
204         { OMAP_TAG_LCD,         &omap3_evm_lcd_config },
205 };
206
207 static struct platform_device *omap3_evm_devices[] __initdata = {
208         &omap3_evm_lcd_device,
209         &omap3evm_kp_device,
210 #ifdef CONFIG_RTC_DRV_TWL4030
211         &omap3_evm_twl4030rtc_device,
212 #endif
213         &omap3evm_smc911x_device,
214 };
215
216 static void __init omap3_evm_init(void)
217 {
218         omap3_evm_i2c_init();
219
220         platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
221         omap_board_config = omap3_evm_config;
222         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
223
224         spi_register_board_info(omap3evm_spi_board_info,
225                                 ARRAY_SIZE(omap3evm_spi_board_info));
226
227         omap_serial_init();
228         hsmmc_init();
229         usb_musb_init();
230         usb_ehci_init();
231         omap3evm_flash_init();
232         ads7846_dev_init();
233 }
234
235 static void __init omap3_evm_map_io(void)
236 {
237         omap2_set_globals_343x();
238         omap2_map_common_io();
239 }
240
241 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
242         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
243         .phys_io        = 0x48000000,
244         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
245         .boot_params    = 0x80000100,
246         .map_io         = omap3_evm_map_io,
247         .init_irq       = omap3_evm_init_irq,
248         .init_machine   = omap3_evm_init,
249         .timer          = &omap_timer,
250 MACHINE_END