blob: b2ee6e009fe44aef0bf3bfdb9a9c1cb7c7f71ecf [file] [log] [blame]
Eric Bénard6f1fa706f2010-06-08 11:03:01 +02001/*
2 * Copyright 2009 Sascha Hauer, <kernel@pengutronix.de>
3 * Copyright 2010 Eric Bénard - Eukréa Electromatique, <eric@eukrea.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <linux/types.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/clk.h>
24#include <linux/irq.h>
25#include <linux/gpio.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020026#include <linux/platform_device.h>
27#include <linux/usb/otg.h>
28#include <linux/usb/ulpi.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020029
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020030#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
33#include <asm/memory.h>
34#include <asm/mach/map.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020035
Shawn Guoe3372472012-09-13 21:01:00 +080036#include "common.h"
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020037#include "devices-imx25.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080038#include "ehci.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-mx25.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080042#include "mx25.h"
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020043
44static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020045 .flags = IMXUART_HAVE_RTSCTS,
46};
47
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020048static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020049 /* FEC - RMII */
50 MX25_PAD_FEC_MDC__FEC_MDC,
51 MX25_PAD_FEC_MDIO__FEC_MDIO,
52 MX25_PAD_FEC_TDATA0__FEC_TDATA0,
53 MX25_PAD_FEC_TDATA1__FEC_TDATA1,
54 MX25_PAD_FEC_TX_EN__FEC_TX_EN,
55 MX25_PAD_FEC_RDATA0__FEC_RDATA0,
56 MX25_PAD_FEC_RDATA1__FEC_RDATA1,
57 MX25_PAD_FEC_RX_DV__FEC_RX_DV,
58 MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
59 /* I2C1 */
60 MX25_PAD_I2C1_CLK__I2C1_CLK,
61 MX25_PAD_I2C1_DAT__I2C1_DAT,
62};
63
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +020064static const struct fec_platform_data mx25_fec_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020065 .phy = PHY_INTERFACE_MODE_RMII,
66};
67
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020068static const struct mxc_nand_platform_data
69eukrea_cpuimx25_nand_board_info __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020070 .width = 1,
71 .hw_ecc = 1,
72 .flash_bbt = 1,
73};
74
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020075static const struct imxi2c_platform_data
76eukrea_cpuimx25_i2c0_data __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020077 .bitrate = 100000,
78};
79
80static struct i2c_board_info eukrea_cpuimx25_i2c_devices[] = {
81 {
82 I2C_BOARD_INFO("pcf8563", 0x51),
83 },
84};
85
Sascha Hauer4bd597b2011-01-03 11:30:28 +010086static int eukrea_cpuimx25_otg_init(struct platform_device *pdev)
87{
88 return mx25_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
89}
90
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +010091static const struct mxc_usbh_platform_data otg_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +010092 .init = eukrea_cpuimx25_otg_init,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020093 .portsc = MXC_EHCI_MODE_UTMI,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020094};
95
Sascha Hauer4bd597b2011-01-03 11:30:28 +010096static int eukrea_cpuimx25_usbh2_init(struct platform_device *pdev)
97{
98 return mx25_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_SINGLE_UNI |
99 MXC_EHCI_INTERNAL_PHY | MXC_EHCI_IPPUE_DOWN);
100}
101
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100102static const struct mxc_usbh_platform_data usbh2_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100103 .init = eukrea_cpuimx25_usbh2_init,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200104 .portsc = MXC_EHCI_MODE_SERIAL,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200105};
106
Uwe Kleine-König224b8c82010-11-10 21:50:07 +0100107static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200108 .operating_mode = FSL_USB2_DR_DEVICE,
109 .phy_mode = FSL_USB2_PHY_UTMI,
Eric Bénardf381f9f2012-05-08 09:20:16 +0200110 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200111};
112
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200113static bool otg_mode_host __initdata;
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200114
115static int __init eukrea_cpuimx25_otg_mode(char *options)
116{
117 if (!strcmp(options, "host"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200118 otg_mode_host = true;
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200119 else if (!strcmp(options, "device"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200120 otg_mode_host = false;
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200121 else
122 pr_info("otg_mode neither \"host\" nor \"device\". "
123 "Defaulting to device\n");
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200124 return 1;
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200125}
126__setup("otg_mode=", eukrea_cpuimx25_otg_mode);
127
128static void __init eukrea_cpuimx25_init(void)
129{
Shawn Guob78d8e52011-06-06 00:07:55 +0800130 imx25_soc_init();
131
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200132 if (mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx25_pads,
133 ARRAY_SIZE(eukrea_cpuimx25_pads)))
134 printk(KERN_ERR "error setting cpuimx25 pads !\n");
135
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200136 imx25_add_imx_uart0(&uart_pdata);
137 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200138 imx25_add_imxdi_rtc();
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200139 imx25_add_fec(&mx25_fec_pdata);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200140 imx25_add_imx2_wdt();
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200141
142 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices,
143 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices));
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200144 imx25_add_imx_i2c0(&eukrea_cpuimx25_i2c0_data);
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200145
Eric Bénard52d084f2010-10-05 18:02:30 +0200146 if (otg_mode_host)
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100147 imx25_add_mxc_ehci_otg(&otg_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200148 else
Uwe Kleine-König224b8c82010-11-10 21:50:07 +0100149 imx25_add_fsl_usb2_udc(&otg_device_pdata);
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200150
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100151 imx25_add_mxc_ehci_hs(&usbh2_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200152
Eric Bénardec53fe32010-07-30 22:58:40 +0200153#ifdef CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD
154 eukrea_mbimxsd25_baseboard_init();
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200155#endif
156}
157
158static void __init eukrea_cpuimx25_timer_init(void)
159{
160 mx25_clocks_init();
161}
162
Eric Bénard0d6cfa32011-08-22 15:41:46 +0100163MACHINE_START(EUKREA_CPUIMX25SD, "Eukrea CPUIMX25")
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200164 /* Maintainer: Eukrea Electromatique */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400165 .atag_offset = 0x100,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100166 .map_io = mx25_map_io,
167 .init_early = imx25_init_early,
168 .init_irq = mx25_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700169 .init_time = eukrea_cpuimx25_timer_init,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100170 .init_machine = eukrea_cpuimx25_init,
Russell King65ea7882011-11-06 17:12:08 +0000171 .restart = mxc_restart,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200172MACHINE_END