mach-mx31lilly.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. * LILLY-1131 module support
  3. *
  4. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  5. *
  6. * based on code for other MX31 boards,
  7. *
  8. * Copyright 2005-2007 Freescale Semiconductor
  9. * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
  10. * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. */
  22. #include <linux/types.h>
  23. #include <linux/init.h>
  24. #include <linux/clk.h>
  25. #include <linux/gpio.h>
  26. #include <linux/delay.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/moduleparam.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/mtd/physmap.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/mfd/mc13783.h>
  34. #include <linux/usb/otg.h>
  35. #include <linux/usb/ulpi.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/time.h>
  39. #include <asm/mach/map.h>
  40. #include <mach/hardware.h>
  41. #include <mach/common.h>
  42. #include <mach/iomux-mx3.h>
  43. #include <mach/board-mx31lilly.h>
  44. #include <mach/ulpi.h>
  45. #include "devices-imx31.h"
  46. /*
  47. * This file contains module-specific initialization routines for LILLY-1131.
  48. * Initialization of peripherals found on the baseboard is implemented in the
  49. * appropriate baseboard support code.
  50. */
  51. /* SMSC ethernet support */
  52. static struct resource smsc91x_resources[] = {
  53. {
  54. .start = MX31_CS4_BASE_ADDR,
  55. .end = MX31_CS4_BASE_ADDR + 0xffff,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. {
  59. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  60. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  61. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  62. }
  63. };
  64. static struct smsc911x_platform_config smsc911x_config = {
  65. .phy_interface = PHY_INTERFACE_MODE_MII,
  66. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  67. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  68. .flags = SMSC911X_USE_32BIT |
  69. SMSC911X_SAVE_MAC_ADDRESS |
  70. SMSC911X_FORCE_INTERNAL_PHY,
  71. };
  72. static struct platform_device smsc91x_device = {
  73. .name = "smsc911x",
  74. .id = -1,
  75. .num_resources = ARRAY_SIZE(smsc91x_resources),
  76. .resource = smsc91x_resources,
  77. .dev = {
  78. .platform_data = &smsc911x_config,
  79. }
  80. };
  81. /* NOR flash */
  82. static struct physmap_flash_data nor_flash_data = {
  83. .width = 2,
  84. };
  85. static struct resource nor_flash_resource = {
  86. .start = 0xa0000000,
  87. .end = 0xa1ffffff,
  88. .flags = IORESOURCE_MEM,
  89. };
  90. static struct platform_device physmap_flash_device = {
  91. .name = "physmap-flash",
  92. .id = 0,
  93. .dev = {
  94. .platform_data = &nor_flash_data,
  95. },
  96. .resource = &nor_flash_resource,
  97. .num_resources = 1,
  98. };
  99. /* USB */
  100. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  101. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  102. static int usbh1_init(struct platform_device *pdev)
  103. {
  104. int pins[] = {
  105. MX31_PIN_CSPI1_MOSI__USBH1_RXDM,
  106. MX31_PIN_CSPI1_MISO__USBH1_RXDP,
  107. MX31_PIN_CSPI1_SS0__USBH1_TXDM,
  108. MX31_PIN_CSPI1_SS1__USBH1_TXDP,
  109. MX31_PIN_CSPI1_SS2__USBH1_RCV,
  110. MX31_PIN_CSPI1_SCLK__USBH1_OEB,
  111. MX31_PIN_CSPI1_SPI_RDY__USBH1_FS,
  112. };
  113. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");
  114. mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI, USB_PAD_CFG);
  115. mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO, USB_PAD_CFG);
  116. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0, USB_PAD_CFG);
  117. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1, USB_PAD_CFG);
  118. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2, USB_PAD_CFG);
  119. mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK, USB_PAD_CFG);
  120. mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY, USB_PAD_CFG);
  121. mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND, true);
  122. mdelay(10);
  123. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
  124. MXC_EHCI_INTERFACE_SINGLE_UNI);
  125. }
  126. static int usbh2_init(struct platform_device *pdev)
  127. {
  128. int pins[] = {
  129. MX31_PIN_USBH2_DATA0__USBH2_DATA0,
  130. MX31_PIN_USBH2_DATA1__USBH2_DATA1,
  131. MX31_PIN_USBH2_CLK__USBH2_CLK,
  132. MX31_PIN_USBH2_DIR__USBH2_DIR,
  133. MX31_PIN_USBH2_NXT__USBH2_NXT,
  134. MX31_PIN_USBH2_STP__USBH2_STP,
  135. };
  136. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
  137. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  138. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  139. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  140. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  141. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  142. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  143. mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
  144. mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
  145. mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
  146. mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
  147. mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
  148. mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
  149. mxc_iomux_set_gpr(MUX_PGP_UH2, true);
  150. /* chip select */
  151. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
  152. "USBH2_CS");
  153. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
  154. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
  155. mdelay(10);
  156. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  157. }
  158. static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {
  159. .init = usbh1_init,
  160. .portsc = MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,
  161. };
  162. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  163. .init = usbh2_init,
  164. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  165. };
  166. static void __init lilly1131_usb_init(void)
  167. {
  168. imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
  169. usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  170. ULPI_OTG_DRVVBUS_EXT);
  171. if (usbh2_pdata.otg)
  172. imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
  173. }
  174. /* SPI */
  175. static int spi_internal_chipselect[] = {
  176. MXC_SPI_CS(0),
  177. MXC_SPI_CS(1),
  178. MXC_SPI_CS(2),
  179. };
  180. static const struct spi_imx_master spi0_pdata __initconst = {
  181. .chipselect = spi_internal_chipselect,
  182. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  183. };
  184. static const struct spi_imx_master spi1_pdata __initconst = {
  185. .chipselect = spi_internal_chipselect,
  186. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  187. };
  188. static struct mc13xxx_platform_data mc13783_pdata __initdata = {
  189. .flags = MC13XXX_USE_RTC | MC13XXX_USE_TOUCHSCREEN,
  190. };
  191. static struct spi_board_info mc13783_dev __initdata = {
  192. .modalias = "mc13783",
  193. .max_speed_hz = 1000000,
  194. .bus_num = 1,
  195. .chip_select = 0,
  196. .platform_data = &mc13783_pdata,
  197. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  198. };
  199. static struct platform_device *devices[] __initdata = {
  200. &smsc91x_device,
  201. &physmap_flash_device,
  202. };
  203. static int mx31lilly_baseboard;
  204. core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
  205. static void __init mx31lilly_board_init(void)
  206. {
  207. imx31_soc_init();
  208. switch (mx31lilly_baseboard) {
  209. case MX31LILLY_NOBOARD:
  210. break;
  211. case MX31LILLY_DB:
  212. mx31lilly_db_init();
  213. break;
  214. default:
  215. printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
  216. mx31lilly_baseboard);
  217. }
  218. mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
  219. /* SPI */
  220. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
  221. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
  222. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
  223. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
  224. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
  225. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
  226. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
  227. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
  228. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
  229. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
  230. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
  231. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
  232. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
  233. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
  234. imx31_add_spi_imx0(&spi0_pdata);
  235. imx31_add_spi_imx1(&spi1_pdata);
  236. spi_register_board_info(&mc13783_dev, 1);
  237. platform_add_devices(devices, ARRAY_SIZE(devices));
  238. /* USB */
  239. lilly1131_usb_init();
  240. }
  241. static void __init mx31lilly_timer_init(void)
  242. {
  243. mx31_clocks_init(26000000);
  244. }
  245. static struct sys_timer mx31lilly_timer = {
  246. .init = mx31lilly_timer_init,
  247. };
  248. MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
  249. .atag_offset = 0x100,
  250. .map_io = mx31_map_io,
  251. .init_early = imx31_init_early,
  252. .init_irq = mx31_init_irq,
  253. .handle_irq = imx31_handle_irq,
  254. .timer = &mx31lilly_timer,
  255. .init_machine = mx31lilly_board_init,
  256. .restart = mxc_restart,
  257. MACHINE_END