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