Linux-2.6.12-rc2
[linux-3.10.git] / arch / arm / mach-omap / board-innovator.c
1 /*
2  * linux/arch/arm/mach-omap/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/device.h>
22 #include <linux/delay.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25
26 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/flash.h>
30 #include <asm/mach/map.h>
31
32 #include <asm/arch/fpga.h>
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/tc.h>
35 #include <asm/arch/usb.h>
36
37 #include "common.h"
38
39 static int __initdata innovator_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
40
41 static struct mtd_partition innovator_partitions[] = {
42         /* bootloader (U-Boot, etc) in first sector */
43         {
44               .name             = "bootloader",
45               .offset           = 0,
46               .size             = SZ_128K,
47               .mask_flags       = MTD_WRITEABLE, /* force read-only */
48         },
49         /* bootloader params in the next sector */
50         {
51               .name             = "params",
52               .offset           = MTDPART_OFS_APPEND,
53               .size             = SZ_128K,
54               .mask_flags       = 0,
55         },
56         /* kernel */
57         {
58               .name             = "kernel",
59               .offset           = MTDPART_OFS_APPEND,
60               .size             = SZ_2M,
61               .mask_flags       = 0
62         },
63         /* rest of flash1 is a file system */
64         {
65               .name             = "rootfs",
66               .offset           = MTDPART_OFS_APPEND,
67               .size             = SZ_16M - SZ_2M - 2 * SZ_128K,
68               .mask_flags       = 0
69         },
70         /* file system */
71         {
72               .name             = "filesystem",
73               .offset           = MTDPART_OFS_APPEND,
74               .size             = MTDPART_SIZ_FULL,
75               .mask_flags       = 0
76         }
77 };
78
79 static struct flash_platform_data innovator_flash_data = {
80         .map_name       = "cfi_probe",
81         .width          = 2,
82         .parts          = innovator_partitions,
83         .nr_parts       = ARRAY_SIZE(innovator_partitions),
84 };
85
86 static struct resource innovator_flash_resource = {
87         .start          = OMAP_CS0_PHYS,
88         .end            = OMAP_CS0_PHYS + SZ_32M - 1,
89         .flags          = IORESOURCE_MEM,
90 };
91
92 static struct platform_device innovator_flash_device = {
93         .name           = "omapflash",
94         .id             = 0,
95         .dev            = {
96                 .platform_data  = &innovator_flash_data,
97         },
98         .num_resources  = 1,
99         .resource       = &innovator_flash_resource,
100 };
101
102 #ifdef CONFIG_ARCH_OMAP1510
103
104 /* Only FPGA needs to be mapped here. All others are done with ioremap */
105 static struct map_desc innovator1510_io_desc[] __initdata = {
106 { OMAP1510_FPGA_BASE, OMAP1510_FPGA_START, OMAP1510_FPGA_SIZE,
107         MT_DEVICE },
108 };
109
110 static struct resource innovator1510_smc91x_resources[] = {
111         [0] = {
112                 .start  = OMAP1510_FPGA_ETHR_START,     /* Physical */
113                 .end    = OMAP1510_FPGA_ETHR_START + 0xf,
114                 .flags  = IORESOURCE_MEM,
115         },
116         [1] = {
117                 .start  = OMAP1510_INT_ETHER,
118                 .end    = OMAP1510_INT_ETHER,
119                 .flags  = IORESOURCE_IRQ,
120         },
121 };
122
123 static struct platform_device innovator1510_smc91x_device = {
124         .name           = "smc91x",
125         .id             = 0,
126         .num_resources  = ARRAY_SIZE(innovator1510_smc91x_resources),
127         .resource       = innovator1510_smc91x_resources,
128 };
129
130 static struct platform_device *innovator1510_devices[] __initdata = {
131         &innovator_flash_device,
132         &innovator1510_smc91x_device,
133 };
134
135 #endif /* CONFIG_ARCH_OMAP1510 */
136
137 #ifdef CONFIG_ARCH_OMAP16XX
138
139 static struct resource innovator1610_smc91x_resources[] = {
140         [0] = {
141                 .start  = INNOVATOR1610_ETHR_START,             /* Physical */
142                 .end    = INNOVATOR1610_ETHR_START + 0xf,
143                 .flags  = IORESOURCE_MEM,
144         },
145         [1] = {
146                 .start  = OMAP_GPIO_IRQ(0),
147                 .end    = OMAP_GPIO_IRQ(0),
148                 .flags  = IORESOURCE_IRQ,
149         },
150 };
151
152 static struct platform_device innovator1610_smc91x_device = {
153         .name           = "smc91x",
154         .id             = 0,
155         .num_resources  = ARRAY_SIZE(innovator1610_smc91x_resources),
156         .resource       = innovator1610_smc91x_resources,
157 };
158
159 static struct platform_device *innovator1610_devices[] __initdata = {
160         &innovator_flash_device,
161         &innovator1610_smc91x_device,
162 };
163
164 #endif /* CONFIG_ARCH_OMAP16XX */
165
166 static void __init innovator_init_smc91x(void)
167 {
168         if (cpu_is_omap1510()) {
169                 fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
170                            OMAP1510_FPGA_RST);
171                 udelay(750);
172         } else {
173                 if ((omap_request_gpio(0)) < 0) {
174                         printk("Error requesting gpio 0 for smc91x irq\n");
175                         return;
176                 }
177                 omap_set_gpio_edge_ctrl(0, OMAP_GPIO_RISING_EDGE);
178         }
179 }
180
181 void innovator_init_irq(void)
182 {
183         omap_init_irq();
184         omap_gpio_init();
185 #ifdef CONFIG_ARCH_OMAP1510
186         if (cpu_is_omap1510()) {
187                 omap1510_fpga_init_irq();
188         }
189 #endif
190         innovator_init_smc91x();
191 }
192
193 #ifdef CONFIG_ARCH_OMAP1510
194 static struct omap_usb_config innovator1510_usb_config __initdata = {
195         /* for bundled non-standard host and peripheral cables */
196         .hmc_mode       = 4,
197
198         .register_host  = 1,
199         .pins[1]        = 6,
200         .pins[2]        = 6,            /* Conflicts with UART2 */
201
202         .register_dev   = 1,
203         .pins[0]        = 2,
204 };
205 #endif
206
207 #ifdef CONFIG_ARCH_OMAP16XX
208 static struct omap_usb_config h2_usb_config __initdata = {
209         /* usb1 has a Mini-AB port and external isp1301 transceiver */
210         .otg            = 2,
211
212 #ifdef  CONFIG_USB_GADGET_OMAP
213         .hmc_mode       = 19,   // 0:host(off) 1:dev|otg 2:disabled
214         // .hmc_mode    = 21,   // 0:host(off) 1:dev(loopback) 2:host(loopback)
215 #elif   defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
216         /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
217         .hmc_mode       = 20,   // 1:dev|otg(off) 1:host 2:disabled
218 #endif
219
220         .pins[1]        = 3,
221 };
222 #endif
223
224 static struct omap_board_config_kernel innovator_config[] = {
225         { OMAP_TAG_USB,         NULL },
226 };
227
228 static void __init innovator_init(void)
229 {
230 #ifdef CONFIG_ARCH_OMAP1510
231         if (cpu_is_omap1510()) {
232                 platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
233         }
234 #endif
235 #ifdef CONFIG_ARCH_OMAP16XX
236         if (!cpu_is_omap1510()) {
237                 platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
238         }
239 #endif
240
241 #ifdef CONFIG_ARCH_OMAP1510
242         if (cpu_is_omap1510())
243                 innovator_config[0].data = &innovator1510_usb_config;
244 #endif
245 #ifdef CONFIG_ARCH_OMAP16XX
246         if (cpu_is_omap1610())
247                 innovator_config[0].data = &h2_usb_config;
248 #endif
249         omap_board_config = innovator_config;
250         omap_board_config_size = ARRAY_SIZE(innovator_config);
251 }
252
253 static void __init innovator_map_io(void)
254 {
255         omap_map_io();
256
257 #ifdef CONFIG_ARCH_OMAP1510
258         if (cpu_is_omap1510()) {
259                 iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
260                 udelay(10);     /* Delay needed for FPGA */
261
262                 /* Dump the Innovator FPGA rev early - useful info for support. */
263                 printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
264                        fpga_read(OMAP1510_FPGA_REV_HIGH),
265                        fpga_read(OMAP1510_FPGA_REV_LOW),
266                        fpga_read(OMAP1510_FPGA_BOARD_REV));
267         }
268 #endif
269         omap_serial_init(innovator_serial_ports);
270 }
271
272 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
273         MAINTAINER("MontaVista Software, Inc.")
274         BOOT_MEM(0x10000000, 0xfff00000, 0xfef00000)
275         BOOT_PARAMS(0x10000100)
276         MAPIO(innovator_map_io)
277         INITIRQ(innovator_init_irq)
278         INIT_MACHINE(innovator_init)
279         .timer          = &omap_timer,
280 MACHINE_END