blob: 9ef4640f3660663dd5fb5eb0f61a38b02e715f8d [file] [log] [blame]
Fabio Estevamec9be0d2009-04-16 12:45:01 -07001/*
2 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * Author: Fabio Estevam <fabio.estevam@freescale.com>
5 *
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.
10 *
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.
Fabio Estevamec9be0d2009-04-16 12:45:01 -070015 */
16
Uwe Kleine-König8fdca372010-03-08 10:46:11 +010017/*
18 * This machine is known as:
19 * - i.MX27 3-Stack Development System
20 * - i.MX27 Platform Development Kit (i.MX27 PDK)
21 */
22
Fabio Estevamec9be0d2009-04-16 12:45:01 -070023#include <linux/platform_device.h>
24#include <linux/gpio.h>
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -020025#include <linux/irq.h>
Fabio Estevam96cf4232010-12-22 12:25:31 -020026#include <linux/usb/otg.h>
27#include <linux/usb/ulpi.h>
28#include <linux/delay.h>
Fabio Estevamc67a3e02011-01-03 11:16:39 -020029#include <linux/mfd/mc13783.h>
30#include <linux/spi/spi.h>
31#include <linux/regulator/machine.h>
Fabio Estevam1abcb4c2011-06-22 09:25:25 -030032#include <linux/spi/l4f00242t03.h>
Fabio Estevam96cf4232010-12-22 12:25:31 -020033
Fabio Estevam4c11c282012-02-15 19:36:10 -020034#include <media/soc_camera.h>
35
Fabio Estevamec9be0d2009-04-16 12:45:01 -070036#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38#include <asm/mach/time.h>
Fabio Estevamec9be0d2009-04-16 12:45:01 -070039
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080040#include "3ds_debugboard.h"
Shawn Guoe3372472012-09-13 21:01:00 +080041#include "common.h"
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +020042#include "devices-imx27.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080043#include "ehci.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080044#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080045#include "iomux-mx27.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080046#include "ulpi.h"
Fabio Estevamec9be0d2009-04-16 12:45:01 -070047
Fabio Estevam98618cf2011-06-22 09:25:23 -030048#define SD1_EN_GPIO IMX_GPIO_NR(2, 25)
49#define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23)
50#define SPI2_SS0 IMX_GPIO_NR(4, 21)
Fabio Estevamaec250d2011-06-22 09:25:24 -030051#define PMIC_INT IMX_GPIO_NR(3, 14)
Fabio Estevam1abcb4c2011-06-22 09:25:25 -030052#define SPI1_SS0 IMX_GPIO_NR(4, 28)
Fabio Estevamc084473d2011-06-22 09:25:27 -030053#define SD1_CD IMX_GPIO_NR(2, 26)
Fabio Estevam1abcb4c2011-06-22 09:25:25 -030054#define LCD_RESET IMX_GPIO_NR(1, 3)
55#define LCD_ENABLE IMX_GPIO_NR(1, 31)
Fabio Estevam4c11c282012-02-15 19:36:10 -020056#define CSI_PWRDWN IMX_GPIO_NR(4, 19)
57#define CSI_RESET IMX_GPIO_NR(3, 6)
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -020058
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020059static const int mx27pdk_pins[] __initconst = {
Fabio Estevamec9be0d2009-04-16 12:45:01 -070060 /* UART1 */
61 PE12_PF_UART1_TXD,
62 PE13_PF_UART1_RXD,
63 PE14_PF_UART1_CTS,
64 PE15_PF_UART1_RTS,
65 /* FEC */
66 PD0_AIN_FEC_TXD0,
67 PD1_AIN_FEC_TXD1,
68 PD2_AIN_FEC_TXD2,
69 PD3_AIN_FEC_TXD3,
70 PD4_AOUT_FEC_RX_ER,
71 PD5_AOUT_FEC_RXD1,
72 PD6_AOUT_FEC_RXD2,
73 PD7_AOUT_FEC_RXD3,
74 PD8_AF_FEC_MDIO,
75 PD9_AIN_FEC_MDC,
76 PD10_AOUT_FEC_CRS,
77 PD11_AOUT_FEC_TX_CLK,
78 PD12_AOUT_FEC_RXD0,
79 PD13_AOUT_FEC_RX_DV,
80 PD14_AOUT_FEC_RX_CLK,
81 PD15_AOUT_FEC_COL,
82 PD16_AIN_FEC_TX_ER,
83 PF23_AIN_FEC_TX_EN,
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -020084 /* SDHC1 */
85 PE18_PF_SD1_D0,
86 PE19_PF_SD1_D1,
87 PE20_PF_SD1_D2,
88 PE21_PF_SD1_D3,
89 PE22_PF_SD1_CMD,
90 PE23_PF_SD1_CLK,
91 SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT,
Fabio Estevam96cf4232010-12-22 12:25:31 -020092 /* OTG */
93 OTG_PHY_RESET_GPIO | GPIO_GPIO | GPIO_OUT,
94 PC7_PF_USBOTG_DATA5,
95 PC8_PF_USBOTG_DATA6,
96 PC9_PF_USBOTG_DATA0,
97 PC10_PF_USBOTG_DATA2,
98 PC11_PF_USBOTG_DATA1,
99 PC12_PF_USBOTG_DATA4,
100 PC13_PF_USBOTG_DATA3,
101 PE0_PF_USBOTG_NXT,
102 PE1_PF_USBOTG_STP,
103 PE2_PF_USBOTG_DIR,
104 PE24_PF_USBOTG_CLK,
105 PE25_PF_USBOTG_DATA7,
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300106 /* CSPI1 */
107 PD31_PF_CSPI1_MOSI,
108 PD30_PF_CSPI1_MISO,
109 PD29_PF_CSPI1_SCLK,
110 PD25_PF_CSPI1_RDY,
111 SPI1_SS0 | GPIO_GPIO | GPIO_OUT,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200112 /* CSPI2 */
113 PD22_PF_CSPI2_SCLK,
114 PD23_PF_CSPI2_MISO,
115 PD24_PF_CSPI2_MOSI,
Fabio Estevamaec250d2011-06-22 09:25:24 -0300116 SPI2_SS0 | GPIO_GPIO | GPIO_OUT,
Fabio Estevam5885f032011-03-01 16:59:46 -0300117 /* I2C1 */
118 PD17_PF_I2C_DATA,
119 PD18_PF_I2C_CLK,
Fabio Estevamaec250d2011-06-22 09:25:24 -0300120 /* PMIC INT */
121 PMIC_INT | GPIO_GPIO | GPIO_IN,
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300122 /* LCD */
123 PA5_PF_LSCLK,
124 PA6_PF_LD0,
125 PA7_PF_LD1,
126 PA8_PF_LD2,
127 PA9_PF_LD3,
128 PA10_PF_LD4,
129 PA11_PF_LD5,
130 PA12_PF_LD6,
131 PA13_PF_LD7,
132 PA14_PF_LD8,
133 PA15_PF_LD9,
134 PA16_PF_LD10,
135 PA17_PF_LD11,
136 PA18_PF_LD12,
137 PA19_PF_LD13,
138 PA20_PF_LD14,
139 PA21_PF_LD15,
140 PA22_PF_LD16,
141 PA23_PF_LD17,
142 PA28_PF_HSYNC,
143 PA29_PF_VSYNC,
144 PA30_PF_CONTRAST,
145 LCD_ENABLE | GPIO_GPIO | GPIO_OUT,
146 LCD_RESET | GPIO_GPIO | GPIO_OUT,
Fabio Estevam4c11c282012-02-15 19:36:10 -0200147 /* CSI */
148 PB10_PF_CSI_D0,
149 PB11_PF_CSI_D1,
150 PB12_PF_CSI_D2,
151 PB13_PF_CSI_D3,
152 PB14_PF_CSI_D4,
153 PB15_PF_CSI_MCLK,
154 PB16_PF_CSI_PIXCLK,
155 PB17_PF_CSI_D5,
156 PB18_PF_CSI_D6,
157 PB19_PF_CSI_D7,
158 PB20_PF_CSI_VSYNC,
159 PB21_PF_CSI_HSYNC,
160 CSI_PWRDWN | GPIO_GPIO | GPIO_OUT,
161 CSI_RESET | GPIO_GPIO | GPIO_OUT,
Fabio Estevam688b5cb2012-07-03 15:44:57 -0300162 /* SSI4 */
163 PC16_PF_SSI4_FS,
164 PC17_PF_SSI4_RXD,
165 PC18_PF_SSI4_TXD,
166 PC19_PF_SSI4_CLK,
Fabio Estevam4c11c282012-02-15 19:36:10 -0200167};
168
169static struct gpio mx27_3ds_camera_gpios[] = {
170 { CSI_PWRDWN, GPIOF_OUT_INIT_HIGH, "camera-power" },
171 { CSI_RESET, GPIOF_OUT_INIT_HIGH, "camera-reset" },
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700172};
173
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200174static const struct imxuart_platform_data uart_pdata __initconst = {
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700175 .flags = IMXUART_HAVE_RTSCTS,
176};
177
Rogerio Pimentel3fac6cf2010-06-25 10:31:33 -0300178/*
179 * Matrix keyboard
180 */
181
182static const uint32_t mx27_3ds_keymap[] = {
183 KEY(0, 0, KEY_UP),
184 KEY(0, 1, KEY_DOWN),
185 KEY(1, 0, KEY_RIGHT),
186 KEY(1, 1, KEY_LEFT),
187 KEY(1, 2, KEY_ENTER),
188 KEY(2, 0, KEY_F6),
189 KEY(2, 1, KEY_F8),
190 KEY(2, 2, KEY_F9),
191 KEY(2, 3, KEY_F10),
192};
193
Uwe Kleine-König3f880142010-11-10 09:58:56 +0100194static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst = {
Rogerio Pimentel3fac6cf2010-06-25 10:31:33 -0300195 .keymap = mx27_3ds_keymap,
196 .keymap_size = ARRAY_SIZE(mx27_3ds_keymap),
197};
198
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -0200199static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
200 void *data)
201{
Fabio Estevamc084473d2011-06-22 09:25:27 -0300202 return request_irq(gpio_to_irq(SD1_CD), detect_irq,
203 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -0200204}
205
206static void mx27_3ds_sdhc1_exit(struct device *dev, void *data)
207{
Fabio Estevamc084473d2011-06-22 09:25:27 -0300208 free_irq(gpio_to_irq(SD1_CD), data);
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -0200209}
210
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100211static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -0200212 .init = mx27_3ds_sdhc1_init,
213 .exit = mx27_3ds_sdhc1_exit,
214};
215
216static void mx27_3ds_sdhc1_enable_level_translator(void)
217{
218 /* Turn on TXB0108 OE pin */
219 gpio_request(SD1_EN_GPIO, "sd1_enable");
220 gpio_direction_output(SD1_EN_GPIO, 1);
221}
222
Fabio Estevam96cf4232010-12-22 12:25:31 -0200223
224static int otg_phy_init(void)
225{
226 gpio_request(OTG_PHY_RESET_GPIO, "usb-otg-reset");
227 gpio_direction_output(OTG_PHY_RESET_GPIO, 0);
228 mdelay(1);
229 gpio_set_value(OTG_PHY_RESET_GPIO, 1);
230 return 0;
231}
232
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100233static int mx27_3ds_otg_init(struct platform_device *pdev)
234{
235 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
236}
Fabio Estevam96cf4232010-12-22 12:25:31 -0200237
238static struct mxc_usbh_platform_data otg_pdata __initdata = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100239 .init = mx27_3ds_otg_init,
Fabio Estevam96cf4232010-12-22 12:25:31 -0200240 .portsc = MXC_EHCI_MODE_ULPI,
Fabio Estevam96cf4232010-12-22 12:25:31 -0200241};
Fabio Estevam96cf4232010-12-22 12:25:31 -0200242
243static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
244 .operating_mode = FSL_USB2_DR_DEVICE,
245 .phy_mode = FSL_USB2_PHY_ULPI,
246};
247
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200248static bool otg_mode_host __initdata;
Fabio Estevam96cf4232010-12-22 12:25:31 -0200249
250static int __init mx27_3ds_otg_mode(char *options)
251{
252 if (!strcmp(options, "host"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200253 otg_mode_host = true;
Fabio Estevam96cf4232010-12-22 12:25:31 -0200254 else if (!strcmp(options, "device"))
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200255 otg_mode_host = false;
Fabio Estevam96cf4232010-12-22 12:25:31 -0200256 else
257 pr_info("otg_mode neither \"host\" nor \"device\". "
258 "Defaulting to device\n");
Benoît Thébaudeau33a264d2012-06-12 19:46:43 +0200259 return 1;
Fabio Estevam96cf4232010-12-22 12:25:31 -0200260}
261__setup("otg_mode=", mx27_3ds_otg_mode);
262
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200263/* Regulators */
Fabio Estevamaec250d2011-06-22 09:25:24 -0300264static struct regulator_init_data gpo_init = {
265 .constraints = {
266 .boot_on = 1,
267 .always_on = 1,
268 }
269};
270
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200271static struct regulator_consumer_supply vmmc1_consumers[] = {
Mark Brown0556dc32011-10-31 17:11:48 -0700272 REGULATOR_SUPPLY("vcore", "spi0.0"),
Fabio Estevam4c11c282012-02-15 19:36:10 -0200273 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200274};
275
276static struct regulator_init_data vmmc1_init = {
277 .constraints = {
278 .min_uV = 2800000,
279 .max_uV = 2800000,
Fabio Estevamaec250d2011-06-22 09:25:24 -0300280 .apply_uV = 1,
281 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
282 REGULATOR_CHANGE_STATUS,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200283 },
284 .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers),
285 .consumer_supplies = vmmc1_consumers,
286};
287
288static struct regulator_consumer_supply vgen_consumers[] = {
Mark Brown0556dc32011-10-31 17:11:48 -0700289 REGULATOR_SUPPLY("vdd", "spi0.0"),
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200290};
291
292static struct regulator_init_data vgen_init = {
293 .constraints = {
294 .min_uV = 1800000,
295 .max_uV = 1800000,
296 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
297 },
298 .num_consumer_supplies = ARRAY_SIZE(vgen_consumers),
299 .consumer_supplies = vgen_consumers,
300};
301
Fabio Estevam4c11c282012-02-15 19:36:10 -0200302static struct regulator_consumer_supply vvib_consumers[] = {
303 REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),
304};
305
306static struct regulator_init_data vvib_init = {
307 .constraints = {
308 .min_uV = 1300000,
309 .max_uV = 1300000,
310 .apply_uV = 1,
311 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
312 REGULATOR_CHANGE_STATUS,
313 },
314 .num_consumer_supplies = ARRAY_SIZE(vvib_consumers),
315 .consumer_supplies = vvib_consumers,
316};
317
David Jander58363722011-02-10 10:59:44 +0100318static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200319 {
Sascha Hauer074cee92011-01-07 17:07:22 +0100320 .id = MC13783_REG_VMMC1,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200321 .init_data = &vmmc1_init,
322 }, {
Sascha Hauer074cee92011-01-07 17:07:22 +0100323 .id = MC13783_REG_VGEN,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200324 .init_data = &vgen_init,
Fabio Estevamaec250d2011-06-22 09:25:24 -0300325 }, {
326 .id = MC13783_REG_GPO1, /* Turn on 1.8V */
327 .init_data = &gpo_init,
328 }, {
329 .id = MC13783_REG_GPO3, /* Turn on 3.3V */
330 .init_data = &gpo_init,
Fabio Estevam4c11c282012-02-15 19:36:10 -0200331 }, {
332 .id = MC13783_REG_VVIB, /* Power OV2640 */
333 .init_data = &vvib_init,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200334 },
335};
336
337/* MC13783 */
Fabio Estevam688b5cb2012-07-03 15:44:57 -0300338static struct mc13xxx_codec_platform_data mx27_3ds_codec = {
339 .dac_ssi_port = MC13783_SSI1_PORT,
340 .adc_ssi_port = MC13783_SSI1_PORT,
341};
342
Andres Salomon4ec1b542011-02-17 19:07:23 -0800343static struct mc13xxx_platform_data mc13783_pdata = {
344 .regulators = {
345 .regulators = mx27_3ds_regulators,
346 .num_regulators = ARRAY_SIZE(mx27_3ds_regulators),
347
348 },
Fabio Estevam688b5cb2012-07-03 15:44:57 -0300349 .flags = MC13XXX_USE_TOUCHSCREEN | MC13XXX_USE_RTC |
350 MC13XXX_USE_CODEC,
351 .codec = &mx27_3ds_codec,
352};
353
354static struct imx_ssi_platform_data mx27_3ds_ssi_pdata = {
355 .flags = IMX_SSI_DMA | IMX_SSI_NET,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200356};
357
358/* SPI */
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300359static int spi1_chipselect[] = {SPI1_SS0};
360
361static const struct spi_imx_master spi1_pdata __initconst = {
362 .chipselect = spi1_chipselect,
363 .num_chipselect = ARRAY_SIZE(spi1_chipselect),
364};
365
Fabio Estevam6d2385a2011-06-22 09:25:28 -0300366static int spi2_chipselect[] = {SPI2_SS0};
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200367
368static const struct spi_imx_master spi2_pdata __initconst = {
Fabio Estevam6d2385a2011-06-22 09:25:28 -0300369 .chipselect = spi2_chipselect,
370 .num_chipselect = ARRAY_SIZE(spi2_chipselect),
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200371};
372
Fabio Estevam4c11c282012-02-15 19:36:10 -0200373static int mx27_3ds_camera_power(struct device *dev, int on)
374{
375 /* enable or disable the camera */
376 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
377 gpio_set_value(CSI_PWRDWN, on ? 0 : 1);
378
379 if (!on)
380 goto out;
381
382 /* If enabled, give a reset impulse */
383 gpio_set_value(CSI_RESET, 0);
384 msleep(20);
385 gpio_set_value(CSI_RESET, 1);
386 msleep(100);
387
388out:
389 return 0;
390}
391
392static struct i2c_board_info mx27_3ds_i2c_camera = {
393 I2C_BOARD_INFO("ov2640", 0x30),
394};
395
396static struct regulator_bulk_data mx27_3ds_camera_regs[] = {
397 { .supply = "cmos_vcore" },
398 { .supply = "cmos_2v8" },
399};
400
401static struct soc_camera_link iclink_ov2640 = {
402 .bus_id = 0,
403 .board_info = &mx27_3ds_i2c_camera,
404 .i2c_adapter_id = 0,
405 .power = mx27_3ds_camera_power,
406 .regulators = mx27_3ds_camera_regs,
407 .num_regulators = ARRAY_SIZE(mx27_3ds_camera_regs),
408};
409
410static struct platform_device mx27_3ds_ov2640 = {
411 .name = "soc-camera-pdrv",
412 .id = 0,
413 .dev = {
414 .platform_data = &iclink_ov2640,
415 },
416};
417
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300418static struct imx_fb_videomode mx27_3ds_modes[] = {
419 { /* 480x640 @ 60 Hz */
420 .mode = {
421 .name = "Epson-VGA",
422 .refresh = 60,
423 .xres = 480,
424 .yres = 640,
425 .pixclock = 41701,
426 .left_margin = 20,
427 .right_margin = 41,
428 .upper_margin = 10,
429 .lower_margin = 5,
430 .hsync_len = 20,
431 .vsync_len = 10,
432 .sync = FB_SYNC_OE_ACT_HIGH |
433 FB_SYNC_CLK_INVERT,
434 .vmode = FB_VMODE_NONINTERLACED,
435 .flag = 0,
436 },
437 .bpp = 16,
438 .pcr = 0xFAC08B82,
439 },
440};
441
442static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = {
443 .mode = mx27_3ds_modes,
444 .num_modes = ARRAY_SIZE(mx27_3ds_modes),
445 .pwmr = 0x00A903FF,
446 .lscr1 = 0x00120300,
447 .dmacr = 0x00020010,
448};
449
450/* LCD */
451static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = {
452 .reset_gpio = LCD_RESET,
453 .data_enable_gpio = LCD_ENABLE,
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300454};
455
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200456static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
457 {
458 .modalias = "mc13783",
459 .max_speed_hz = 1000000,
460 .bus_num = 1,
461 .chip_select = 0, /* SS0 */
462 .platform_data = &mc13783_pdata,
Shawn Guo84715dd2011-12-02 15:31:11 +0800463 /* irq number is run-time assigned */
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200464 .mode = SPI_CS_HIGH,
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300465 }, {
466 .modalias = "l4f00242t03",
467 .max_speed_hz = 5000000,
468 .bus_num = 0,
469 .chip_select = 0, /* SS0 */
470 .platform_data = &mx27_3ds_lcd_pdata,
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200471 },
472};
473
Fabio Estevam4c11c282012-02-15 19:36:10 -0200474static struct platform_device *devices[] __initdata = {
475 &mx27_3ds_ov2640,
476};
477
478static const struct mx2_camera_platform_data mx27_3ds_cam_pdata __initconst = {
479 .clk = 26000000,
480};
481
Fabio Estevam5885f032011-03-01 16:59:46 -0300482static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = {
483 .bitrate = 100000,
484};
Fabio Estevam96cf4232010-12-22 12:25:31 -0200485
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700486static void __init mx27pdk_init(void)
487{
Fabio Estevam4c11c282012-02-15 19:36:10 -0200488 int ret;
Shawn Guob78d8e52011-06-06 00:07:55 +0800489 imx27_soc_init();
490
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700491 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
492 "mx27pdk");
Rogerio Pimentelb5ec73e2010-10-22 11:03:54 -0200493 mx27_3ds_sdhc1_enable_level_translator();
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200494 imx27_add_imx_uart0(&uart_pdata);
Uwe Kleine-König6bd96f32010-10-06 12:00:18 +0200495 imx27_add_fec(NULL);
Uwe Kleine-König3f880142010-11-10 09:58:56 +0100496 imx27_add_imx_keypad(&mx27_3ds_keymap_data);
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100497 imx27_add_mxc_mmc(0, &sdhc1_pdata);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200498 imx27_add_imx2_wdt();
Fabio Estevam96cf4232010-12-22 12:25:31 -0200499 otg_phy_init();
Fabio Estevam96cf4232010-12-22 12:25:31 -0200500
Sascha Hauer48f6b092011-03-02 09:27:42 +0100501 if (otg_mode_host) {
502 otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
503 ULPI_OTG_DRVVBUS_EXT);
504
505 if (otg_pdata.otg)
506 imx27_add_mxc_ehci_otg(&otg_pdata);
Fabio Estevam96cf4232010-12-22 12:25:31 -0200507 }
Sascha Hauer48f6b092011-03-02 09:27:42 +0100508
Fabio Estevam96cf4232010-12-22 12:25:31 -0200509 if (!otg_mode_host)
510 imx27_add_fsl_usb2_udc(&otg_device_pdata);
511
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200512 imx27_add_spi_imx1(&spi2_pdata);
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300513 imx27_add_spi_imx0(&spi1_pdata);
Shawn Guo84715dd2011-12-02 15:31:11 +0800514 mx27_3ds_spi_devs[0].irq = gpio_to_irq(PMIC_INT);
Fabio Estevamc67a3e02011-01-03 11:16:39 -0200515 spi_register_board_info(mx27_3ds_spi_devs,
516 ARRAY_SIZE(mx27_3ds_spi_devs));
Fabio Estevam92cb33f2011-01-10 18:17:37 -0200517
Shawn Guoed4a7fb2012-06-13 15:58:08 +0800518 if (mxc_expio_init(MX27_CS5_BASE_ADDR, IMX_GPIO_NR(3, 28)))
Fabio Estevam92cb33f2011-01-10 18:17:37 -0200519 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
Fabio Estevam5885f032011-03-01 16:59:46 -0300520 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
Fabio Estevam4c11c282012-02-15 19:36:10 -0200521 platform_add_devices(devices, ARRAY_SIZE(devices));
Fabio Estevam1abcb4c2011-06-22 09:25:25 -0300522 imx27_add_imx_fb(&mx27_3ds_fb_data);
Fabio Estevam4c11c282012-02-15 19:36:10 -0200523
524 ret = gpio_request_array(mx27_3ds_camera_gpios,
525 ARRAY_SIZE(mx27_3ds_camera_gpios));
526 if (ret) {
527 pr_err("Failed to request camera gpios");
528 iclink_ov2640.power = NULL;
529 }
530
531 imx27_add_mx2_camera(&mx27_3ds_cam_pdata);
Fabio Estevam688b5cb2012-07-03 15:44:57 -0300532 imx27_add_imx_ssi(0, &mx27_3ds_ssi_pdata);
533
534 imx_add_platform_device("imx_mc13783", 0, NULL, 0, NULL, 0);
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700535}
536
537static void __init mx27pdk_timer_init(void)
538{
539 mx27_clocks_init(26000000);
540}
541
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700542MACHINE_START(MX27_3DS, "Freescale MX27PDK")
543 /* maintainer: Freescale Semiconductor, Inc. */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400544 .atag_offset = 0x100,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100545 .map_io = mx27_map_io,
546 .init_early = imx27_init_early,
547 .init_irq = mx27_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700548 .init_time = mx27pdk_timer_init,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100549 .init_machine = mx27pdk_init,
Russell King65ea7882011-11-06 17:12:08 +0000550 .restart = mxc_restart,
Fabio Estevamec9be0d2009-04-16 12:45:01 -0700551MACHINE_END