vserver 1.9.5.x5
[linux-2.6.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
24 #include <asm/hardware.h>
25 #include <asm/mach-types.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28
29 #include <asm/arch/clocks.h>
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/fpga.h>
32 #include <asm/arch/usb.h>
33
34 #include "common.h"
35
36 static int __initdata innovator_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
37
38 #ifdef CONFIG_ARCH_OMAP1510
39
40 /* Only FPGA needs to be mapped here. All others are done with ioremap */
41 static struct map_desc innovator1510_io_desc[] __initdata = {
42 { OMAP1510_FPGA_BASE, OMAP1510_FPGA_START, OMAP1510_FPGA_SIZE,
43         MT_DEVICE },
44 };
45
46 static struct resource innovator1510_smc91x_resources[] = {
47         [0] = {
48                 .start  = OMAP1510_FPGA_ETHR_START,     /* Physical */
49                 .end    = OMAP1510_FPGA_ETHR_START + 16,
50                 .flags  = IORESOURCE_MEM,
51         },
52         [1] = {
53                 .start  = OMAP1510_INT_ETHER,
54                 .end    = OMAP1510_INT_ETHER,
55                 .flags  = IORESOURCE_IRQ,
56         },
57 };
58
59 static struct platform_device innovator1510_smc91x_device = {
60         .name           = "smc91x",
61         .id             = 0,
62         .num_resources  = ARRAY_SIZE(innovator1510_smc91x_resources),
63         .resource       = innovator1510_smc91x_resources,
64 };
65
66 static struct platform_device *innovator1510_devices[] __initdata = {
67         &innovator1510_smc91x_device,
68 };
69
70 #endif /* CONFIG_ARCH_OMAP1510 */
71
72 #ifdef CONFIG_ARCH_OMAP16XX
73
74 static struct resource innovator1610_smc91x_resources[] = {
75         [0] = {
76                 .start  = INNOVATOR1610_ETHR_START,             /* Physical */
77                 .end    = INNOVATOR1610_ETHR_START + SZ_4K,
78                 .flags  = IORESOURCE_MEM,
79         },
80         [1] = {
81                 .start  = OMAP_GPIO_IRQ(0),
82                 .end    = OMAP_GPIO_IRQ(0),
83                 .flags  = IORESOURCE_IRQ,
84         },
85 };
86
87 static struct platform_device innovator1610_smc91x_device = {
88         .name           = "smc91x",
89         .id             = 0,
90         .num_resources  = ARRAY_SIZE(innovator1610_smc91x_resources),
91         .resource       = innovator1610_smc91x_resources,
92 };
93
94 static struct platform_device *innovator1610_devices[] __initdata = {
95         &innovator1610_smc91x_device,
96 };
97
98 #endif /* CONFIG_ARCH_OMAP16XX */
99
100 static void __init innovator_init_smc91x(void)
101 {
102         if (cpu_is_omap1510()) {
103                 fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
104                            OMAP1510_FPGA_RST);
105                 udelay(750);
106         } else {
107                 if ((omap_request_gpio(0)) < 0) {
108                         printk("Error requesting gpio 0 for smc91x irq\n");
109                         return;
110                 }
111                 omap_set_gpio_edge_ctrl(0, OMAP_GPIO_RISING_EDGE);
112         }
113 }
114
115 void innovator_init_irq(void)
116 {
117         omap_init_irq();
118         omap_gpio_init();
119 #ifdef CONFIG_ARCH_OMAP1510
120         if (cpu_is_omap1510()) {
121                 omap1510_fpga_init_irq();
122         }
123 #endif
124         innovator_init_smc91x();
125 }
126
127 #ifdef CONFIG_ARCH_OMAP1510
128 static struct omap_usb_config innovator1510_usb_config __initdata = {
129         /* for bundled non-standard host and peripheral cables */
130         .hmc_mode       = 4,
131
132         .register_host  = 1,
133         .pins[1]        = 6,
134         .pins[2]        = 6,            /* Conflicts with UART2 */
135
136         .register_dev   = 1,
137         .pins[0]        = 2,
138 };
139 #endif
140
141 #ifdef CONFIG_ARCH_OMAP16XX
142 static struct omap_usb_config h2_usb_config __initdata = {
143         /* usb1 has a Mini-AB port and external isp1301 transceiver */
144         .otg            = 2,
145
146 #ifdef  CONFIG_USB_GADGET_OMAP
147         .hmc_mode       = 19,   // 0:host(off) 1:dev|otg 2:disabled
148         // .hmc_mode    = 21,   // 0:host(off) 1:dev(loopback) 2:host(loopback)
149 #elif   defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
150         /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
151         .hmc_mode       = 20,   // 1:dev|otg(off) 1:host 2:disabled
152 #endif
153
154         .pins[1]        = 3,
155 };
156 #endif
157
158 static struct omap_board_config_kernel innovator_config[] = {
159         { OMAP_TAG_USB,         NULL },
160 };
161
162 static void __init innovator_init(void)
163 {
164 #ifdef CONFIG_ARCH_OMAP1510
165         if (cpu_is_omap1510()) {
166                 platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
167         }
168 #endif
169 #ifdef CONFIG_ARCH_OMAP16XX
170         if (!cpu_is_omap1510()) {
171                 platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
172         }
173 #endif
174
175 #ifdef CONFIG_ARCH_OMAP1510
176         if (cpu_is_omap1510())
177                 innovator_config[0].data = &innovator1510_usb_config;
178 #endif
179 #ifdef CONFIG_ARCH_OMAP16XX
180         if (cpu_is_omap1610())
181                 innovator_config[0].data = &h2_usb_config;
182 #endif
183         omap_board_config = innovator_config;
184         omap_board_config_size = ARRAY_SIZE(innovator_config);
185 }
186
187 static void __init innovator_map_io(void)
188 {
189         omap_map_io();
190
191 #ifdef CONFIG_ARCH_OMAP1510
192         if (cpu_is_omap1510()) {
193                 iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
194                 udelay(10);     /* Delay needed for FPGA */
195
196                 /* Dump the Innovator FPGA rev early - useful info for support. */
197                 printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
198                        fpga_read(OMAP1510_FPGA_REV_HIGH),
199                        fpga_read(OMAP1510_FPGA_REV_LOW),
200                        fpga_read(OMAP1510_FPGA_BOARD_REV));
201         }
202 #endif
203         omap_serial_init(innovator_serial_ports);
204 }
205
206 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
207         MAINTAINER("MontaVista Software, Inc.")
208         BOOT_MEM(0x10000000, 0xfff00000, 0xfef00000)
209         BOOT_PARAMS(0x10000100)
210         MAPIO(innovator_map_io)
211         INITIRQ(innovator_init_irq)
212         INIT_MACHINE(innovator_init)
213         .timer          = &omap_timer,
214 MACHINE_END