ARM: imx/mx27_3ds: Add debug board support
[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>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/time.h>
36#include <mach/common.h>
3b161e51 37#include <mach/iomux.h>
3b161e51
JM
38
39#include "devices-imx27.h"
3b161e51
JM
40
41#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
42#define SDHC1_IRQ IRQ_GPIOB(25)
43
6c80ee51 44static const int visstrim_m10_pins[] __initconst = {
3b161e51
JM
45 /* UART1 (console) */
46 PE12_PF_UART1_TXD,
47 PE13_PF_UART1_RXD,
48 PE14_PF_UART1_CTS,
49 PE15_PF_UART1_RTS,
50 /* FEC */
51 PD0_AIN_FEC_TXD0,
52 PD1_AIN_FEC_TXD1,
53 PD2_AIN_FEC_TXD2,
54 PD3_AIN_FEC_TXD3,
55 PD4_AOUT_FEC_RX_ER,
56 PD5_AOUT_FEC_RXD1,
57 PD6_AOUT_FEC_RXD2,
58 PD7_AOUT_FEC_RXD3,
59 PD8_AF_FEC_MDIO,
60 PD9_AIN_FEC_MDC,
61 PD10_AOUT_FEC_CRS,
62 PD11_AOUT_FEC_TX_CLK,
63 PD12_AOUT_FEC_RXD0,
64 PD13_AOUT_FEC_RX_DV,
65 PD14_AOUT_FEC_RX_CLK,
66 PD15_AOUT_FEC_COL,
67 PD16_AIN_FEC_TX_ER,
68 PF23_AIN_FEC_TX_EN,
69 /* SDHC1 */
70 PE18_PF_SD1_D0,
71 PE19_PF_SD1_D1,
72 PE20_PF_SD1_D2,
73 PE21_PF_SD1_D3,
74 PE22_PF_SD1_CMD,
75 PE23_PF_SD1_CLK,
76 /* Both I2Cs */
77 PD17_PF_I2C_DATA,
78 PD18_PF_I2C_CLK,
79 PC5_PF_I2C2_SDA,
80 PC6_PF_I2C2_SCL,
81 /* USB OTG */
82 OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
83 PC9_PF_USBOTG_DATA0,
84 PC11_PF_USBOTG_DATA1,
85 PC10_PF_USBOTG_DATA2,
86 PC13_PF_USBOTG_DATA3,
87 PC12_PF_USBOTG_DATA4,
88 PC7_PF_USBOTG_DATA5,
89 PC8_PF_USBOTG_DATA6,
90 PE25_PF_USBOTG_DATA7,
91 PE24_PF_USBOTG_CLK,
92 PE2_PF_USBOTG_DIR,
93 PE0_PF_USBOTG_NXT,
94 PE1_PF_USBOTG_STP,
95 PB23_PF_USB_PWR,
96 PB24_PF_USB_OC,
97};
98
99/* GPIOs used as events for applications */
100static struct gpio_keys_button visstrim_gpio_keys[] = {
101 {
102 .type = EV_KEY,
103 .code = KEY_RESTART,
104 .gpio = (GPIO_PORTC + 15),
105 .desc = "Default config",
106 .active_low = 0,
107 .wakeup = 1,
108 },
109 {
110 .type = EV_KEY,
111 .code = KEY_RECORD,
112 .gpio = (GPIO_PORTF + 14),
113 .desc = "Record",
114 .active_low = 0,
115 .wakeup = 1,
116 },
117 {
118 .type = EV_KEY,
119 .code = KEY_STOP,
120 .gpio = (GPIO_PORTF + 13),
121 .desc = "Stop",
122 .active_low = 0,
123 .wakeup = 1,
124 }
125};
126
127static struct gpio_keys_platform_data visstrim_gpio_keys_platform_data = {
128 .buttons = visstrim_gpio_keys,
129 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
130};
131
132static struct platform_device visstrim_gpio_keys_device = {
133 .name = "gpio-keys",
134 .id = -1,
135 .dev = {
136 .platform_data = &visstrim_gpio_keys_platform_data,
137 },
138};
139
140/* Visstrim_SM10 has a microSD slot connected to sdhc1 */
141static int visstrim_m10_sdhc1_init(struct device *dev,
142 irq_handler_t detect_irq, void *data)
143{
144 int ret;
145
146 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
147 "mmc-detect", data);
148 return ret;
149}
150
151static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
152{
153 free_irq(SDHC1_IRQ, data);
154}
155
9d3d945a 156static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
3b161e51
JM
157 .init = visstrim_m10_sdhc1_init,
158 .exit = visstrim_m10_sdhc1_exit,
159};
160
161/* Visstrim_SM10 NOR flash */
162static struct physmap_flash_data visstrim_m10_flash_data = {
163 .width = 2,
164};
165
166static struct resource visstrim_m10_flash_resource = {
167 .start = 0xc0000000,
168 .end = 0xc0000000 + SZ_64M - 1,
169 .flags = IORESOURCE_MEM,
170};
171
172static struct platform_device visstrim_m10_nor_mtd_device = {
173 .name = "physmap-flash",
174 .id = 0,
175 .dev = {
176 .platform_data = &visstrim_m10_flash_data,
177 },
178 .num_resources = 1,
179 .resource = &visstrim_m10_flash_resource,
180};
181
182static struct platform_device *platform_devices[] __initdata = {
183 &visstrim_gpio_keys_device,
184 &visstrim_m10_nor_mtd_device,
3b161e51
JM
185};
186
187/* Visstrim_M10 uses UART0 as console */
188static const struct imxuart_platform_data uart_pdata __initconst = {
189 .flags = IMXUART_HAVE_RTSCTS,
190};
191
192/* I2C */
193static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
194 .bitrate = 100000,
195};
196
197static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
198 .gpio_base = 240, /* After MX27 internal GPIOs */
199 .invert = 0,
200};
201
202static struct i2c_board_info visstrim_m10_i2c_devices[] = {
203 {
204 I2C_BOARD_INFO("pca9555", 0x20),
205 .platform_data = &visstrim_m10_pca9555_pdata,
206 },
207};
208
209/* USB OTG */
210static int otg_phy_init(struct platform_device *pdev)
211{
212 gpio_set_value(OTG_PHY_CS_GPIO, 0);
213 return 0;
214}
215
2eb42d5c
UKK
216static const struct mxc_usbh_platform_data
217visstrim_m10_usbotg_pdata __initconst = {
3b161e51
JM
218 .init = otg_phy_init,
219 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
220 .flags = MXC_EHCI_POWER_PINS_ENABLED,
221};
222
223static void __init visstrim_m10_board_init(void)
224{
225 int ret;
226
227 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
228 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
229 if (ret)
230 pr_err("Failed to setup pins (%d)\n", ret);
231
232 imx27_add_imx_uart0(&uart_pdata);
233
234 i2c_register_board_info(0, visstrim_m10_i2c_devices,
235 ARRAY_SIZE(visstrim_m10_i2c_devices));
77a406da
UKK
236 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
237 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
9d3d945a 238 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
2eb42d5c 239 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
6bd96f3c 240 imx27_add_fec(NULL);
3b161e51
JM
241 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
242}
243
244static void __init visstrim_m10_timer_init(void)
245{
246 mx27_clocks_init((unsigned long)25000000);
247}
248
249static struct sys_timer visstrim_m10_timer = {
250 .init = visstrim_m10_timer_init,
251};
252
253MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
3b161e51
JM
254 .boot_params = MX27_PHYS_OFFSET + 0x100,
255 .map_io = mx27_map_io,
256 .init_irq = mx27_init_irq,
257 .init_machine = visstrim_m10_board_init,
258 .timer = &visstrim_m10_timer,
259MACHINE_END
This page took 0.056964 seconds and 5 git commands to generate.