mach-pca100.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*
  2. * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  3. * Copyright (C) 2009 Sascha Hauer (kernel@pengutronix.de)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  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. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/i2c.h>
  22. #include <linux/i2c/at24.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/eeprom.h>
  26. #include <linux/irq.h>
  27. #include <linux/delay.h>
  28. #include <linux/gpio.h>
  29. #include <linux/usb/otg.h>
  30. #include <linux/usb/ulpi.h>
  31. #include <linux/fsl_devices.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach-types.h>
  34. #include <mach/common.h>
  35. #include <mach/hardware.h>
  36. #include <mach/iomux-mx27.h>
  37. #include <asm/mach/time.h>
  38. #include <mach/audmux.h>
  39. #include <mach/mxc_nand.h>
  40. #include <mach/irqs.h>
  41. #include <mach/ulpi.h>
  42. #include "devices-imx27.h"
  43. #include "devices.h"
  44. #define OTG_PHY_CS_GPIO (GPIO_PORTB + 23)
  45. #define USBH2_PHY_CS_GPIO (GPIO_PORTB + 24)
  46. #define SPI1_SS0 (GPIO_PORTD + 28)
  47. #define SPI1_SS1 (GPIO_PORTD + 27)
  48. #define SD2_CD (GPIO_PORTC + 29)
  49. static const int pca100_pins[] __initconst = {
  50. /* UART1 */
  51. PE12_PF_UART1_TXD,
  52. PE13_PF_UART1_RXD,
  53. PE14_PF_UART1_CTS,
  54. PE15_PF_UART1_RTS,
  55. /* SDHC */
  56. PB4_PF_SD2_D0,
  57. PB5_PF_SD2_D1,
  58. PB6_PF_SD2_D2,
  59. PB7_PF_SD2_D3,
  60. PB8_PF_SD2_CMD,
  61. PB9_PF_SD2_CLK,
  62. SD2_CD | GPIO_GPIO | GPIO_IN,
  63. /* FEC */
  64. PD0_AIN_FEC_TXD0,
  65. PD1_AIN_FEC_TXD1,
  66. PD2_AIN_FEC_TXD2,
  67. PD3_AIN_FEC_TXD3,
  68. PD4_AOUT_FEC_RX_ER,
  69. PD5_AOUT_FEC_RXD1,
  70. PD6_AOUT_FEC_RXD2,
  71. PD7_AOUT_FEC_RXD3,
  72. PD8_AF_FEC_MDIO,
  73. PD9_AIN_FEC_MDC,
  74. PD10_AOUT_FEC_CRS,
  75. PD11_AOUT_FEC_TX_CLK,
  76. PD12_AOUT_FEC_RXD0,
  77. PD13_AOUT_FEC_RX_DV,
  78. PD14_AOUT_FEC_RX_CLK,
  79. PD15_AOUT_FEC_COL,
  80. PD16_AIN_FEC_TX_ER,
  81. PF23_AIN_FEC_TX_EN,
  82. /* SSI1 */
  83. PC20_PF_SSI1_FS,
  84. PC21_PF_SSI1_RXD,
  85. PC22_PF_SSI1_TXD,
  86. PC23_PF_SSI1_CLK,
  87. /* onboard I2C */
  88. PC5_PF_I2C2_SDA,
  89. PC6_PF_I2C2_SCL,
  90. /* external I2C */
  91. PD17_PF_I2C_DATA,
  92. PD18_PF_I2C_CLK,
  93. /* SPI1 */
  94. PD25_PF_CSPI1_RDY,
  95. PD29_PF_CSPI1_SCLK,
  96. PD30_PF_CSPI1_MISO,
  97. PD31_PF_CSPI1_MOSI,
  98. /* OTG */
  99. OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
  100. PC7_PF_USBOTG_DATA5,
  101. PC8_PF_USBOTG_DATA6,
  102. PC9_PF_USBOTG_DATA0,
  103. PC10_PF_USBOTG_DATA2,
  104. PC11_PF_USBOTG_DATA1,
  105. PC12_PF_USBOTG_DATA4,
  106. PC13_PF_USBOTG_DATA3,
  107. PE0_PF_USBOTG_NXT,
  108. PE1_PF_USBOTG_STP,
  109. PE2_PF_USBOTG_DIR,
  110. PE24_PF_USBOTG_CLK,
  111. PE25_PF_USBOTG_DATA7,
  112. /* USBH2 */
  113. USBH2_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
  114. PA0_PF_USBH2_CLK,
  115. PA1_PF_USBH2_DIR,
  116. PA2_PF_USBH2_DATA7,
  117. PA3_PF_USBH2_NXT,
  118. PA4_PF_USBH2_STP,
  119. PD19_AF_USBH2_DATA4,
  120. PD20_AF_USBH2_DATA3,
  121. PD21_AF_USBH2_DATA6,
  122. PD22_AF_USBH2_DATA0,
  123. PD23_AF_USBH2_DATA2,
  124. PD24_AF_USBH2_DATA1,
  125. PD26_AF_USBH2_DATA5,
  126. /* display */
  127. PA5_PF_LSCLK,
  128. PA6_PF_LD0,
  129. PA7_PF_LD1,
  130. PA8_PF_LD2,
  131. PA9_PF_LD3,
  132. PA10_PF_LD4,
  133. PA11_PF_LD5,
  134. PA12_PF_LD6,
  135. PA13_PF_LD7,
  136. PA14_PF_LD8,
  137. PA15_PF_LD9,
  138. PA16_PF_LD10,
  139. PA17_PF_LD11,
  140. PA18_PF_LD12,
  141. PA19_PF_LD13,
  142. PA20_PF_LD14,
  143. PA21_PF_LD15,
  144. PA22_PF_LD16,
  145. PA23_PF_LD17,
  146. PA26_PF_PS,
  147. PA28_PF_HSYNC,
  148. PA29_PF_VSYNC,
  149. PA31_PF_OE_ACD,
  150. /* free GPIO */
  151. GPIO_PORTC | 31 | GPIO_GPIO | GPIO_IN, /* GPIO0_IRQ */
  152. GPIO_PORTC | 25 | GPIO_GPIO | GPIO_IN, /* GPIO1_IRQ */
  153. GPIO_PORTE | 5 | GPIO_GPIO | GPIO_IN, /* GPIO2_IRQ */
  154. };
  155. static const struct imxuart_platform_data uart_pdata __initconst = {
  156. .flags = IMXUART_HAVE_RTSCTS,
  157. };
  158. static const struct mxc_nand_platform_data
  159. pca100_nand_board_info __initconst = {
  160. .width = 1,
  161. .hw_ecc = 1,
  162. };
  163. static const struct imxi2c_platform_data pca100_i2c1_data __initconst = {
  164. .bitrate = 100000,
  165. };
  166. static struct at24_platform_data board_eeprom = {
  167. .byte_len = 4096,
  168. .page_size = 32,
  169. .flags = AT24_FLAG_ADDR16,
  170. };
  171. static struct i2c_board_info pca100_i2c_devices[] = {
  172. {
  173. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  174. .platform_data = &board_eeprom,
  175. }, {
  176. I2C_BOARD_INFO("pcf8563", 0x51),
  177. }, {
  178. I2C_BOARD_INFO("lm75", 0x4a),
  179. }
  180. };
  181. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  182. static struct spi_eeprom at25320 = {
  183. .name = "at25320an",
  184. .byte_len = 4096,
  185. .page_size = 32,
  186. .flags = EE_ADDR2,
  187. };
  188. static struct spi_board_info pca100_spi_board_info[] __initdata = {
  189. {
  190. .modalias = "at25",
  191. .max_speed_hz = 30000,
  192. .bus_num = 0,
  193. .chip_select = 1,
  194. .platform_data = &at25320,
  195. },
  196. };
  197. static int pca100_spi_cs[] = {SPI1_SS0, SPI1_SS1};
  198. static const struct spi_imx_master pca100_spi0_data __initconst = {
  199. .chipselect = pca100_spi_cs,
  200. .num_chipselect = ARRAY_SIZE(pca100_spi_cs),
  201. };
  202. #endif
  203. static void pca100_ac97_warm_reset(struct snd_ac97 *ac97)
  204. {
  205. mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT);
  206. gpio_set_value(GPIO_PORTC + 20, 1);
  207. udelay(2);
  208. gpio_set_value(GPIO_PORTC + 20, 0);
  209. mxc_gpio_mode(PC20_PF_SSI1_FS);
  210. msleep(2);
  211. }
  212. static void pca100_ac97_cold_reset(struct snd_ac97 *ac97)
  213. {
  214. mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); /* FS */
  215. gpio_set_value(GPIO_PORTC + 20, 0);
  216. mxc_gpio_mode(GPIO_PORTC | 22 | GPIO_GPIO | GPIO_OUT); /* TX */
  217. gpio_set_value(GPIO_PORTC + 22, 0);
  218. mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_OUT); /* reset */
  219. gpio_set_value(GPIO_PORTC + 28, 0);
  220. udelay(10);
  221. gpio_set_value(GPIO_PORTC + 28, 1);
  222. mxc_gpio_mode(PC20_PF_SSI1_FS);
  223. mxc_gpio_mode(PC22_PF_SSI1_TXD);
  224. msleep(2);
  225. }
  226. static const struct imx_ssi_platform_data pca100_ssi_pdata __initconst = {
  227. .ac97_reset = pca100_ac97_cold_reset,
  228. .ac97_warm_reset = pca100_ac97_warm_reset,
  229. .flags = IMX_SSI_USE_AC97,
  230. };
  231. static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
  232. void *data)
  233. {
  234. int ret;
  235. ret = request_irq(IRQ_GPIOC(29), detect_irq,
  236. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  237. "imx-mmc-detect", data);
  238. if (ret)
  239. printk(KERN_ERR
  240. "pca100: Failed to reuest irq for sd/mmc detection\n");
  241. return ret;
  242. }
  243. static void pca100_sdhc2_exit(struct device *dev, void *data)
  244. {
  245. free_irq(IRQ_GPIOC(29), data);
  246. }
  247. static const struct imxmmc_platform_data sdhc_pdata __initconst = {
  248. .init = pca100_sdhc2_init,
  249. .exit = pca100_sdhc2_exit,
  250. };
  251. #if defined(CONFIG_USB_ULPI)
  252. static int otg_phy_init(struct platform_device *pdev)
  253. {
  254. gpio_set_value(OTG_PHY_CS_GPIO, 0);
  255. return 0;
  256. }
  257. static struct mxc_usbh_platform_data otg_pdata __initdata = {
  258. .init = otg_phy_init,
  259. .portsc = MXC_EHCI_MODE_ULPI,
  260. .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
  261. };
  262. static int usbh2_phy_init(struct platform_device *pdev)
  263. {
  264. gpio_set_value(USBH2_PHY_CS_GPIO, 0);
  265. return 0;
  266. }
  267. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  268. .init = usbh2_phy_init,
  269. .portsc = MXC_EHCI_MODE_ULPI,
  270. .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
  271. };
  272. #endif
  273. static struct fsl_usb2_platform_data otg_device_pdata = {
  274. .operating_mode = FSL_USB2_DR_DEVICE,
  275. .phy_mode = FSL_USB2_PHY_ULPI,
  276. };
  277. static int otg_mode_host;
  278. static int __init pca100_otg_mode(char *options)
  279. {
  280. if (!strcmp(options, "host"))
  281. otg_mode_host = 1;
  282. else if (!strcmp(options, "device"))
  283. otg_mode_host = 0;
  284. else
  285. pr_info("otg_mode neither \"host\" nor \"device\". "
  286. "Defaulting to device\n");
  287. return 0;
  288. }
  289. __setup("otg_mode=", pca100_otg_mode);
  290. /* framebuffer info */
  291. static struct imx_fb_videomode pca100_fb_modes[] = {
  292. {
  293. .mode = {
  294. .name = "EMERGING-ETV570G0DHU",
  295. .refresh = 60,
  296. .xres = 640,
  297. .yres = 480,
  298. .pixclock = 39722, /* in ps (25.175 MHz) */
  299. .hsync_len = 30,
  300. .left_margin = 114,
  301. .right_margin = 16,
  302. .vsync_len = 3,
  303. .upper_margin = 32,
  304. .lower_margin = 0,
  305. },
  306. /*
  307. * TFT
  308. * Pixel pol active high
  309. * HSYNC active low
  310. * VSYNC active low
  311. * use HSYNC for ACD count
  312. * line clock disable while idle
  313. * always enable line clock even if no data
  314. */
  315. .pcr = 0xf0c08080,
  316. .bpp = 16,
  317. },
  318. };
  319. static const struct imx_fb_platform_data pca100_fb_data __initconst = {
  320. .mode = pca100_fb_modes,
  321. .num_modes = ARRAY_SIZE(pca100_fb_modes),
  322. .pwmr = 0x00A903FF,
  323. .lscr1 = 0x00120300,
  324. .dmacr = 0x00020010,
  325. };
  326. static void __init pca100_init(void)
  327. {
  328. int ret;
  329. /* SSI unit */
  330. mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
  331. MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  332. MXC_AUDMUX_V1_PCR_TFCSEL(3) |
  333. MXC_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
  334. MXC_AUDMUX_V1_PCR_RXDSEL(3));
  335. mxc_audmux_v1_configure_port(3,
  336. MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  337. MXC_AUDMUX_V1_PCR_TFCSEL(0) |
  338. MXC_AUDMUX_V1_PCR_TFSDIR |
  339. MXC_AUDMUX_V1_PCR_RXDSEL(0));
  340. ret = mxc_gpio_setup_multiple_pins(pca100_pins,
  341. ARRAY_SIZE(pca100_pins), "PCA100");
  342. if (ret)
  343. printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret);
  344. imx27_add_imx_ssi(0, &pca100_ssi_pdata);
  345. imx27_add_imx_uart0(&uart_pdata);
  346. imx27_add_mxc_mmc(1, &sdhc_pdata);
  347. imx27_add_mxc_nand(&pca100_nand_board_info);
  348. /* only the i2c master 1 is used on this CPU card */
  349. i2c_register_board_info(1, pca100_i2c_devices,
  350. ARRAY_SIZE(pca100_i2c_devices));
  351. imx27_add_imx_i2c(1, &pca100_i2c1_data);
  352. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  353. mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_IN);
  354. mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN);
  355. spi_register_board_info(pca100_spi_board_info,
  356. ARRAY_SIZE(pca100_spi_board_info));
  357. imx27_add_spi_imx0(&pca100_spi0_data);
  358. #endif
  359. gpio_request(OTG_PHY_CS_GPIO, "usb-otg-cs");
  360. gpio_direction_output(OTG_PHY_CS_GPIO, 1);
  361. gpio_request(USBH2_PHY_CS_GPIO, "usb-host2-cs");
  362. gpio_direction_output(USBH2_PHY_CS_GPIO, 1);
  363. #if defined(CONFIG_USB_ULPI)
  364. if (otg_mode_host) {
  365. otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  366. ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
  367. imx27_add_mxc_ehci_otg(&otg_pdata);
  368. }
  369. usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  370. ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
  371. imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
  372. #endif
  373. if (!otg_mode_host) {
  374. gpio_set_value(OTG_PHY_CS_GPIO, 0);
  375. mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
  376. }
  377. imx27_add_imx_fb(&pca100_fb_data);
  378. imx27_add_fec(NULL);
  379. imx27_add_imx2_wdt(NULL);
  380. imx27_add_mxc_w1(NULL);
  381. }
  382. static void __init pca100_timer_init(void)
  383. {
  384. mx27_clocks_init(26000000);
  385. }
  386. static struct sys_timer pca100_timer = {
  387. .init = pca100_timer_init,
  388. };
  389. MACHINE_START(PCA100, "phyCARD-i.MX27")
  390. .boot_params = MX27_PHYS_OFFSET + 0x100,
  391. .map_io = mx27_map_io,
  392. .init_irq = mx27_init_irq,
  393. .init_machine = pca100_init,
  394. .timer = &pca100_timer,
  395. MACHINE_END