blob: 62a6e02f476318593171c38fe5c5c5b80fab1bec [file] [log] [blame]
Eric Bénard21744f12010-06-10 16:07:50 +02001/*
2 * Copyright (C) 2010 Eric Benard - eric@eukrea.com
3 * Copyright (C) 2009 Sascha Hauer, Pengutronix
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/types.h>
21#include <linux/init.h>
22
23#include <linux/platform_device.h>
24#include <linux/mtd/physmap.h>
25#include <linux/memory.h>
26#include <linux/gpio.h>
27#include <linux/interrupt.h>
28#include <linux/delay.h>
29#include <linux/i2c.h>
30#include <linux/i2c/tsc2007.h>
31#include <linux/usb/otg.h>
32#include <linux/usb/ulpi.h>
Eric Bénard54dc3f42010-10-02 17:15:26 +020033#include <linux/i2c-gpio.h>
Eric Bénard21744f12010-06-10 16:07:50 +020034
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/time.h>
38#include <asm/mach/map.h>
39
Shawn Guoe3372472012-09-13 21:01:00 +080040#include "common.h"
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020041#include "devices-imx35.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080042#include "ehci.h"
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080043#include "eukrea-baseboards.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080044#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080045#include "iomux-mx35.h"
Eric Bénard21744f12010-06-10 16:07:50 +020046
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020047static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard21744f12010-06-10 16:07:50 +020048 .flags = IMXUART_HAVE_RTSCTS,
49};
50
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020051static const struct imxi2c_platform_data
Eric Bénard54dc3f42010-10-02 17:15:26 +020052 eukrea_cpuimx35_i2c0_data __initconst = {
53 .bitrate = 100000,
Eric Bénard21744f12010-06-10 16:07:50 +020054};
55
Eric Bénard4d4b2562011-12-13 07:31:44 +010056#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2)
Denis Carikli07f9e5c2013-11-19 11:56:04 -080057static int tsc2007_get_pendown_state(struct device *dev)
Eric Bénard4d4b2562011-12-13 07:31:44 +010058{
59 return !gpio_get_value(TSC2007_IRQGPIO);
60}
61
Eric Bénard21744f12010-06-10 16:07:50 +020062static struct tsc2007_platform_data tsc2007_info = {
63 .model = 2007,
64 .x_plate_ohms = 180,
Eric Bénard4d4b2562011-12-13 07:31:44 +010065 .get_pendown_state = tsc2007_get_pendown_state,
Eric Bénard21744f12010-06-10 16:07:50 +020066};
67
68static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
69 {
70 I2C_BOARD_INFO("pcf8563", 0x51),
71 }, {
72 I2C_BOARD_INFO("tsc2007", 0x48),
Eric Bénard21744f12010-06-10 16:07:50 +020073 .platform_data = &tsc2007_info,
Shawn Guo84715dd2011-12-02 15:31:11 +080074 /* irq number is run-time assigned */
Eric Bénard21744f12010-06-10 16:07:50 +020075 },
76};
77
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020078static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = {
Eric Bénard21744f12010-06-10 16:07:50 +020079 /* UART1 */
80 MX35_PAD_CTS1__UART1_CTS,
81 MX35_PAD_RTS1__UART1_RTS,
82 MX35_PAD_TXD1__UART1_TXD_MUX,
83 MX35_PAD_RXD1__UART1_RXD_MUX,
84 /* FEC */
85 MX35_PAD_FEC_TX_CLK__FEC_TX_CLK,
86 MX35_PAD_FEC_RX_CLK__FEC_RX_CLK,
87 MX35_PAD_FEC_RX_DV__FEC_RX_DV,
88 MX35_PAD_FEC_COL__FEC_COL,
89 MX35_PAD_FEC_RDATA0__FEC_RDATA_0,
90 MX35_PAD_FEC_TDATA0__FEC_TDATA_0,
91 MX35_PAD_FEC_TX_EN__FEC_TX_EN,
92 MX35_PAD_FEC_MDC__FEC_MDC,
93 MX35_PAD_FEC_MDIO__FEC_MDIO,
94 MX35_PAD_FEC_TX_ERR__FEC_TX_ERR,
95 MX35_PAD_FEC_RX_ERR__FEC_RX_ERR,
96 MX35_PAD_FEC_CRS__FEC_CRS,
97 MX35_PAD_FEC_RDATA1__FEC_RDATA_1,
98 MX35_PAD_FEC_TDATA1__FEC_TDATA_1,
99 MX35_PAD_FEC_RDATA2__FEC_RDATA_2,
100 MX35_PAD_FEC_TDATA2__FEC_TDATA_2,
101 MX35_PAD_FEC_RDATA3__FEC_RDATA_3,
102 MX35_PAD_FEC_TDATA3__FEC_TDATA_3,
103 /* I2C1 */
104 MX35_PAD_I2C1_CLK__I2C1_SCL,
105 MX35_PAD_I2C1_DAT__I2C1_SDA,
106 /* TSC2007 IRQ */
107 MX35_PAD_ATA_DA2__GPIO3_2,
108};
109
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200110static const struct mxc_nand_platform_data
Eric Bénard54dc3f42010-10-02 17:15:26 +0200111 eukrea_cpuimx35_nand_board_info __initconst = {
Eric Bénard21744f12010-06-10 16:07:50 +0200112 .width = 1,
113 .hw_ecc = 1,
114 .flash_bbt = 1,
115};
116
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100117static int eukrea_cpuimx35_otg_init(struct platform_device *pdev)
118{
119 return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
120}
121
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100122static const struct mxc_usbh_platform_data otg_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100123 .init = eukrea_cpuimx35_otg_init,
Eric Bénard21744f12010-06-10 16:07:50 +0200124 .portsc = MXC_EHCI_MODE_UTMI,
Eric Bénard21744f12010-06-10 16:07:50 +0200125};
126
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100127static int eukrea_cpuimx35_usbh1_init(struct platform_device *pdev)
128{
129 return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_SINGLE_UNI |
130 MXC_EHCI_INTERNAL_PHY | MXC_EHCI_IPPUE_DOWN);
131}
132
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100133static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100134 .init = eukrea_cpuimx35_usbh1_init,
Eric Bénard21744f12010-06-10 16:07:50 +0200135 .portsc = MXC_EHCI_MODE_SERIAL,
Eric Bénard21744f12010-06-10 16:07:50 +0200136};
137
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +0100138static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
Eric Bénard21744f12010-06-10 16:07:50 +0200139 .operating_mode = FSL_USB2_DR_DEVICE,
140 .phy_mode = FSL_USB2_PHY_UTMI,
Eric Bénard69cb1ec2010-10-15 14:30:58 +0200141 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
Eric Bénard21744f12010-06-10 16:07:50 +0200142};
143
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200144static bool otg_mode_host __initdata;
Eric Bénard21744f12010-06-10 16:07:50 +0200145
146static int __init eukrea_cpuimx35_otg_mode(char *options)
147{
148 if (!strcmp(options, "host"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200149 otg_mode_host = true;
Eric Bénard21744f12010-06-10 16:07:50 +0200150 else if (!strcmp(options, "device"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200151 otg_mode_host = false;
Eric Bénard21744f12010-06-10 16:07:50 +0200152 else
153 pr_info("otg_mode neither \"host\" nor \"device\". "
154 "Defaulting to device\n");
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200155 return 1;
Eric Bénard21744f12010-06-10 16:07:50 +0200156}
157__setup("otg_mode=", eukrea_cpuimx35_otg_mode);
158
159/*
160 * Board specific initialization.
161 */
Uwe Kleine-Könige134fb22011-02-11 10:23:19 +0100162static void __init eukrea_cpuimx35_init(void)
Eric Bénard21744f12010-06-10 16:07:50 +0200163{
Shawn Guob78d8e52011-06-06 00:07:55 +0800164 imx35_soc_init();
165
Eric Bénard21744f12010-06-10 16:07:50 +0200166 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads,
167 ARRAY_SIZE(eukrea_cpuimx35_pads));
168
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200169 imx35_add_fec(NULL);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200170 imx35_add_imx2_wdt();
Eric Bénard21744f12010-06-10 16:07:50 +0200171
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200172 imx35_add_imx_uart0(&uart_pdata);
173 imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info);
Eric Bénard21744f12010-06-10 16:07:50 +0200174
Shawn Guo84715dd2011-12-02 15:31:11 +0800175 eukrea_cpuimx35_i2c_devices[1].irq = gpio_to_irq(TSC2007_IRQGPIO);
Eric Bénard21744f12010-06-10 16:07:50 +0200176 i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices,
177 ARRAY_SIZE(eukrea_cpuimx35_i2c_devices));
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200178 imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data);
Eric Bénard21744f12010-06-10 16:07:50 +0200179
Eric Bénard52d084f2010-10-05 18:02:30 +0200180 if (otg_mode_host)
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100181 imx35_add_mxc_ehci_otg(&otg_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200182 else
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +0100183 imx35_add_fsl_usb2_udc(&otg_device_pdata);
Eric Bénard21744f12010-06-10 16:07:50 +0200184
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100185 imx35_add_mxc_ehci_hs(&usbh1_pdata);
Eric Bénard52d084f2010-10-05 18:02:30 +0200186
Eric Bénardec53fe32010-07-30 22:58:40 +0200187#ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD
188 eukrea_mbimxsd35_baseboard_init();
Eric Bénard21744f12010-06-10 16:07:50 +0200189#endif
190}
191
192static void __init eukrea_cpuimx35_timer_init(void)
193{
194 mx35_clocks_init();
195}
196
Eric Bénard0d6cfa32011-08-22 15:41:46 +0100197MACHINE_START(EUKREA_CPUIMX35SD, "Eukrea CPUIMX35")
Eric Bénard21744f12010-06-10 16:07:50 +0200198 /* Maintainer: Eukrea Electromatique */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400199 .atag_offset = 0x100,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100200 .map_io = mx35_map_io,
Uwe Kleine-König3fc6b602011-03-01 21:30:58 +0100201 .init_early = imx35_init_early,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100202 .init_irq = mx35_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700203 .init_time = eukrea_cpuimx35_timer_init,
Uwe Kleine-Könige134fb22011-02-11 10:23:19 +0100204 .init_machine = eukrea_cpuimx35_init,
Russell King65ea7882011-11-06 17:12:08 +0000205 .restart = mxc_restart,
Eric Bénard21744f12010-06-10 16:07:50 +0200206MACHINE_END