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