Pull novell-bugzilla-156426 into release branch
[linux-2.6] / 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
41 static int innovator_keymap[] = {
42         KEY(0, 0, KEY_F1),
43         KEY(0, 3, KEY_DOWN),
44         KEY(1, 1, KEY_F2),
45         KEY(1, 2, KEY_RIGHT),
46         KEY(2, 0, KEY_F3),
47         KEY(2, 1, KEY_F4),
48         KEY(2, 2, KEY_UP),
49         KEY(3, 2, KEY_ENTER),
50         KEY(3, 3, KEY_LEFT),
51         0
52 };
53
54 static struct mtd_partition innovator_partitions[] = {
55         /* bootloader (U-Boot, etc) in first sector */
56         {
57               .name             = "bootloader",
58               .offset           = 0,
59               .size             = SZ_128K,
60               .mask_flags       = MTD_WRITEABLE, /* force read-only */
61         },
62         /* bootloader params in the next sector */
63         {
64               .name             = "params",
65               .offset           = MTDPART_OFS_APPEND,
66               .size             = SZ_128K,
67               .mask_flags       = 0,
68         },
69         /* kernel */
70         {
71               .name             = "kernel",
72               .offset           = MTDPART_OFS_APPEND,
73               .size             = SZ_2M,
74               .mask_flags       = 0
75         },
76         /* rest of flash1 is a file system */
77         {
78               .name             = "rootfs",
79               .offset           = MTDPART_OFS_APPEND,
80               .size             = SZ_16M - SZ_2M - 2 * SZ_128K,
81               .mask_flags       = 0
82         },
83         /* file system */
84         {
85               .name             = "filesystem",
86               .offset           = MTDPART_OFS_APPEND,
87               .size             = MTDPART_SIZ_FULL,
88               .mask_flags       = 0
89         }
90 };
91
92 static struct flash_platform_data innovator_flash_data = {
93         .map_name       = "cfi_probe",
94         .width          = 2,
95         .parts          = innovator_partitions,
96         .nr_parts       = ARRAY_SIZE(innovator_partitions),
97 };
98
99 static struct resource innovator_flash_resource = {
100         .start          = OMAP_CS0_PHYS,
101         .end            = OMAP_CS0_PHYS + SZ_32M - 1,
102         .flags          = IORESOURCE_MEM,
103 };
104
105 static struct platform_device innovator_flash_device = {
106         .name           = "omapflash",
107         .id             = 0,
108         .dev            = {
109                 .platform_data  = &innovator_flash_data,
110         },
111         .num_resources  = 1,
112         .resource       = &innovator_flash_resource,
113 };
114
115 static struct resource innovator_kp_resources[] = {
116         [0] = {
117                 .start  = INT_KEYBOARD,
118                 .end    = INT_KEYBOARD,
119                 .flags  = IORESOURCE_IRQ,
120         },
121 };
122
123 static struct omap_kp_platform_data innovator_kp_data = {
124         .rows   = 8,
125         .cols   = 8,
126         .keymap = innovator_keymap,
127 };
128
129 static struct platform_device innovator_kp_device = {
130         .name           = "omap-keypad",
131         .id             = -1,
132         .dev            = {
133                 .platform_data = &innovator_kp_data,
134         },
135         .num_resources  = ARRAY_SIZE(innovator_kp_resources),
136         .resource       = innovator_kp_resources,
137 };
138
139
140 #ifdef CONFIG_ARCH_OMAP15XX
141
142 /* Only FPGA needs to be mapped here. All others are done with ioremap */
143 static struct map_desc innovator1510_io_desc[] __initdata = {
144         {
145                 .virtual        = OMAP1510_FPGA_BASE,
146                 .pfn            = __phys_to_pfn(OMAP1510_FPGA_START),
147                 .length         = OMAP1510_FPGA_SIZE,
148                 .type           = MT_DEVICE
149         }
150 };
151
152 static struct resource innovator1510_smc91x_resources[] = {
153         [0] = {
154                 .start  = OMAP1510_FPGA_ETHR_START,     /* Physical */
155                 .end    = OMAP1510_FPGA_ETHR_START + 0xf,
156                 .flags  = IORESOURCE_MEM,
157         },
158         [1] = {
159                 .start  = OMAP1510_INT_ETHER,
160                 .end    = OMAP1510_INT_ETHER,
161                 .flags  = IORESOURCE_IRQ,
162         },
163 };
164
165 static struct platform_device innovator1510_smc91x_device = {
166         .name           = "smc91x",
167         .id             = 0,
168         .num_resources  = ARRAY_SIZE(innovator1510_smc91x_resources),
169         .resource       = innovator1510_smc91x_resources,
170 };
171
172 static struct platform_device innovator1510_lcd_device = {
173         .name           = "lcd_inn1510",
174         .id             = -1,
175 };
176
177 static struct platform_device *innovator1510_devices[] __initdata = {
178         &innovator_flash_device,
179         &innovator1510_smc91x_device,
180         &innovator_kp_device,
181         &innovator1510_lcd_device,
182 };
183
184 #endif /* CONFIG_ARCH_OMAP15XX */
185
186 #ifdef CONFIG_ARCH_OMAP16XX
187
188 static struct resource innovator1610_smc91x_resources[] = {
189         [0] = {
190                 .start  = INNOVATOR1610_ETHR_START,             /* Physical */
191                 .end    = INNOVATOR1610_ETHR_START + 0xf,
192                 .flags  = IORESOURCE_MEM,
193         },
194         [1] = {
195                 .start  = OMAP_GPIO_IRQ(0),
196                 .end    = OMAP_GPIO_IRQ(0),
197                 .flags  = IORESOURCE_IRQ,
198         },
199 };
200
201 static struct platform_device innovator1610_smc91x_device = {
202         .name           = "smc91x",
203         .id             = 0,
204         .num_resources  = ARRAY_SIZE(innovator1610_smc91x_resources),
205         .resource       = innovator1610_smc91x_resources,
206 };
207
208 static struct platform_device innovator1610_lcd_device = {
209         .name           = "inn1610_lcd",
210         .id             = -1,
211 };
212
213 static struct platform_device *innovator1610_devices[] __initdata = {
214         &innovator_flash_device,
215         &innovator1610_smc91x_device,
216         &innovator_kp_device,
217         &innovator1610_lcd_device,
218 };
219
220 #endif /* CONFIG_ARCH_OMAP16XX */
221
222 static void __init innovator_init_smc91x(void)
223 {
224         if (cpu_is_omap1510()) {
225                 fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
226                            OMAP1510_FPGA_RST);
227                 udelay(750);
228         } else {
229                 if ((omap_request_gpio(0)) < 0) {
230                         printk("Error requesting gpio 0 for smc91x irq\n");
231                         return;
232                 }
233         }
234 }
235
236 void innovator_init_irq(void)
237 {
238         omap1_init_common_hw();
239         omap_init_irq();
240         omap_gpio_init();
241 #ifdef CONFIG_ARCH_OMAP15XX
242         if (cpu_is_omap1510()) {
243                 omap1510_fpga_init_irq();
244         }
245 #endif
246         innovator_init_smc91x();
247 }
248
249 #ifdef CONFIG_ARCH_OMAP15XX
250 static struct omap_usb_config innovator1510_usb_config __initdata = {
251         /* for bundled non-standard host and peripheral cables */
252         .hmc_mode       = 4,
253
254         .register_host  = 1,
255         .pins[1]        = 6,
256         .pins[2]        = 6,            /* Conflicts with UART2 */
257
258         .register_dev   = 1,
259         .pins[0]        = 2,
260 };
261
262 static struct omap_lcd_config innovator1510_lcd_config __initdata = {
263         .ctrl_name      = "internal",
264 };
265 #endif
266
267 #ifdef CONFIG_ARCH_OMAP16XX
268 static struct omap_usb_config h2_usb_config __initdata = {
269         /* usb1 has a Mini-AB port and external isp1301 transceiver */
270         .otg            = 2,
271
272 #ifdef  CONFIG_USB_GADGET_OMAP
273         .hmc_mode       = 19,   // 0:host(off) 1:dev|otg 2:disabled
274         // .hmc_mode    = 21,   // 0:host(off) 1:dev(loopback) 2:host(loopback)
275 #elif   defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
276         /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
277         .hmc_mode       = 20,   // 1:dev|otg(off) 1:host 2:disabled
278 #endif
279
280         .pins[1]        = 3,
281 };
282
283 static struct omap_lcd_config innovator1610_lcd_config __initdata = {
284         .ctrl_name      = "internal",
285 };
286 #endif
287
288 static struct omap_mmc_config innovator_mmc_config __initdata = {
289         .mmc [0] = {
290                 .enabled        = 1,
291                 .wire4          = 1,
292                 .wp_pin         = OMAP_MPUIO(3),
293                 .power_pin      = -1,   /* FPGA F3 UIO42 */
294                 .switch_pin     = -1,   /* FPGA F4 UIO43 */
295         },
296 };
297
298 static struct omap_uart_config innovator_uart_config __initdata = {
299         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
300 };
301
302 static struct omap_board_config_kernel innovator_config[] = {
303         { OMAP_TAG_USB,         NULL },
304         { OMAP_TAG_LCD,         NULL },
305         { OMAP_TAG_MMC,         &innovator_mmc_config },
306         { OMAP_TAG_UART,        &innovator_uart_config },
307 };
308
309 static void __init innovator_init(void)
310 {
311 #ifdef CONFIG_ARCH_OMAP15XX
312         if (cpu_is_omap1510()) {
313                 platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
314         }
315 #endif
316 #ifdef CONFIG_ARCH_OMAP16XX
317         if (!cpu_is_omap1510()) {
318                 platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
319         }
320 #endif
321
322 #ifdef CONFIG_ARCH_OMAP15XX
323         if (cpu_is_omap1510()) {
324                 innovator_config[0].data = &innovator1510_usb_config;
325                 innovator_config[1].data = &innovator1510_lcd_config;
326         }
327 #endif
328 #ifdef CONFIG_ARCH_OMAP16XX
329         if (cpu_is_omap1610()) {
330                 innovator_config[0].data = &h2_usb_config;
331                 innovator_config[1].data = &innovator1610_lcd_config;
332         }
333 #endif
334         omap_board_config = innovator_config;
335         omap_board_config_size = ARRAY_SIZE(innovator_config);
336         omap_serial_init();
337 }
338
339 static void __init innovator_map_io(void)
340 {
341         omap1_map_common_io();
342
343 #ifdef CONFIG_ARCH_OMAP15XX
344         if (cpu_is_omap1510()) {
345                 iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
346                 udelay(10);     /* Delay needed for FPGA */
347
348                 /* Dump the Innovator FPGA rev early - useful info for support. */
349                 printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
350                        fpga_read(OMAP1510_FPGA_REV_HIGH),
351                        fpga_read(OMAP1510_FPGA_REV_LOW),
352                        fpga_read(OMAP1510_FPGA_BOARD_REV));
353         }
354 #endif
355 }
356
357 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
358         /* Maintainer: MontaVista Software, Inc. */
359         .phys_io        = 0xfff00000,
360         .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
361         .boot_params    = 0x10000100,
362         .map_io         = innovator_map_io,
363         .init_irq       = innovator_init_irq,
364         .init_machine   = innovator_init,
365         .timer          = &omap_timer,
366 MACHINE_END