blob: 148cff2819b95246c9c8946c62f41600fb546402 [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énard95afd092010-07-23 14:56:40 +020030#include <mach/eukrea-baseboards.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020031#include <mach/hardware.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/time.h>
35#include <asm/memory.h>
36#include <asm/mach/map.h>
37#include <mach/common.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020038#include <mach/mx25.h>
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020039#include <mach/iomux-mx25.h>
40
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020041#include "devices-imx25.h"
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020042
43static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020044 .flags = IMXUART_HAVE_RTSCTS,
45};
46
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020047static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020048 /* FEC - RMII */
49 MX25_PAD_FEC_MDC__FEC_MDC,
50 MX25_PAD_FEC_MDIO__FEC_MDIO,
51 MX25_PAD_FEC_TDATA0__FEC_TDATA0,
52 MX25_PAD_FEC_TDATA1__FEC_TDATA1,
53 MX25_PAD_FEC_TX_EN__FEC_TX_EN,
54 MX25_PAD_FEC_RDATA0__FEC_RDATA0,
55 MX25_PAD_FEC_RDATA1__FEC_RDATA1,
56 MX25_PAD_FEC_RX_DV__FEC_RX_DV,
57 MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
58 /* I2C1 */
59 MX25_PAD_I2C1_CLK__I2C1_CLK,
60 MX25_PAD_I2C1_DAT__I2C1_DAT,
61};
62
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +020063static const struct fec_platform_data mx25_fec_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020064 .phy = PHY_INTERFACE_MODE_RMII,
65};
66
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020067static const struct mxc_nand_platform_data
68eukrea_cpuimx25_nand_board_info __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020069 .width = 1,
70 .hw_ecc = 1,
71 .flash_bbt = 1,
72};
73
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020074static const struct imxi2c_platform_data
75eukrea_cpuimx25_i2c0_data __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020076 .bitrate = 100000,
77};
78
79static struct i2c_board_info eukrea_cpuimx25_i2c_devices[] = {
80 {
81 I2C_BOARD_INFO("pcf8563", 0x51),
82 },
83};
84
Sascha Hauer4bd597b2011-01-03 11:30:28 +010085static int eukrea_cpuimx25_otg_init(struct platform_device *pdev)
86{
87 return mx25_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
88}
89
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +010090static const struct mxc_usbh_platform_data otg_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +010091 .init = eukrea_cpuimx25_otg_init,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020092 .portsc = MXC_EHCI_MODE_UTMI,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +020093};
94
Sascha Hauer4bd597b2011-01-03 11:30:28 +010095static int eukrea_cpuimx25_usbh2_init(struct platform_device *pdev)
96{
97 return mx25_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_SINGLE_UNI |
98 MXC_EHCI_INTERNAL_PHY | MXC_EHCI_IPPUE_DOWN);
99}
100
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100101static const struct mxc_usbh_platform_data usbh2_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100102 .init = eukrea_cpuimx25_usbh2_init,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200103 .portsc = MXC_EHCI_MODE_SERIAL,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200104};
105
Uwe Kleine-König224b8c82010-11-10 21:50:07 +0100106static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200107 .operating_mode = FSL_USB2_DR_DEVICE,
108 .phy_mode = FSL_USB2_PHY_UTMI,
109};
110
111static int otg_mode_host;
112
113static int __init eukrea_cpuimx25_otg_mode(char *options)
114{
115 if (!strcmp(options, "host"))
116 otg_mode_host = 1;
117 else if (!strcmp(options, "device"))
118 otg_mode_host = 0;
119 else
120 pr_info("otg_mode neither \"host\" nor \"device\". "
121 "Defaulting to device\n");
122 return 0;
123}
124__setup("otg_mode=", eukrea_cpuimx25_otg_mode);
125
126static void __init eukrea_cpuimx25_init(void)
127{
128 if (mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx25_pads,
129 ARRAY_SIZE(eukrea_cpuimx25_pads)))
130 printk(KERN_ERR "error setting cpuimx25 pads !\n");
131
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200132 imx25_add_imx_uart0(&uart_pdata);
133 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info);
Uwe Kleine-Könige7c74b32010-11-11 11:57:21 +0100134 imx25_add_imxdi_rtc(NULL);
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200135 imx25_add_fec(&mx25_fec_pdata);
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200136
137 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices,
138 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices));
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200139 imx25_add_imx_i2c0(&eukrea_cpuimx25_i2c0_data);
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200140
Eric Bénard52d084f2010-10-05 18:02:30 +0200141 if (otg_mode_host)
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100142 imx25_add_mxc_ehci_otg(&otg_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200143 else
Uwe Kleine-König224b8c82010-11-10 21:50:07 +0100144 imx25_add_fsl_usb2_udc(&otg_device_pdata);
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200145
Uwe Kleine-König2c20b9f2010-11-10 21:27:55 +0100146 imx25_add_mxc_ehci_hs(&usbh2_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200147
Eric Bénardec53fe32010-07-30 22:58:40 +0200148#ifdef CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD
149 eukrea_mbimxsd25_baseboard_init();
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200150#endif
151}
152
153static void __init eukrea_cpuimx25_timer_init(void)
154{
155 mx25_clocks_init();
156}
157
158static struct sys_timer eukrea_cpuimx25_timer = {
159 .init = eukrea_cpuimx25_timer_init,
160};
161
162MACHINE_START(EUKREA_CPUIMX25, "Eukrea CPUIMX25")
163 /* Maintainer: Eukrea Electromatique */
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100164 .boot_params = MX25_PHYS_OFFSET + 0x100,
165 .map_io = mx25_map_io,
166 .init_early = imx25_init_early,
167 .init_irq = mx25_init_irq,
168 .timer = &eukrea_cpuimx25_timer,
169 .init_machine = eukrea_cpuimx25_init,
Eric Bénard6f1fa706f2010-06-08 11:03:01 +0200170MACHINE_END