mach-mx31lite.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * Copyright (C) 2000 Deep Blue Solutions Ltd
  3. * Copyright (C) 2002 Shane Nay (shane@minirl.com)
  4. * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  5. * Copyright (C) 2009 Daniel Mack <daniel@caiaq.de>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  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. #include <linux/types.h>
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/memory.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/gpio.h>
  23. #include <linux/moduleparam.h>
  24. #include <linux/smsc911x.h>
  25. #include <linux/mfd/mc13783.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/usb/otg.h>
  28. #include <linux/usb/ulpi.h>
  29. #include <linux/mtd/physmap.h>
  30. #include <linux/delay.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/regulator/fixed.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/time.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/page.h>
  38. #include <asm/setup.h>
  39. #include "board-mx31lite.h"
  40. #include "common.h"
  41. #include "devices-imx31.h"
  42. #include "ehci.h"
  43. #include "hardware.h"
  44. #include "iomux-mx3.h"
  45. #include "ulpi.h"
  46. /*
  47. * This file contains the module-specific initialization routines.
  48. */
  49. static unsigned int mx31lite_pins[] = {
  50. /* UART1 */
  51. MX31_PIN_CTS1__CTS1,
  52. MX31_PIN_RTS1__RTS1,
  53. MX31_PIN_TXD1__TXD1,
  54. MX31_PIN_RXD1__RXD1,
  55. /* SPI 0 */
  56. MX31_PIN_CSPI1_SCLK__SCLK,
  57. MX31_PIN_CSPI1_MOSI__MOSI,
  58. MX31_PIN_CSPI1_MISO__MISO,
  59. MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
  60. MX31_PIN_CSPI1_SS0__SS0,
  61. MX31_PIN_CSPI1_SS1__SS1,
  62. MX31_PIN_CSPI1_SS2__SS2,
  63. /* LAN9117 IRQ pin */
  64. IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO),
  65. /* SPI 1 */
  66. MX31_PIN_CSPI2_SCLK__SCLK,
  67. MX31_PIN_CSPI2_MOSI__MOSI,
  68. MX31_PIN_CSPI2_MISO__MISO,
  69. MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,
  70. MX31_PIN_CSPI2_SS0__SS0,
  71. MX31_PIN_CSPI2_SS1__SS1,
  72. MX31_PIN_CSPI2_SS2__SS2,
  73. };
  74. /* UART */
  75. static const struct imxuart_platform_data uart_pdata __initconst = {
  76. .flags = IMXUART_HAVE_RTSCTS,
  77. };
  78. /* SPI */
  79. static const struct spi_imx_master spi0_pdata __initconst = {
  80. .num_chipselect = 3,
  81. };
  82. static const struct mxc_nand_platform_data
  83. mx31lite_nand_board_info __initconst = {
  84. .width = 1,
  85. .hw_ecc = 1,
  86. };
  87. static struct smsc911x_platform_config smsc911x_config = {
  88. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  89. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  90. .flags = SMSC911X_USE_16BIT,
  91. };
  92. static struct resource smsc911x_resources[] = {
  93. {
  94. .start = MX31_CS4_BASE_ADDR,
  95. .end = MX31_CS4_BASE_ADDR + 0x100,
  96. .flags = IORESOURCE_MEM,
  97. }, {
  98. /* irq number is run-time assigned */
  99. .flags = IORESOURCE_IRQ,
  100. },
  101. };
  102. static struct platform_device smsc911x_device = {
  103. .name = "smsc911x",
  104. .id = -1,
  105. .num_resources = ARRAY_SIZE(smsc911x_resources),
  106. .resource = smsc911x_resources,
  107. .dev = {
  108. .platform_data = &smsc911x_config,
  109. },
  110. };
  111. /*
  112. * SPI
  113. *
  114. * The MC13783 is the only hard-wired SPI device on the module.
  115. */
  116. static const struct spi_imx_master spi1_pdata __initconst = {
  117. .num_chipselect = 1,
  118. };
  119. static struct mc13xxx_platform_data mc13783_pdata __initdata = {
  120. .flags = MC13XXX_USE_RTC,
  121. };
  122. static struct spi_board_info mc13783_spi_dev __initdata = {
  123. .modalias = "mc13783",
  124. .max_speed_hz = 1000000,
  125. .bus_num = 1,
  126. .chip_select = 0,
  127. .platform_data = &mc13783_pdata,
  128. /* irq number is run-time assigned */
  129. };
  130. /*
  131. * USB
  132. */
  133. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  134. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  135. static int usbh2_init(struct platform_device *pdev)
  136. {
  137. int pins[] = {
  138. MX31_PIN_USBH2_DATA0__USBH2_DATA0,
  139. MX31_PIN_USBH2_DATA1__USBH2_DATA1,
  140. MX31_PIN_USBH2_CLK__USBH2_CLK,
  141. MX31_PIN_USBH2_DIR__USBH2_DIR,
  142. MX31_PIN_USBH2_NXT__USBH2_NXT,
  143. MX31_PIN_USBH2_STP__USBH2_STP,
  144. };
  145. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
  146. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  147. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  148. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  149. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  150. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  151. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  152. mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
  153. mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
  154. mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
  155. mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
  156. mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
  157. mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
  158. mxc_iomux_set_gpr(MUX_PGP_UH2, true);
  159. /* chip select */
  160. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
  161. "USBH2_CS");
  162. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
  163. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
  164. mdelay(10);
  165. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  166. }
  167. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  168. .init = usbh2_init,
  169. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  170. };
  171. /*
  172. * NOR flash
  173. */
  174. static struct physmap_flash_data nor_flash_data = {
  175. .width = 2,
  176. };
  177. static struct resource nor_flash_resource = {
  178. .start = 0xa0000000,
  179. .end = 0xa1ffffff,
  180. .flags = IORESOURCE_MEM,
  181. };
  182. static struct platform_device physmap_flash_device = {
  183. .name = "physmap-flash",
  184. .id = 0,
  185. .dev = {
  186. .platform_data = &nor_flash_data,
  187. },
  188. .resource = &nor_flash_resource,
  189. .num_resources = 1,
  190. };
  191. /*
  192. * This structure defines the MX31 memory map.
  193. */
  194. static struct map_desc mx31lite_io_desc[] __initdata = {
  195. {
  196. .virtual = (unsigned long)MX31_CS4_BASE_ADDR_VIRT,
  197. .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),
  198. .length = MX31_CS4_SIZE,
  199. .type = MT_DEVICE
  200. }
  201. };
  202. /*
  203. * Set up static virtual mappings.
  204. */
  205. static void __init mx31lite_map_io(void)
  206. {
  207. mx31_map_io();
  208. iotable_init(mx31lite_io_desc, ARRAY_SIZE(mx31lite_io_desc));
  209. }
  210. static int mx31lite_baseboard;
  211. core_param(mx31lite_baseboard, mx31lite_baseboard, int, 0444);
  212. static struct regulator_consumer_supply dummy_supplies[] = {
  213. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  214. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  215. };
  216. static void __init mx31lite_init(void)
  217. {
  218. imx31_soc_init();
  219. mxc_iomux_setup_multiple_pins(mx31lite_pins, ARRAY_SIZE(mx31lite_pins),
  220. "mx31lite");
  221. imx31_add_imx_uart0(&uart_pdata);
  222. imx31_add_spi_imx0(&spi0_pdata);
  223. /* NOR and NAND flash */
  224. platform_device_register(&physmap_flash_device);
  225. imx31_add_mxc_nand(&mx31lite_nand_board_info);
  226. imx31_add_spi_imx1(&spi1_pdata);
  227. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  228. }
  229. static void __init mx31lite_late(void)
  230. {
  231. int ret;
  232. if (mx31lite_baseboard == MX31LITE_DB)
  233. mx31lite_db_init();
  234. mc13783_spi_dev.irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
  235. spi_register_board_info(&mc13783_spi_dev, 1);
  236. /* USB */
  237. usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  238. ULPI_OTG_DRVVBUS_EXT);
  239. if (usbh2_pdata.otg)
  240. imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
  241. /* SMSC9117 IRQ pin */
  242. ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_SFS6), "sms9117-irq");
  243. if (ret)
  244. pr_warn("could not get LAN irq gpio\n");
  245. else {
  246. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  247. smsc911x_resources[1].start =
  248. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  249. smsc911x_resources[1].end =
  250. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  251. platform_device_register(&smsc911x_device);
  252. }
  253. }
  254. static void __init mx31lite_timer_init(void)
  255. {
  256. mx31_clocks_init(26000000);
  257. }
  258. MACHINE_START(MX31LITE, "LogicPD i.MX31 SOM")
  259. /* Maintainer: Freescale Semiconductor, Inc. */
  260. .atag_offset = 0x100,
  261. .map_io = mx31lite_map_io,
  262. .init_early = imx31_init_early,
  263. .init_irq = mx31_init_irq,
  264. .init_time = mx31lite_timer_init,
  265. .init_machine = mx31lite_init,
  266. .init_late = mx31lite_late,
  267. .restart = mxc_restart,
  268. MACHINE_END