blob: ea50870bda80762d66b7499d5c999bafc558aa3b [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>
Eric Benardaf5b1df2009-07-16 16:26:33 +020031
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/time.h>
35#include <asm/mach/map.h>
36
Shawn Guoe3372472012-09-13 21:01:00 +080037#include "common.h"
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +020038#include "devices-imx27.h"
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080039#include "eukrea-baseboards.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080040#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080041#include "iomux-mx27.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080042#include "ulpi.h"
Eric Benardaf5b1df2009-07-16 16:26:33 +020043
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020044static const int eukrea_cpuimx27_pins[] __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +020045 /* UART1 */
46 PE12_PF_UART1_TXD,
47 PE13_PF_UART1_RXD,
48 PE14_PF_UART1_CTS,
49 PE15_PF_UART1_RTS,
50 /* UART4 */
Paul Bolle4f5ef62c2013-03-22 01:15:02 +010051#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +020052 PB26_AF_UART4_RTS,
53 PB28_AF_UART4_TXD,
54 PB29_AF_UART4_CTS,
55 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020056#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020057 /* FEC */
58 PD0_AIN_FEC_TXD0,
59 PD1_AIN_FEC_TXD1,
60 PD2_AIN_FEC_TXD2,
61 PD3_AIN_FEC_TXD3,
62 PD4_AOUT_FEC_RX_ER,
63 PD5_AOUT_FEC_RXD1,
64 PD6_AOUT_FEC_RXD2,
65 PD7_AOUT_FEC_RXD3,
66 PD8_AF_FEC_MDIO,
67 PD9_AIN_FEC_MDC,
68 PD10_AOUT_FEC_CRS,
69 PD11_AOUT_FEC_TX_CLK,
70 PD12_AOUT_FEC_RXD0,
71 PD13_AOUT_FEC_RX_DV,
72 PD14_AOUT_FEC_RX_CLK,
73 PD15_AOUT_FEC_COL,
74 PD16_AIN_FEC_TX_ER,
75 PF23_AIN_FEC_TX_EN,
76 /* I2C1 */
77 PD17_PF_I2C_DATA,
78 PD18_PF_I2C_CLK,
79 /* SDHC2 */
Eric Bénard2d66c782010-05-19 18:45:59 +020080#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
Eric Benardaf5b1df2009-07-16 16:26:33 +020081 PB4_PF_SD2_D0,
82 PB5_PF_SD2_D1,
83 PB6_PF_SD2_D2,
84 PB7_PF_SD2_D3,
85 PB8_PF_SD2_CMD,
86 PB9_PF_SD2_CLK,
Eric Bénard2d66c782010-05-19 18:45:59 +020087#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020088#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
89 /* Quad UART's IRQ */
Eric Bénardebb4fc82010-05-19 18:46:00 +020090 GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN,
91 GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN,
92 GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN,
93 GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN,
Eric Benardaf5b1df2009-07-16 16:26:33 +020094#endif
Eric Bénard9f2270d2010-05-19 18:46:02 +020095 /* OTG */
96 PC7_PF_USBOTG_DATA5,
97 PC8_PF_USBOTG_DATA6,
98 PC9_PF_USBOTG_DATA0,
99 PC10_PF_USBOTG_DATA2,
100 PC11_PF_USBOTG_DATA1,
101 PC12_PF_USBOTG_DATA4,
102 PC13_PF_USBOTG_DATA3,
103 PE0_PF_USBOTG_NXT,
104 PE1_PF_USBOTG_STP,
105 PE2_PF_USBOTG_DIR,
106 PE24_PF_USBOTG_CLK,
107 PE25_PF_USBOTG_DATA7,
108 /* USBH2 */
109 PA0_PF_USBH2_CLK,
110 PA1_PF_USBH2_DIR,
111 PA2_PF_USBH2_DATA7,
112 PA3_PF_USBH2_NXT,
113 PA4_PF_USBH2_STP,
114 PD19_AF_USBH2_DATA4,
115 PD20_AF_USBH2_DATA3,
116 PD21_AF_USBH2_DATA6,
117 PD22_AF_USBH2_DATA0,
118 PD23_AF_USBH2_DATA2,
119 PD24_AF_USBH2_DATA1,
120 PD26_AF_USBH2_DATA5,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200121};
122
123static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
124 .width = 2,
125};
126
127static struct resource eukrea_cpuimx27_flash_resource = {
128 .start = 0xc0000000,
129 .end = 0xc3ffffff,
130 .flags = IORESOURCE_MEM,
131};
132
133static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
134 .name = "physmap-flash",
135 .id = 0,
136 .dev = {
137 .platform_data = &eukrea_cpuimx27_flash_data,
138 },
139 .num_resources = 1,
140 .resource = &eukrea_cpuimx27_flash_resource,
141};
142
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200143static const struct imxuart_platform_data uart_pdata __initconst = {
144 .flags = IMXUART_HAVE_RTSCTS,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200145};
146
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200147static const struct mxc_nand_platform_data
148cpuimx27_nand_board_info __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +0200149 .width = 1,
150 .hw_ecc = 1,
151};
152
153static struct platform_device *platform_devices[] __initdata = {
154 &eukrea_cpuimx27_nor_mtd_device,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200155};
156
Uwe Kleine-Königc6987152010-06-16 17:25:40 +0200157static const struct imxi2c_platform_data cpuimx27_i2c1_data __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +0200158 .bitrate = 100000,
159};
160
161static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
162 {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200163 I2C_BOARD_INFO("pcf8563", 0x51),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200164 },
165};
166
167#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
168static struct plat_serial8250_port serial_platform_data[] = {
169 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100170 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
Shawn Guo438196c2011-12-05 10:12:28 +0800171 /* irq number is run-time assigned */
Eric Benardaf5b1df2009-07-16 16:26:33 +0200172 .uartclk = 14745600,
173 .regshift = 1,
174 .iotype = UPIO_MEM,
175 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
176 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100177 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
Shawn Guo438196c2011-12-05 10:12:28 +0800178 /* irq number is run-time assigned */
Eric Benardaf5b1df2009-07-16 16:26:33 +0200179 .uartclk = 14745600,
180 .regshift = 1,
181 .iotype = UPIO_MEM,
182 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
183 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100184 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
Shawn Guo438196c2011-12-05 10:12:28 +0800185 /* irq number is run-time assigned */
Eric Benardaf5b1df2009-07-16 16:26:33 +0200186 .uartclk = 14745600,
187 .regshift = 1,
188 .iotype = UPIO_MEM,
189 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
190 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100191 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
Shawn Guo438196c2011-12-05 10:12:28 +0800192 /* irq number is run-time assigned */
Eric Benardaf5b1df2009-07-16 16:26:33 +0200193 .uartclk = 14745600,
194 .regshift = 1,
195 .iotype = UPIO_MEM,
196 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
197 }, {
198 }
199};
200
201static struct platform_device serial_device = {
202 .name = "serial8250",
203 .id = 0,
204 .dev = {
205 .platform_data = serial_platform_data,
206 },
207};
208#endif
209
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100210static int eukrea_cpuimx27_otg_init(struct platform_device *pdev)
211{
212 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
213}
214
Uwe Kleine-König2eb42d52010-11-05 18:52:09 +0100215static struct mxc_usbh_platform_data otg_pdata __initdata = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100216 .init = eukrea_cpuimx27_otg_init,
Eric Bénard9f2270d2010-05-19 18:46:02 +0200217 .portsc = MXC_EHCI_MODE_ULPI,
Eric Bénard9f2270d2010-05-19 18:46:02 +0200218};
219
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100220static int eukrea_cpuimx27_usbh2_init(struct platform_device *pdev)
221{
222 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
223}
224
Uwe Kleine-König2eb42d52010-11-05 18:52:09 +0100225static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100226 .init = eukrea_cpuimx27_usbh2_init,
Eric Bénard9f2270d2010-05-19 18:46:02 +0200227 .portsc = MXC_EHCI_MODE_ULPI,
Eric Bénard9f2270d2010-05-19 18:46:02 +0200228};
229
Uwe Kleine-Königbd455ed2010-11-09 17:52:14 +0100230static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
Eric Bénard9f2270d2010-05-19 18:46:02 +0200231 .operating_mode = FSL_USB2_DR_DEVICE,
232 .phy_mode = FSL_USB2_PHY_ULPI,
233};
234
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200235static bool otg_mode_host __initdata;
Eric Bénard9f2270d2010-05-19 18:46:02 +0200236
237static int __init eukrea_cpuimx27_otg_mode(char *options)
238{
239 if (!strcmp(options, "host"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200240 otg_mode_host = true;
Eric Bénard9f2270d2010-05-19 18:46:02 +0200241 else if (!strcmp(options, "device"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200242 otg_mode_host = false;
Eric Bénard9f2270d2010-05-19 18:46:02 +0200243 else
244 pr_info("otg_mode neither \"host\" nor \"device\". "
245 "Defaulting to device\n");
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200246 return 1;
Eric Bénard9f2270d2010-05-19 18:46:02 +0200247}
248__setup("otg_mode=", eukrea_cpuimx27_otg_mode);
249
Eric Benardaf5b1df2009-07-16 16:26:33 +0200250static void __init eukrea_cpuimx27_init(void)
251{
Shawn Guob78d8e52011-06-06 00:07:55 +0800252 imx27_soc_init();
253
Eric Benardaf5b1df2009-07-16 16:26:33 +0200254 mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
255 ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
256
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200257 imx27_add_imx_uart0(&uart_pdata);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200258
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200259 imx27_add_mxc_nand(&cpuimx27_nand_board_info);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200260
261 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
262 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
263
Russell Kingf779b7d2010-10-19 20:12:24 +0100264 imx27_add_imx_i2c(0, &cpuimx27_i2c1_data);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200265
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200266 imx27_add_fec(NULL);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200267 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200268 imx27_add_imx2_wdt();
269 imx27_add_mxc_w1();
Eric Benardaf5b1df2009-07-16 16:26:33 +0200270
271#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
272 /* SDHC2 can be used for Wifi */
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100273 imx27_add_mxc_mmc(1, NULL);
Eric Bénard2d66c782010-05-19 18:45:59 +0200274#endif
Paul Bolle4f5ef62c2013-03-22 01:15:02 +0100275#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +0200276 /* in which case UART4 is also used for Bluetooth */
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200277 imx27_add_imx_uart3(&uart_pdata);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200278#endif
279
280#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
Shawn Guo438196c2011-12-05 10:12:28 +0800281 serial_platform_data[0].irq = IMX_GPIO_NR(2, 23);
282 serial_platform_data[1].irq = IMX_GPIO_NR(2, 22);
283 serial_platform_data[2].irq = IMX_GPIO_NR(2, 27);
284 serial_platform_data[3].irq = IMX_GPIO_NR(2, 30);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200285 platform_device_register(&serial_device);
286#endif
287
Eric Bénard9f2270d2010-05-19 18:46:02 +0200288 if (otg_mode_host) {
Sascha Hauer48f6b092011-03-02 09:27:42 +0100289 otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
290 ULPI_OTG_DRVVBUS_EXT);
291 if (otg_pdata.otg)
292 imx27_add_mxc_ehci_otg(&otg_pdata);
293 } else {
294 imx27_add_fsl_usb2_udc(&otg_device_pdata);
Eric Bénard9f2270d2010-05-19 18:46:02 +0200295 }
296
Sascha Hauer48f6b092011-03-02 09:27:42 +0100297 usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
298 ULPI_OTG_DRVVBUS_EXT);
299 if (usbh2_pdata.otg)
300 imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
Eric Bénard9f2270d2010-05-19 18:46:02 +0200301
Eric Benardaf5b1df2009-07-16 16:26:33 +0200302#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
303 eukrea_mbimx27_baseboard_init();
304#endif
305}
306
307static void __init eukrea_cpuimx27_timer_init(void)
308{
309 mx27_clocks_init(26000000);
310}
311
Eric Bénard0d6cfa32011-08-22 15:41:46 +0100312MACHINE_START(EUKREA_CPUIMX27, "EUKREA CPUIMX27")
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400313 .atag_offset = 0x100,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100314 .map_io = mx27_map_io,
315 .init_early = imx27_init_early,
316 .init_irq = mx27_init_irq,
Sascha Hauerffa2ea32011-09-20 14:31:24 +0200317 .handle_irq = imx27_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700318 .init_time = eukrea_cpuimx27_timer_init,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100319 .init_machine = eukrea_cpuimx27_init,
Russell King65ea7882011-11-06 17:12:08 +0000320 .restart = mxc_restart,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200321MACHINE_END