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