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>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/time.h>
36 #include <mach/hardware.h>
37 #include <mach/common.h>
38 #include <mach/iomux-mx27.h>
39 #include <mach/ulpi.h>
40 #include <mach/irqs.h>
41 #include <mach/3ds_debugboard.h>
43 #include "devices-imx27.h"
45 #define SD1_EN_GPIO (GPIO_PORTB + 25)
46 #define OTG_PHY_RESET_GPIO (GPIO_PORTB + 23)
47 #define SPI2_SS0 (GPIO_PORTD + 21)
48 #define EXPIO_PARENT_INT (MXC_INTERNAL_IRQS + GPIO_PORTC + 28)
50 static const int mx27pdk_pins[] __initconst = {
82 SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT,
84 OTG_PHY_RESET_GPIO | GPIO_GPIO | GPIO_OUT,
103 static const struct imxuart_platform_data uart_pdata __initconst = {
104 .flags = IMXUART_HAVE_RTSCTS,
111 static const uint32_t mx27_3ds_keymap[] = {
114 KEY(1, 0, KEY_RIGHT),
116 KEY(1, 2, KEY_ENTER),
123 static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst = {
124 .keymap = mx27_3ds_keymap,
125 .keymap_size = ARRAY_SIZE(mx27_3ds_keymap),
128 static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
131 return request_irq(IRQ_GPIOB(26), detect_irq, IRQF_TRIGGER_FALLING |
132 IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
135 static void mx27_3ds_sdhc1_exit(struct device *dev, void *data)
137 free_irq(IRQ_GPIOB(26), data);
140 static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
141 .init = mx27_3ds_sdhc1_init,
142 .exit = mx27_3ds_sdhc1_exit,
145 static void mx27_3ds_sdhc1_enable_level_translator(void)
147 /* Turn on TXB0108 OE pin */
148 gpio_request(SD1_EN_GPIO, "sd1_enable");
149 gpio_direction_output(SD1_EN_GPIO, 1);
153 static int otg_phy_init(void)
155 gpio_request(OTG_PHY_RESET_GPIO, "usb-otg-reset");
156 gpio_direction_output(OTG_PHY_RESET_GPIO, 0);
158 gpio_set_value(OTG_PHY_RESET_GPIO, 1);
162 #if defined(CONFIG_USB_ULPI)
163 static int mx27_3ds_otg_init(struct platform_device *pdev)
165 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
168 static struct mxc_usbh_platform_data otg_pdata __initdata = {
169 .init = mx27_3ds_otg_init,
170 .portsc = MXC_EHCI_MODE_ULPI,
174 static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
175 .operating_mode = FSL_USB2_DR_DEVICE,
176 .phy_mode = FSL_USB2_PHY_ULPI,
179 static int otg_mode_host;
181 static int __init mx27_3ds_otg_mode(char *options)
183 if (!strcmp(options, "host"))
185 else if (!strcmp(options, "device"))
188 pr_info("otg_mode neither \"host\" nor \"device\". "
189 "Defaulting to device\n");
192 __setup("otg_mode=", mx27_3ds_otg_mode);
195 static struct regulator_consumer_supply vmmc1_consumers[] = {
196 REGULATOR_SUPPLY("lcd_2v8", NULL),
199 static struct regulator_init_data vmmc1_init = {
203 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
205 .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers),
206 .consumer_supplies = vmmc1_consumers,
209 static struct regulator_consumer_supply vgen_consumers[] = {
210 REGULATOR_SUPPLY("vdd_lcdio", NULL),
213 static struct regulator_init_data vgen_init = {
217 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
219 .num_consumer_supplies = ARRAY_SIZE(vgen_consumers),
220 .consumer_supplies = vgen_consumers,
223 static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
225 .id = MC13783_REG_VMMC1,
226 .init_data = &vmmc1_init,
228 .id = MC13783_REG_VGEN,
229 .init_data = &vgen_init,
234 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
235 .regulators = mx27_3ds_regulators,
236 .num_regulators = ARRAY_SIZE(mx27_3ds_regulators),
237 .flags = MC13XXX_USE_REGULATOR,
241 static int spi2_internal_chipselect[] = {SPI2_SS0};
243 static const struct spi_imx_master spi2_pdata __initconst = {
244 .chipselect = spi2_internal_chipselect,
245 .num_chipselect = ARRAY_SIZE(spi2_internal_chipselect),
248 static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
250 .modalias = "mc13783",
251 .max_speed_hz = 1000000,
253 .chip_select = 0, /* SS0 */
254 .platform_data = &mc13783_pdata,
255 .irq = IRQ_GPIOC(14),
261 static void __init mx27pdk_init(void)
263 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
265 mx27_3ds_sdhc1_enable_level_translator();
266 imx27_add_imx_uart0(&uart_pdata);
268 imx27_add_imx_keypad(&mx27_3ds_keymap_data);
269 imx27_add_mxc_mmc(0, &sdhc1_pdata);
270 imx27_add_imx2_wdt(NULL);
272 #if defined(CONFIG_USB_ULPI)
274 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
275 ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
277 imx27_add_mxc_ehci_otg(&otg_pdata);
281 imx27_add_fsl_usb2_udc(&otg_device_pdata);
283 imx27_add_spi_imx1(&spi2_pdata);
284 spi_register_board_info(mx27_3ds_spi_devs,
285 ARRAY_SIZE(mx27_3ds_spi_devs));
287 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT))
288 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
291 static void __init mx27pdk_timer_init(void)
293 mx27_clocks_init(26000000);
296 static struct sys_timer mx27pdk_timer = {
297 .init = mx27pdk_timer_init,
300 MACHINE_START(MX27_3DS, "Freescale MX27PDK")
301 /* maintainer: Freescale Semiconductor, Inc. */
302 .boot_params = MX27_PHYS_OFFSET + 0x100,
303 .map_io = mx27_map_io,
304 .init_early = imx27_init_early,
305 .init_irq = mx27_init_irq,
306 .timer = &mx27pdk_timer,
307 .init_machine = mx27pdk_init,