1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * Author: Fabio Estevam <fabio.estevam@freescale.com>
9 * This machine is known as:
10 * - i.MX27 3-Stack Development System
11 * - i.MX27 Platform Development Kit (i.MX27 PDK)
14 #include <linux/platform_device.h>
15 #include <linux/gpio.h>
16 #include <linux/irq.h>
17 #include <linux/usb/otg.h>
18 #include <linux/usb/ulpi.h>
19 #include <linux/delay.h>
20 #include <linux/mfd/mc13783.h>
21 #include <linux/spi/spi.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/spi/l4f00242t03.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/time.h>
30 #include "3ds_debugboard.h"
32 #include "devices-imx27.h"
35 #include "iomux-mx27.h"
38 #define SD1_EN_GPIO IMX_GPIO_NR(2, 25)
39 #define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23)
40 #define SPI2_SS0 IMX_GPIO_NR(4, 21)
41 #define PMIC_INT IMX_GPIO_NR(3, 14)
42 #define SPI1_SS0 IMX_GPIO_NR(4, 28)
43 #define SD1_CD IMX_GPIO_NR(2, 26)
44 #define LCD_RESET IMX_GPIO_NR(1, 3)
45 #define LCD_ENABLE IMX_GPIO_NR(1, 31)
47 static const int mx27pdk_pins
[] __initconst
= {
79 SD1_EN_GPIO
| GPIO_GPIO
| GPIO_OUT
,
81 OTG_PHY_RESET_GPIO
| GPIO_GPIO
| GPIO_OUT
,
99 SPI1_SS0
| GPIO_GPIO
| GPIO_OUT
,
104 SPI2_SS0
| GPIO_GPIO
| GPIO_OUT
,
109 PMIC_INT
| GPIO_GPIO
| GPIO_IN
,
133 LCD_ENABLE
| GPIO_GPIO
| GPIO_OUT
,
134 LCD_RESET
| GPIO_GPIO
| GPIO_OUT
,
142 static const struct imxuart_platform_data uart_pdata __initconst
= {
143 .flags
= IMXUART_HAVE_RTSCTS
,
150 static const uint32_t mx27_3ds_keymap
[] = {
153 KEY(1, 0, KEY_RIGHT
),
155 KEY(1, 2, KEY_ENTER
),
162 static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst
= {
163 .keymap
= mx27_3ds_keymap
,
164 .keymap_size
= ARRAY_SIZE(mx27_3ds_keymap
),
167 static int mx27_3ds_sdhc1_init(struct device
*dev
, irq_handler_t detect_irq
,
170 return request_irq(gpio_to_irq(SD1_CD
), detect_irq
,
171 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
, "sdhc1-card-detect", data
);
174 static void mx27_3ds_sdhc1_exit(struct device
*dev
, void *data
)
176 free_irq(gpio_to_irq(SD1_CD
), data
);
179 static const struct imxmmc_platform_data sdhc1_pdata __initconst
= {
180 .init
= mx27_3ds_sdhc1_init
,
181 .exit
= mx27_3ds_sdhc1_exit
,
184 static void mx27_3ds_sdhc1_enable_level_translator(void)
186 /* Turn on TXB0108 OE pin */
187 gpio_request(SD1_EN_GPIO
, "sd1_enable");
188 gpio_direction_output(SD1_EN_GPIO
, 1);
192 static int otg_phy_init(void)
194 gpio_request(OTG_PHY_RESET_GPIO
, "usb-otg-reset");
195 gpio_direction_output(OTG_PHY_RESET_GPIO
, 0);
197 gpio_set_value(OTG_PHY_RESET_GPIO
, 1);
201 static int mx27_3ds_otg_init(struct platform_device
*pdev
)
203 return mx27_initialize_usb_hw(pdev
->id
, MXC_EHCI_INTERFACE_DIFF_UNI
);
206 static struct mxc_usbh_platform_data otg_pdata __initdata
= {
207 .init
= mx27_3ds_otg_init
,
208 .portsc
= MXC_EHCI_MODE_ULPI
,
211 static const struct fsl_usb2_platform_data otg_device_pdata __initconst
= {
212 .operating_mode
= FSL_USB2_DR_DEVICE
,
213 .phy_mode
= FSL_USB2_PHY_ULPI
,
216 static bool otg_mode_host __initdata
;
218 static int __init
mx27_3ds_otg_mode(char *options
)
220 if (!strcmp(options
, "host"))
221 otg_mode_host
= true;
222 else if (!strcmp(options
, "device"))
223 otg_mode_host
= false;
225 pr_info("otg_mode neither \"host\" nor \"device\". "
226 "Defaulting to device\n");
229 __setup("otg_mode=", mx27_3ds_otg_mode
);
232 static struct regulator_init_data gpo_init
= {
239 static struct regulator_consumer_supply vmmc1_consumers
[] = {
240 REGULATOR_SUPPLY("vcore", "spi0.0"),
243 static struct regulator_init_data vmmc1_init
= {
248 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
|
249 REGULATOR_CHANGE_STATUS
,
251 .num_consumer_supplies
= ARRAY_SIZE(vmmc1_consumers
),
252 .consumer_supplies
= vmmc1_consumers
,
255 static struct regulator_consumer_supply vgen_consumers
[] = {
256 REGULATOR_SUPPLY("vdd", "spi0.0"),
259 static struct regulator_init_data vgen_init
= {
263 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
265 .num_consumer_supplies
= ARRAY_SIZE(vgen_consumers
),
266 .consumer_supplies
= vgen_consumers
,
269 static struct mc13xxx_regulator_init_data mx27_3ds_regulators
[] = {
271 .id
= MC13783_REG_VMMC1
,
272 .init_data
= &vmmc1_init
,
274 .id
= MC13783_REG_VGEN
,
275 .init_data
= &vgen_init
,
277 .id
= MC13783_REG_GPO1
, /* Turn on 1.8V */
278 .init_data
= &gpo_init
,
280 .id
= MC13783_REG_GPO3
, /* Turn on 3.3V */
281 .init_data
= &gpo_init
,
286 static struct mc13xxx_codec_platform_data mx27_3ds_codec
= {
287 .dac_ssi_port
= MC13783_SSI1_PORT
,
288 .adc_ssi_port
= MC13783_SSI1_PORT
,
291 static struct mc13xxx_platform_data mc13783_pdata
= {
293 .regulators
= mx27_3ds_regulators
,
294 .num_regulators
= ARRAY_SIZE(mx27_3ds_regulators
),
297 .flags
= MC13XXX_USE_TOUCHSCREEN
| MC13XXX_USE_RTC
|
299 .codec
= &mx27_3ds_codec
,
302 static struct imx_ssi_platform_data mx27_3ds_ssi_pdata
= {
303 .flags
= IMX_SSI_DMA
| IMX_SSI_NET
,
307 static int spi1_chipselect
[] = {SPI1_SS0
};
309 static const struct spi_imx_master spi1_pdata __initconst
= {
310 .chipselect
= spi1_chipselect
,
311 .num_chipselect
= ARRAY_SIZE(spi1_chipselect
),
314 static int spi2_chipselect
[] = {SPI2_SS0
};
316 static const struct spi_imx_master spi2_pdata __initconst
= {
317 .chipselect
= spi2_chipselect
,
318 .num_chipselect
= ARRAY_SIZE(spi2_chipselect
),
321 static struct imx_fb_videomode mx27_3ds_modes
[] = {
322 { /* 480x640 @ 60 Hz */
335 .sync
= FB_SYNC_OE_ACT_HIGH
|
337 .vmode
= FB_VMODE_NONINTERLACED
,
345 static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst
= {
346 .mode
= mx27_3ds_modes
,
347 .num_modes
= ARRAY_SIZE(mx27_3ds_modes
),
354 static struct l4f00242t03_pdata mx27_3ds_lcd_pdata
= {
355 .reset_gpio
= LCD_RESET
,
356 .data_enable_gpio
= LCD_ENABLE
,
359 static struct spi_board_info mx27_3ds_spi_devs
[] __initdata
= {
361 .modalias
= "mc13783",
362 .max_speed_hz
= 1000000,
364 .chip_select
= 0, /* SS0 */
365 .platform_data
= &mc13783_pdata
,
366 /* irq number is run-time assigned */
369 .modalias
= "l4f00242t03",
370 .max_speed_hz
= 5000000,
372 .chip_select
= 0, /* SS0 */
373 .platform_data
= &mx27_3ds_lcd_pdata
,
377 static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst
= {
381 static void __init
mx27pdk_init(void)
385 mxc_gpio_setup_multiple_pins(mx27pdk_pins
, ARRAY_SIZE(mx27pdk_pins
),
387 imx27_add_imx_uart0(&uart_pdata
);
389 imx27_add_imx_keypad(&mx27_3ds_keymap_data
);
390 imx27_add_imx2_wdt();
392 imx27_add_spi_imx1(&spi2_pdata
);
393 imx27_add_spi_imx0(&spi1_pdata
);
395 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data
);
396 imx27_add_imx_fb(&mx27_3ds_fb_data
);
398 imx27_add_imx_ssi(0, &mx27_3ds_ssi_pdata
);
401 static void __init
mx27pdk_late_init(void)
403 mx27_3ds_sdhc1_enable_level_translator();
404 imx27_add_mxc_mmc(0, &sdhc1_pdata
);
409 otg_pdata
.otg
= imx_otg_ulpi_create(ULPI_OTG_DRVVBUS
|
410 ULPI_OTG_DRVVBUS_EXT
);
413 imx27_add_mxc_ehci_otg(&otg_pdata
);
417 imx27_add_fsl_usb2_udc(&otg_device_pdata
);
419 mx27_3ds_spi_devs
[0].irq
= gpio_to_irq(PMIC_INT
);
420 spi_register_board_info(mx27_3ds_spi_devs
,
421 ARRAY_SIZE(mx27_3ds_spi_devs
));
423 if (mxc_expio_init(MX27_CS5_BASE_ADDR
, IMX_GPIO_NR(3, 28)))
424 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
427 imx_add_platform_device("imx_mc13783", 0, NULL
, 0, NULL
, 0);
430 static void __init
mx27pdk_timer_init(void)
432 mx27_clocks_init(26000000);
435 MACHINE_START(MX27_3DS
, "Freescale MX27PDK")
436 /* maintainer: Freescale Semiconductor, Inc. */
437 .atag_offset
= 0x100,
438 .map_io
= mx27_map_io
,
439 .init_early
= imx27_init_early
,
440 .init_irq
= mx27_init_irq
,
441 .init_time
= mx27pdk_timer_init
,
442 .init_machine
= mx27pdk_init
,
443 .init_late
= mx27pdk_late_init
,
444 .restart
= mxc_restart
,