mach-mx31lite.c 7.3 KB

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