Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / arm / mach-omap1 / board-innovator.c
1 /*
2  * linux/arch/arm/mach-omap1/board-innovator.c
3  *
4  * Board specific inits for OMAP-1510 and OMAP-1610 Innovator
5  *
6  * Copyright (C) 2001 RidgeRun, Inc.
7  * Author: Greg Lonnon <glonnon@ridgerun.com>
8  *
9  * Copyright (C) 2002 MontaVista Software, Inc.
10  *
11  * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
12  * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2 as
16  * published by the Free Software Foundation.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/delay.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/input.h>
26
27 #include <asm/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/flash.h>
31 #include <asm/mach/map.h>
32
33 #include <asm/arch/mux.h>
34 #include <asm/arch/fpga.h>
35 #include <asm/arch/gpio.h>
36 #include <asm/arch/tc.h>
37 #include <asm/arch/usb.h>
38 #include <asm/arch/keypad.h>
39 #include <asm/arch/common.h>
40 #include <asm/arch/mcbsp.h>
41 #include <asm/arch/omap-alsa.h>
42
43 static int innovator_keymap[] = {
44         KEY(0, 0, KEY_F1),
45         KEY(0, 3, KEY_DOWN),
46         KEY(1, 1, KEY_F2),
47         KEY(1, 2, KEY_RIGHT),
48         KEY(2, 0, KEY_F3),
49         KEY(2, 1, KEY_F4),
50         KEY(2, 2, KEY_UP),
51         KEY(3, 2, KEY_ENTER),
52         KEY(3, 3, KEY_LEFT),
53         0
54 };
55
56 static struct mtd_partition innovator_partitions[] = {
57         /* bootloader (U-Boot, etc) in first sector */
58         {
59               .name             = "bootloader",
60               .offset           = 0,
61               .size             = SZ_128K,
62               .mask_flags       = MTD_WRITEABLE, /* force read-only */
63         },
64         /* bootloader params in the next sector */
65         {
66               .name             = "params",
67               .offset           = MTDPART_OFS_APPEND,
68               .size             = SZ_128K,
69               .mask_flags       = 0,
70         },
71         /* kernel */
72         {
73               .name             = "kernel",
74               .offset           = MTDPART_OFS_APPEND,
75               .size             = SZ_2M,
76               .mask_flags       = 0
77         },
78         /* rest of flash1 is a file system */
79         {
80               .name             = "rootfs",
81               .offset           = MTDPART_OFS_APPEND,
82               .size             = SZ_16M - SZ_2M - 2 * SZ_128K,
83               .mask_flags       = 0
84         },
85         /* file system */
86         {
87               .name             = "filesystem",
88               .offset           = MTDPART_OFS_APPEND,
89               .size             = MTDPART_SIZ_FULL,
90               .mask_flags       = 0
91         }
92 };
93
94 static struct flash_platform_data innovator_flash_data = {
95         .map_name       = "cfi_probe",
96         .width          = 2,
97         .parts          = innovator_partitions,
98         .nr_parts       = ARRAY_SIZE(innovator_partitions),
99 };
100
101 static struct resource innovator_flash_resource = {
102         .start          = OMAP_CS0_PHYS,
103         .end            = OMAP_CS0_PHYS + SZ_32M - 1,
104         .flags          = IORESOURCE_MEM,
105 };
106
107 static struct platform_device innovator_flash_device = {
108         .name           = "omapflash",
109         .id             = 0,
110         .dev            = {
111                 .platform_data  = &innovator_flash_data,
112         },
113         .num_resources  = 1,
114         .resource       = &innovator_flash_resource,
115 };
116
117 #define DEFAULT_BITPERSAMPLE 16
118
119 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
120         .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
121         .spcr1 = RINTM(3) | RRST,
122         .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
123             RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
124         .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
125         .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
126             XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
127         .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
128         .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
129         .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
130         /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
131         .pcr0 = CLKXP | CLKRP,  /* mcbsp: slave */
132 };
133
134 static struct omap_alsa_codec_config alsa_config = {
135         .name                   = "OMAP Innovator AIC23",
136         .mcbsp_regs_alsa        = &mcbsp_regs,
137         .codec_configure_dev    = NULL, // aic23_configure,
138         .codec_set_samplerate   = NULL, // aic23_set_samplerate,
139         .codec_clock_setup      = NULL, // aic23_clock_setup,
140         .codec_clock_on         = NULL, // aic23_clock_on,
141         .codec_clock_off        = NULL, // aic23_clock_off,
142         .get_default_samplerate = NULL, // aic23_get_default_samplerate,
143 };
144
145 static struct platform_device innovator_mcbsp1_device = {
146         .name   = "omap_alsa_mcbsp",
147         .id     = 1,
148         .dev = {
149                 .platform_data  = &alsa_config,
150         },
151 };
152
153 static struct resource innovator_kp_resources[] = {
154         [0] = {
155                 .start  = INT_KEYBOARD,
156                 .end    = INT_KEYBOARD,
157                 .flags  = IORESOURCE_IRQ,
158         },
159 };
160
161 static struct omap_kp_platform_data innovator_kp_data = {
162         .rows   = 8,
163         .cols   = 8,
164         .keymap = innovator_keymap,
165 };
166
167 static struct platform_device innovator_kp_device = {
168         .name           = "omap-keypad",
169         .id             = -1,
170         .dev            = {
171                 .platform_data = &innovator_kp_data,
172         },
173         .num_resources  = ARRAY_SIZE(innovator_kp_resources),
174         .resource       = innovator_kp_resources,
175 };
176
177
178 #ifdef CONFIG_ARCH_OMAP15XX
179
180 #include <linux/spi/spi.h>
181 #include <linux/spi/ads7846.h>
182
183
184 /* Only FPGA needs to be mapped here. All others are done with ioremap */
185 static struct map_desc innovator1510_io_desc[] __initdata = {
186         {
187                 .virtual        = OMAP1510_FPGA_BASE,
188                 .pfn            = __phys_to_pfn(OMAP1510_FPGA_START),
189                 .length         = OMAP1510_FPGA_SIZE,
190                 .type           = MT_DEVICE
191         }
192 };
193
194 static struct resource innovator1510_smc91x_resources[] = {
195         [0] = {
196                 .start  = OMAP1510_FPGA_ETHR_START,     /* Physical */
197                 .end    = OMAP1510_FPGA_ETHR_START + 0xf,
198                 .flags  = IORESOURCE_MEM,
199         },
200         [1] = {
201                 .start  = OMAP1510_INT_ETHER,
202                 .end    = OMAP1510_INT_ETHER,
203                 .flags  = IORESOURCE_IRQ,
204         },
205 };
206
207 static struct platform_device innovator1510_smc91x_device = {
208         .name           = "smc91x",
209         .id             = 0,
210         .num_resources  = ARRAY_SIZE(innovator1510_smc91x_resources),
211         .resource       = innovator1510_smc91x_resources,
212 };
213
214 static struct platform_device innovator1510_lcd_device = {
215         .name           = "lcd_inn1510",
216         .id             = -1,
217 };
218
219 static struct platform_device innovator1510_spi_device = {
220         .name           = "spi_inn1510",
221         .id             = -1,
222 };
223
224 static struct platform_device *innovator1510_devices[] __initdata = {
225         &innovator_flash_device,
226         &innovator1510_smc91x_device,
227         &innovator_mcbsp1_device,
228         &innovator_kp_device,
229         &innovator1510_lcd_device,
230         &innovator1510_spi_device,
231 };
232
233 static int innovator_get_pendown_state(void)
234 {
235         return !(fpga_read(OMAP1510_FPGA_TOUCHSCREEN) & (1 << 5));
236 }
237
238 static const struct ads7846_platform_data innovator1510_ts_info = {
239         .model                  = 7846,
240         .vref_delay_usecs       = 100,  /* internal, no capacitor */
241         .x_plate_ohms           = 419,
242         .y_plate_ohms           = 486,
243         .get_pendown_state      = innovator_get_pendown_state,
244 };
245
246 static struct spi_board_info __initdata innovator1510_boardinfo[] = { {
247         /* FPGA (bus "10") CS0 has an ads7846e */
248         .modalias               = "ads7846",
249         .platform_data          = &innovator1510_ts_info,
250         .irq                    = OMAP1510_INT_FPGA_TS,
251         .max_speed_hz           = 120000 /* max sample rate at 3V */
252                                         * 26 /* command + data + overhead */,
253         .bus_num                = 10,
254         .chip_select            = 0,
255 } };
256
257 #endif /* CONFIG_ARCH_OMAP15XX */
258
259 #ifdef CONFIG_ARCH_OMAP16XX
260
261 static struct resource innovator1610_smc91x_resources[] = {
262         [0] = {
263                 .start  = INNOVATOR1610_ETHR_START,             /* Physical */
264                 .end    = INNOVATOR1610_ETHR_START + 0xf,
265                 .flags  = IORESOURCE_MEM,
266         },
267         [1] = {
268                 .start  = OMAP_GPIO_IRQ(0),
269                 .end    = OMAP_GPIO_IRQ(0),
270                 .flags  = IORESOURCE_IRQ,
271         },
272 };
273
274 static struct platform_device innovator1610_smc91x_device = {
275         .name           = "smc91x",
276         .id             = 0,
277         .num_resources  = ARRAY_SIZE(innovator1610_smc91x_resources),
278         .resource       = innovator1610_smc91x_resources,
279 };
280
281 static struct platform_device innovator1610_lcd_device = {
282         .name           = "inn1610_lcd",
283         .id             = -1,
284 };
285
286 static struct platform_device *innovator1610_devices[] __initdata = {
287         &innovator_flash_device,
288         &innovator1610_smc91x_device,
289         &innovator_kp_device,
290         &innovator1610_lcd_device,
291 };
292
293 #endif /* CONFIG_ARCH_OMAP16XX */
294
295 static void __init innovator_init_smc91x(void)
296 {
297         if (cpu_is_omap1510()) {
298                 fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
299                            OMAP1510_FPGA_RST);
300                 udelay(750);
301         } else {
302                 if ((omap_request_gpio(0)) < 0) {
303                         printk("Error requesting gpio 0 for smc91x irq\n");
304                         return;
305                 }
306         }
307 }
308
309 void innovator_init_irq(void)
310 {
311         omap1_init_common_hw();
312         omap_init_irq();
313         omap_gpio_init();
314 #ifdef CONFIG_ARCH_OMAP15XX
315         if (cpu_is_omap1510()) {
316                 omap1510_fpga_init_irq();
317         }
318 #endif
319         innovator_init_smc91x();
320 }
321
322 #ifdef CONFIG_ARCH_OMAP15XX
323 static struct omap_usb_config innovator1510_usb_config __initdata = {
324         /* for bundled non-standard host and peripheral cables */
325         .hmc_mode       = 4,
326
327         .register_host  = 1,
328         .pins[1]        = 6,
329         .pins[2]        = 6,            /* Conflicts with UART2 */
330
331         .register_dev   = 1,
332         .pins[0]        = 2,
333 };
334
335 static struct omap_lcd_config innovator1510_lcd_config __initdata = {
336         .ctrl_name      = "internal",
337 };
338 #endif
339
340 #ifdef CONFIG_ARCH_OMAP16XX
341 static struct omap_usb_config h2_usb_config __initdata = {
342         /* usb1 has a Mini-AB port and external isp1301 transceiver */
343         .otg            = 2,
344
345 #ifdef  CONFIG_USB_GADGET_OMAP
346         .hmc_mode       = 19,   // 0:host(off) 1:dev|otg 2:disabled
347         // .hmc_mode    = 21,   // 0:host(off) 1:dev(loopback) 2:host(loopback)
348 #elif   defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
349         /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
350         .hmc_mode       = 20,   // 1:dev|otg(off) 1:host 2:disabled
351 #endif
352
353         .pins[1]        = 3,
354 };
355
356 static struct omap_lcd_config innovator1610_lcd_config __initdata = {
357         .ctrl_name      = "internal",
358 };
359 #endif
360
361 static struct omap_mmc_config innovator_mmc_config __initdata = {
362         .mmc [0] = {
363                 .enabled        = 1,
364                 .wire4          = 1,
365                 .wp_pin         = OMAP_MPUIO(3),
366                 .power_pin      = -1,   /* FPGA F3 UIO42 */
367                 .switch_pin     = -1,   /* FPGA F4 UIO43 */
368         },
369 };
370
371 static struct omap_uart_config innovator_uart_config __initdata = {
372         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
373 };
374
375 static struct omap_board_config_kernel innovator_config[] = {
376         { OMAP_TAG_USB,         NULL },
377         { OMAP_TAG_LCD,         NULL },
378         { OMAP_TAG_MMC,         &innovator_mmc_config },
379         { OMAP_TAG_UART,        &innovator_uart_config },
380 };
381
382 static void __init innovator_init(void)
383 {
384 #ifdef CONFIG_ARCH_OMAP15XX
385         if (cpu_is_omap1510()) {
386                 platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
387                 spi_register_board_info(innovator1510_boardinfo,
388                                 ARRAY_SIZE(innovator1510_boardinfo));
389         }
390 #endif
391 #ifdef CONFIG_ARCH_OMAP16XX
392         if (!cpu_is_omap1510()) {
393                 platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
394         }
395 #endif
396
397 #ifdef CONFIG_ARCH_OMAP15XX
398         if (cpu_is_omap1510()) {
399                 innovator_config[0].data = &innovator1510_usb_config;
400                 innovator_config[1].data = &innovator1510_lcd_config;
401         }
402 #endif
403 #ifdef CONFIG_ARCH_OMAP16XX
404         if (cpu_is_omap1610()) {
405                 innovator_config[0].data = &h2_usb_config;
406                 innovator_config[1].data = &innovator1610_lcd_config;
407         }
408 #endif
409         omap_board_config = innovator_config;
410         omap_board_config_size = ARRAY_SIZE(innovator_config);
411         omap_serial_init();
412 }
413
414 static void __init innovator_map_io(void)
415 {
416         omap1_map_common_io();
417
418 #ifdef CONFIG_ARCH_OMAP15XX
419         if (cpu_is_omap1510()) {
420                 iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
421                 udelay(10);     /* Delay needed for FPGA */
422
423                 /* Dump the Innovator FPGA rev early - useful info for support. */
424                 printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
425                        fpga_read(OMAP1510_FPGA_REV_HIGH),
426                        fpga_read(OMAP1510_FPGA_REV_LOW),
427                        fpga_read(OMAP1510_FPGA_BOARD_REV));
428         }
429 #endif
430 }
431
432 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
433         /* Maintainer: MontaVista Software, Inc. */
434         .phys_io        = 0xfff00000,
435         .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
436         .boot_params    = 0x10000100,
437         .map_io         = innovator_map_io,
438         .init_irq       = innovator_init_irq,
439         .init_machine   = innovator_init,
440         .timer          = &omap_timer,
441 MACHINE_END