]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3evm.c
Merge branch 'omap-fixes'
[linux-2.6-omap-h63xx.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/input.h>
22 #include <linux/leds.h>
23
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
26 #include <linux/i2c/twl4030.h>
27
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32
33 #include <mach/gpio.h>
34 #include <mach/board.h>
35 #include <mach/mux.h>
36 #include <mach/usb.h>
37 #include <mach/common.h>
38 #include <mach/mcspi.h>
39
40 #include "sdram-micron-mt46h32m32lf-6.h"
41 #include "twl4030-generic-scripts.h"
42 #include "mmc-twl4030.h"
43
44 #define OMAP3_EVM_TS_GPIO       175
45
46 #define OMAP3EVM_ETHR_START     0x2c000000
47 #define OMAP3EVM_ETHR_SIZE      1024
48 #define OMAP3EVM_ETHR_GPIO_IRQ  176
49 #define OMAP3EVM_SMC911X_CS     5
50
51 extern void omap3evm_flash_init(void);
52
53 static struct resource omap3evm_smc911x_resources[] = {
54         [0] =   {
55                 .start  = OMAP3EVM_ETHR_START,
56                 .end    = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
57                 .flags  = IORESOURCE_MEM,
58         },
59         [1] =   {
60                 .start  = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
61                 .end    = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
62                 .flags  = IORESOURCE_IRQ,
63         },
64 };
65
66 static struct platform_device omap3evm_smc911x_device = {
67         .name           = "smc911x",
68         .id             = -1,
69         .num_resources  = ARRAY_SIZE(omap3evm_smc911x_resources),
70         .resource       = &omap3evm_smc911x_resources [0],
71 };
72
73 static inline void __init omap3evm_init_smc911x(void)
74 {
75         int eth_cs;
76         struct clk *l3ck;
77         unsigned int rate;
78
79         eth_cs = OMAP3EVM_SMC911X_CS;
80
81         l3ck = clk_get(NULL, "l3_ck");
82         if (IS_ERR(l3ck))
83                 rate = 100000000;
84         else
85                 rate = clk_get_rate(l3ck);
86
87         if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x irq") < 0) {
88                 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
89                         OMAP3EVM_ETHR_GPIO_IRQ);
90                 return;
91         }
92
93         gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
94 }
95
96 static struct omap_uart_config omap3_evm_uart_config __initdata = {
97         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
98 };
99
100 static struct twl4030_hsmmc_info mmc[] = {
101         {
102                 .mmc            = 1,
103                 .wires          = 4,
104                 .gpio_cd        = -EINVAL,
105                 .gpio_wp        = 63,
106         },
107         {}      /* Terminator */
108 };
109
110 static struct gpio_led gpio_leds[] = {
111         {
112                 .name                   = "omap3evm::ledb",
113                 /* normally not visible (board underside) */
114                 .default_trigger        = "default-on",
115                 .gpio                   = -EINVAL,      /* gets replaced */
116                 .active_low             = true,
117         },
118 };
119
120 static struct gpio_led_platform_data gpio_led_info = {
121         .leds           = gpio_leds,
122         .num_leds       = ARRAY_SIZE(gpio_leds),
123 };
124
125 static struct platform_device leds_gpio = {
126         .name   = "leds-gpio",
127         .id     = -1,
128         .dev    = {
129                 .platform_data  = &gpio_led_info,
130         },
131 };
132
133
134 static int omap3evm_twl_gpio_setup(struct device *dev,
135                 unsigned gpio, unsigned ngpio)
136 {
137         /* gpio + 0 is "mmc0_cd" (input/IRQ) */
138         omap_cfg_reg(L8_34XX_GPIO63);
139         mmc[0].gpio_cd = gpio + 0;
140         twl4030_mmc_init(mmc);
141
142         /* Most GPIOs are for USB OTG.  Some are mostly sent to
143          * the P2 connector; notably LEDA for the LCD backlight.
144          */
145
146         /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
147         gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
148
149         platform_device_register(&leds_gpio);
150
151         return 0;
152 }
153
154 static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
155         .gpio_base      = OMAP_MAX_GPIO_LINES,
156         .irq_base       = TWL4030_GPIO_IRQ_BASE,
157         .irq_end        = TWL4030_GPIO_IRQ_END,
158         .use_leds       = true,
159         .setup          = omap3evm_twl_gpio_setup,
160 };
161
162 static struct twl4030_usb_data omap3evm_usb_data = {
163         .usb_mode       = T2_USB_MODE_ULPI,
164 };
165
166 static int omap3evm_keymap[] = {
167         KEY(0, 0, KEY_LEFT),
168         KEY(0, 1, KEY_RIGHT),
169         KEY(0, 2, KEY_A),
170         KEY(0, 3, KEY_B),
171         KEY(1, 0, KEY_DOWN),
172         KEY(1, 1, KEY_UP),
173         KEY(1, 2, KEY_E),
174         KEY(1, 3, KEY_F),
175         KEY(2, 0, KEY_ENTER),
176         KEY(2, 1, KEY_I),
177         KEY(2, 2, KEY_J),
178         KEY(2, 3, KEY_K),
179         KEY(3, 0, KEY_M),
180         KEY(3, 1, KEY_N),
181         KEY(3, 2, KEY_O),
182         KEY(3, 3, KEY_P)
183 };
184
185 static struct twl4030_keypad_data omap3evm_kp_data = {
186         .rows           = 4,
187         .cols           = 4,
188         .keymap         = omap3evm_keymap,
189         .keymapsize     = ARRAY_SIZE(omap3evm_keymap),
190         .rep            = 1,
191 };
192
193 static struct twl4030_madc_platform_data omap3evm_madc_data = {
194         .irq_line       = 1,
195 };
196
197 static struct twl4030_platform_data omap3evm_twldata = {
198         .irq_base       = TWL4030_IRQ_BASE,
199         .irq_end        = TWL4030_IRQ_END,
200
201         /* platform_data for children goes here */
202         .keypad         = &omap3evm_kp_data,
203         .madc           = &omap3evm_madc_data,
204         .usb            = &omap3evm_usb_data,
205         .power          = GENERIC3430_T2SCRIPTS_DATA,
206         .gpio           = &omap3evm_gpio_data,
207 };
208
209 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
210         {
211                 I2C_BOARD_INFO("twl4030", 0x48),
212                 .flags = I2C_CLIENT_WAKE,
213                 .irq = INT_34XX_SYS_NIRQ,
214                 .platform_data = &omap3evm_twldata,
215         },
216 };
217
218 static int __init omap3_evm_i2c_init(void)
219 {
220         omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
221                         ARRAY_SIZE(omap3evm_i2c_boardinfo));
222         omap_register_i2c_bus(2, 400, NULL, 0);
223         omap_register_i2c_bus(3, 400, NULL, 0);
224         return 0;
225 }
226
227 static struct platform_device omap3_evm_lcd_device = {
228         .name           = "omap3evm_lcd",
229         .id             = -1,
230 };
231
232 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
233         .ctrl_name      = "internal",
234 };
235
236 static void ads7846_dev_init(void)
237 {
238         if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
239                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
240
241         gpio_direction_input(OMAP3_EVM_TS_GPIO);
242
243         omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
244         omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
245 }
246
247 static int ads7846_get_pendown_state(void)
248 {
249         return !gpio_get_value(OMAP3_EVM_TS_GPIO);
250 }
251
252 struct ads7846_platform_data ads7846_config = {
253         .x_max                  = 0x0fff,
254         .y_max                  = 0x0fff,
255         .x_plate_ohms           = 180,
256         .pressure_max           = 255,
257         .debounce_max           = 10,
258         .debounce_tol           = 3,
259         .debounce_rep           = 1,
260         .get_pendown_state      = ads7846_get_pendown_state,
261         .keep_vref_on           = 1,
262         .settle_delay_usecs     = 150,
263 };
264
265 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
266         .turbo_mode     = 0,
267         .single_channel = 1,  /* 0: slave, 1: master */
268 };
269
270 struct spi_board_info omap3evm_spi_board_info[] = {
271         [0] = {
272                 .modalias               = "ads7846",
273                 .bus_num                = 1,
274                 .chip_select            = 0,
275                 .max_speed_hz           = 1500000,
276                 .controller_data        = &ads7846_mcspi_config,
277                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
278                 .platform_data          = &ads7846_config,
279         },
280 };
281
282 static void __init omap3_evm_init_irq(void)
283 {
284         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
285         omap_init_irq();
286         omap_gpio_init();
287         omap3evm_init_smc911x();
288 }
289
290 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
291         { OMAP_TAG_UART,        &omap3_evm_uart_config },
292         { OMAP_TAG_LCD,         &omap3_evm_lcd_config },
293 };
294
295 static struct platform_device *omap3_evm_devices[] __initdata = {
296         &omap3_evm_lcd_device,
297         &omap3evm_smc911x_device,
298 };
299
300 static void __init omap3_evm_init(void)
301 {
302         omap3_evm_i2c_init();
303
304         platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
305         omap_board_config = omap3_evm_config;
306         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
307
308         spi_register_board_info(omap3evm_spi_board_info,
309                                 ARRAY_SIZE(omap3evm_spi_board_info));
310
311         omap_serial_init();
312         usb_musb_init();
313         usb_ehci_init();
314         omap3evm_flash_init();
315         ads7846_dev_init();
316 }
317
318 static void __init omap3_evm_map_io(void)
319 {
320         omap2_set_globals_343x();
321         omap2_map_common_io();
322 }
323
324 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
325         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
326         .phys_io        = 0x48000000,
327         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
328         .boot_params    = 0x80000100,
329         .map_io         = omap3_evm_map_io,
330         .init_irq       = omap3_evm_init_irq,
331         .init_machine   = omap3_evm_init,
332         .timer          = &omap_timer,
333 MACHINE_END