mach-cpuimx27.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright (C) 2009 Eric Benard - eric@eukrea.com
  3. *
  4. * Based on pcm038.c which is :
  5. * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  6. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. * MA 02110-1301, USA.
  21. */
  22. #include <linux/i2c.h>
  23. #include <linux/io.h>
  24. #include <linux/mtd/plat-ram.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/serial_8250.h>
  28. #include <linux/usb/otg.h>
  29. #include <linux/usb/ulpi.h>
  30. #include <linux/fsl_devices.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/time.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/eukrea-baseboards.h>
  36. #include <mach/common.h>
  37. #include <mach/hardware.h>
  38. #include <mach/iomux-mx27.h>
  39. #include <mach/mxc_nand.h>
  40. #include <mach/mxc_ehci.h>
  41. #include <mach/ulpi.h>
  42. #include "devices-imx27.h"
  43. #include "devices.h"
  44. static int eukrea_cpuimx27_pins[] = {
  45. /* UART1 */
  46. PE12_PF_UART1_TXD,
  47. PE13_PF_UART1_RXD,
  48. PE14_PF_UART1_CTS,
  49. PE15_PF_UART1_RTS,
  50. /* UART4 */
  51. #if defined(MACH_EUKREA_CPUIMX27_USEUART4)
  52. PB26_AF_UART4_RTS,
  53. PB28_AF_UART4_TXD,
  54. PB29_AF_UART4_CTS,
  55. PB31_AF_UART4_RXD,
  56. #endif
  57. /* FEC */
  58. PD0_AIN_FEC_TXD0,
  59. PD1_AIN_FEC_TXD1,
  60. PD2_AIN_FEC_TXD2,
  61. PD3_AIN_FEC_TXD3,
  62. PD4_AOUT_FEC_RX_ER,
  63. PD5_AOUT_FEC_RXD1,
  64. PD6_AOUT_FEC_RXD2,
  65. PD7_AOUT_FEC_RXD3,
  66. PD8_AF_FEC_MDIO,
  67. PD9_AIN_FEC_MDC,
  68. PD10_AOUT_FEC_CRS,
  69. PD11_AOUT_FEC_TX_CLK,
  70. PD12_AOUT_FEC_RXD0,
  71. PD13_AOUT_FEC_RX_DV,
  72. PD14_AOUT_FEC_RX_CLK,
  73. PD15_AOUT_FEC_COL,
  74. PD16_AIN_FEC_TX_ER,
  75. PF23_AIN_FEC_TX_EN,
  76. /* I2C1 */
  77. PD17_PF_I2C_DATA,
  78. PD18_PF_I2C_CLK,
  79. /* SDHC2 */
  80. #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
  81. PB4_PF_SD2_D0,
  82. PB5_PF_SD2_D1,
  83. PB6_PF_SD2_D2,
  84. PB7_PF_SD2_D3,
  85. PB8_PF_SD2_CMD,
  86. PB9_PF_SD2_CLK,
  87. #endif
  88. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  89. /* Quad UART's IRQ */
  90. GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN,
  91. GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN,
  92. GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN,
  93. GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN,
  94. #endif
  95. /* OTG */
  96. PC7_PF_USBOTG_DATA5,
  97. PC8_PF_USBOTG_DATA6,
  98. PC9_PF_USBOTG_DATA0,
  99. PC10_PF_USBOTG_DATA2,
  100. PC11_PF_USBOTG_DATA1,
  101. PC12_PF_USBOTG_DATA4,
  102. PC13_PF_USBOTG_DATA3,
  103. PE0_PF_USBOTG_NXT,
  104. PE1_PF_USBOTG_STP,
  105. PE2_PF_USBOTG_DIR,
  106. PE24_PF_USBOTG_CLK,
  107. PE25_PF_USBOTG_DATA7,
  108. /* USBH2 */
  109. PA0_PF_USBH2_CLK,
  110. PA1_PF_USBH2_DIR,
  111. PA2_PF_USBH2_DATA7,
  112. PA3_PF_USBH2_NXT,
  113. PA4_PF_USBH2_STP,
  114. PD19_AF_USBH2_DATA4,
  115. PD20_AF_USBH2_DATA3,
  116. PD21_AF_USBH2_DATA6,
  117. PD22_AF_USBH2_DATA0,
  118. PD23_AF_USBH2_DATA2,
  119. PD24_AF_USBH2_DATA1,
  120. PD26_AF_USBH2_DATA5,
  121. };
  122. static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
  123. .width = 2,
  124. };
  125. static struct resource eukrea_cpuimx27_flash_resource = {
  126. .start = 0xc0000000,
  127. .end = 0xc3ffffff,
  128. .flags = IORESOURCE_MEM,
  129. };
  130. static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
  131. .name = "physmap-flash",
  132. .id = 0,
  133. .dev = {
  134. .platform_data = &eukrea_cpuimx27_flash_data,
  135. },
  136. .num_resources = 1,
  137. .resource = &eukrea_cpuimx27_flash_resource,
  138. };
  139. static const struct imxuart_platform_data uart_pdata __initconst = {
  140. .flags = IMXUART_HAVE_RTSCTS,
  141. };
  142. static const struct mxc_nand_platform_data
  143. cpuimx27_nand_board_info __initconst = {
  144. .width = 1,
  145. .hw_ecc = 1,
  146. };
  147. static struct platform_device *platform_devices[] __initdata = {
  148. &eukrea_cpuimx27_nor_mtd_device,
  149. &mxc_fec_device,
  150. &mxc_wdt,
  151. &mxc_w1_master_device,
  152. };
  153. static const struct imxi2c_platform_data cpuimx27_i2c1_data __initconst = {
  154. .bitrate = 100000,
  155. };
  156. static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
  157. {
  158. I2C_BOARD_INFO("pcf8563", 0x51),
  159. },
  160. };
  161. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  162. static struct plat_serial8250_port serial_platform_data[] = {
  163. {
  164. .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
  165. .irq = IRQ_GPIOB(23),
  166. .uartclk = 14745600,
  167. .regshift = 1,
  168. .iotype = UPIO_MEM,
  169. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
  170. }, {
  171. .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
  172. .irq = IRQ_GPIOB(22),
  173. .uartclk = 14745600,
  174. .regshift = 1,
  175. .iotype = UPIO_MEM,
  176. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
  177. }, {
  178. .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
  179. .irq = IRQ_GPIOB(27),
  180. .uartclk = 14745600,
  181. .regshift = 1,
  182. .iotype = UPIO_MEM,
  183. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
  184. }, {
  185. .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
  186. .irq = IRQ_GPIOB(30),
  187. .uartclk = 14745600,
  188. .regshift = 1,
  189. .iotype = UPIO_MEM,
  190. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
  191. }, {
  192. }
  193. };
  194. static struct platform_device serial_device = {
  195. .name = "serial8250",
  196. .id = 0,
  197. .dev = {
  198. .platform_data = serial_platform_data,
  199. },
  200. };
  201. #endif
  202. #if defined(CONFIG_USB_ULPI)
  203. static struct mxc_usbh_platform_data otg_pdata = {
  204. .portsc = MXC_EHCI_MODE_ULPI,
  205. .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
  206. };
  207. static struct mxc_usbh_platform_data usbh2_pdata = {
  208. .portsc = MXC_EHCI_MODE_ULPI,
  209. .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
  210. };
  211. #endif
  212. static struct fsl_usb2_platform_data otg_device_pdata = {
  213. .operating_mode = FSL_USB2_DR_DEVICE,
  214. .phy_mode = FSL_USB2_PHY_ULPI,
  215. };
  216. static int otg_mode_host;
  217. static int __init eukrea_cpuimx27_otg_mode(char *options)
  218. {
  219. if (!strcmp(options, "host"))
  220. otg_mode_host = 1;
  221. else if (!strcmp(options, "device"))
  222. otg_mode_host = 0;
  223. else
  224. pr_info("otg_mode neither \"host\" nor \"device\". "
  225. "Defaulting to device\n");
  226. return 0;
  227. }
  228. __setup("otg_mode=", eukrea_cpuimx27_otg_mode);
  229. static void __init eukrea_cpuimx27_init(void)
  230. {
  231. mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
  232. ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
  233. imx27_add_imx_uart0(&uart_pdata);
  234. imx27_add_mxc_nand(&cpuimx27_nand_board_info);
  235. i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
  236. ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
  237. imx27_add_i2c_imx1(&cpuimx27_i2c1_data);
  238. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  239. #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
  240. /* SDHC2 can be used for Wifi */
  241. mxc_register_device(&mxc_sdhc_device1, NULL);
  242. #endif
  243. #if defined(MACH_EUKREA_CPUIMX27_USEUART4)
  244. /* in which case UART4 is also used for Bluetooth */
  245. imx27_add_imx_uart3(&uart_pdata);
  246. #endif
  247. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  248. platform_device_register(&serial_device);
  249. #endif
  250. #if defined(CONFIG_USB_ULPI)
  251. if (otg_mode_host) {
  252. otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  253. ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
  254. mxc_register_device(&mxc_otg_host, &otg_pdata);
  255. }
  256. usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  257. ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
  258. mxc_register_device(&mxc_usbh2, &usbh2_pdata);
  259. #endif
  260. if (!otg_mode_host)
  261. mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
  262. #ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
  263. eukrea_mbimx27_baseboard_init();
  264. #endif
  265. }
  266. static void __init eukrea_cpuimx27_timer_init(void)
  267. {
  268. mx27_clocks_init(26000000);
  269. }
  270. static struct sys_timer eukrea_cpuimx27_timer = {
  271. .init = eukrea_cpuimx27_timer_init,
  272. };
  273. MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
  274. .phys_io = MX27_AIPI_BASE_ADDR,
  275. .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  276. .boot_params = MX27_PHYS_OFFSET + 0x100,
  277. .map_io = mx27_map_io,
  278. .init_irq = mx27_init_irq,
  279. .init_machine = eukrea_cpuimx27_init,
  280. .timer = &eukrea_cpuimx27_timer,
  281. MACHINE_END