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