2 * Copyright (C) 2009 Eric Benard - eric@eukrea.com
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)
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.
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,
23 #include <linux/i2c.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>
29 #include <linux/usb/otg.h>
30 #include <linux/usb/ulpi.h>
31 #include <linux/fsl_devices.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/time.h>
36 #include <asm/mach/map.h>
38 #include <mach/board-eukrea_cpuimx27.h>
39 #include <mach/common.h>
40 #include <mach/hardware.h>
42 #include <mach/iomux-mx27.h>
43 #include <mach/imx-uart.h>
44 #include <mach/mxc_nand.h>
45 #include <mach/mxc_ehci.h>
46 #include <mach/ulpi.h>
50 static int eukrea_cpuimx27_pins[] = {
57 #if defined(MACH_EUKREA_CPUIMX27_USEUART4)
86 #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
94 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
96 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,
105 PC10_PF_USBOTG_DATA2,
106 PC11_PF_USBOTG_DATA1,
107 PC12_PF_USBOTG_DATA4,
108 PC13_PF_USBOTG_DATA3,
113 PE25_PF_USBOTG_DATA7,
129 static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
133 static struct resource eukrea_cpuimx27_flash_resource = {
136 .flags = IORESOURCE_MEM,
139 static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
140 .name = "physmap-flash",
143 .platform_data = &eukrea_cpuimx27_flash_data,
146 .resource = &eukrea_cpuimx27_flash_resource,
149 static struct imxuart_platform_data uart_pdata[] = {
151 .flags = IMXUART_HAVE_RTSCTS,
153 .flags = IMXUART_HAVE_RTSCTS,
157 static struct mxc_nand_platform_data eukrea_cpuimx27_nand_board_info = {
162 static struct platform_device *platform_devices[] __initdata = {
163 &eukrea_cpuimx27_nor_mtd_device,
166 &mxc_w1_master_device,
169 static struct imxi2c_platform_data eukrea_cpuimx27_i2c_1_data = {
173 static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
175 I2C_BOARD_INFO("pcf8563", 0x51),
179 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
180 static struct plat_serial8250_port serial_platform_data[] = {
182 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
183 .irq = IRQ_GPIOB(23),
187 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
189 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
190 .irq = IRQ_GPIOB(22),
194 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
196 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
197 .irq = IRQ_GPIOB(27),
201 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
203 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
204 .irq = IRQ_GPIOB(30),
208 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
213 static struct platform_device serial_device = {
214 .name = "serial8250",
217 .platform_data = serial_platform_data,
222 #if defined(CONFIG_USB_ULPI)
223 static struct mxc_usbh_platform_data otg_pdata = {
224 .portsc = MXC_EHCI_MODE_ULPI,
225 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
228 static struct mxc_usbh_platform_data usbh2_pdata = {
229 .portsc = MXC_EHCI_MODE_ULPI,
230 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
234 static struct fsl_usb2_platform_data otg_device_pdata = {
235 .operating_mode = FSL_USB2_DR_DEVICE,
236 .phy_mode = FSL_USB2_PHY_ULPI,
239 static int otg_mode_host;
241 static int __init eukrea_cpuimx27_otg_mode(char *options)
243 if (!strcmp(options, "host"))
245 else if (!strcmp(options, "device"))
248 pr_info("otg_mode neither \"host\" nor \"device\". "
249 "Defaulting to device\n");
252 __setup("otg_mode=", eukrea_cpuimx27_otg_mode);
254 static void __init eukrea_cpuimx27_init(void)
256 mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
257 ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
259 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
261 mxc_register_device(&imx27_nand_device,
262 &eukrea_cpuimx27_nand_board_info);
264 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
265 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
267 mxc_register_device(&mxc_i2c_device0, &eukrea_cpuimx27_i2c_1_data);
269 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
271 #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
272 /* SDHC2 can be used for Wifi */
273 mxc_register_device(&mxc_sdhc_device1, NULL);
275 #if defined(MACH_EUKREA_CPUIMX27_USEUART4)
276 /* in which case UART4 is also used for Bluetooth */
277 mxc_register_device(&mxc_uart_device3, &uart_pdata[1]);
280 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
281 platform_device_register(&serial_device);
284 #if defined(CONFIG_USB_ULPI)
286 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
287 USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
289 mxc_register_device(&mxc_otg_host, &otg_pdata);
292 usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
293 USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
295 mxc_register_device(&mxc_usbh2, &usbh2_pdata);
298 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
300 #ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
301 eukrea_mbimx27_baseboard_init();
305 static void __init eukrea_cpuimx27_timer_init(void)
307 mx27_clocks_init(26000000);
310 static struct sys_timer eukrea_cpuimx27_timer = {
311 .init = eukrea_cpuimx27_timer_init,
314 MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
315 .phys_io = MX27_AIPI_BASE_ADDR,
316 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
317 .boot_params = MX27_PHYS_OFFSET + 0x100,
318 .map_io = mx27_map_io,
319 .init_irq = mx27_init_irq,
320 .init_machine = eukrea_cpuimx27_init,
321 .timer = &eukrea_cpuimx27_timer,