Commit | Line | Data |
---|---|---|
af5b1df7 EB |
1 | /* |
2 | * Copyright (C) 2009 Eric Benard - eric@eukrea.com | |
3 | * | |
4 | * Based on pcm038.c which is : | |
5 | * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix | |
6 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version 2 | |
11 | * of the License, or (at your option) any later version. | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
20 | * MA 02110-1301, USA. | |
21 | */ | |
22 | ||
23 | #include <linux/i2c.h> | |
24 | #include <linux/io.h> | |
25 | #include <linux/mtd/plat-ram.h> | |
26 | #include <linux/mtd/physmap.h> | |
27 | #include <linux/platform_device.h> | |
28 | #include <linux/serial_8250.h> | |
9f2270da EB |
29 | #include <linux/usb/otg.h> |
30 | #include <linux/usb/ulpi.h> | |
31 | #include <linux/fsl_devices.h> | |
af5b1df7 EB |
32 | |
33 | #include <asm/mach-types.h> | |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/time.h> | |
36 | #include <asm/mach/map.h> | |
37 | ||
95afd090 | 38 | #include <mach/eukrea-baseboards.h> |
af5b1df7 EB |
39 | #include <mach/common.h> |
40 | #include <mach/hardware.h> | |
e835d88e | 41 | #include <mach/iomux-mx27.h> |
af5b1df7 | 42 | #include <mach/mxc_nand.h> |
9f2270da | 43 | #include <mach/ulpi.h> |
af5b1df7 | 44 | |
0e7a29a8 | 45 | #include "devices-imx27.h" |
af5b1df7 EB |
46 | #include "devices.h" |
47 | ||
6c80ee51 | 48 | static const int eukrea_cpuimx27_pins[] __initconst = { |
af5b1df7 EB |
49 | /* UART1 */ |
50 | PE12_PF_UART1_TXD, | |
51 | PE13_PF_UART1_RXD, | |
52 | PE14_PF_UART1_CTS, | |
53 | PE15_PF_UART1_RTS, | |
54 | /* UART4 */ | |
2d66c780 | 55 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) |
af5b1df7 EB |
56 | PB26_AF_UART4_RTS, |
57 | PB28_AF_UART4_TXD, | |
58 | PB29_AF_UART4_CTS, | |
59 | PB31_AF_UART4_RXD, | |
2d66c780 | 60 | #endif |
af5b1df7 EB |
61 | /* FEC */ |
62 | PD0_AIN_FEC_TXD0, | |
63 | PD1_AIN_FEC_TXD1, | |
64 | PD2_AIN_FEC_TXD2, | |
65 | PD3_AIN_FEC_TXD3, | |
66 | PD4_AOUT_FEC_RX_ER, | |
67 | PD5_AOUT_FEC_RXD1, | |
68 | PD6_AOUT_FEC_RXD2, | |
69 | PD7_AOUT_FEC_RXD3, | |
70 | PD8_AF_FEC_MDIO, | |
71 | PD9_AIN_FEC_MDC, | |
72 | PD10_AOUT_FEC_CRS, | |
73 | PD11_AOUT_FEC_TX_CLK, | |
74 | PD12_AOUT_FEC_RXD0, | |
75 | PD13_AOUT_FEC_RX_DV, | |
76 | PD14_AOUT_FEC_RX_CLK, | |
77 | PD15_AOUT_FEC_COL, | |
78 | PD16_AIN_FEC_TX_ER, | |
79 | PF23_AIN_FEC_TX_EN, | |
80 | /* I2C1 */ | |
81 | PD17_PF_I2C_DATA, | |
82 | PD18_PF_I2C_CLK, | |
83 | /* SDHC2 */ | |
2d66c780 | 84 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) |
af5b1df7 EB |
85 | PB4_PF_SD2_D0, |
86 | PB5_PF_SD2_D1, | |
87 | PB6_PF_SD2_D2, | |
88 | PB7_PF_SD2_D3, | |
89 | PB8_PF_SD2_CMD, | |
90 | PB9_PF_SD2_CLK, | |
2d66c780 | 91 | #endif |
af5b1df7 EB |
92 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
93 | /* Quad UART's IRQ */ | |
ebb4fc82 EB |
94 | GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN, |
95 | GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN, | |
96 | GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN, | |
97 | GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN, | |
af5b1df7 | 98 | #endif |
9f2270da EB |
99 | /* OTG */ |
100 | PC7_PF_USBOTG_DATA5, | |
101 | PC8_PF_USBOTG_DATA6, | |
102 | PC9_PF_USBOTG_DATA0, | |
103 | PC10_PF_USBOTG_DATA2, | |
104 | PC11_PF_USBOTG_DATA1, | |
105 | PC12_PF_USBOTG_DATA4, | |
106 | PC13_PF_USBOTG_DATA3, | |
107 | PE0_PF_USBOTG_NXT, | |
108 | PE1_PF_USBOTG_STP, | |
109 | PE2_PF_USBOTG_DIR, | |
110 | PE24_PF_USBOTG_CLK, | |
111 | PE25_PF_USBOTG_DATA7, | |
112 | /* USBH2 */ | |
113 | PA0_PF_USBH2_CLK, | |
114 | PA1_PF_USBH2_DIR, | |
115 | PA2_PF_USBH2_DATA7, | |
116 | PA3_PF_USBH2_NXT, | |
117 | PA4_PF_USBH2_STP, | |
118 | PD19_AF_USBH2_DATA4, | |
119 | PD20_AF_USBH2_DATA3, | |
120 | PD21_AF_USBH2_DATA6, | |
121 | PD22_AF_USBH2_DATA0, | |
122 | PD23_AF_USBH2_DATA2, | |
123 | PD24_AF_USBH2_DATA1, | |
124 | PD26_AF_USBH2_DATA5, | |
af5b1df7 EB |
125 | }; |
126 | ||
127 | static struct physmap_flash_data eukrea_cpuimx27_flash_data = { | |
128 | .width = 2, | |
129 | }; | |
130 | ||
131 | static struct resource eukrea_cpuimx27_flash_resource = { | |
132 | .start = 0xc0000000, | |
133 | .end = 0xc3ffffff, | |
134 | .flags = IORESOURCE_MEM, | |
135 | }; | |
136 | ||
137 | static struct platform_device eukrea_cpuimx27_nor_mtd_device = { | |
138 | .name = "physmap-flash", | |
139 | .id = 0, | |
140 | .dev = { | |
141 | .platform_data = &eukrea_cpuimx27_flash_data, | |
142 | }, | |
143 | .num_resources = 1, | |
144 | .resource = &eukrea_cpuimx27_flash_resource, | |
145 | }; | |
146 | ||
d5dac4a6 UKK |
147 | static const struct imxuart_platform_data uart_pdata __initconst = { |
148 | .flags = IMXUART_HAVE_RTSCTS, | |
af5b1df7 EB |
149 | }; |
150 | ||
0e7a29a8 UKK |
151 | static const struct mxc_nand_platform_data |
152 | cpuimx27_nand_board_info __initconst = { | |
af5b1df7 EB |
153 | .width = 1, |
154 | .hw_ecc = 1, | |
155 | }; | |
156 | ||
157 | static struct platform_device *platform_devices[] __initdata = { | |
158 | &eukrea_cpuimx27_nor_mtd_device, | |
af5b1df7 EB |
159 | }; |
160 | ||
c6987159 | 161 | static const struct imxi2c_platform_data cpuimx27_i2c1_data __initconst = { |
af5b1df7 EB |
162 | .bitrate = 100000, |
163 | }; | |
164 | ||
165 | static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = { | |
166 | { | |
cf87a6e2 | 167 | I2C_BOARD_INFO("pcf8563", 0x51), |
af5b1df7 EB |
168 | }, |
169 | }; | |
170 | ||
171 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) | |
172 | static struct plat_serial8250_port serial_platform_data[] = { | |
173 | { | |
3f35d1f5 | 174 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000), |
af5b1df7 EB |
175 | .irq = IRQ_GPIOB(23), |
176 | .uartclk = 14745600, | |
177 | .regshift = 1, | |
178 | .iotype = UPIO_MEM, | |
179 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
180 | }, { | |
3f35d1f5 | 181 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000), |
af5b1df7 EB |
182 | .irq = IRQ_GPIOB(22), |
183 | .uartclk = 14745600, | |
184 | .regshift = 1, | |
185 | .iotype = UPIO_MEM, | |
186 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
187 | }, { | |
3f35d1f5 | 188 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000), |
af5b1df7 EB |
189 | .irq = IRQ_GPIOB(27), |
190 | .uartclk = 14745600, | |
191 | .regshift = 1, | |
192 | .iotype = UPIO_MEM, | |
193 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
194 | }, { | |
3f35d1f5 | 195 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000), |
af5b1df7 EB |
196 | .irq = IRQ_GPIOB(30), |
197 | .uartclk = 14745600, | |
198 | .regshift = 1, | |
199 | .iotype = UPIO_MEM, | |
200 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
201 | }, { | |
202 | } | |
203 | }; | |
204 | ||
205 | static struct platform_device serial_device = { | |
206 | .name = "serial8250", | |
207 | .id = 0, | |
208 | .dev = { | |
209 | .platform_data = serial_platform_data, | |
210 | }, | |
211 | }; | |
212 | #endif | |
213 | ||
cbb052c9 | 214 | #if defined(CONFIG_USB_ULPI) |
2eb42d5c | 215 | static struct mxc_usbh_platform_data otg_pdata __initdata = { |
9f2270da EB |
216 | .portsc = MXC_EHCI_MODE_ULPI, |
217 | .flags = MXC_EHCI_INTERFACE_DIFF_UNI, | |
218 | }; | |
219 | ||
2eb42d5c | 220 | static struct mxc_usbh_platform_data usbh2_pdata __initdata = { |
9f2270da EB |
221 | .portsc = MXC_EHCI_MODE_ULPI, |
222 | .flags = MXC_EHCI_INTERFACE_DIFF_UNI, | |
223 | }; | |
cbb052c9 | 224 | #endif |
9f2270da EB |
225 | |
226 | static struct fsl_usb2_platform_data otg_device_pdata = { | |
227 | .operating_mode = FSL_USB2_DR_DEVICE, | |
228 | .phy_mode = FSL_USB2_PHY_ULPI, | |
229 | }; | |
230 | ||
231 | static int otg_mode_host; | |
232 | ||
233 | static int __init eukrea_cpuimx27_otg_mode(char *options) | |
234 | { | |
235 | if (!strcmp(options, "host")) | |
236 | otg_mode_host = 1; | |
237 | else if (!strcmp(options, "device")) | |
238 | otg_mode_host = 0; | |
239 | else | |
240 | pr_info("otg_mode neither \"host\" nor \"device\". " | |
241 | "Defaulting to device\n"); | |
242 | return 0; | |
243 | } | |
244 | __setup("otg_mode=", eukrea_cpuimx27_otg_mode); | |
245 | ||
af5b1df7 EB |
246 | static void __init eukrea_cpuimx27_init(void) |
247 | { | |
248 | mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins, | |
249 | ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27"); | |
250 | ||
d5dac4a6 | 251 | imx27_add_imx_uart0(&uart_pdata); |
af5b1df7 | 252 | |
0e7a29a8 | 253 | imx27_add_mxc_nand(&cpuimx27_nand_board_info); |
af5b1df7 EB |
254 | |
255 | i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices, | |
256 | ARRAY_SIZE(eukrea_cpuimx27_i2c_devices)); | |
257 | ||
f779b7dd | 258 | imx27_add_imx_i2c(0, &cpuimx27_i2c1_data); |
af5b1df7 | 259 | |
6bd96f3c | 260 | imx27_add_fec(NULL); |
af5b1df7 | 261 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
e0a1961d | 262 | imx27_add_imx2_wdt(NULL); |
ae71a562 | 263 | imx27_add_mxc_w1(NULL); |
af5b1df7 EB |
264 | |
265 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) | |
266 | /* SDHC2 can be used for Wifi */ | |
9d3d945a | 267 | imx27_add_mxc_mmc(1, NULL); |
2d66c780 EB |
268 | #endif |
269 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) | |
af5b1df7 | 270 | /* in which case UART4 is also used for Bluetooth */ |
d5dac4a6 | 271 | imx27_add_imx_uart3(&uart_pdata); |
af5b1df7 EB |
272 | #endif |
273 | ||
274 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) | |
275 | platform_device_register(&serial_device); | |
276 | #endif | |
277 | ||
9f2270da EB |
278 | #if defined(CONFIG_USB_ULPI) |
279 | if (otg_mode_host) { | |
280 | otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, | |
70ddd47f | 281 | ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); |
9f2270da | 282 | |
2eb42d5c | 283 | imx27_add_mxc_ehci_otg(&otg_pdata); |
9f2270da EB |
284 | } |
285 | ||
286 | usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, | |
70ddd47f | 287 | ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); |
9f2270da | 288 | |
2eb42d5c | 289 | imx27_add_mxc_ehci_hs(2, &usbh2_pdata); |
9f2270da EB |
290 | #endif |
291 | if (!otg_mode_host) | |
292 | mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata); | |
293 | ||
af5b1df7 EB |
294 | #ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD |
295 | eukrea_mbimx27_baseboard_init(); | |
296 | #endif | |
297 | } | |
298 | ||
299 | static void __init eukrea_cpuimx27_timer_init(void) | |
300 | { | |
301 | mx27_clocks_init(26000000); | |
302 | } | |
303 | ||
304 | static struct sys_timer eukrea_cpuimx27_timer = { | |
305 | .init = eukrea_cpuimx27_timer_init, | |
306 | }; | |
307 | ||
308 | MACHINE_START(CPUIMX27, "EUKREA CPUIMX27") | |
34101237 | 309 | .boot_params = MX27_PHYS_OFFSET + 0x100, |
af5b1df7 EB |
310 | .map_io = mx27_map_io, |
311 | .init_irq = mx27_init_irq, | |
312 | .init_machine = eukrea_cpuimx27_init, | |
313 | .timer = &eukrea_cpuimx27_timer, | |
314 | MACHINE_END |