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