mach-mx31lite.c 7.2 KB

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