mach-pcm037.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Copyright (C) 2008 Sascha Hauer, Pengutronix
  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/types.h>
  15. #include <linux/init.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/mtd/plat-ram.h>
  20. #include <linux/memory.h>
  21. #include <linux/gpio.h>
  22. #include <linux/smsc911x.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/i2c.h>
  25. #include <linux/platform_data/at24.h>
  26. #include <linux/delay.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/irq.h>
  29. #include <linux/can/platform/sja1000.h>
  30. #include <linux/usb/otg.h>
  31. #include <linux/usb/ulpi.h>
  32. #include <linux/gfp.h>
  33. #include <linux/memblock.h>
  34. #include <linux/regulator/machine.h>
  35. #include <linux/regulator/fixed.h>
  36. #include <media/soc_camera.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/time.h>
  40. #include <asm/mach/map.h>
  41. #include <asm/memblock.h>
  42. #include "common.h"
  43. #include "devices-imx31.h"
  44. #include "ehci.h"
  45. #include "hardware.h"
  46. #include "iomux-mx3.h"
  47. #include "pcm037.h"
  48. #include "ulpi.h"
  49. static enum pcm037_board_variant pcm037_instance = PCM037_PCM970;
  50. static int __init pcm037_variant_setup(char *str)
  51. {
  52. if (!strcmp("eet", str))
  53. pcm037_instance = PCM037_EET;
  54. else if (strcmp("pcm970", str))
  55. pr_warn("Unknown pcm037 baseboard variant %s\n", str);
  56. return 1;
  57. }
  58. /* Supported values: "pcm970" (default) and "eet" */
  59. __setup("pcm037_variant=", pcm037_variant_setup);
  60. enum pcm037_board_variant pcm037_variant(void)
  61. {
  62. return pcm037_instance;
  63. }
  64. /* UART1 with RTS/CTS handshake signals */
  65. static unsigned int pcm037_uart1_handshake_pins[] = {
  66. MX31_PIN_CTS1__CTS1,
  67. MX31_PIN_RTS1__RTS1,
  68. MX31_PIN_TXD1__TXD1,
  69. MX31_PIN_RXD1__RXD1,
  70. };
  71. /* UART1 without RTS/CTS handshake signals */
  72. static unsigned int pcm037_uart1_pins[] = {
  73. MX31_PIN_TXD1__TXD1,
  74. MX31_PIN_RXD1__RXD1,
  75. };
  76. static unsigned int pcm037_pins[] = {
  77. /* I2C */
  78. MX31_PIN_CSPI2_MOSI__SCL,
  79. MX31_PIN_CSPI2_MISO__SDA,
  80. MX31_PIN_CSPI2_SS2__I2C3_SDA,
  81. MX31_PIN_CSPI2_SCLK__I2C3_SCL,
  82. /* SDHC1 */
  83. MX31_PIN_SD1_DATA3__SD1_DATA3,
  84. MX31_PIN_SD1_DATA2__SD1_DATA2,
  85. MX31_PIN_SD1_DATA1__SD1_DATA1,
  86. MX31_PIN_SD1_DATA0__SD1_DATA0,
  87. MX31_PIN_SD1_CLK__SD1_CLK,
  88. MX31_PIN_SD1_CMD__SD1_CMD,
  89. IOMUX_MODE(MX31_PIN_SCK6, IOMUX_CONFIG_GPIO), /* card detect */
  90. IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO), /* write protect */
  91. /* SPI1 */
  92. MX31_PIN_CSPI1_MOSI__MOSI,
  93. MX31_PIN_CSPI1_MISO__MISO,
  94. MX31_PIN_CSPI1_SCLK__SCLK,
  95. MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
  96. MX31_PIN_CSPI1_SS0__SS0,
  97. MX31_PIN_CSPI1_SS1__SS1,
  98. MX31_PIN_CSPI1_SS2__SS2,
  99. /* UART2 */
  100. MX31_PIN_TXD2__TXD2,
  101. MX31_PIN_RXD2__RXD2,
  102. MX31_PIN_CTS2__CTS2,
  103. MX31_PIN_RTS2__RTS2,
  104. /* UART3 */
  105. MX31_PIN_CSPI3_MOSI__RXD3,
  106. MX31_PIN_CSPI3_MISO__TXD3,
  107. MX31_PIN_CSPI3_SCLK__RTS3,
  108. MX31_PIN_CSPI3_SPI_RDY__CTS3,
  109. /* LAN9217 irq pin */
  110. IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO),
  111. /* Onewire */
  112. MX31_PIN_BATT_LINE__OWIRE,
  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_DRDY0__DRDY0,
  136. MX31_PIN_D3_REV__D3_REV,
  137. MX31_PIN_CONTRAST__CONTRAST,
  138. MX31_PIN_D3_SPL__D3_SPL,
  139. MX31_PIN_D3_CLS__D3_CLS,
  140. MX31_PIN_LCS0__GPIO3_23,
  141. /* CSI */
  142. IOMUX_MODE(MX31_PIN_CSI_D5, IOMUX_CONFIG_GPIO),
  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. /* GPIO */
  158. IOMUX_MODE(MX31_PIN_ATA_DMACK, IOMUX_CONFIG_GPIO),
  159. /* OTG */
  160. MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
  161. MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
  162. MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
  163. MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
  164. MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
  165. MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
  166. MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
  167. MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
  168. MX31_PIN_USBOTG_CLK__USBOTG_CLK,
  169. MX31_PIN_USBOTG_DIR__USBOTG_DIR,
  170. MX31_PIN_USBOTG_NXT__USBOTG_NXT,
  171. MX31_PIN_USBOTG_STP__USBOTG_STP,
  172. /* USB host 2 */
  173. IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC),
  174. IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC),
  175. IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC),
  176. IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC),
  177. IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC),
  178. IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC),
  179. IOMUX_MODE(MX31_PIN_STXD3, IOMUX_CONFIG_FUNC),
  180. IOMUX_MODE(MX31_PIN_SRXD3, IOMUX_CONFIG_FUNC),
  181. IOMUX_MODE(MX31_PIN_SCK3, IOMUX_CONFIG_FUNC),
  182. IOMUX_MODE(MX31_PIN_SFS3, IOMUX_CONFIG_FUNC),
  183. IOMUX_MODE(MX31_PIN_STXD6, IOMUX_CONFIG_FUNC),
  184. IOMUX_MODE(MX31_PIN_SRXD6, IOMUX_CONFIG_FUNC),
  185. };
  186. static struct physmap_flash_data pcm037_flash_data = {
  187. .width = 2,
  188. };
  189. static struct resource pcm037_flash_resource = {
  190. .start = 0xa0000000,
  191. .end = 0xa1ffffff,
  192. .flags = IORESOURCE_MEM,
  193. };
  194. static struct platform_device pcm037_flash = {
  195. .name = "physmap-flash",
  196. .id = 0,
  197. .dev = {
  198. .platform_data = &pcm037_flash_data,
  199. },
  200. .resource = &pcm037_flash_resource,
  201. .num_resources = 1,
  202. };
  203. static const struct imxuart_platform_data uart_pdata __initconst = {
  204. .flags = IMXUART_HAVE_RTSCTS,
  205. };
  206. static struct resource smsc911x_resources[] = {
  207. {
  208. .start = MX31_CS1_BASE_ADDR + 0x300,
  209. .end = MX31_CS1_BASE_ADDR + 0x300 + SZ_64K - 1,
  210. .flags = IORESOURCE_MEM,
  211. }, {
  212. /* irq number is run-time assigned */
  213. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  214. },
  215. };
  216. static struct smsc911x_platform_config smsc911x_info = {
  217. .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY |
  218. SMSC911X_SAVE_MAC_ADDRESS,
  219. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  220. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  221. .phy_interface = PHY_INTERFACE_MODE_MII,
  222. };
  223. static struct platform_device pcm037_eth = {
  224. .name = "smsc911x",
  225. .id = -1,
  226. .num_resources = ARRAY_SIZE(smsc911x_resources),
  227. .resource = smsc911x_resources,
  228. .dev = {
  229. .platform_data = &smsc911x_info,
  230. },
  231. };
  232. static struct platdata_mtd_ram pcm038_sram_data = {
  233. .bankwidth = 2,
  234. };
  235. static struct resource pcm038_sram_resource = {
  236. .start = MX31_CS4_BASE_ADDR,
  237. .end = MX31_CS4_BASE_ADDR + 512 * 1024 - 1,
  238. .flags = IORESOURCE_MEM,
  239. };
  240. static struct platform_device pcm037_sram_device = {
  241. .name = "mtd-ram",
  242. .id = 0,
  243. .dev = {
  244. .platform_data = &pcm038_sram_data,
  245. },
  246. .num_resources = 1,
  247. .resource = &pcm038_sram_resource,
  248. };
  249. static const struct mxc_nand_platform_data
  250. pcm037_nand_board_info __initconst = {
  251. .width = 1,
  252. .hw_ecc = 1,
  253. };
  254. static const struct imxi2c_platform_data pcm037_i2c1_data __initconst = {
  255. .bitrate = 100000,
  256. };
  257. static const struct imxi2c_platform_data pcm037_i2c2_data __initconst = {
  258. .bitrate = 20000,
  259. };
  260. static struct at24_platform_data board_eeprom = {
  261. .byte_len = 4096,
  262. .page_size = 32,
  263. .flags = AT24_FLAG_ADDR16,
  264. };
  265. static int pcm037_camera_power(struct device *dev, int on)
  266. {
  267. /* disable or enable the camera in X7 or X8 PCM970 connector */
  268. gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), !on);
  269. return 0;
  270. }
  271. static struct i2c_board_info pcm037_i2c_camera[] = {
  272. {
  273. I2C_BOARD_INFO("mt9t031", 0x5d),
  274. }, {
  275. I2C_BOARD_INFO("mt9v022", 0x48),
  276. },
  277. };
  278. static struct soc_camera_link iclink_mt9v022 = {
  279. .bus_id = 0, /* Must match with the camera ID */
  280. .board_info = &pcm037_i2c_camera[1],
  281. .i2c_adapter_id = 2,
  282. };
  283. static struct soc_camera_link iclink_mt9t031 = {
  284. .bus_id = 0, /* Must match with the camera ID */
  285. .power = pcm037_camera_power,
  286. .board_info = &pcm037_i2c_camera[0],
  287. .i2c_adapter_id = 2,
  288. };
  289. static struct i2c_board_info pcm037_i2c_devices[] = {
  290. {
  291. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  292. .platform_data = &board_eeprom,
  293. }, {
  294. I2C_BOARD_INFO("pcf8563", 0x51),
  295. }
  296. };
  297. static struct platform_device pcm037_mt9t031 = {
  298. .name = "soc-camera-pdrv",
  299. .id = 0,
  300. .dev = {
  301. .platform_data = &iclink_mt9t031,
  302. },
  303. };
  304. static struct platform_device pcm037_mt9v022 = {
  305. .name = "soc-camera-pdrv",
  306. .id = 1,
  307. .dev = {
  308. .platform_data = &iclink_mt9v022,
  309. },
  310. };
  311. /* Not connected by default */
  312. #ifdef PCM970_SDHC_RW_SWITCH
  313. static int pcm970_sdhc1_get_ro(struct device *dev)
  314. {
  315. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  316. }
  317. #endif
  318. #define SDHC1_GPIO_WP IOMUX_TO_GPIO(MX31_PIN_SFS6)
  319. #define SDHC1_GPIO_DET IOMUX_TO_GPIO(MX31_PIN_SCK6)
  320. static int pcm970_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
  321. void *data)
  322. {
  323. int ret;
  324. ret = gpio_request(SDHC1_GPIO_DET, "sdhc-detect");
  325. if (ret)
  326. return ret;
  327. gpio_direction_input(SDHC1_GPIO_DET);
  328. #ifdef PCM970_SDHC_RW_SWITCH
  329. ret = gpio_request(SDHC1_GPIO_WP, "sdhc-wp");
  330. if (ret)
  331. goto err_gpio_free;
  332. gpio_direction_input(SDHC1_GPIO_WP);
  333. #endif
  334. ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SCK6)), detect_irq,
  335. IRQF_TRIGGER_FALLING, "sdhc-detect", data);
  336. if (ret)
  337. goto err_gpio_free_2;
  338. return 0;
  339. err_gpio_free_2:
  340. #ifdef PCM970_SDHC_RW_SWITCH
  341. gpio_free(SDHC1_GPIO_WP);
  342. err_gpio_free:
  343. #endif
  344. gpio_free(SDHC1_GPIO_DET);
  345. return ret;
  346. }
  347. static void pcm970_sdhc1_exit(struct device *dev, void *data)
  348. {
  349. free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SCK6)), data);
  350. gpio_free(SDHC1_GPIO_DET);
  351. gpio_free(SDHC1_GPIO_WP);
  352. }
  353. static const struct imxmmc_platform_data sdhc_pdata __initconst = {
  354. #ifdef PCM970_SDHC_RW_SWITCH
  355. .get_ro = pcm970_sdhc1_get_ro,
  356. #endif
  357. .init = pcm970_sdhc1_init,
  358. .exit = pcm970_sdhc1_exit,
  359. };
  360. struct mx3_camera_pdata camera_pdata __initdata = {
  361. .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10,
  362. .mclk_10khz = 2000,
  363. };
  364. static phys_addr_t mx3_camera_base __initdata;
  365. #define MX3_CAMERA_BUF_SIZE SZ_4M
  366. static int __init pcm037_init_camera(void)
  367. {
  368. int dma, ret = -ENOMEM;
  369. struct platform_device *pdev = imx31_alloc_mx3_camera(&camera_pdata);
  370. if (IS_ERR(pdev))
  371. return PTR_ERR(pdev);
  372. dma = dma_declare_coherent_memory(&pdev->dev,
  373. mx3_camera_base, mx3_camera_base,
  374. MX3_CAMERA_BUF_SIZE,
  375. DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
  376. if (!(dma & DMA_MEMORY_MAP))
  377. goto err;
  378. ret = platform_device_add(pdev);
  379. if (ret)
  380. err:
  381. platform_device_put(pdev);
  382. return ret;
  383. }
  384. static struct platform_device *devices[] __initdata = {
  385. &pcm037_flash,
  386. &pcm037_sram_device,
  387. &pcm037_mt9t031,
  388. &pcm037_mt9v022,
  389. };
  390. static const struct fb_videomode fb_modedb[] = {
  391. {
  392. /* 240x320 @ 60 Hz Sharp */
  393. .name = "Sharp-LQ035Q7DH06-QVGA",
  394. .refresh = 60,
  395. .xres = 240,
  396. .yres = 320,
  397. .pixclock = 185925,
  398. .left_margin = 9,
  399. .right_margin = 16,
  400. .upper_margin = 7,
  401. .lower_margin = 9,
  402. .hsync_len = 1,
  403. .vsync_len = 1,
  404. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_SHARP_MODE |
  405. FB_SYNC_CLK_INVERT | FB_SYNC_CLK_IDLE_EN,
  406. .vmode = FB_VMODE_NONINTERLACED,
  407. .flag = 0,
  408. }, {
  409. /* 240x320 @ 60 Hz */
  410. .name = "TX090",
  411. .refresh = 60,
  412. .xres = 240,
  413. .yres = 320,
  414. .pixclock = 38255,
  415. .left_margin = 144,
  416. .right_margin = 0,
  417. .upper_margin = 7,
  418. .lower_margin = 40,
  419. .hsync_len = 96,
  420. .vsync_len = 1,
  421. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
  422. .vmode = FB_VMODE_NONINTERLACED,
  423. .flag = 0,
  424. }, {
  425. /* 240x320 @ 60 Hz */
  426. .name = "CMEL-OLED",
  427. .refresh = 60,
  428. .xres = 240,
  429. .yres = 320,
  430. .pixclock = 185925,
  431. .left_margin = 9,
  432. .right_margin = 16,
  433. .upper_margin = 7,
  434. .lower_margin = 9,
  435. .hsync_len = 1,
  436. .vsync_len = 1,
  437. .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
  438. .vmode = FB_VMODE_NONINTERLACED,
  439. .flag = 0,
  440. },
  441. };
  442. static struct mx3fb_platform_data mx3fb_pdata = {
  443. .name = "Sharp-LQ035Q7DH06-QVGA",
  444. .mode = fb_modedb,
  445. .num_modes = ARRAY_SIZE(fb_modedb),
  446. };
  447. static struct resource pcm970_sja1000_resources[] = {
  448. {
  449. .start = MX31_CS5_BASE_ADDR,
  450. .end = MX31_CS5_BASE_ADDR + 0x100 - 1,
  451. .flags = IORESOURCE_MEM,
  452. }, {
  453. /* irq number is run-time assigned */
  454. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  455. },
  456. };
  457. struct sja1000_platform_data pcm970_sja1000_platform_data = {
  458. .osc_freq = 16000000,
  459. .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
  460. .cdr = CDR_CBP,
  461. };
  462. static struct platform_device pcm970_sja1000 = {
  463. .name = "sja1000_platform",
  464. .dev = {
  465. .platform_data = &pcm970_sja1000_platform_data,
  466. },
  467. .resource = pcm970_sja1000_resources,
  468. .num_resources = ARRAY_SIZE(pcm970_sja1000_resources),
  469. };
  470. static int pcm037_otg_init(struct platform_device *pdev)
  471. {
  472. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
  473. }
  474. static struct mxc_usbh_platform_data otg_pdata __initdata = {
  475. .init = pcm037_otg_init,
  476. .portsc = MXC_EHCI_MODE_ULPI,
  477. };
  478. static int pcm037_usbh2_init(struct platform_device *pdev)
  479. {
  480. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
  481. }
  482. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  483. .init = pcm037_usbh2_init,
  484. .portsc = MXC_EHCI_MODE_ULPI,
  485. };
  486. static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
  487. .operating_mode = FSL_USB2_DR_DEVICE,
  488. .phy_mode = FSL_USB2_PHY_ULPI,
  489. };
  490. static bool otg_mode_host __initdata;
  491. static int __init pcm037_otg_mode(char *options)
  492. {
  493. if (!strcmp(options, "host"))
  494. otg_mode_host = true;
  495. else if (!strcmp(options, "device"))
  496. otg_mode_host = false;
  497. else
  498. pr_info("otg_mode neither \"host\" nor \"device\". "
  499. "Defaulting to device\n");
  500. return 1;
  501. }
  502. __setup("otg_mode=", pcm037_otg_mode);
  503. static struct regulator_consumer_supply dummy_supplies[] = {
  504. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  505. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  506. };
  507. /*
  508. * Board specific initialization.
  509. */
  510. static void __init pcm037_init(void)
  511. {
  512. imx31_soc_init();
  513. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  514. mxc_iomux_set_gpr(MUX_PGP_UH2, 1);
  515. mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins),
  516. "pcm037");
  517. #define H2_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS \
  518. | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  519. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, H2_PAD_CFG);
  520. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, H2_PAD_CFG);
  521. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, H2_PAD_CFG);
  522. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, H2_PAD_CFG);
  523. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, H2_PAD_CFG); /* USBH2_DATA0 */
  524. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, H2_PAD_CFG); /* USBH2_DATA1 */
  525. mxc_iomux_set_pad(MX31_PIN_SRXD6, H2_PAD_CFG); /* USBH2_DATA2 */
  526. mxc_iomux_set_pad(MX31_PIN_STXD6, H2_PAD_CFG); /* USBH2_DATA3 */
  527. mxc_iomux_set_pad(MX31_PIN_SFS3, H2_PAD_CFG); /* USBH2_DATA4 */
  528. mxc_iomux_set_pad(MX31_PIN_SCK3, H2_PAD_CFG); /* USBH2_DATA5 */
  529. mxc_iomux_set_pad(MX31_PIN_SRXD3, H2_PAD_CFG); /* USBH2_DATA6 */
  530. mxc_iomux_set_pad(MX31_PIN_STXD3, H2_PAD_CFG); /* USBH2_DATA7 */
  531. if (pcm037_variant() == PCM037_EET)
  532. mxc_iomux_setup_multiple_pins(pcm037_uart1_pins,
  533. ARRAY_SIZE(pcm037_uart1_pins), "pcm037_uart1");
  534. else
  535. mxc_iomux_setup_multiple_pins(pcm037_uart1_handshake_pins,
  536. ARRAY_SIZE(pcm037_uart1_handshake_pins),
  537. "pcm037_uart1");
  538. platform_add_devices(devices, ARRAY_SIZE(devices));
  539. imx31_add_imx2_wdt();
  540. imx31_add_imx_uart0(&uart_pdata);
  541. /* XXX: should't this have .flags = 0 (i.e. no RTSCTS) on PCM037_EET? */
  542. imx31_add_imx_uart1(&uart_pdata);
  543. imx31_add_imx_uart2(&uart_pdata);
  544. imx31_add_mxc_w1();
  545. /* I2C adapters and devices */
  546. i2c_register_board_info(1, pcm037_i2c_devices,
  547. ARRAY_SIZE(pcm037_i2c_devices));
  548. imx31_add_imx_i2c1(&pcm037_i2c1_data);
  549. imx31_add_imx_i2c2(&pcm037_i2c2_data);
  550. imx31_add_mxc_nand(&pcm037_nand_board_info);
  551. imx31_add_ipu_core();
  552. imx31_add_mx3_sdc_fb(&mx3fb_pdata);
  553. if (otg_mode_host) {
  554. otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  555. ULPI_OTG_DRVVBUS_EXT);
  556. if (otg_pdata.otg)
  557. imx31_add_mxc_ehci_otg(&otg_pdata);
  558. }
  559. usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  560. ULPI_OTG_DRVVBUS_EXT);
  561. if (usbh2_pdata.otg)
  562. imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
  563. if (!otg_mode_host)
  564. imx31_add_fsl_usb2_udc(&otg_device_pdata);
  565. }
  566. static void __init pcm037_timer_init(void)
  567. {
  568. mx31_clocks_init(26000000);
  569. }
  570. static void __init pcm037_reserve(void)
  571. {
  572. /* reserve 4 MiB for mx3-camera */
  573. mx3_camera_base = arm_memblock_steal(MX3_CAMERA_BUF_SIZE,
  574. MX3_CAMERA_BUF_SIZE);
  575. }
  576. static void __init pcm037_init_late(void)
  577. {
  578. int ret;
  579. /* LAN9217 IRQ pin */
  580. ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1), "lan9217-irq");
  581. if (!ret) {
  582. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
  583. smsc911x_resources[1].start =
  584. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
  585. smsc911x_resources[1].end =
  586. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
  587. platform_device_register(&pcm037_eth);
  588. } else {
  589. pr_warn("could not get LAN irq gpio\n");
  590. }
  591. imx31_add_mxc_mmc(0, &sdhc_pdata);
  592. /* CSI */
  593. /* Camera power: default - off */
  594. ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), "mt9t031-power");
  595. if (!ret)
  596. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), 1);
  597. else
  598. iclink_mt9t031.power = NULL;
  599. pcm037_init_camera();
  600. pcm970_sja1000_resources[1].start =
  601. gpio_to_irq(IOMUX_TO_GPIO(IOMUX_PIN(48, 105)));
  602. pcm970_sja1000_resources[1].end =
  603. gpio_to_irq(IOMUX_TO_GPIO(IOMUX_PIN(48, 105)));
  604. platform_device_register(&pcm970_sja1000);
  605. pcm037_eet_init_devices();
  606. }
  607. MACHINE_START(PCM037, "Phytec Phycore pcm037")
  608. /* Maintainer: Pengutronix */
  609. .atag_offset = 0x100,
  610. .reserve = pcm037_reserve,
  611. .map_io = mx31_map_io,
  612. .init_early = imx31_init_early,
  613. .init_irq = mx31_init_irq,
  614. .init_time = pcm037_timer_init,
  615. .init_machine = pcm037_init,
  616. .init_late = pcm037_init_late,
  617. .restart = mxc_restart,
  618. MACHINE_END