blob: dc2dca3ff9b74c1fe1b0b74cc720ae15292b06a5 [file] [log] [blame]
Eric Benardaf5b1df2009-07-16 16:26:33 +02001/*
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>
Eric Bénard9f2270d2010-05-19 18:46:02 +020029#include <linux/usb/otg.h>
30#include <linux/usb/ulpi.h>
31#include <linux/fsl_devices.h>
Eric Benardaf5b1df2009-07-16 16:26:33 +020032
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
38#include <mach/board-eukrea_cpuimx27.h>
39#include <mach/common.h>
40#include <mach/hardware.h>
41#include <mach/i2c.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010042#include <mach/iomux-mx27.h>
Eric Benardaf5b1df2009-07-16 16:26:33 +020043#include <mach/imx-uart.h>
44#include <mach/mxc_nand.h>
Eric Bénard9f2270d2010-05-19 18:46:02 +020045#include <mach/mxc_ehci.h>
46#include <mach/ulpi.h>
Eric Benardaf5b1df2009-07-16 16:26:33 +020047
48#include "devices.h"
49
50static int eukrea_cpuimx27_pins[] = {
51 /* UART1 */
52 PE12_PF_UART1_TXD,
53 PE13_PF_UART1_RXD,
54 PE14_PF_UART1_CTS,
55 PE15_PF_UART1_RTS,
56 /* UART4 */
Eric Bénard2d66c782010-05-19 18:45:59 +020057#if defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +020058 PB26_AF_UART4_RTS,
59 PB28_AF_UART4_TXD,
60 PB29_AF_UART4_CTS,
61 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020062#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020063 /* FEC */
64 PD0_AIN_FEC_TXD0,
65 PD1_AIN_FEC_TXD1,
66 PD2_AIN_FEC_TXD2,
67 PD3_AIN_FEC_TXD3,
68 PD4_AOUT_FEC_RX_ER,
69 PD5_AOUT_FEC_RXD1,
70 PD6_AOUT_FEC_RXD2,
71 PD7_AOUT_FEC_RXD3,
72 PD8_AF_FEC_MDIO,
73 PD9_AIN_FEC_MDC,
74 PD10_AOUT_FEC_CRS,
75 PD11_AOUT_FEC_TX_CLK,
76 PD12_AOUT_FEC_RXD0,
77 PD13_AOUT_FEC_RX_DV,
78 PD14_AOUT_FEC_RX_CLK,
79 PD15_AOUT_FEC_COL,
80 PD16_AIN_FEC_TX_ER,
81 PF23_AIN_FEC_TX_EN,
82 /* I2C1 */
83 PD17_PF_I2C_DATA,
84 PD18_PF_I2C_CLK,
85 /* SDHC2 */
Eric Bénard2d66c782010-05-19 18:45:59 +020086#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
Eric Benardaf5b1df2009-07-16 16:26:33 +020087 PB4_PF_SD2_D0,
88 PB5_PF_SD2_D1,
89 PB6_PF_SD2_D2,
90 PB7_PF_SD2_D3,
91 PB8_PF_SD2_CMD,
92 PB9_PF_SD2_CLK,
Eric Bénard2d66c782010-05-19 18:45:59 +020093#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020094#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
95 /* Quad UART's IRQ */
Eric Bénardebb4fc82010-05-19 18:46:00 +020096 GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN,
97 GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN,
98 GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN,
99 GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200100#endif
Eric Bénard9f2270d2010-05-19 18:46:02 +0200101 /* OTG */
102 PC7_PF_USBOTG_DATA5,
103 PC8_PF_USBOTG_DATA6,
104 PC9_PF_USBOTG_DATA0,
105 PC10_PF_USBOTG_DATA2,
106 PC11_PF_USBOTG_DATA1,
107 PC12_PF_USBOTG_DATA4,
108 PC13_PF_USBOTG_DATA3,
109 PE0_PF_USBOTG_NXT,
110 PE1_PF_USBOTG_STP,
111 PE2_PF_USBOTG_DIR,
112 PE24_PF_USBOTG_CLK,
113 PE25_PF_USBOTG_DATA7,
114 /* USBH2 */
115 PA0_PF_USBH2_CLK,
116 PA1_PF_USBH2_DIR,
117 PA2_PF_USBH2_DATA7,
118 PA3_PF_USBH2_NXT,
119 PA4_PF_USBH2_STP,
120 PD19_AF_USBH2_DATA4,
121 PD20_AF_USBH2_DATA3,
122 PD21_AF_USBH2_DATA6,
123 PD22_AF_USBH2_DATA0,
124 PD23_AF_USBH2_DATA2,
125 PD24_AF_USBH2_DATA1,
126 PD26_AF_USBH2_DATA5,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200127};
128
129static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
130 .width = 2,
131};
132
133static struct resource eukrea_cpuimx27_flash_resource = {
134 .start = 0xc0000000,
135 .end = 0xc3ffffff,
136 .flags = IORESOURCE_MEM,
137};
138
139static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
140 .name = "physmap-flash",
141 .id = 0,
142 .dev = {
143 .platform_data = &eukrea_cpuimx27_flash_data,
144 },
145 .num_resources = 1,
146 .resource = &eukrea_cpuimx27_flash_resource,
147};
148
149static struct imxuart_platform_data uart_pdata[] = {
150 {
151 .flags = IMXUART_HAVE_RTSCTS,
152 }, {
153 .flags = IMXUART_HAVE_RTSCTS,
154 },
155};
156
157static struct mxc_nand_platform_data eukrea_cpuimx27_nand_board_info = {
158 .width = 1,
159 .hw_ecc = 1,
160};
161
162static struct platform_device *platform_devices[] __initdata = {
163 &eukrea_cpuimx27_nor_mtd_device,
164 &mxc_fec_device,
Eric Bénardebfc7e62010-05-19 18:46:03 +0200165 &mxc_wdt,
166 &mxc_w1_master_device,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200167};
168
169static struct imxi2c_platform_data eukrea_cpuimx27_i2c_1_data = {
170 .bitrate = 100000,
171};
172
173static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
174 {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200175 I2C_BOARD_INFO("pcf8563", 0x51),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200176 },
177};
178
179#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
180static struct plat_serial8250_port serial_platform_data[] = {
181 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100182 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200183 .irq = IRQ_GPIOB(23),
184 .uartclk = 14745600,
185 .regshift = 1,
186 .iotype = UPIO_MEM,
187 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
188 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100189 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200190 .irq = IRQ_GPIOB(22),
191 .uartclk = 14745600,
192 .regshift = 1,
193 .iotype = UPIO_MEM,
194 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
195 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100196 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200197 .irq = IRQ_GPIOB(27),
198 .uartclk = 14745600,
199 .regshift = 1,
200 .iotype = UPIO_MEM,
201 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
202 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100203 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200204 .irq = IRQ_GPIOB(30),
205 .uartclk = 14745600,
206 .regshift = 1,
207 .iotype = UPIO_MEM,
208 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
209 }, {
210 }
211};
212
213static struct platform_device serial_device = {
214 .name = "serial8250",
215 .id = 0,
216 .dev = {
217 .platform_data = serial_platform_data,
218 },
219};
220#endif
221
Eric Bénard9f2270d2010-05-19 18:46:02 +0200222static struct mxc_usbh_platform_data otg_pdata = {
223 .portsc = MXC_EHCI_MODE_ULPI,
224 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
225};
226
227static struct mxc_usbh_platform_data usbh2_pdata = {
228 .portsc = MXC_EHCI_MODE_ULPI,
229 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
230};
231
232static struct fsl_usb2_platform_data otg_device_pdata = {
233 .operating_mode = FSL_USB2_DR_DEVICE,
234 .phy_mode = FSL_USB2_PHY_ULPI,
235};
236
237static int otg_mode_host;
238
239static int __init eukrea_cpuimx27_otg_mode(char *options)
240{
241 if (!strcmp(options, "host"))
242 otg_mode_host = 1;
243 else if (!strcmp(options, "device"))
244 otg_mode_host = 0;
245 else
246 pr_info("otg_mode neither \"host\" nor \"device\". "
247 "Defaulting to device\n");
248 return 0;
249}
250__setup("otg_mode=", eukrea_cpuimx27_otg_mode);
251
Eric Benardaf5b1df2009-07-16 16:26:33 +0200252static void __init eukrea_cpuimx27_init(void)
253{
254 mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
255 ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
256
257 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
258
Uwe Kleine-König3636a142010-02-11 16:31:49 +0100259 mxc_register_device(&imx27_nand_device,
260 &eukrea_cpuimx27_nand_board_info);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200261
262 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
263 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
264
265 mxc_register_device(&mxc_i2c_device0, &eukrea_cpuimx27_i2c_1_data);
266
267 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
268
269#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
270 /* SDHC2 can be used for Wifi */
271 mxc_register_device(&mxc_sdhc_device1, NULL);
Eric Bénard2d66c782010-05-19 18:45:59 +0200272#endif
273#if defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +0200274 /* in which case UART4 is also used for Bluetooth */
275 mxc_register_device(&mxc_uart_device3, &uart_pdata[1]);
276#endif
277
278#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
279 platform_device_register(&serial_device);
280#endif
281
Eric Bénard9f2270d2010-05-19 18:46:02 +0200282#if defined(CONFIG_USB_ULPI)
283 if (otg_mode_host) {
284 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
285 USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
286
287 mxc_register_device(&mxc_otg_host, &otg_pdata);
288 }
289
290 usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
291 USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
292
293 mxc_register_device(&mxc_usbh2, &usbh2_pdata);
294#endif
295 if (!otg_mode_host)
296 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
297
Eric Benardaf5b1df2009-07-16 16:26:33 +0200298#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
299 eukrea_mbimx27_baseboard_init();
300#endif
301}
302
303static void __init eukrea_cpuimx27_timer_init(void)
304{
305 mx27_clocks_init(26000000);
306}
307
308static struct sys_timer eukrea_cpuimx27_timer = {
309 .init = eukrea_cpuimx27_timer_init,
310};
311
312MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100313 .phys_io = MX27_AIPI_BASE_ADDR,
314 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
Uwe Kleine-König34101232010-01-29 17:36:05 +0100315 .boot_params = MX27_PHYS_OFFSET + 0x100,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200316 .map_io = mx27_map_io,
317 .init_irq = mx27_init_irq,
318 .init_machine = eukrea_cpuimx27_init,
319 .timer = &eukrea_cpuimx27_timer,
320MACHINE_END