]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-2430sdp.c
Merge omap-drivers
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-2430sdp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-2430sdp.c
3  *
4  * Copyright (C) 2006 Texas Instruments
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * Initial Code : Based on a patch from Komal Shah and Richard Woodruff
9  * Updated the Code for 2430 SDP : Syed Mohammed Khasim
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/delay.h>
22 #include <linux/input.h>
23 #include <linux/err.h>
24 #include <linux/clk.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/tsc2046.h>
27
28 #include <asm/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/flash.h>
33
34 #include <asm/arch/gpio.h>
35 #include <asm/arch/mux.h>
36 #include <asm/arch/board.h>
37 #include <asm/arch/common.h>
38 #include <asm/arch/keypad.h>
39 #include <asm/arch/gpmc.h>
40 #include <asm/arch/mcspi.h>
41 #include "prcm-regs.h"
42
43 #include <asm/io.h>
44
45 #define SDP2430_FLASH_CS        0
46 #define SDP2430_SMC91X_CS       5
47
48 /* TSC2046 (touchscreen) */
49 #define TS_GPIO                 24
50
51 static struct mtd_partition sdp2430_partitions[] = {
52         /* bootloader (U-Boot, etc) in first sector */
53         {
54                 .name           = "bootloader",
55                 .offset         = 0,
56                 .size           = SZ_256K,
57                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
58          },
59         /* bootloader params in the next sector */
60         {
61                 .name           = "params",
62                 .offset         = MTDPART_OFS_APPEND,
63                 .size           = SZ_128K,
64                 .mask_flags     = 0,
65          },
66         /* kernel */
67         {
68                 .name           = "kernel",
69                 .offset         = MTDPART_OFS_APPEND,
70                 .size           = SZ_2M,
71                 .mask_flags     = 0
72         },
73         /* file system */
74         {
75                 .name           = "filesystem",
76                 .offset         = MTDPART_OFS_APPEND,
77                 .size           = MTDPART_SIZ_FULL,
78                 .mask_flags     = 0
79         }
80 };
81
82 static struct flash_platform_data sdp2430_flash_data = {
83         .map_name       = "cfi_probe",
84         .width          = 2,
85         .parts          = sdp2430_partitions,
86         .nr_parts       = ARRAY_SIZE(sdp2430_partitions),
87 };
88
89 static struct resource sdp2430_flash_resource = {
90         .start          = SDP2430_CS0_BASE,
91         .end            = SDP2430_CS0_BASE + SZ_64M - 1,
92         .flags          = IORESOURCE_MEM,
93 };
94
95 static struct platform_device sdp2430_flash_device = {
96         .name           = "omapflash",
97         .id             = 0,
98         .dev = {
99                 .platform_data  = &sdp2430_flash_data,
100         },
101         .num_resources  = 1,
102         .resource       = &sdp2430_flash_resource,
103 };
104
105 static struct resource sdp2430_smc91x_resources[] = {
106         [0] = {
107                 .start  = SDP2430_CS0_BASE,
108                 .end    = SDP2430_CS0_BASE + SZ_64M - 1,
109                 .flags  = IORESOURCE_MEM,
110         },
111         [1] = {
112                 .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
113                 .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
114                 .flags  = IORESOURCE_IRQ,
115         },
116 };
117
118 static struct platform_device sdp2430_smc91x_device = {
119         .name           = "smc91x",
120         .id             = -1,
121         .num_resources  = ARRAY_SIZE(sdp2430_smc91x_resources),
122         .resource       = sdp2430_smc91x_resources,
123 };
124
125 /*
126  * Key mapping for 2430 SDP board
127  */
128
129 static int sdp2430_keymap[] = {
130         KEY(0, 0, KEY_LEFT),
131         KEY(0, 1, KEY_RIGHT),
132         KEY(0, 2, KEY_A),
133         KEY(0, 3, KEY_B),
134         KEY(0, 4, KEY_C),
135         KEY(1, 0, KEY_DOWN),
136         KEY(1, 1, KEY_UP),
137         KEY(1, 2, KEY_E),
138         KEY(1, 3, KEY_F),
139         KEY(1, 4, KEY_G),
140         KEY(2, 0, KEY_ENTER),
141         KEY(2, 1, KEY_I),
142         KEY(2, 2, KEY_J),
143         KEY(2, 3, KEY_K),
144         KEY(2, 4, KEY_3),
145         KEY(3, 0, KEY_M),
146         KEY(3, 1, KEY_N),
147         KEY(3, 2, KEY_O),
148         KEY(3, 3, KEY_P),
149         KEY(3, 4, KEY_Q),
150         KEY(4, 0, KEY_R),
151         KEY(4, 1, KEY_4),
152         KEY(4, 2, KEY_T),
153         KEY(4, 3, KEY_U),
154         KEY(4, 4, KEY_D),
155         KEY(5, 0, KEY_V),
156         KEY(5, 1, KEY_W),
157         KEY(5, 2, KEY_L),
158         KEY(5, 3, KEY_S),
159         KEY(5, 4, KEY_H),
160         0
161 };
162
163 static struct omap_kp_platform_data sdp2430_kp_data = {
164         .rows           = 5,
165         .cols           = 6,
166         .keymap         = sdp2430_keymap,
167         .keymapsize     = ARRAY_SIZE(sdp2430_keymap),
168         .rep            = 1,
169 };
170
171 static struct platform_device sdp2430_kp_device = {
172         .name           = "omap_twl4030keypad",
173         .id             = -1,
174         .dev            = {
175                 .platform_data  = &sdp2430_kp_data,
176         },
177 };
178
179 static struct platform_device *sdp2430_devices[] __initdata = {
180         &sdp2430_smc91x_device,
181         &sdp2430_flash_device,
182         &sdp2430_kp_device,
183 };
184
185 static struct tsc2046_platform_data tsc2046_config = {
186         .dav_gpio       = TS_GPIO,
187         .gpio_debounce  = 0xa,
188 };
189
190 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
191         .turbo_mode     = 0,
192         .single_channel = 0,  /* 0: slave, 1: master */
193 };
194
195 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
196         [0] = {
197                 /*
198                  * TSC2046 operates at a max freqency of 2MHz, so
199                  * operate slightly below at 1.5MHz
200                  */
201                 .modalias        = "tsc2046",
202                 .bus_num         = 1,
203                 .chip_select     = 0,
204                 .max_speed_hz    = 1500000,
205                 .controller_data = &tsc2046_mcspi_config,
206                 .platform_data   = &tsc2046_config,
207         },
208 };
209
210 static inline void __init sdp2430_init_smc91x(void)
211 {
212         int eth_cs;
213         unsigned long cs_mem_base;
214         unsigned int rate;
215         struct clk *l3ck;
216
217         eth_cs = SDP2430_SMC91X_CS;
218
219         l3ck = clk_get(NULL, "core_l3_ck");
220         if (IS_ERR(l3ck))
221                 rate = 100000000;
222         else
223                 rate = clk_get_rate(l3ck);
224
225         /* Make sure CS1 timings are correct, for 2430 always muxed */
226         gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
227
228         if (rate >= 160000000) {
229                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
230                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
231                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
232                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
233                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
234         } else if (rate >= 130000000) {
235                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
236                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
237                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
238                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
239                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
240         } else { /* rate = 100000000 */
241                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
242                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
243                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
244                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
245                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
246         }
247
248         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
249                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
250                 return;
251         }
252
253         sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
254         sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
255         udelay(100);
256
257         if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
258                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
259                         OMAP24XX_ETHR_GPIO_IRQ);
260                 gpmc_cs_free(eth_cs);
261                 return;
262         }
263         omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
264
265 }
266
267 static void __init omap_2430sdp_init_irq(void)
268 {
269         omap2_init_common_hw();
270         omap_init_irq();
271         omap_gpio_init();
272         sdp2430_init_smc91x();
273 }
274
275 static struct omap_uart_config sdp2430_uart_config __initdata = {
276         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
277 };
278
279 static struct omap_board_config_kernel sdp2430_config[] = {
280         {OMAP_TAG_UART, &sdp2430_uart_config},
281 };
282
283 #if     defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
284
285 #define OMAP2_I2C_BASE1         0x48070000
286 #define OMAP2_I2C_BASE2         0x48072000
287 #define OMAP2_I2C_INT1          56
288 #define OMAP2_I2C_INT2          57
289
290 static u32 omap2_i2c1_clkrate   = 400;
291 static u32 omap2_i2c2_clkrate   = 2600;
292
293 static struct resource i2c_resources1[] = {
294         {
295                 .start  = OMAP2_I2C_BASE1,
296                 .end    = OMAP2_I2C_BASE1 + 0x3f,
297                 .flags  = IORESOURCE_MEM,
298         },
299         {
300                 .start  = OMAP2_I2C_INT1,
301                 .flags  = IORESOURCE_IRQ,
302         },
303 };
304
305 static struct resource i2c_resources2[] = {
306         {
307                 .start  = OMAP2_I2C_BASE2,
308                 .end    = OMAP2_I2C_BASE2 + 0x3f,
309                 .flags  = IORESOURCE_MEM,
310         },
311         {
312                 .start  = OMAP2_I2C_INT2,
313                 .flags  = IORESOURCE_IRQ,
314         },
315 };
316
317 static struct platform_device omap_i2c_device1 = {
318         .name           = "i2c_omap",
319         .id             = 1,
320         .num_resources  = ARRAY_SIZE(i2c_resources1),
321         .resource       = i2c_resources1,
322         .dev            = {
323                 .platform_data  = &omap2_i2c1_clkrate,
324         },
325 };
326
327 static struct platform_device omap_i2c_device2 = {
328         .name           = "i2c_omap",
329         .id             = 2,
330         .num_resources  = ARRAY_SIZE(i2c_resources2),
331         .resource       = i2c_resources2,
332         .dev            = {
333                 .platform_data  = &omap2_i2c2_clkrate,
334         },
335 };
336
337 static void omap_init_i2c(void)
338 {
339         (void) platform_device_register(&omap_i2c_device2);
340         (void) platform_device_register(&omap_i2c_device1);
341 }
342
343 #else
344
345 static void omap_init_i2c(void) {}
346
347 #endif
348
349 static int __init omap2430_i2c_init(void)
350 {
351         omap_init_i2c();
352         return 0;
353 }
354
355 extern void __init sdp2430_flash_init(void);
356 extern void __init sdp2430_usb_init(void);
357
358 static void __init omap_2430sdp_init(void)
359 {
360         platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
361         omap_board_config = sdp2430_config;
362         omap_board_config_size = ARRAY_SIZE(sdp2430_config);
363         omap_serial_init();
364
365         sdp2430_flash_init();
366         sdp2430_usb_init();
367
368         spi_register_board_info(sdp2430_spi_board_info,
369                                 ARRAY_SIZE(sdp2430_spi_board_info));
370 }
371
372 static void __init omap_2430sdp_map_io(void)
373 {
374         omap2_map_common_io();
375 }
376
377 arch_initcall(omap2430_i2c_init);
378
379 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
380         /* Maintainer: Syed Khasim - Texas Instruments Inc */
381         .phys_io        = 0x48000000,
382         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
383         .boot_params    = 0x80000100,
384         .map_io         = omap_2430sdp_map_io,
385         .init_irq       = omap_2430sdp_init_irq,
386         .init_machine   = omap_2430sdp_init,
387         .timer          = &omap_timer,
388 MACHINE_END