2 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
4 * Author: Fabio Estevam <fabio.estevam@freescale.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 * This machine is known as:
19 * - i.MX27 3-Stack Development System
20 * - i.MX27 Platform Development Kit (i.MX27 PDK)
23 #include <linux/platform_device.h>
24 #include <linux/gpio.h>
25 #include <linux/irq.h>
26 #include <linux/usb/otg.h>
27 #include <linux/usb/ulpi.h>
28 #include <linux/delay.h>
29 #include <linux/mfd/mc13783.h>
30 #include <linux/spi/spi.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/spi/l4f00242t03.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/time.h>
37 #include <mach/hardware.h>
38 #include <mach/common.h>
39 #include <mach/iomux-mx27.h>
40 #include <mach/ulpi.h>
41 #include <mach/irqs.h>
42 #include <mach/3ds_debugboard.h>
44 #include "devices-imx27.h"
46 #define SD1_EN_GPIO IMX_GPIO_NR(2, 25)
47 #define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23)
48 #define SPI2_SS0 IMX_GPIO_NR(4, 21)
49 #define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(3, 28))
50 #define PMIC_INT IMX_GPIO_NR(3, 14)
51 #define SPI1_SS0 IMX_GPIO_NR(4, 28)
52 #define SD1_CD IMX_GPIO_NR(2, 26)
53 #define LCD_RESET IMX_GPIO_NR(1, 3)
54 #define LCD_ENABLE IMX_GPIO_NR(1, 31)
56 static const int mx27pdk_pins
[] __initconst
= {
88 SD1_EN_GPIO
| GPIO_GPIO
| GPIO_OUT
,
90 OTG_PHY_RESET_GPIO
| GPIO_GPIO
| GPIO_OUT
,
102 PE25_PF_USBOTG_DATA7
,
108 SPI1_SS0
| GPIO_GPIO
| GPIO_OUT
,
113 SPI2_SS0
| GPIO_GPIO
| GPIO_OUT
,
118 PMIC_INT
| GPIO_GPIO
| GPIO_IN
,
142 LCD_ENABLE
| GPIO_GPIO
| GPIO_OUT
,
143 LCD_RESET
| GPIO_GPIO
| GPIO_OUT
,
146 static const struct imxuart_platform_data uart_pdata __initconst
= {
147 .flags
= IMXUART_HAVE_RTSCTS
,
154 static const uint32_t mx27_3ds_keymap
[] = {
157 KEY(1, 0, KEY_RIGHT
),
159 KEY(1, 2, KEY_ENTER
),
166 static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst
= {
167 .keymap
= mx27_3ds_keymap
,
168 .keymap_size
= ARRAY_SIZE(mx27_3ds_keymap
),
171 static int mx27_3ds_sdhc1_init(struct device
*dev
, irq_handler_t detect_irq
,
174 return request_irq(gpio_to_irq(SD1_CD
), detect_irq
,
175 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
, "sdhc1-card-detect", data
);
178 static void mx27_3ds_sdhc1_exit(struct device
*dev
, void *data
)
180 free_irq(gpio_to_irq(SD1_CD
), data
);
183 static const struct imxmmc_platform_data sdhc1_pdata __initconst
= {
184 .init
= mx27_3ds_sdhc1_init
,
185 .exit
= mx27_3ds_sdhc1_exit
,
188 static void mx27_3ds_sdhc1_enable_level_translator(void)
190 /* Turn on TXB0108 OE pin */
191 gpio_request(SD1_EN_GPIO
, "sd1_enable");
192 gpio_direction_output(SD1_EN_GPIO
, 1);
196 static int otg_phy_init(void)
198 gpio_request(OTG_PHY_RESET_GPIO
, "usb-otg-reset");
199 gpio_direction_output(OTG_PHY_RESET_GPIO
, 0);
201 gpio_set_value(OTG_PHY_RESET_GPIO
, 1);
205 static int mx27_3ds_otg_init(struct platform_device
*pdev
)
207 return mx27_initialize_usb_hw(pdev
->id
, MXC_EHCI_INTERFACE_DIFF_UNI
);
210 static struct mxc_usbh_platform_data otg_pdata __initdata
= {
211 .init
= mx27_3ds_otg_init
,
212 .portsc
= MXC_EHCI_MODE_ULPI
,
215 static const struct fsl_usb2_platform_data otg_device_pdata __initconst
= {
216 .operating_mode
= FSL_USB2_DR_DEVICE
,
217 .phy_mode
= FSL_USB2_PHY_ULPI
,
220 static int otg_mode_host
;
222 static int __init
mx27_3ds_otg_mode(char *options
)
224 if (!strcmp(options
, "host"))
226 else if (!strcmp(options
, "device"))
229 pr_info("otg_mode neither \"host\" nor \"device\". "
230 "Defaulting to device\n");
233 __setup("otg_mode=", mx27_3ds_otg_mode
);
236 static struct regulator_init_data gpo_init
= {
243 static struct regulator_consumer_supply vmmc1_consumers
[] = {
244 REGULATOR_SUPPLY("lcd_2v8", NULL
),
247 static struct regulator_init_data vmmc1_init
= {
252 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
|
253 REGULATOR_CHANGE_STATUS
,
255 .num_consumer_supplies
= ARRAY_SIZE(vmmc1_consumers
),
256 .consumer_supplies
= vmmc1_consumers
,
259 static struct regulator_consumer_supply vgen_consumers
[] = {
260 REGULATOR_SUPPLY("vdd_lcdio", NULL
),
263 static struct regulator_init_data vgen_init
= {
267 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
269 .num_consumer_supplies
= ARRAY_SIZE(vgen_consumers
),
270 .consumer_supplies
= vgen_consumers
,
273 static struct mc13xxx_regulator_init_data mx27_3ds_regulators
[] = {
275 .id
= MC13783_REG_VMMC1
,
276 .init_data
= &vmmc1_init
,
278 .id
= MC13783_REG_VGEN
,
279 .init_data
= &vgen_init
,
281 .id
= MC13783_REG_GPO1
, /* Turn on 1.8V */
282 .init_data
= &gpo_init
,
284 .id
= MC13783_REG_GPO3
, /* Turn on 3.3V */
285 .init_data
= &gpo_init
,
290 static struct mc13xxx_platform_data mc13783_pdata
= {
292 .regulators
= mx27_3ds_regulators
,
293 .num_regulators
= ARRAY_SIZE(mx27_3ds_regulators
),
296 .flags
= MC13783_USE_REGULATOR
| MC13783_USE_TOUCHSCREEN
|
301 static int spi1_chipselect
[] = {SPI1_SS0
};
303 static const struct spi_imx_master spi1_pdata __initconst
= {
304 .chipselect
= spi1_chipselect
,
305 .num_chipselect
= ARRAY_SIZE(spi1_chipselect
),
308 static int spi2_chipselect
[] = {SPI2_SS0
};
310 static const struct spi_imx_master spi2_pdata __initconst
= {
311 .chipselect
= spi2_chipselect
,
312 .num_chipselect
= ARRAY_SIZE(spi2_chipselect
),
315 static struct imx_fb_videomode mx27_3ds_modes
[] = {
316 { /* 480x640 @ 60 Hz */
329 .sync
= FB_SYNC_OE_ACT_HIGH
|
331 .vmode
= FB_VMODE_NONINTERLACED
,
339 static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst
= {
340 .mode
= mx27_3ds_modes
,
341 .num_modes
= ARRAY_SIZE(mx27_3ds_modes
),
348 static struct l4f00242t03_pdata mx27_3ds_lcd_pdata
= {
349 .reset_gpio
= LCD_RESET
,
350 .data_enable_gpio
= LCD_ENABLE
,
351 .core_supply
= "lcd_2v8",
352 .io_supply
= "vdd_lcdio",
355 static struct spi_board_info mx27_3ds_spi_devs
[] __initdata
= {
357 .modalias
= "mc13783",
358 .max_speed_hz
= 1000000,
360 .chip_select
= 0, /* SS0 */
361 .platform_data
= &mc13783_pdata
,
362 .irq
= gpio_to_irq(PMIC_INT
),
365 .modalias
= "l4f00242t03",
366 .max_speed_hz
= 5000000,
368 .chip_select
= 0, /* SS0 */
369 .platform_data
= &mx27_3ds_lcd_pdata
,
373 static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst
= {
377 static void __init
mx27pdk_init(void)
381 mxc_gpio_setup_multiple_pins(mx27pdk_pins
, ARRAY_SIZE(mx27pdk_pins
),
383 mx27_3ds_sdhc1_enable_level_translator();
384 imx27_add_imx_uart0(&uart_pdata
);
386 imx27_add_imx_keypad(&mx27_3ds_keymap_data
);
387 imx27_add_mxc_mmc(0, &sdhc1_pdata
);
388 imx27_add_imx2_wdt(NULL
);
392 otg_pdata
.otg
= imx_otg_ulpi_create(ULPI_OTG_DRVVBUS
|
393 ULPI_OTG_DRVVBUS_EXT
);
396 imx27_add_mxc_ehci_otg(&otg_pdata
);
400 imx27_add_fsl_usb2_udc(&otg_device_pdata
);
402 imx27_add_spi_imx1(&spi2_pdata
);
403 imx27_add_spi_imx0(&spi1_pdata
);
404 spi_register_board_info(mx27_3ds_spi_devs
,
405 ARRAY_SIZE(mx27_3ds_spi_devs
));
407 if (mxc_expio_init(MX27_CS5_BASE_ADDR
, EXPIO_PARENT_INT
))
408 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
409 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data
);
410 imx27_add_imx_fb(&mx27_3ds_fb_data
);
413 static void __init
mx27pdk_timer_init(void)
415 mx27_clocks_init(26000000);
418 static struct sys_timer mx27pdk_timer
= {
419 .init
= mx27pdk_timer_init
,
422 MACHINE_START(MX27_3DS
, "Freescale MX27PDK")
423 /* maintainer: Freescale Semiconductor, Inc. */
424 .boot_params
= MX27_PHYS_OFFSET
+ 0x100,
425 .map_io
= mx27_map_io
,
426 .init_early
= imx27_init_early
,
427 .init_irq
= mx27_init_irq
,
428 .timer
= &mx27pdk_timer
,
429 .init_machine
= mx27pdk_init
,