ARM i.MX ehci: do ehci init in board specific functions
[deliverable/linux.git] / arch / arm / mach-imx / mach-imx27_visstrim_m10.c
CommitLineData
3b161e51
JM
1/*
2 * mach-imx27_visstrim_m10.c
3 *
4 * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com>
5 *
6 * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
26#include <linux/platform_device.h>
27#include <linux/mtd/physmap.h>
28#include <linux/i2c.h>
29#include <linux/i2c/pca953x.h>
30#include <linux/gpio_keys.h>
31#include <linux/input.h>
32#include <linux/gpio.h>
4bd597b6 33#include <linux/delay.h>
3b161e51
JM
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/time.h>
37#include <mach/common.h>
3b161e51 38#include <mach/iomux.h>
3b161e51
JM
39
40#include "devices-imx27.h"
3b161e51
JM
41
42#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
43#define SDHC1_IRQ IRQ_GPIOB(25)
44
6c80ee51 45static const int visstrim_m10_pins[] __initconst = {
3b161e51
JM
46 /* UART1 (console) */
47 PE12_PF_UART1_TXD,
48 PE13_PF_UART1_RXD,
49 PE14_PF_UART1_CTS,
50 PE15_PF_UART1_RTS,
51 /* FEC */
52 PD0_AIN_FEC_TXD0,
53 PD1_AIN_FEC_TXD1,
54 PD2_AIN_FEC_TXD2,
55 PD3_AIN_FEC_TXD3,
56 PD4_AOUT_FEC_RX_ER,
57 PD5_AOUT_FEC_RXD1,
58 PD6_AOUT_FEC_RXD2,
59 PD7_AOUT_FEC_RXD3,
60 PD8_AF_FEC_MDIO,
61 PD9_AIN_FEC_MDC,
62 PD10_AOUT_FEC_CRS,
63 PD11_AOUT_FEC_TX_CLK,
64 PD12_AOUT_FEC_RXD0,
65 PD13_AOUT_FEC_RX_DV,
66 PD14_AOUT_FEC_RX_CLK,
67 PD15_AOUT_FEC_COL,
68 PD16_AIN_FEC_TX_ER,
69 PF23_AIN_FEC_TX_EN,
70 /* SDHC1 */
71 PE18_PF_SD1_D0,
72 PE19_PF_SD1_D1,
73 PE20_PF_SD1_D2,
74 PE21_PF_SD1_D3,
75 PE22_PF_SD1_CMD,
76 PE23_PF_SD1_CLK,
77 /* Both I2Cs */
78 PD17_PF_I2C_DATA,
79 PD18_PF_I2C_CLK,
80 PC5_PF_I2C2_SDA,
81 PC6_PF_I2C2_SCL,
82 /* USB OTG */
83 OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
84 PC9_PF_USBOTG_DATA0,
85 PC11_PF_USBOTG_DATA1,
86 PC10_PF_USBOTG_DATA2,
87 PC13_PF_USBOTG_DATA3,
88 PC12_PF_USBOTG_DATA4,
89 PC7_PF_USBOTG_DATA5,
90 PC8_PF_USBOTG_DATA6,
91 PE25_PF_USBOTG_DATA7,
92 PE24_PF_USBOTG_CLK,
93 PE2_PF_USBOTG_DIR,
94 PE0_PF_USBOTG_NXT,
95 PE1_PF_USBOTG_STP,
96 PB23_PF_USB_PWR,
97 PB24_PF_USB_OC,
98};
99
100/* GPIOs used as events for applications */
101static struct gpio_keys_button visstrim_gpio_keys[] = {
102 {
103 .type = EV_KEY,
104 .code = KEY_RESTART,
105 .gpio = (GPIO_PORTC + 15),
106 .desc = "Default config",
107 .active_low = 0,
108 .wakeup = 1,
109 },
110 {
111 .type = EV_KEY,
112 .code = KEY_RECORD,
113 .gpio = (GPIO_PORTF + 14),
114 .desc = "Record",
115 .active_low = 0,
116 .wakeup = 1,
117 },
118 {
119 .type = EV_KEY,
120 .code = KEY_STOP,
121 .gpio = (GPIO_PORTF + 13),
122 .desc = "Stop",
123 .active_low = 0,
124 .wakeup = 1,
125 }
126};
127
128static struct gpio_keys_platform_data visstrim_gpio_keys_platform_data = {
129 .buttons = visstrim_gpio_keys,
130 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
131};
132
133static struct platform_device visstrim_gpio_keys_device = {
134 .name = "gpio-keys",
135 .id = -1,
136 .dev = {
137 .platform_data = &visstrim_gpio_keys_platform_data,
138 },
139};
140
141/* Visstrim_SM10 has a microSD slot connected to sdhc1 */
142static int visstrim_m10_sdhc1_init(struct device *dev,
143 irq_handler_t detect_irq, void *data)
144{
145 int ret;
146
147 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
148 "mmc-detect", data);
149 return ret;
150}
151
152static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
153{
154 free_irq(SDHC1_IRQ, data);
155}
156
9d3d945a 157static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
3b161e51
JM
158 .init = visstrim_m10_sdhc1_init,
159 .exit = visstrim_m10_sdhc1_exit,
160};
161
162/* Visstrim_SM10 NOR flash */
163static struct physmap_flash_data visstrim_m10_flash_data = {
164 .width = 2,
165};
166
167static struct resource visstrim_m10_flash_resource = {
168 .start = 0xc0000000,
169 .end = 0xc0000000 + SZ_64M - 1,
170 .flags = IORESOURCE_MEM,
171};
172
173static struct platform_device visstrim_m10_nor_mtd_device = {
174 .name = "physmap-flash",
175 .id = 0,
176 .dev = {
177 .platform_data = &visstrim_m10_flash_data,
178 },
179 .num_resources = 1,
180 .resource = &visstrim_m10_flash_resource,
181};
182
183static struct platform_device *platform_devices[] __initdata = {
184 &visstrim_gpio_keys_device,
185 &visstrim_m10_nor_mtd_device,
3b161e51
JM
186};
187
188/* Visstrim_M10 uses UART0 as console */
189static const struct imxuart_platform_data uart_pdata __initconst = {
190 .flags = IMXUART_HAVE_RTSCTS,
191};
192
193/* I2C */
194static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
195 .bitrate = 100000,
196};
197
198static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
199 .gpio_base = 240, /* After MX27 internal GPIOs */
200 .invert = 0,
201};
202
203static struct i2c_board_info visstrim_m10_i2c_devices[] = {
204 {
205 I2C_BOARD_INFO("pca9555", 0x20),
206 .platform_data = &visstrim_m10_pca9555_pdata,
207 },
208};
209
210/* USB OTG */
211static int otg_phy_init(struct platform_device *pdev)
212{
213 gpio_set_value(OTG_PHY_CS_GPIO, 0);
4bd597b6
SH
214
215 mdelay(10);
216
217 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
3b161e51
JM
218}
219
2eb42d5c
UKK
220static const struct mxc_usbh_platform_data
221visstrim_m10_usbotg_pdata __initconst = {
3b161e51
JM
222 .init = otg_phy_init,
223 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
3b161e51
JM
224};
225
226static void __init visstrim_m10_board_init(void)
227{
228 int ret;
229
230 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
231 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
232 if (ret)
233 pr_err("Failed to setup pins (%d)\n", ret);
234
235 imx27_add_imx_uart0(&uart_pdata);
236
237 i2c_register_board_info(0, visstrim_m10_i2c_devices,
238 ARRAY_SIZE(visstrim_m10_i2c_devices));
77a406da
UKK
239 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
240 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
9d3d945a 241 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
2eb42d5c 242 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
6bd96f3c 243 imx27_add_fec(NULL);
3b161e51
JM
244 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
245}
246
247static void __init visstrim_m10_timer_init(void)
248{
249 mx27_clocks_init((unsigned long)25000000);
250}
251
252static struct sys_timer visstrim_m10_timer = {
253 .init = visstrim_m10_timer_init,
254};
255
256MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
3dac2196
UKK
257 .boot_params = MX27_PHYS_OFFSET + 0x100,
258 .map_io = mx27_map_io,
259 .init_early = imx27_init_early,
260 .init_irq = mx27_init_irq,
261 .timer = &visstrim_m10_timer,
262 .init_machine = visstrim_m10_board_init,
3b161e51 263MACHINE_END
This page took 0.053351 seconds and 5 git commands to generate.