blob: 7ae43b1ec51715ece828b11a72937c99ccb920a7 [file] [log] [blame]
Javier Martin3b161e52010-07-30 10:06:01 +02001/*
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>
Javier Martin3b161e52010-07-30 10:06:01 +020030#include <linux/input.h>
31#include <linux/gpio.h>
Sascha Hauer4bd597b2011-01-03 11:30:28 +010032#include <linux/delay.h>
Javier Martin3b161e52010-07-30 10:06:01 +020033#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/time.h>
36#include <mach/common.h>
Javier Martin3b161e52010-07-30 10:06:01 +020037#include <mach/iomux.h>
Javier Martin3b161e52010-07-30 10:06:01 +020038
39#include "devices-imx27.h"
Javier Martin3b161e52010-07-30 10:06:01 +020040
41#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
42#define SDHC1_IRQ IRQ_GPIOB(25)
43
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020044static const int visstrim_m10_pins[] __initconst = {
Javier Martin3b161e52010-07-30 10:06:01 +020045 /* 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,
Javier Martina5e20512011-03-01 15:02:08 +010069 /* SSI1 */
70 PC20_PF_SSI1_FS,
71 PC21_PF_SSI1_RXD,
72 PC22_PF_SSI1_TXD,
73 PC23_PF_SSI1_CLK,
Javier Martin3b161e52010-07-30 10:06:01 +020074 /* SDHC1 */
75 PE18_PF_SD1_D0,
76 PE19_PF_SD1_D1,
77 PE20_PF_SD1_D2,
78 PE21_PF_SD1_D3,
79 PE22_PF_SD1_CMD,
80 PE23_PF_SD1_CLK,
81 /* Both I2Cs */
82 PD17_PF_I2C_DATA,
83 PD18_PF_I2C_CLK,
84 PC5_PF_I2C2_SDA,
85 PC6_PF_I2C2_SCL,
86 /* USB OTG */
87 OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
88 PC9_PF_USBOTG_DATA0,
89 PC11_PF_USBOTG_DATA1,
90 PC10_PF_USBOTG_DATA2,
91 PC13_PF_USBOTG_DATA3,
92 PC12_PF_USBOTG_DATA4,
93 PC7_PF_USBOTG_DATA5,
94 PC8_PF_USBOTG_DATA6,
95 PE25_PF_USBOTG_DATA7,
96 PE24_PF_USBOTG_CLK,
97 PE2_PF_USBOTG_DIR,
98 PE0_PF_USBOTG_NXT,
99 PE1_PF_USBOTG_STP,
100 PB23_PF_USB_PWR,
101 PB24_PF_USB_OC,
102};
103
104/* GPIOs used as events for applications */
105static struct gpio_keys_button visstrim_gpio_keys[] = {
106 {
107 .type = EV_KEY,
108 .code = KEY_RESTART,
109 .gpio = (GPIO_PORTC + 15),
110 .desc = "Default config",
111 .active_low = 0,
112 .wakeup = 1,
113 },
114 {
115 .type = EV_KEY,
116 .code = KEY_RECORD,
117 .gpio = (GPIO_PORTF + 14),
118 .desc = "Record",
119 .active_low = 0,
120 .wakeup = 1,
121 },
122 {
123 .type = EV_KEY,
124 .code = KEY_STOP,
125 .gpio = (GPIO_PORTF + 13),
126 .desc = "Stop",
127 .active_low = 0,
128 .wakeup = 1,
129 }
130};
131
Uwe Kleine-König53094982011-02-28 18:04:33 +0100132static const struct gpio_keys_platform_data
133 visstrim_gpio_keys_platform_data __initconst = {
Javier Martin3b161e52010-07-30 10:06:01 +0200134 .buttons = visstrim_gpio_keys,
135 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
136};
137
Javier Martin3b161e52010-07-30 10:06:01 +0200138/* Visstrim_SM10 has a microSD slot connected to sdhc1 */
139static int visstrim_m10_sdhc1_init(struct device *dev,
140 irq_handler_t detect_irq, void *data)
141{
142 int ret;
143
144 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
145 "mmc-detect", data);
146 return ret;
147}
148
149static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
150{
151 free_irq(SDHC1_IRQ, data);
152}
153
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100154static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
Javier Martin3b161e52010-07-30 10:06:01 +0200155 .init = visstrim_m10_sdhc1_init,
156 .exit = visstrim_m10_sdhc1_exit,
157};
158
159/* Visstrim_SM10 NOR flash */
160static struct physmap_flash_data visstrim_m10_flash_data = {
161 .width = 2,
162};
163
164static struct resource visstrim_m10_flash_resource = {
165 .start = 0xc0000000,
166 .end = 0xc0000000 + SZ_64M - 1,
167 .flags = IORESOURCE_MEM,
168};
169
170static struct platform_device visstrim_m10_nor_mtd_device = {
171 .name = "physmap-flash",
172 .id = 0,
173 .dev = {
174 .platform_data = &visstrim_m10_flash_data,
175 },
176 .num_resources = 1,
177 .resource = &visstrim_m10_flash_resource,
178};
179
180static struct platform_device *platform_devices[] __initdata = {
Javier Martin3b161e52010-07-30 10:06:01 +0200181 &visstrim_m10_nor_mtd_device,
Javier Martin3b161e52010-07-30 10:06:01 +0200182};
183
184/* Visstrim_M10 uses UART0 as console */
185static const struct imxuart_platform_data uart_pdata __initconst = {
186 .flags = IMXUART_HAVE_RTSCTS,
187};
188
189/* I2C */
190static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
191 .bitrate = 100000,
192};
193
194static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
195 .gpio_base = 240, /* After MX27 internal GPIOs */
196 .invert = 0,
197};
198
199static struct i2c_board_info visstrim_m10_i2c_devices[] = {
200 {
201 I2C_BOARD_INFO("pca9555", 0x20),
202 .platform_data = &visstrim_m10_pca9555_pdata,
203 },
Javier Martina5e20512011-03-01 15:02:08 +0100204 {
205 I2C_BOARD_INFO("tlv320aic32x4", 0x18),
206 }
Javier Martin3b161e52010-07-30 10:06:01 +0200207};
208
209/* USB OTG */
210static int otg_phy_init(struct platform_device *pdev)
211{
212 gpio_set_value(OTG_PHY_CS_GPIO, 0);
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100213
214 mdelay(10);
215
216 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
Javier Martin3b161e52010-07-30 10:06:01 +0200217}
218
Uwe Kleine-König2eb42d52010-11-05 18:52:09 +0100219static const struct mxc_usbh_platform_data
220visstrim_m10_usbotg_pdata __initconst = {
Javier Martin3b161e52010-07-30 10:06:01 +0200221 .init = otg_phy_init,
222 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Javier Martin3b161e52010-07-30 10:06:01 +0200223};
224
Javier Martina5e20512011-03-01 15:02:08 +0100225/* SSI */
226static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
227 .flags = IMX_SSI_DMA | IMX_SSI_SYN,
228};
229
Javier Martin3b161e52010-07-30 10:06:01 +0200230static void __init visstrim_m10_board_init(void)
231{
232 int ret;
233
234 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
235 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
236 if (ret)
237 pr_err("Failed to setup pins (%d)\n", ret);
238
Javier Martina5e20512011-03-01 15:02:08 +0100239 imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata);
Javier Martin3b161e52010-07-30 10:06:01 +0200240 imx27_add_imx_uart0(&uart_pdata);
241
242 i2c_register_board_info(0, visstrim_m10_i2c_devices,
243 ARRAY_SIZE(visstrim_m10_i2c_devices));
Uwe Kleine-König77a406d2010-08-25 12:19:50 +0200244 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
245 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100246 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
Uwe Kleine-König2eb42d52010-11-05 18:52:09 +0100247 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200248 imx27_add_fec(NULL);
Uwe Kleine-König53094982011-02-28 18:04:33 +0100249 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data);
Javier Martin3b161e52010-07-30 10:06:01 +0200250 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
251}
252
253static void __init visstrim_m10_timer_init(void)
254{
255 mx27_clocks_init((unsigned long)25000000);
256}
257
258static struct sys_timer visstrim_m10_timer = {
259 .init = visstrim_m10_timer_init,
260};
261
262MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100263 .boot_params = MX27_PHYS_OFFSET + 0x100,
264 .map_io = mx27_map_io,
265 .init_early = imx27_init_early,
266 .init_irq = mx27_init_irq,
267 .timer = &visstrim_m10_timer,
268 .init_machine = visstrim_m10_board_init,
Javier Martin3b161e52010-07-30 10:06:01 +0200269MACHINE_END