]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3evm.c
2c1d76f37103494d25efcfd9fa28740a57d65e05
[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/io.h>
22 #include <linux/input.h>
23
24 #include <linux/i2c/twl4030.h>
25
26 #include <linux/spi/spi.h>
27 #include <linux/spi/ads7846.h>
28 #include <linux/i2c/twl4030.h>
29
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34
35 #include <mach/gpio.h>
36 #include <mach/keypad.h>
37 #include <mach/board.h>
38 #include <mach/hsmmc.h>
39 #include <mach/usb-musb.h>
40 #include <mach/usb-ehci.h>
41 #include <mach/common.h>
42 #include <mach/mcspi.h>
43
44 #include "sdram-micron-mt46h32m32lf-6.h"
45
46 static struct resource omap3evm_smc911x_resources[] = {
47         [0] =   {
48                 .start  = OMAP3EVM_ETHR_START,
49                 .end    = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
50                 .flags  = IORESOURCE_MEM,
51         },
52         [1] =   {
53                 .start  = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
54                 .end    = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
55                 .flags  = IORESOURCE_IRQ,
56         },
57 };
58
59 static struct platform_device omap3evm_smc911x_device = {
60         .name           = "smc911x",
61         .id             = -1,
62         .num_resources  = ARRAY_SIZE(omap3evm_smc911x_resources),
63         .resource       = &omap3evm_smc911x_resources [0],
64 };
65
66 static inline void __init omap3evm_init_smc911x(void)
67 {
68         int eth_cs;
69         struct clk *l3ck;
70         unsigned int rate;
71
72         eth_cs = OMAP3EVM_SMC911X_CS;
73
74         l3ck = clk_get(NULL, "l3_ck");
75         if (IS_ERR(l3ck))
76                 rate = 100000000;
77         else
78                 rate = clk_get_rate(l3ck);
79
80         if (omap_request_gpio(OMAP3EVM_ETHR_GPIO_IRQ) < 0) {
81                 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
82                         OMAP3EVM_ETHR_GPIO_IRQ);
83                 return;
84         }
85
86         omap_set_gpio_direction(OMAP3EVM_ETHR_GPIO_IRQ, 1);
87 }
88
89 static struct omap_uart_config omap3_evm_uart_config __initdata = {
90         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
91 };
92
93 static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
94         .gpio_base      = OMAP_MAX_GPIO_LINES,
95         .irq_base       = TWL4030_GPIO_IRQ_BASE,
96         .irq_end        = TWL4030_GPIO_IRQ_END,
97 };
98
99 static struct twl4030_usb_data omap3evm_usb_data = {
100         .usb_mode       = T2_USB_MODE_ULPI,
101 };
102
103 static int omap3evm_keymap[] = {
104         KEY(0, 0, KEY_LEFT),
105         KEY(0, 1, KEY_RIGHT),
106         KEY(0, 2, KEY_A),
107         KEY(0, 3, KEY_B),
108         KEY(1, 0, KEY_DOWN),
109         KEY(1, 1, KEY_UP),
110         KEY(1, 2, KEY_E),
111         KEY(1, 3, KEY_F),
112         KEY(2, 0, KEY_ENTER),
113         KEY(2, 1, KEY_I),
114         KEY(2, 2, KEY_J),
115         KEY(2, 3, KEY_K),
116         KEY(3, 0, KEY_M),
117         KEY(3, 1, KEY_N),
118         KEY(3, 2, KEY_O),
119         KEY(3, 3, KEY_P)
120 };
121
122 static struct twl4030_keypad_data omap3evm_kp_data = {
123         .rows           = 4,
124         .cols           = 4,
125         .keymap         = omap3evm_keymap,
126         .keymapsize     = ARRAY_SIZE(omap3evm_keymap),
127         .rep            = 1,
128         .irq            = TWL4030_MODIRQ_KEYPAD,
129 };
130
131 static struct twl4030_platform_data omap3evm_twldata = {
132         .irq_base       = TWL4030_IRQ_BASE,
133         .irq_end        = TWL4030_IRQ_END,
134
135         /* platform_data for children goes here */
136         .keypad         = &omap3evm_kp_data,
137         .usb            = &omap3evm_usb_data,
138         .gpio           = &omap3evm_gpio_data,
139 };
140
141 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
142         {
143                 I2C_BOARD_INFO("twl4030", 0x48),
144                 .flags = I2C_CLIENT_WAKE,
145                 .irq = INT_34XX_SYS_NIRQ,
146                 .platform_data = &omap3evm_twldata,
147         },
148 };
149
150 static int __init omap3_evm_i2c_init(void)
151 {
152         omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
153                         ARRAY_SIZE(omap3evm_i2c_boardinfo));
154         omap_register_i2c_bus(2, 400, NULL, 0);
155         omap_register_i2c_bus(3, 400, NULL, 0);
156         return 0;
157 }
158
159 static struct platform_device omap3_evm_lcd_device = {
160         .name           = "omap3evm_lcd",
161         .id             = -1,
162 };
163
164 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
165         .ctrl_name      = "internal",
166 };
167
168 static void ads7846_dev_init(void)
169 {
170         if (omap_request_gpio(OMAP3_EVM_TS_GPIO) < 0)
171                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
172
173         omap_set_gpio_direction(OMAP3_EVM_TS_GPIO, 1);
174
175         omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
176         omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
177 }
178
179 static int ads7846_get_pendown_state(void)
180 {
181         return !omap_get_gpio_datain(OMAP3_EVM_TS_GPIO);
182 }
183
184 struct ads7846_platform_data ads7846_config = {
185         .x_max                  = 0x0fff,
186         .y_max                  = 0x0fff,
187         .x_plate_ohms           = 180,
188         .pressure_max           = 255,
189         .debounce_max           = 10,
190         .debounce_tol           = 3,
191         .debounce_rep           = 1,
192         .get_pendown_state      = ads7846_get_pendown_state,
193         .keep_vref_on           = 1,
194         .settle_delay_usecs     = 150,
195 };
196
197 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
198         .turbo_mode     = 0,
199         .single_channel = 1,  /* 0: slave, 1: master */
200 };
201
202 struct spi_board_info omap3evm_spi_board_info[] = {
203         [0] = {
204                 .modalias               = "ads7846",
205                 .bus_num                = 1,
206                 .chip_select            = 0,
207                 .max_speed_hz           = 1500000,
208                 .controller_data        = &ads7846_mcspi_config,
209                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
210                 .platform_data          = &ads7846_config,
211         },
212 };
213
214 static void __init omap3_evm_init_irq(void)
215 {
216         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
217         omap_init_irq();
218         omap_gpio_init();
219         omap3evm_init_smc911x();
220 }
221
222 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
223         { OMAP_TAG_UART,        &omap3_evm_uart_config },
224         { OMAP_TAG_LCD,         &omap3_evm_lcd_config },
225 };
226
227 static struct platform_device *omap3_evm_devices[] __initdata = {
228         &omap3_evm_lcd_device,
229         &omap3evm_smc911x_device,
230 };
231
232 static void __init omap3_evm_init(void)
233 {
234         omap3_evm_i2c_init();
235
236         platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
237         omap_board_config = omap3_evm_config;
238         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
239
240         spi_register_board_info(omap3evm_spi_board_info,
241                                 ARRAY_SIZE(omap3evm_spi_board_info));
242
243         omap_serial_init();
244         hsmmc_init();
245         usb_musb_init();
246         usb_ehci_init();
247         omap3evm_flash_init();
248         ads7846_dev_init();
249 }
250
251 static void __init omap3_evm_map_io(void)
252 {
253         omap2_set_globals_343x();
254         omap2_map_common_io();
255 }
256
257 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
258         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
259         .phys_io        = 0x48000000,
260         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
261         .boot_params    = 0x80000100,
262         .map_io         = omap3_evm_map_io,
263         .init_irq       = omap3_evm_init_irq,
264         .init_machine   = omap3_evm_init,
265         .timer          = &omap_timer,
266 MACHINE_END