]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3evm.c
775a1f319318cecbb061d63aa131804838238618
[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
23 #include <linux/spi/spi.h>
24 #include <linux/spi/ads7846.h>
25 #include <linux/i2c/twl4030.h>
26
27 #include <mach/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
32 #include <mach/gpio.h>
33 #include <mach/board.h>
34 #include <mach/usb-musb.h>
35 #include <mach/usb-ehci.h>
36 #include <mach/common.h>
37 #include <mach/mcspi.h>
38
39 #include "sdram-micron-mt46h32m32lf-6.h"
40 #include "twl4030-generic-scripts.h"
41 #include "mmc-twl4030.h"
42
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 (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x 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         gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
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 struct twl4030_gpio_platform_data omap3evm_gpio_data = {
92         .gpio_base      = OMAP_MAX_GPIO_LINES,
93         .irq_base       = TWL4030_GPIO_IRQ_BASE,
94         .irq_end        = TWL4030_GPIO_IRQ_END,
95 };
96
97 static struct twl4030_usb_data omap3evm_usb_data = {
98         .usb_mode       = T2_USB_MODE_ULPI,
99 };
100
101 static int omap3evm_keymap[] = {
102         KEY(0, 0, KEY_LEFT),
103         KEY(0, 1, KEY_RIGHT),
104         KEY(0, 2, KEY_A),
105         KEY(0, 3, KEY_B),
106         KEY(1, 0, KEY_DOWN),
107         KEY(1, 1, KEY_UP),
108         KEY(1, 2, KEY_E),
109         KEY(1, 3, KEY_F),
110         KEY(2, 0, KEY_ENTER),
111         KEY(2, 1, KEY_I),
112         KEY(2, 2, KEY_J),
113         KEY(2, 3, KEY_K),
114         KEY(3, 0, KEY_M),
115         KEY(3, 1, KEY_N),
116         KEY(3, 2, KEY_O),
117         KEY(3, 3, KEY_P)
118 };
119
120 static struct twl4030_keypad_data omap3evm_kp_data = {
121         .rows           = 4,
122         .cols           = 4,
123         .keymap         = omap3evm_keymap,
124         .keymapsize     = ARRAY_SIZE(omap3evm_keymap),
125         .rep            = 1,
126 };
127
128 static struct twl4030_madc_platform_data omap3evm_madc_data = {
129         .irq_line       = 1,
130 };
131
132 static struct twl4030_platform_data omap3evm_twldata = {
133         .irq_base       = TWL4030_IRQ_BASE,
134         .irq_end        = TWL4030_IRQ_END,
135
136         /* platform_data for children goes here */
137         .keypad         = &omap3evm_kp_data,
138         .madc           = &omap3evm_madc_data,
139         .usb            = &omap3evm_usb_data,
140         .power          = GENERIC3430_T2SCRIPTS_DATA,
141         .gpio           = &omap3evm_gpio_data,
142 };
143
144 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
145         {
146                 I2C_BOARD_INFO("twl4030", 0x48),
147                 .flags = I2C_CLIENT_WAKE,
148                 .irq = INT_34XX_SYS_NIRQ,
149                 .platform_data = &omap3evm_twldata,
150         },
151 };
152
153 static int __init omap3_evm_i2c_init(void)
154 {
155         omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
156                         ARRAY_SIZE(omap3evm_i2c_boardinfo));
157         omap_register_i2c_bus(2, 400, NULL, 0);
158         omap_register_i2c_bus(3, 400, NULL, 0);
159         return 0;
160 }
161
162 static struct platform_device omap3_evm_lcd_device = {
163         .name           = "omap3evm_lcd",
164         .id             = -1,
165 };
166
167 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
168         .ctrl_name      = "internal",
169 };
170
171 static void ads7846_dev_init(void)
172 {
173         if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
174                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
175
176         gpio_direction_input(OMAP3_EVM_TS_GPIO);
177
178         omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
179         omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
180 }
181
182 static int ads7846_get_pendown_state(void)
183 {
184         return !gpio_get_value(OMAP3_EVM_TS_GPIO);
185 }
186
187 struct ads7846_platform_data ads7846_config = {
188         .x_max                  = 0x0fff,
189         .y_max                  = 0x0fff,
190         .x_plate_ohms           = 180,
191         .pressure_max           = 255,
192         .debounce_max           = 10,
193         .debounce_tol           = 3,
194         .debounce_rep           = 1,
195         .get_pendown_state      = ads7846_get_pendown_state,
196         .keep_vref_on           = 1,
197         .settle_delay_usecs     = 150,
198 };
199
200 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
201         .turbo_mode     = 0,
202         .single_channel = 1,  /* 0: slave, 1: master */
203 };
204
205 struct spi_board_info omap3evm_spi_board_info[] = {
206         [0] = {
207                 .modalias               = "ads7846",
208                 .bus_num                = 1,
209                 .chip_select            = 0,
210                 .max_speed_hz           = 1500000,
211                 .controller_data        = &ads7846_mcspi_config,
212                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
213                 .platform_data          = &ads7846_config,
214         },
215 };
216
217 static void __init omap3_evm_init_irq(void)
218 {
219         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
220         omap_init_irq();
221         omap_gpio_init();
222         omap3evm_init_smc911x();
223 }
224
225 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
226         { OMAP_TAG_UART,        &omap3_evm_uart_config },
227         { OMAP_TAG_LCD,         &omap3_evm_lcd_config },
228 };
229
230 static struct platform_device *omap3_evm_devices[] __initdata = {
231         &omap3_evm_lcd_device,
232         &omap3evm_smc911x_device,
233 };
234
235 static struct twl4030_hsmmc_info mmc[] __initdata = {
236         {
237                 .mmc            = 1,
238                 .wires          = 4,
239                 .gpio_cd        = -EINVAL,
240                 .gpio_wp        = -EINVAL,
241         },
242         {}      /* Terminator */
243 };
244
245 static void __init omap3_evm_init(void)
246 {
247         omap3_evm_i2c_init();
248
249         platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
250         omap_board_config = omap3_evm_config;
251         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
252
253         spi_register_board_info(omap3evm_spi_board_info,
254                                 ARRAY_SIZE(omap3evm_spi_board_info));
255
256         omap_serial_init();
257         twl4030_mmc_init(mmc);
258         usb_musb_init();
259         usb_ehci_init();
260         omap3evm_flash_init();
261         ads7846_dev_init();
262 }
263
264 static void __init omap3_evm_map_io(void)
265 {
266         omap2_set_globals_343x();
267         omap2_map_common_io();
268 }
269
270 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
271         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
272         .phys_io        = 0x48000000,
273         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
274         .boot_params    = 0x80000100,
275         .map_io         = omap3_evm_map_io,
276         .init_irq       = omap3_evm_init_irq,
277         .init_machine   = omap3_evm_init,
278         .timer          = &omap_timer,
279 MACHINE_END