ARM: OMAP: Remove smp.h
[linux-2.6.git] / arch / arm / mach-imx / mach-mx27_3ds.c
blob58c24c1a7ab70ac26e47db241e882800a2cf9cc5
1 /*
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 <media/soc_camera.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/time.h>
39 #include <mach/hardware.h>
40 #include <mach/common.h>
41 #include <mach/iomux-mx27.h>
42 #include <mach/ulpi.h>
43 #include <mach/3ds_debugboard.h>
45 #include "devices-imx27.h"
47 #define SD1_EN_GPIO IMX_GPIO_NR(2, 25)
48 #define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23)
49 #define SPI2_SS0 IMX_GPIO_NR(4, 21)
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)
55 #define CSI_PWRDWN IMX_GPIO_NR(4, 19)
56 #define CSI_RESET IMX_GPIO_NR(3, 6)
58 static const int mx27pdk_pins[] __initconst = {
59 /* UART1 */
60 PE12_PF_UART1_TXD,
61 PE13_PF_UART1_RXD,
62 PE14_PF_UART1_CTS,
63 PE15_PF_UART1_RTS,
64 /* FEC */
65 PD0_AIN_FEC_TXD0,
66 PD1_AIN_FEC_TXD1,
67 PD2_AIN_FEC_TXD2,
68 PD3_AIN_FEC_TXD3,
69 PD4_AOUT_FEC_RX_ER,
70 PD5_AOUT_FEC_RXD1,
71 PD6_AOUT_FEC_RXD2,
72 PD7_AOUT_FEC_RXD3,
73 PD8_AF_FEC_MDIO,
74 PD9_AIN_FEC_MDC,
75 PD10_AOUT_FEC_CRS,
76 PD11_AOUT_FEC_TX_CLK,
77 PD12_AOUT_FEC_RXD0,
78 PD13_AOUT_FEC_RX_DV,
79 PD14_AOUT_FEC_RX_CLK,
80 PD15_AOUT_FEC_COL,
81 PD16_AIN_FEC_TX_ER,
82 PF23_AIN_FEC_TX_EN,
83 /* SDHC1 */
84 PE18_PF_SD1_D0,
85 PE19_PF_SD1_D1,
86 PE20_PF_SD1_D2,
87 PE21_PF_SD1_D3,
88 PE22_PF_SD1_CMD,
89 PE23_PF_SD1_CLK,
90 SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT,
91 /* OTG */
92 OTG_PHY_RESET_GPIO | GPIO_GPIO | GPIO_OUT,
93 PC7_PF_USBOTG_DATA5,
94 PC8_PF_USBOTG_DATA6,
95 PC9_PF_USBOTG_DATA0,
96 PC10_PF_USBOTG_DATA2,
97 PC11_PF_USBOTG_DATA1,
98 PC12_PF_USBOTG_DATA4,
99 PC13_PF_USBOTG_DATA3,
100 PE0_PF_USBOTG_NXT,
101 PE1_PF_USBOTG_STP,
102 PE2_PF_USBOTG_DIR,
103 PE24_PF_USBOTG_CLK,
104 PE25_PF_USBOTG_DATA7,
105 /* CSPI1 */
106 PD31_PF_CSPI1_MOSI,
107 PD30_PF_CSPI1_MISO,
108 PD29_PF_CSPI1_SCLK,
109 PD25_PF_CSPI1_RDY,
110 SPI1_SS0 | GPIO_GPIO | GPIO_OUT,
111 /* CSPI2 */
112 PD22_PF_CSPI2_SCLK,
113 PD23_PF_CSPI2_MISO,
114 PD24_PF_CSPI2_MOSI,
115 SPI2_SS0 | GPIO_GPIO | GPIO_OUT,
116 /* I2C1 */
117 PD17_PF_I2C_DATA,
118 PD18_PF_I2C_CLK,
119 /* PMIC INT */
120 PMIC_INT | GPIO_GPIO | GPIO_IN,
121 /* LCD */
122 PA5_PF_LSCLK,
123 PA6_PF_LD0,
124 PA7_PF_LD1,
125 PA8_PF_LD2,
126 PA9_PF_LD3,
127 PA10_PF_LD4,
128 PA11_PF_LD5,
129 PA12_PF_LD6,
130 PA13_PF_LD7,
131 PA14_PF_LD8,
132 PA15_PF_LD9,
133 PA16_PF_LD10,
134 PA17_PF_LD11,
135 PA18_PF_LD12,
136 PA19_PF_LD13,
137 PA20_PF_LD14,
138 PA21_PF_LD15,
139 PA22_PF_LD16,
140 PA23_PF_LD17,
141 PA28_PF_HSYNC,
142 PA29_PF_VSYNC,
143 PA30_PF_CONTRAST,
144 LCD_ENABLE | GPIO_GPIO | GPIO_OUT,
145 LCD_RESET | GPIO_GPIO | GPIO_OUT,
146 /* CSI */
147 PB10_PF_CSI_D0,
148 PB11_PF_CSI_D1,
149 PB12_PF_CSI_D2,
150 PB13_PF_CSI_D3,
151 PB14_PF_CSI_D4,
152 PB15_PF_CSI_MCLK,
153 PB16_PF_CSI_PIXCLK,
154 PB17_PF_CSI_D5,
155 PB18_PF_CSI_D6,
156 PB19_PF_CSI_D7,
157 PB20_PF_CSI_VSYNC,
158 PB21_PF_CSI_HSYNC,
159 CSI_PWRDWN | GPIO_GPIO | GPIO_OUT,
160 CSI_RESET | GPIO_GPIO | GPIO_OUT,
163 static struct gpio mx27_3ds_camera_gpios[] = {
164 { CSI_PWRDWN, GPIOF_OUT_INIT_HIGH, "camera-power" },
165 { CSI_RESET, GPIOF_OUT_INIT_HIGH, "camera-reset" },
168 static const struct imxuart_platform_data uart_pdata __initconst = {
169 .flags = IMXUART_HAVE_RTSCTS,
173 * Matrix keyboard
176 static const uint32_t mx27_3ds_keymap[] = {
177 KEY(0, 0, KEY_UP),
178 KEY(0, 1, KEY_DOWN),
179 KEY(1, 0, KEY_RIGHT),
180 KEY(1, 1, KEY_LEFT),
181 KEY(1, 2, KEY_ENTER),
182 KEY(2, 0, KEY_F6),
183 KEY(2, 1, KEY_F8),
184 KEY(2, 2, KEY_F9),
185 KEY(2, 3, KEY_F10),
188 static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst = {
189 .keymap = mx27_3ds_keymap,
190 .keymap_size = ARRAY_SIZE(mx27_3ds_keymap),
193 static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
194 void *data)
196 return request_irq(gpio_to_irq(SD1_CD), detect_irq,
197 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
200 static void mx27_3ds_sdhc1_exit(struct device *dev, void *data)
202 free_irq(gpio_to_irq(SD1_CD), data);
205 static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
206 .init = mx27_3ds_sdhc1_init,
207 .exit = mx27_3ds_sdhc1_exit,
210 static void mx27_3ds_sdhc1_enable_level_translator(void)
212 /* Turn on TXB0108 OE pin */
213 gpio_request(SD1_EN_GPIO, "sd1_enable");
214 gpio_direction_output(SD1_EN_GPIO, 1);
218 static int otg_phy_init(void)
220 gpio_request(OTG_PHY_RESET_GPIO, "usb-otg-reset");
221 gpio_direction_output(OTG_PHY_RESET_GPIO, 0);
222 mdelay(1);
223 gpio_set_value(OTG_PHY_RESET_GPIO, 1);
224 return 0;
227 static int mx27_3ds_otg_init(struct platform_device *pdev)
229 return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
232 static struct mxc_usbh_platform_data otg_pdata __initdata = {
233 .init = mx27_3ds_otg_init,
234 .portsc = MXC_EHCI_MODE_ULPI,
237 static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
238 .operating_mode = FSL_USB2_DR_DEVICE,
239 .phy_mode = FSL_USB2_PHY_ULPI,
242 static bool otg_mode_host __initdata;
244 static int __init mx27_3ds_otg_mode(char *options)
246 if (!strcmp(options, "host"))
247 otg_mode_host = true;
248 else if (!strcmp(options, "device"))
249 otg_mode_host = false;
250 else
251 pr_info("otg_mode neither \"host\" nor \"device\". "
252 "Defaulting to device\n");
253 return 1;
255 __setup("otg_mode=", mx27_3ds_otg_mode);
257 /* Regulators */
258 static struct regulator_init_data gpo_init = {
259 .constraints = {
260 .boot_on = 1,
261 .always_on = 1,
265 static struct regulator_consumer_supply vmmc1_consumers[] = {
266 REGULATOR_SUPPLY("vcore", "spi0.0"),
267 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
270 static struct regulator_init_data vmmc1_init = {
271 .constraints = {
272 .min_uV = 2800000,
273 .max_uV = 2800000,
274 .apply_uV = 1,
275 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
276 REGULATOR_CHANGE_STATUS,
278 .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers),
279 .consumer_supplies = vmmc1_consumers,
282 static struct regulator_consumer_supply vgen_consumers[] = {
283 REGULATOR_SUPPLY("vdd", "spi0.0"),
286 static struct regulator_init_data vgen_init = {
287 .constraints = {
288 .min_uV = 1800000,
289 .max_uV = 1800000,
290 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
292 .num_consumer_supplies = ARRAY_SIZE(vgen_consumers),
293 .consumer_supplies = vgen_consumers,
296 static struct regulator_consumer_supply vvib_consumers[] = {
297 REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),
300 static struct regulator_init_data vvib_init = {
301 .constraints = {
302 .min_uV = 1300000,
303 .max_uV = 1300000,
304 .apply_uV = 1,
305 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
306 REGULATOR_CHANGE_STATUS,
308 .num_consumer_supplies = ARRAY_SIZE(vvib_consumers),
309 .consumer_supplies = vvib_consumers,
312 static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
314 .id = MC13783_REG_VMMC1,
315 .init_data = &vmmc1_init,
316 }, {
317 .id = MC13783_REG_VGEN,
318 .init_data = &vgen_init,
319 }, {
320 .id = MC13783_REG_GPO1, /* Turn on 1.8V */
321 .init_data = &gpo_init,
322 }, {
323 .id = MC13783_REG_GPO3, /* Turn on 3.3V */
324 .init_data = &gpo_init,
325 }, {
326 .id = MC13783_REG_VVIB, /* Power OV2640 */
327 .init_data = &vvib_init,
331 /* MC13783 */
332 static struct mc13xxx_platform_data mc13783_pdata = {
333 .regulators = {
334 .regulators = mx27_3ds_regulators,
335 .num_regulators = ARRAY_SIZE(mx27_3ds_regulators),
338 .flags = MC13XXX_USE_TOUCHSCREEN | MC13XXX_USE_RTC,
341 /* SPI */
342 static int spi1_chipselect[] = {SPI1_SS0};
344 static const struct spi_imx_master spi1_pdata __initconst = {
345 .chipselect = spi1_chipselect,
346 .num_chipselect = ARRAY_SIZE(spi1_chipselect),
349 static int spi2_chipselect[] = {SPI2_SS0};
351 static const struct spi_imx_master spi2_pdata __initconst = {
352 .chipselect = spi2_chipselect,
353 .num_chipselect = ARRAY_SIZE(spi2_chipselect),
356 static int mx27_3ds_camera_power(struct device *dev, int on)
358 /* enable or disable the camera */
359 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
360 gpio_set_value(CSI_PWRDWN, on ? 0 : 1);
362 if (!on)
363 goto out;
365 /* If enabled, give a reset impulse */
366 gpio_set_value(CSI_RESET, 0);
367 msleep(20);
368 gpio_set_value(CSI_RESET, 1);
369 msleep(100);
371 out:
372 return 0;
375 static struct i2c_board_info mx27_3ds_i2c_camera = {
376 I2C_BOARD_INFO("ov2640", 0x30),
379 static struct regulator_bulk_data mx27_3ds_camera_regs[] = {
380 { .supply = "cmos_vcore" },
381 { .supply = "cmos_2v8" },
384 static struct soc_camera_link iclink_ov2640 = {
385 .bus_id = 0,
386 .board_info = &mx27_3ds_i2c_camera,
387 .i2c_adapter_id = 0,
388 .power = mx27_3ds_camera_power,
389 .regulators = mx27_3ds_camera_regs,
390 .num_regulators = ARRAY_SIZE(mx27_3ds_camera_regs),
393 static struct platform_device mx27_3ds_ov2640 = {
394 .name = "soc-camera-pdrv",
395 .id = 0,
396 .dev = {
397 .platform_data = &iclink_ov2640,
401 static struct imx_fb_videomode mx27_3ds_modes[] = {
402 { /* 480x640 @ 60 Hz */
403 .mode = {
404 .name = "Epson-VGA",
405 .refresh = 60,
406 .xres = 480,
407 .yres = 640,
408 .pixclock = 41701,
409 .left_margin = 20,
410 .right_margin = 41,
411 .upper_margin = 10,
412 .lower_margin = 5,
413 .hsync_len = 20,
414 .vsync_len = 10,
415 .sync = FB_SYNC_OE_ACT_HIGH |
416 FB_SYNC_CLK_INVERT,
417 .vmode = FB_VMODE_NONINTERLACED,
418 .flag = 0,
420 .bpp = 16,
421 .pcr = 0xFAC08B82,
425 static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = {
426 .mode = mx27_3ds_modes,
427 .num_modes = ARRAY_SIZE(mx27_3ds_modes),
428 .pwmr = 0x00A903FF,
429 .lscr1 = 0x00120300,
430 .dmacr = 0x00020010,
433 /* LCD */
434 static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = {
435 .reset_gpio = LCD_RESET,
436 .data_enable_gpio = LCD_ENABLE,
439 static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
441 .modalias = "mc13783",
442 .max_speed_hz = 1000000,
443 .bus_num = 1,
444 .chip_select = 0, /* SS0 */
445 .platform_data = &mc13783_pdata,
446 /* irq number is run-time assigned */
447 .mode = SPI_CS_HIGH,
448 }, {
449 .modalias = "l4f00242t03",
450 .max_speed_hz = 5000000,
451 .bus_num = 0,
452 .chip_select = 0, /* SS0 */
453 .platform_data = &mx27_3ds_lcd_pdata,
457 static struct platform_device *devices[] __initdata = {
458 &mx27_3ds_ov2640,
461 static const struct mx2_camera_platform_data mx27_3ds_cam_pdata __initconst = {
462 .clk = 26000000,
465 static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = {
466 .bitrate = 100000,
469 static void __init mx27pdk_init(void)
471 int ret;
472 imx27_soc_init();
474 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
475 "mx27pdk");
476 mx27_3ds_sdhc1_enable_level_translator();
477 imx27_add_imx_uart0(&uart_pdata);
478 imx27_add_fec(NULL);
479 imx27_add_imx_keypad(&mx27_3ds_keymap_data);
480 imx27_add_mxc_mmc(0, &sdhc1_pdata);
481 imx27_add_imx2_wdt();
482 otg_phy_init();
484 if (otg_mode_host) {
485 otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
486 ULPI_OTG_DRVVBUS_EXT);
488 if (otg_pdata.otg)
489 imx27_add_mxc_ehci_otg(&otg_pdata);
492 if (!otg_mode_host)
493 imx27_add_fsl_usb2_udc(&otg_device_pdata);
495 imx27_add_spi_imx1(&spi2_pdata);
496 imx27_add_spi_imx0(&spi1_pdata);
497 mx27_3ds_spi_devs[0].irq = gpio_to_irq(PMIC_INT);
498 spi_register_board_info(mx27_3ds_spi_devs,
499 ARRAY_SIZE(mx27_3ds_spi_devs));
501 if (mxc_expio_init(MX27_CS5_BASE_ADDR, IMX_GPIO_NR(3, 28)))
502 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
503 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
504 platform_add_devices(devices, ARRAY_SIZE(devices));
505 imx27_add_imx_fb(&mx27_3ds_fb_data);
507 ret = gpio_request_array(mx27_3ds_camera_gpios,
508 ARRAY_SIZE(mx27_3ds_camera_gpios));
509 if (ret) {
510 pr_err("Failed to request camera gpios");
511 iclink_ov2640.power = NULL;
514 imx27_add_mx2_camera(&mx27_3ds_cam_pdata);
517 static void __init mx27pdk_timer_init(void)
519 mx27_clocks_init(26000000);
522 static struct sys_timer mx27pdk_timer = {
523 .init = mx27pdk_timer_init,
526 MACHINE_START(MX27_3DS, "Freescale MX27PDK")
527 /* maintainer: Freescale Semiconductor, Inc. */
528 .atag_offset = 0x100,
529 .map_io = mx27_map_io,
530 .init_early = imx27_init_early,
531 .init_irq = mx27_init_irq,
532 .handle_irq = imx27_handle_irq,
533 .timer = &mx27pdk_timer,
534 .init_machine = mx27pdk_init,
535 .restart = mxc_restart,
536 MACHINE_END