mach-mx31_3ds.c 20 KB

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