mx31lite.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. #include <linux/kernel.h>
  24. #include <linux/memory.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/gpio.h>
  27. #include <linux/smsc911x.h>
  28. #include <linux/mfd/mc13783.h>
  29. #include <linux/spi/spi.h>
  30. #include <linux/usb/otg.h>
  31. #include <linux/usb/ulpi.h>
  32. #include <linux/mtd/physmap.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 <mach/hardware.h>
  40. #include <mach/common.h>
  41. #include <mach/board-mx31lite.h>
  42. #include <mach/imx-uart.h>
  43. #include <mach/iomux-mx3.h>
  44. #include <mach/irqs.h>
  45. #include <mach/mxc_nand.h>
  46. #include <mach/spi.h>
  47. #include <mach/mxc_ehci.h>
  48. #include <mach/ulpi.h>
  49. #include "devices.h"
  50. /*
  51. * This file contains the module-specific initialization routines.
  52. */
  53. static unsigned int mx31lite_pins[] = {
  54. /* LAN9117 IRQ pin */
  55. IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO),
  56. /* SPI 1 */
  57. MX31_PIN_CSPI2_SCLK__SCLK,
  58. MX31_PIN_CSPI2_MOSI__MOSI,
  59. MX31_PIN_CSPI2_MISO__MISO,
  60. MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,
  61. MX31_PIN_CSPI2_SS0__SS0,
  62. MX31_PIN_CSPI2_SS1__SS1,
  63. MX31_PIN_CSPI2_SS2__SS2,
  64. };
  65. static struct mxc_nand_platform_data mx31lite_nand_board_info = {
  66. .width = 1,
  67. .hw_ecc = 1,
  68. };
  69. static struct smsc911x_platform_config smsc911x_config = {
  70. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  71. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  72. .flags = SMSC911X_USE_16BIT,
  73. };
  74. static struct resource smsc911x_resources[] = {
  75. {
  76. .start = CS4_BASE_ADDR,
  77. .end = CS4_BASE_ADDR + 0x100,
  78. .flags = IORESOURCE_MEM,
  79. }, {
  80. .start = IOMUX_TO_IRQ(MX31_PIN_SFS6),
  81. .end = IOMUX_TO_IRQ(MX31_PIN_SFS6),
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. };
  85. static struct platform_device smsc911x_device = {
  86. .name = "smsc911x",
  87. .id = -1,
  88. .num_resources = ARRAY_SIZE(smsc911x_resources),
  89. .resource = smsc911x_resources,
  90. .dev = {
  91. .platform_data = &smsc911x_config,
  92. },
  93. };
  94. /*
  95. * SPI
  96. *
  97. * The MC13783 is the only hard-wired SPI device on the module.
  98. */
  99. static int spi_internal_chipselect[] = {
  100. MXC_SPI_CS(0),
  101. };
  102. static struct spi_imx_master spi1_pdata = {
  103. .chipselect = spi_internal_chipselect,
  104. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  105. };
  106. static struct mc13783_platform_data mc13783_pdata __initdata = {
  107. .flags = MC13783_USE_RTC |
  108. MC13783_USE_REGULATOR,
  109. };
  110. static struct spi_board_info mc13783_spi_dev __initdata = {
  111. .modalias = "mc13783",
  112. .max_speed_hz = 1000000,
  113. .bus_num = 1,
  114. .chip_select = 0,
  115. .platform_data = &mc13783_pdata,
  116. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  117. };
  118. /*
  119. * USB
  120. */
  121. #if defined(CONFIG_USB_ULPI)
  122. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  123. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  124. static int usbh2_init(struct platform_device *pdev)
  125. {
  126. int pins[] = {
  127. MX31_PIN_USBH2_DATA0__USBH2_DATA0,
  128. MX31_PIN_USBH2_DATA1__USBH2_DATA1,
  129. MX31_PIN_USBH2_CLK__USBH2_CLK,
  130. MX31_PIN_USBH2_DIR__USBH2_DIR,
  131. MX31_PIN_USBH2_NXT__USBH2_NXT,
  132. MX31_PIN_USBH2_STP__USBH2_STP,
  133. };
  134. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
  135. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  136. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  137. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  138. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  139. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  140. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  141. mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
  142. mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
  143. mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
  144. mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
  145. mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
  146. mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
  147. mxc_iomux_set_gpr(MUX_PGP_UH2, true);
  148. /* chip select */
  149. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
  150. "USBH2_CS");
  151. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
  152. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
  153. return 0;
  154. }
  155. static struct mxc_usbh_platform_data usbh2_pdata = {
  156. .init = usbh2_init,
  157. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  158. .flags = MXC_EHCI_POWER_PINS_ENABLED,
  159. };
  160. #endif
  161. /*
  162. * NOR flash
  163. */
  164. static struct physmap_flash_data nor_flash_data = {
  165. .width = 2,
  166. };
  167. static struct resource nor_flash_resource = {
  168. .start = 0xa0000000,
  169. .end = 0xa1ffffff,
  170. .flags = IORESOURCE_MEM,
  171. };
  172. static struct platform_device physmap_flash_device = {
  173. .name = "physmap-flash",
  174. .id = 0,
  175. .dev = {
  176. .platform_data = &nor_flash_data,
  177. },
  178. .resource = &nor_flash_resource,
  179. .num_resources = 1,
  180. };
  181. /*
  182. * This structure defines the MX31 memory map.
  183. */
  184. static struct map_desc mx31lite_io_desc[] __initdata = {
  185. {
  186. .virtual = CS4_BASE_ADDR_VIRT,
  187. .pfn = __phys_to_pfn(CS4_BASE_ADDR),
  188. .length = CS4_SIZE,
  189. .type = MT_DEVICE
  190. }
  191. };
  192. /*
  193. * Set up static virtual mappings.
  194. */
  195. void __init mx31lite_map_io(void)
  196. {
  197. mx31_map_io();
  198. iotable_init(mx31lite_io_desc, ARRAY_SIZE(mx31lite_io_desc));
  199. }
  200. static int mx31lite_baseboard;
  201. core_param(mx31lite_baseboard, mx31lite_baseboard, int, 0444);
  202. static void __init mxc_board_init(void)
  203. {
  204. int ret;
  205. switch (mx31lite_baseboard) {
  206. case MX31LITE_NOBOARD:
  207. break;
  208. case MX31LITE_DB:
  209. mx31lite_db_init();
  210. break;
  211. default:
  212. printk(KERN_ERR "Illegal mx31lite_baseboard type %d\n",
  213. mx31lite_baseboard);
  214. }
  215. mxc_iomux_setup_multiple_pins(mx31lite_pins, ARRAY_SIZE(mx31lite_pins),
  216. "mx31lite");
  217. /* NOR and NAND flash */
  218. platform_device_register(&physmap_flash_device);
  219. mxc_register_device(&mxc_nand_device, &mx31lite_nand_board_info);
  220. mxc_register_device(&mxc_spi_device1, &spi1_pdata);
  221. spi_register_board_info(&mc13783_spi_dev, 1);
  222. #if defined(CONFIG_USB_ULPI)
  223. /* USB */
  224. usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  225. USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
  226. mxc_register_device(&mxc_usbh2, &usbh2_pdata);
  227. #endif
  228. /* SMSC9117 IRQ pin */
  229. ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_SFS6), "sms9117-irq");
  230. if (ret)
  231. pr_warning("could not get LAN irq gpio\n");
  232. else {
  233. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  234. platform_device_register(&smsc911x_device);
  235. }
  236. }
  237. static void __init mx31lite_timer_init(void)
  238. {
  239. mx31_clocks_init(26000000);
  240. }
  241. struct sys_timer mx31lite_timer = {
  242. .init = mx31lite_timer_init,
  243. };
  244. MACHINE_START(MX31LITE, "LogicPD i.MX31 SOM")
  245. /* Maintainer: Freescale Semiconductor, Inc. */
  246. .phys_io = AIPS1_BASE_ADDR,
  247. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  248. .boot_params = PHYS_OFFSET + 0x100,
  249. .map_io = mx31lite_map_io,
  250. .init_irq = mx31_init_irq,
  251. .init_machine = mxc_board_init,
  252. .timer = &mx31lite_timer,
  253. MACHINE_END