Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa...
[sfrench/cifs-2.6.git] / arch / arm / mach-mx3 / mach-cpuimx35.c
1 /*
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>
33 #include <linux/fsl_devices.h>
34 #include <linux/i2c-gpio.h>
35
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/time.h>
39 #include <asm/mach/map.h>
40
41 #include <mach/eukrea-baseboards.h>
42 #include <mach/hardware.h>
43 #include <mach/common.h>
44 #include <mach/iomux-mx35.h>
45 #include <mach/mxc_nand.h>
46 #include <mach/mxc_ehci.h>
47 #include <mach/ulpi.h>
48
49 #include "devices-imx35.h"
50 #include "devices.h"
51
52 static const struct imxuart_platform_data uart_pdata __initconst = {
53         .flags = IMXUART_HAVE_RTSCTS,
54 };
55
56 static const struct imxi2c_platform_data
57                 eukrea_cpuimx35_i2c0_data __initconst = {
58         .bitrate =              100000,
59 };
60
61 static struct tsc2007_platform_data tsc2007_info = {
62         .model                  = 2007,
63         .x_plate_ohms           = 180,
64 };
65
66 #define TSC2007_IRQGPIO         (2 * 32 + 2)
67 static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
68         {
69                 I2C_BOARD_INFO("pcf8563", 0x51),
70         }, {
71                 I2C_BOARD_INFO("tsc2007", 0x48),
72                 .type           = "tsc2007",
73                 .platform_data  = &tsc2007_info,
74                 .irq            = gpio_to_irq(TSC2007_IRQGPIO),
75         },
76 };
77
78 static struct platform_device *devices[] __initdata = {
79         &imx_wdt_device0,
80 };
81
82 static struct pad_desc eukrea_cpuimx35_pads[] = {
83         /* UART1 */
84         MX35_PAD_CTS1__UART1_CTS,
85         MX35_PAD_RTS1__UART1_RTS,
86         MX35_PAD_TXD1__UART1_TXD_MUX,
87         MX35_PAD_RXD1__UART1_RXD_MUX,
88         /* FEC */
89         MX35_PAD_FEC_TX_CLK__FEC_TX_CLK,
90         MX35_PAD_FEC_RX_CLK__FEC_RX_CLK,
91         MX35_PAD_FEC_RX_DV__FEC_RX_DV,
92         MX35_PAD_FEC_COL__FEC_COL,
93         MX35_PAD_FEC_RDATA0__FEC_RDATA_0,
94         MX35_PAD_FEC_TDATA0__FEC_TDATA_0,
95         MX35_PAD_FEC_TX_EN__FEC_TX_EN,
96         MX35_PAD_FEC_MDC__FEC_MDC,
97         MX35_PAD_FEC_MDIO__FEC_MDIO,
98         MX35_PAD_FEC_TX_ERR__FEC_TX_ERR,
99         MX35_PAD_FEC_RX_ERR__FEC_RX_ERR,
100         MX35_PAD_FEC_CRS__FEC_CRS,
101         MX35_PAD_FEC_RDATA1__FEC_RDATA_1,
102         MX35_PAD_FEC_TDATA1__FEC_TDATA_1,
103         MX35_PAD_FEC_RDATA2__FEC_RDATA_2,
104         MX35_PAD_FEC_TDATA2__FEC_TDATA_2,
105         MX35_PAD_FEC_RDATA3__FEC_RDATA_3,
106         MX35_PAD_FEC_TDATA3__FEC_TDATA_3,
107         /* I2C1 */
108         MX35_PAD_I2C1_CLK__I2C1_SCL,
109         MX35_PAD_I2C1_DAT__I2C1_SDA,
110         /* TSC2007 IRQ */
111         MX35_PAD_ATA_DA2__GPIO3_2,
112 };
113
114 static const struct mxc_nand_platform_data
115                 eukrea_cpuimx35_nand_board_info __initconst = {
116         .width          = 1,
117         .hw_ecc         = 1,
118         .flash_bbt      = 1,
119 };
120
121 static struct mxc_usbh_platform_data __maybe_unused otg_pdata = {
122         .portsc = MXC_EHCI_MODE_UTMI,
123         .flags  = MXC_EHCI_INTERFACE_DIFF_UNI,
124 };
125
126 static struct mxc_usbh_platform_data __maybe_unused usbh1_pdata = {
127         .portsc = MXC_EHCI_MODE_SERIAL,
128         .flags  = MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY |
129                   MXC_EHCI_IPPUE_DOWN,
130 };
131
132 static struct fsl_usb2_platform_data otg_device_pdata = {
133         .operating_mode = FSL_USB2_DR_DEVICE,
134         .phy_mode       = FSL_USB2_PHY_UTMI,
135 };
136
137 static int otg_mode_host;
138
139 static int __init eukrea_cpuimx35_otg_mode(char *options)
140 {
141         if (!strcmp(options, "host"))
142                 otg_mode_host = 1;
143         else if (!strcmp(options, "device"))
144                 otg_mode_host = 0;
145         else
146                 pr_info("otg_mode neither \"host\" nor \"device\". "
147                         "Defaulting to device\n");
148         return 0;
149 }
150 __setup("otg_mode=", eukrea_cpuimx35_otg_mode);
151
152 /*
153  * Board specific initialization.
154  */
155 static void __init mxc_board_init(void)
156 {
157         mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads,
158                         ARRAY_SIZE(eukrea_cpuimx35_pads));
159
160         imx35_add_fec(NULL);
161         platform_add_devices(devices, ARRAY_SIZE(devices));
162
163         imx35_add_imx_uart0(&uart_pdata);
164         imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info);
165
166         i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices,
167                         ARRAY_SIZE(eukrea_cpuimx35_i2c_devices));
168         imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data);
169
170 #if defined(CONFIG_USB_ULPI)
171         if (otg_mode_host) {
172                 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
173                                 ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
174
175                 mxc_register_device(&mxc_otg_host, &otg_pdata);
176         }
177         mxc_register_device(&mxc_usbh1, &usbh1_pdata);
178 #endif
179         if (!otg_mode_host)
180                 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
181
182 #ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD
183         eukrea_mbimxsd35_baseboard_init();
184 #endif
185 }
186
187 static void __init eukrea_cpuimx35_timer_init(void)
188 {
189         mx35_clocks_init();
190 }
191
192 struct sys_timer eukrea_cpuimx35_timer = {
193         .init   = eukrea_cpuimx35_timer_init,
194 };
195
196 MACHINE_START(EUKREA_CPUIMX35, "Eukrea CPUIMX35")
197         /* Maintainer: Eukrea Electromatique */
198         .phys_io        = MX35_AIPS1_BASE_ADDR,
199         .io_pg_offst    = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
200         .boot_params    = MX3x_PHYS_OFFSET + 0x100,
201         .map_io         = mx35_map_io,
202         .init_irq       = mx35_init_irq,
203         .init_machine   = mxc_board_init,
204         .timer          = &eukrea_cpuimx35_timer,
205 MACHINE_END