mach-mx31lite.c 7.1 KB

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