mach-mx31_3ds.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/types.h>
  17. #include <linux/init.h>
  18. #include <linux/clk.h>
  19. #include <linux/irq.h>
  20. #include <linux/gpio.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mfd/mc13783.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/l4f00242t03.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/usb/otg.h>
  27. #include <linux/usb/ulpi.h>
  28. #include <linux/memblock.h>
  29. #include <media/soc_camera.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/time.h>
  34. #include <asm/memory.h>
  35. #include <asm/mach/map.h>
  36. #include <mach/common.h>
  37. #include <mach/iomux-mx3.h>
  38. #include <mach/3ds_debugboard.h>
  39. #include <mach/ulpi.h>
  40. #include "devices-imx31.h"
  41. /* CPLD IRQ line for external uart, external ethernet etc */
  42. #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)
  43. static int mx31_3ds_pins[] = {
  44. /* UART1 */
  45. MX31_PIN_CTS1__CTS1,
  46. MX31_PIN_RTS1__RTS1,
  47. MX31_PIN_TXD1__TXD1,
  48. MX31_PIN_RXD1__RXD1,
  49. IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO),
  50. /*SPI0*/
  51. MX31_PIN_CSPI1_SCLK__SCLK,
  52. MX31_PIN_CSPI1_MOSI__MOSI,
  53. MX31_PIN_CSPI1_MISO__MISO,
  54. MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
  55. MX31_PIN_CSPI1_SS2__SS2, /* CS for LCD */
  56. /* SPI 1 */
  57. MX31_PIN_CSPI2_SCLK__SCLK,
  58. MX31_PIN_CSPI2_MOSI__MOSI,
  59. MX31_PIN_CSPI2_MISO__MISO,
  60. MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,
  61. MX31_PIN_CSPI2_SS0__SS0,
  62. MX31_PIN_CSPI2_SS2__SS2, /*CS for MC13783 */
  63. /* MC13783 IRQ */
  64. IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO),
  65. /* USB OTG reset */
  66. IOMUX_MODE(MX31_PIN_USB_PWR, IOMUX_CONFIG_GPIO),
  67. /* USB OTG */
  68. MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
  69. MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
  70. MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
  71. MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
  72. MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
  73. MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
  74. MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
  75. MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
  76. MX31_PIN_USBOTG_CLK__USBOTG_CLK,
  77. MX31_PIN_USBOTG_DIR__USBOTG_DIR,
  78. MX31_PIN_USBOTG_NXT__USBOTG_NXT,
  79. MX31_PIN_USBOTG_STP__USBOTG_STP,
  80. /*Keyboard*/
  81. MX31_PIN_KEY_ROW0_KEY_ROW0,
  82. MX31_PIN_KEY_ROW1_KEY_ROW1,
  83. MX31_PIN_KEY_ROW2_KEY_ROW2,
  84. MX31_PIN_KEY_COL0_KEY_COL0,
  85. MX31_PIN_KEY_COL1_KEY_COL1,
  86. MX31_PIN_KEY_COL2_KEY_COL2,
  87. MX31_PIN_KEY_COL3_KEY_COL3,
  88. /* USB Host 2 */
  89. IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC),
  90. IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC),
  91. IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC),
  92. IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC),
  93. IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC),
  94. IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC),
  95. IOMUX_MODE(MX31_PIN_PC_VS2, IOMUX_CONFIG_ALT1),
  96. IOMUX_MODE(MX31_PIN_PC_BVD1, IOMUX_CONFIG_ALT1),
  97. IOMUX_MODE(MX31_PIN_PC_BVD2, IOMUX_CONFIG_ALT1),
  98. IOMUX_MODE(MX31_PIN_PC_RST, IOMUX_CONFIG_ALT1),
  99. IOMUX_MODE(MX31_PIN_IOIS16, IOMUX_CONFIG_ALT1),
  100. IOMUX_MODE(MX31_PIN_PC_RW_B, IOMUX_CONFIG_ALT1),
  101. /* USB Host2 reset */
  102. IOMUX_MODE(MX31_PIN_USB_BYP, IOMUX_CONFIG_GPIO),
  103. /* I2C1 */
  104. MX31_PIN_I2C_CLK__I2C1_SCL,
  105. MX31_PIN_I2C_DAT__I2C1_SDA,
  106. /* SDHC1 */
  107. MX31_PIN_SD1_DATA3__SD1_DATA3,
  108. MX31_PIN_SD1_DATA2__SD1_DATA2,
  109. MX31_PIN_SD1_DATA1__SD1_DATA1,
  110. MX31_PIN_SD1_DATA0__SD1_DATA0,
  111. MX31_PIN_SD1_CLK__SD1_CLK,
  112. MX31_PIN_SD1_CMD__SD1_CMD,
  113. MX31_PIN_GPIO3_1__GPIO3_1, /* Card detect */
  114. MX31_PIN_GPIO3_0__GPIO3_0, /* OE */
  115. /* Framebuffer */
  116. MX31_PIN_LD0__LD0,
  117. MX31_PIN_LD1__LD1,
  118. MX31_PIN_LD2__LD2,
  119. MX31_PIN_LD3__LD3,
  120. MX31_PIN_LD4__LD4,
  121. MX31_PIN_LD5__LD5,
  122. MX31_PIN_LD6__LD6,
  123. MX31_PIN_LD7__LD7,
  124. MX31_PIN_LD8__LD8,
  125. MX31_PIN_LD9__LD9,
  126. MX31_PIN_LD10__LD10,
  127. MX31_PIN_LD11__LD11,
  128. MX31_PIN_LD12__LD12,
  129. MX31_PIN_LD13__LD13,
  130. MX31_PIN_LD14__LD14,
  131. MX31_PIN_LD15__LD15,
  132. MX31_PIN_LD16__LD16,
  133. MX31_PIN_LD17__LD17,
  134. MX31_PIN_VSYNC3__VSYNC3,
  135. MX31_PIN_HSYNC__HSYNC,
  136. MX31_PIN_FPSHIFT__FPSHIFT,
  137. MX31_PIN_CONTRAST__CONTRAST,
  138. /* CSI */
  139. MX31_PIN_CSI_D6__CSI_D6,
  140. MX31_PIN_CSI_D7__CSI_D7,
  141. MX31_PIN_CSI_D8__CSI_D8,
  142. MX31_PIN_CSI_D9__CSI_D9,
  143. MX31_PIN_CSI_D10__CSI_D10,
  144. MX31_PIN_CSI_D11__CSI_D11,
  145. MX31_PIN_CSI_D12__CSI_D12,
  146. MX31_PIN_CSI_D13__CSI_D13,
  147. MX31_PIN_CSI_D14__CSI_D14,
  148. MX31_PIN_CSI_D15__CSI_D15,
  149. MX31_PIN_CSI_HSYNC__CSI_HSYNC,
  150. MX31_PIN_CSI_MCLK__CSI_MCLK,
  151. MX31_PIN_CSI_PIXCLK__CSI_PIXCLK,
  152. MX31_PIN_CSI_VSYNC__CSI_VSYNC,
  153. MX31_PIN_CSI_D5__GPIO3_5, /* CMOS PWDN */
  154. IOMUX_MODE(MX31_PIN_RI_DTE1, IOMUX_CONFIG_GPIO), /* CMOS reset */
  155. };
  156. /*
  157. * Camera support
  158. */
  159. static phys_addr_t mx3_camera_base __initdata;
  160. #define MX31_3DS_CAMERA_BUF_SIZE SZ_8M
  161. #define MX31_3DS_GPIO_CAMERA_PW IOMUX_TO_GPIO(MX31_PIN_CSI_D5)
  162. #define MX31_3DS_GPIO_CAMERA_RST IOMUX_TO_GPIO(MX31_PIN_RI_DTE1)
  163. static struct gpio mx31_3ds_camera_gpios[] = {
  164. { MX31_3DS_GPIO_CAMERA_PW, GPIOF_OUT_INIT_HIGH, "camera-power" },
  165. { MX31_3DS_GPIO_CAMERA_RST, GPIOF_OUT_INIT_HIGH, "camera-reset" },
  166. };
  167. static const struct mx3_camera_pdata mx31_3ds_camera_pdata __initconst = {
  168. .flags = MX3_CAMERA_DATAWIDTH_10,
  169. .mclk_10khz = 2600,
  170. };
  171. static int __init mx31_3ds_init_camera(void)
  172. {
  173. int dma, ret = -ENOMEM;
  174. struct platform_device *pdev =
  175. imx31_alloc_mx3_camera(&mx31_3ds_camera_pdata);
  176. if (IS_ERR(pdev))
  177. return PTR_ERR(pdev);
  178. if (!mx3_camera_base)
  179. goto err;
  180. dma = dma_declare_coherent_memory(&pdev->dev,
  181. mx3_camera_base, mx3_camera_base,
  182. MX31_3DS_CAMERA_BUF_SIZE,
  183. DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
  184. if (!(dma & DMA_MEMORY_MAP))
  185. goto err;
  186. ret = platform_device_add(pdev);
  187. if (ret)
  188. err:
  189. platform_device_put(pdev);
  190. return ret;
  191. }
  192. static int mx31_3ds_camera_power(struct device *dev, int on)
  193. {
  194. /* enable or disable the camera */
  195. pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
  196. gpio_set_value(MX31_3DS_GPIO_CAMERA_PW, on ? 0 : 1);
  197. if (!on)
  198. goto out;
  199. /* If enabled, give a reset impulse */
  200. gpio_set_value(MX31_3DS_GPIO_CAMERA_RST, 0);
  201. msleep(20);
  202. gpio_set_value(MX31_3DS_GPIO_CAMERA_RST, 1);
  203. msleep(100);
  204. out:
  205. return 0;
  206. }
  207. static struct i2c_board_info mx31_3ds_i2c_camera = {
  208. I2C_BOARD_INFO("ov2640", 0x30),
  209. };
  210. static struct regulator_bulk_data mx31_3ds_camera_regs[] = {
  211. { .supply = "cmos_vcore" },
  212. { .supply = "cmos_2v8" },
  213. };
  214. static struct soc_camera_link iclink_ov2640 = {
  215. .bus_id = 0,
  216. .board_info = &mx31_3ds_i2c_camera,
  217. .i2c_adapter_id = 0,
  218. .power = mx31_3ds_camera_power,
  219. .regulators = mx31_3ds_camera_regs,
  220. .num_regulators = ARRAY_SIZE(mx31_3ds_camera_regs),
  221. };
  222. static struct platform_device mx31_3ds_ov2640 = {
  223. .name = "soc-camera-pdrv",
  224. .id = 0,
  225. .dev = {
  226. .platform_data = &iclink_ov2640,
  227. },
  228. };
  229. /*
  230. * FB support
  231. */
  232. static const struct fb_videomode fb_modedb[] = {
  233. { /* 480x640 @ 60 Hz */
  234. .name = "Epson-VGA",
  235. .refresh = 60,
  236. .xres = 480,
  237. .yres = 640,
  238. .pixclock = 41701,
  239. .left_margin = 20,
  240. .right_margin = 41,
  241. .upper_margin = 10,
  242. .lower_margin = 5,
  243. .hsync_len = 20,
  244. .vsync_len = 10,
  245. .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
  246. .vmode = FB_VMODE_NONINTERLACED,
  247. .flag = 0,
  248. },
  249. };
  250. static struct ipu_platform_data mx3_ipu_data = {
  251. .irq_base = MXC_IPU_IRQ_START,
  252. };
  253. static struct mx3fb_platform_data mx3fb_pdata __initdata = {
  254. .name = "Epson-VGA",
  255. .mode = fb_modedb,
  256. .num_modes = ARRAY_SIZE(fb_modedb),
  257. };
  258. /* LCD */
  259. static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = {
  260. .reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1),
  261. .data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS),
  262. .core_supply = "lcd_2v8",
  263. .io_supply = "vdd_lcdio",
  264. };
  265. /*
  266. * Support for SD card slot in personality board
  267. */
  268. #define MX31_3DS_GPIO_SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)
  269. #define MX31_3DS_GPIO_SDHC1_BE IOMUX_TO_GPIO(MX31_PIN_GPIO3_0)
  270. static struct gpio mx31_3ds_sdhc1_gpios[] = {
  271. { MX31_3DS_GPIO_SDHC1_CD, GPIOF_IN, "sdhc1-card-detect" },
  272. { MX31_3DS_GPIO_SDHC1_BE, GPIOF_OUT_INIT_LOW, "sdhc1-bus-en" },
  273. };
  274. static int mx31_3ds_sdhc1_init(struct device *dev,
  275. irq_handler_t detect_irq,
  276. void *data)
  277. {
  278. int ret;
  279. ret = gpio_request_array(mx31_3ds_sdhc1_gpios,
  280. ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
  281. if (ret) {
  282. pr_warning("Unable to request the SD/MMC GPIOs.\n");
  283. return ret;
  284. }
  285. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
  286. detect_irq, IRQF_DISABLED |
  287. IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  288. "sdhc1-detect", data);
  289. if (ret) {
  290. pr_warning("Unable to request the SD/MMC card-detect IRQ.\n");
  291. goto gpio_free;
  292. }
  293. return 0;
  294. gpio_free:
  295. gpio_free_array(mx31_3ds_sdhc1_gpios,
  296. ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
  297. return ret;
  298. }
  299. static void mx31_3ds_sdhc1_exit(struct device *dev, void *data)
  300. {
  301. free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), data);
  302. gpio_free_array(mx31_3ds_sdhc1_gpios,
  303. ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
  304. }
  305. static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd)
  306. {
  307. /*
  308. * While the voltage stuff is done by the driver, activate the
  309. * Buffer Enable Pin only if there is a card in slot to fix the card
  310. * voltage issue caused by bi-directional chip TXB0108 on 3Stack.
  311. * Done here because at this stage we have for sure a debounced value
  312. * of the presence of the card, showed by the value of vdd.
  313. * 7 == ilog2(MMC_VDD_165_195)
  314. */
  315. if (vdd > 7)
  316. gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 1);
  317. else
  318. gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 0);
  319. }
  320. static struct imxmmc_platform_data sdhc1_pdata = {
  321. .init = mx31_3ds_sdhc1_init,
  322. .exit = mx31_3ds_sdhc1_exit,
  323. .setpower = mx31_3ds_sdhc1_setpower,
  324. };
  325. /*
  326. * Matrix keyboard
  327. */
  328. static const uint32_t mx31_3ds_keymap[] = {
  329. KEY(0, 0, KEY_UP),
  330. KEY(0, 1, KEY_DOWN),
  331. KEY(1, 0, KEY_RIGHT),
  332. KEY(1, 1, KEY_LEFT),
  333. KEY(1, 2, KEY_ENTER),
  334. KEY(2, 0, KEY_F6),
  335. KEY(2, 1, KEY_F8),
  336. KEY(2, 2, KEY_F9),
  337. KEY(2, 3, KEY_F10),
  338. };
  339. static const struct matrix_keymap_data mx31_3ds_keymap_data __initconst = {
  340. .keymap = mx31_3ds_keymap,
  341. .keymap_size = ARRAY_SIZE(mx31_3ds_keymap),
  342. };
  343. /* Regulators */
  344. static struct regulator_init_data pwgtx_init = {
  345. .constraints = {
  346. .boot_on = 1,
  347. .always_on = 1,
  348. },
  349. };
  350. static struct regulator_init_data gpo_init = {
  351. .constraints = {
  352. .boot_on = 1,
  353. .always_on = 1,
  354. }
  355. };
  356. static struct regulator_consumer_supply vmmc2_consumers[] = {
  357. REGULATOR_SUPPLY("vmmc", "mxc-mmc.0"),
  358. };
  359. static struct regulator_init_data vmmc2_init = {
  360. .constraints = {
  361. .min_uV = 3000000,
  362. .max_uV = 3000000,
  363. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  364. REGULATOR_CHANGE_STATUS,
  365. },
  366. .num_consumer_supplies = ARRAY_SIZE(vmmc2_consumers),
  367. .consumer_supplies = vmmc2_consumers,
  368. };
  369. static struct regulator_consumer_supply vmmc1_consumers[] = {
  370. REGULATOR_SUPPLY("lcd_2v8", NULL),
  371. REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
  372. };
  373. static struct regulator_init_data vmmc1_init = {
  374. .constraints = {
  375. .min_uV = 2800000,
  376. .max_uV = 2800000,
  377. .apply_uV = 1,
  378. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  379. REGULATOR_CHANGE_STATUS,
  380. },
  381. .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers),
  382. .consumer_supplies = vmmc1_consumers,
  383. };
  384. static struct regulator_consumer_supply vgen_consumers[] = {
  385. REGULATOR_SUPPLY("vdd_lcdio", NULL),
  386. };
  387. static struct regulator_init_data vgen_init = {
  388. .constraints = {
  389. .min_uV = 1800000,
  390. .max_uV = 1800000,
  391. .apply_uV = 1,
  392. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  393. REGULATOR_CHANGE_STATUS,
  394. },
  395. .num_consumer_supplies = ARRAY_SIZE(vgen_consumers),
  396. .consumer_supplies = vgen_consumers,
  397. };
  398. static struct regulator_consumer_supply vvib_consumers[] = {
  399. REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),
  400. };
  401. static struct regulator_init_data vvib_init = {
  402. .constraints = {
  403. .min_uV = 1300000,
  404. .max_uV = 1300000,
  405. .apply_uV = 1,
  406. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  407. REGULATOR_CHANGE_STATUS,
  408. },
  409. .num_consumer_supplies = ARRAY_SIZE(vvib_consumers),
  410. .consumer_supplies = vvib_consumers,
  411. };
  412. static struct mc13xxx_regulator_init_data mx31_3ds_regulators[] = {
  413. {
  414. .id = MC13783_REG_PWGT1SPI, /* Power Gate for ARM core. */
  415. .init_data = &pwgtx_init,
  416. }, {
  417. .id = MC13783_REG_PWGT2SPI, /* Power Gate for L2 Cache. */
  418. .init_data = &pwgtx_init,
  419. }, {
  420. .id = MC13783_REG_GPO1, /* Turn on 1.8V */
  421. .init_data = &gpo_init,
  422. }, {
  423. .id = MC13783_REG_GPO3, /* Turn on 3.3V */
  424. .init_data = &gpo_init,
  425. }, {
  426. .id = MC13783_REG_VMMC2, /* Power MMC/SD, WiFi/Bluetooth. */
  427. .init_data = &vmmc2_init,
  428. }, {
  429. .id = MC13783_REG_VMMC1, /* Power LCD, CMOS, FM, GPS, Accel. */
  430. .init_data = &vmmc1_init,
  431. }, {
  432. .id = MC13783_REG_VGEN, /* Power LCD */
  433. .init_data = &vgen_init,
  434. }, {
  435. .id = MC13783_REG_VVIB, /* Power CMOS */
  436. .init_data = &vvib_init,
  437. },
  438. };
  439. /* MC13783 */
  440. static struct mc13xxx_platform_data mc13783_pdata = {
  441. .regulators = {
  442. .regulators = mx31_3ds_regulators,
  443. .num_regulators = ARRAY_SIZE(mx31_3ds_regulators),
  444. },
  445. .flags = MC13783_USE_REGULATOR | MC13783_USE_TOUCHSCREEN,
  446. };
  447. /* SPI */
  448. static int spi0_internal_chipselect[] = {
  449. MXC_SPI_CS(2),
  450. };
  451. static const struct spi_imx_master spi0_pdata __initconst = {
  452. .chipselect = spi0_internal_chipselect,
  453. .num_chipselect = ARRAY_SIZE(spi0_internal_chipselect),
  454. };
  455. static int spi1_internal_chipselect[] = {
  456. MXC_SPI_CS(0),
  457. MXC_SPI_CS(2),
  458. };
  459. static const struct spi_imx_master spi1_pdata __initconst = {
  460. .chipselect = spi1_internal_chipselect,
  461. .num_chipselect = ARRAY_SIZE(spi1_internal_chipselect),
  462. };
  463. static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
  464. {
  465. .modalias = "mc13783",
  466. .max_speed_hz = 1000000,
  467. .bus_num = 1,
  468. .chip_select = 1, /* SS2 */
  469. .platform_data = &mc13783_pdata,
  470. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  471. .mode = SPI_CS_HIGH,
  472. }, {
  473. .modalias = "l4f00242t03",
  474. .max_speed_hz = 5000000,
  475. .bus_num = 0,
  476. .chip_select = 0, /* SS2 */
  477. .platform_data = &mx31_3ds_l4f00242t03_pdata,
  478. },
  479. };
  480. /*
  481. * NAND Flash
  482. */
  483. static const struct mxc_nand_platform_data
  484. mx31_3ds_nand_board_info __initconst = {
  485. .width = 1,
  486. .hw_ecc = 1,
  487. #ifdef MACH_MX31_3DS_MXC_NAND_USE_BBT
  488. .flash_bbt = 1,
  489. #endif
  490. };
  491. /*
  492. * USB OTG
  493. */
  494. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  495. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  496. #define USBOTG_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_PWR)
  497. #define USBH2_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_BYP)
  498. static int mx31_3ds_usbotg_init(void)
  499. {
  500. int err;
  501. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);
  502. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);
  503. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);
  504. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);
  505. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);
  506. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);
  507. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);
  508. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);
  509. mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);
  510. mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);
  511. mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);
  512. mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);
  513. err = gpio_request(USBOTG_RST_B, "otgusb-reset");
  514. if (err) {
  515. pr_err("Failed to request the USB OTG reset gpio\n");
  516. return err;
  517. }
  518. err = gpio_direction_output(USBOTG_RST_B, 0);
  519. if (err) {
  520. pr_err("Failed to drive the USB OTG reset gpio\n");
  521. goto usbotg_free_reset;
  522. }
  523. mdelay(1);
  524. gpio_set_value(USBOTG_RST_B, 1);
  525. return 0;
  526. usbotg_free_reset:
  527. gpio_free(USBOTG_RST_B);
  528. return err;
  529. }
  530. static int mx31_3ds_otg_init(struct platform_device *pdev)
  531. {
  532. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  533. }
  534. static int mx31_3ds_host2_init(struct platform_device *pdev)
  535. {
  536. int err;
  537. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  538. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  539. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  540. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  541. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  542. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  543. mxc_iomux_set_pad(MX31_PIN_PC_VS2, USB_PAD_CFG);
  544. mxc_iomux_set_pad(MX31_PIN_PC_BVD1, USB_PAD_CFG);
  545. mxc_iomux_set_pad(MX31_PIN_PC_BVD2, USB_PAD_CFG);
  546. mxc_iomux_set_pad(MX31_PIN_PC_RST, USB_PAD_CFG);
  547. mxc_iomux_set_pad(MX31_PIN_IOIS16, USB_PAD_CFG);
  548. mxc_iomux_set_pad(MX31_PIN_PC_RW_B, USB_PAD_CFG);
  549. err = gpio_request(USBH2_RST_B, "usbh2-reset");
  550. if (err) {
  551. pr_err("Failed to request the USB Host 2 reset gpio\n");
  552. return err;
  553. }
  554. err = gpio_direction_output(USBH2_RST_B, 0);
  555. if (err) {
  556. pr_err("Failed to drive the USB Host 2 reset gpio\n");
  557. goto usbotg_free_reset;
  558. }
  559. mdelay(1);
  560. gpio_set_value(USBH2_RST_B, 1);
  561. mdelay(10);
  562. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  563. usbotg_free_reset:
  564. gpio_free(USBH2_RST_B);
  565. return err;
  566. }
  567. static struct mxc_usbh_platform_data otg_pdata __initdata = {
  568. .init = mx31_3ds_otg_init,
  569. .portsc = MXC_EHCI_MODE_ULPI,
  570. };
  571. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  572. .init = mx31_3ds_host2_init,
  573. .portsc = MXC_EHCI_MODE_ULPI,
  574. };
  575. static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {
  576. .operating_mode = FSL_USB2_DR_DEVICE,
  577. .phy_mode = FSL_USB2_PHY_ULPI,
  578. };
  579. static int otg_mode_host;
  580. static int __init mx31_3ds_otg_mode(char *options)
  581. {
  582. if (!strcmp(options, "host"))
  583. otg_mode_host = 1;
  584. else if (!strcmp(options, "device"))
  585. otg_mode_host = 0;
  586. else
  587. pr_info("otg_mode neither \"host\" nor \"device\". "
  588. "Defaulting to device\n");
  589. return 0;
  590. }
  591. __setup("otg_mode=", mx31_3ds_otg_mode);
  592. static const struct imxuart_platform_data uart_pdata __initconst = {
  593. .flags = IMXUART_HAVE_RTSCTS,
  594. };
  595. static const struct imxi2c_platform_data mx31_3ds_i2c0_data __initconst = {
  596. .bitrate = 100000,
  597. };
  598. static struct platform_device *devices[] __initdata = {
  599. &mx31_3ds_ov2640,
  600. };
  601. static void __init mx31_3ds_init(void)
  602. {
  603. int ret;
  604. imx31_soc_init();
  605. mxc_iomux_setup_multiple_pins(mx31_3ds_pins, ARRAY_SIZE(mx31_3ds_pins),
  606. "mx31_3ds");
  607. imx31_add_imx_uart0(&uart_pdata);
  608. imx31_add_mxc_nand(&mx31_3ds_nand_board_info);
  609. imx31_add_spi_imx1(&spi1_pdata);
  610. spi_register_board_info(mx31_3ds_spi_devs,
  611. ARRAY_SIZE(mx31_3ds_spi_devs));
  612. platform_add_devices(devices, ARRAY_SIZE(devices));
  613. imx31_add_imx_keypad(&mx31_3ds_keymap_data);
  614. mx31_3ds_usbotg_init();
  615. if (otg_mode_host) {
  616. otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  617. ULPI_OTG_DRVVBUS_EXT);
  618. if (otg_pdata.otg)
  619. imx31_add_mxc_ehci_otg(&otg_pdata);
  620. }
  621. usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  622. ULPI_OTG_DRVVBUS_EXT);
  623. if (usbh2_pdata.otg)
  624. imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
  625. if (!otg_mode_host)
  626. imx31_add_fsl_usb2_udc(&usbotg_pdata);
  627. if (mxc_expio_init(MX31_CS5_BASE_ADDR, EXPIO_PARENT_INT))
  628. printk(KERN_WARNING "Init of the debug board failed, all "
  629. "devices on the debug board are unusable.\n");
  630. imx31_add_imx2_wdt(NULL);
  631. imx31_add_imx_i2c0(&mx31_3ds_i2c0_data);
  632. imx31_add_mxc_mmc(0, &sdhc1_pdata);
  633. imx31_add_spi_imx0(&spi0_pdata);
  634. imx31_add_ipu_core(&mx3_ipu_data);
  635. imx31_add_mx3_sdc_fb(&mx3fb_pdata);
  636. /* CSI */
  637. /* Camera power: default - off */
  638. ret = gpio_request_array(mx31_3ds_camera_gpios,
  639. ARRAY_SIZE(mx31_3ds_camera_gpios));
  640. if (ret) {
  641. pr_err("Failed to request camera gpios");
  642. iclink_ov2640.power = NULL;
  643. }
  644. mx31_3ds_init_camera();
  645. }
  646. static void __init mx31_3ds_timer_init(void)
  647. {
  648. mx31_clocks_init(26000000);
  649. }
  650. static struct sys_timer mx31_3ds_timer = {
  651. .init = mx31_3ds_timer_init,
  652. };
  653. static void __init mx31_3ds_reserve(void)
  654. {
  655. /* reserve MX31_3DS_CAMERA_BUF_SIZE bytes for mx3-camera */
  656. mx3_camera_base = memblock_alloc(MX31_3DS_CAMERA_BUF_SIZE,
  657. MX31_3DS_CAMERA_BUF_SIZE);
  658. memblock_free(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);
  659. memblock_remove(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);
  660. }
  661. MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")
  662. /* Maintainer: Freescale Semiconductor, Inc. */
  663. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  664. .map_io = mx31_map_io,
  665. .init_early = imx31_init_early,
  666. .init_irq = mx31_init_irq,
  667. .timer = &mx31_3ds_timer,
  668. .init_machine = mx31_3ds_init,
  669. .reserve = mx31_3ds_reserve,
  670. MACHINE_END