mach-mx31lilly.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 <linux/regulator/machine.h>
  37. #include <linux/regulator/fixed.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/time.h>
  41. #include <asm/mach/map.h>
  42. #include "board-mx31lilly.h"
  43. #include "common.h"
  44. #include "devices-imx31.h"
  45. #include "ehci.h"
  46. #include "hardware.h"
  47. #include "iomux-mx3.h"
  48. #include "ulpi.h"
  49. /*
  50. * This file contains module-specific initialization routines for LILLY-1131.
  51. * Initialization of peripherals found on the baseboard is implemented in the
  52. * appropriate baseboard support code.
  53. */
  54. static unsigned int mx31lilly_pins[] __initdata = {
  55. MX31_PIN_CTS1__CTS1,
  56. MX31_PIN_RTS1__RTS1,
  57. MX31_PIN_TXD1__TXD1,
  58. MX31_PIN_RXD1__RXD1,
  59. MX31_PIN_CTS2__CTS2,
  60. MX31_PIN_RTS2__RTS2,
  61. MX31_PIN_TXD2__TXD2,
  62. MX31_PIN_RXD2__RXD2,
  63. MX31_PIN_CSPI3_MOSI__RXD3,
  64. MX31_PIN_CSPI3_MISO__TXD3,
  65. MX31_PIN_CSPI3_SCLK__RTS3,
  66. MX31_PIN_CSPI3_SPI_RDY__CTS3,
  67. };
  68. /* UART */
  69. static const struct imxuart_platform_data uart_pdata __initconst = {
  70. .flags = IMXUART_HAVE_RTSCTS,
  71. };
  72. /* SMSC ethernet support */
  73. static struct resource smsc91x_resources[] = {
  74. {
  75. .start = MX31_CS4_BASE_ADDR,
  76. .end = MX31_CS4_BASE_ADDR + 0xffff,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. {
  80. /* irq number is run-time assigned */
  81. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  82. }
  83. };
  84. static struct smsc911x_platform_config smsc911x_config = {
  85. .phy_interface = PHY_INTERFACE_MODE_MII,
  86. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  87. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  88. .flags = SMSC911X_USE_32BIT |
  89. SMSC911X_SAVE_MAC_ADDRESS |
  90. SMSC911X_FORCE_INTERNAL_PHY,
  91. };
  92. static struct platform_device smsc91x_device = {
  93. .name = "smsc911x",
  94. .id = -1,
  95. .num_resources = ARRAY_SIZE(smsc91x_resources),
  96. .resource = smsc91x_resources,
  97. .dev = {
  98. .platform_data = &smsc911x_config,
  99. }
  100. };
  101. /* NOR flash */
  102. static struct physmap_flash_data nor_flash_data = {
  103. .width = 2,
  104. };
  105. static struct resource nor_flash_resource = {
  106. .start = 0xa0000000,
  107. .end = 0xa1ffffff,
  108. .flags = IORESOURCE_MEM,
  109. };
  110. static struct platform_device physmap_flash_device = {
  111. .name = "physmap-flash",
  112. .id = 0,
  113. .dev = {
  114. .platform_data = &nor_flash_data,
  115. },
  116. .resource = &nor_flash_resource,
  117. .num_resources = 1,
  118. };
  119. /* USB */
  120. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  121. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  122. static int usbh1_init(struct platform_device *pdev)
  123. {
  124. int pins[] = {
  125. MX31_PIN_CSPI1_MOSI__USBH1_RXDM,
  126. MX31_PIN_CSPI1_MISO__USBH1_RXDP,
  127. MX31_PIN_CSPI1_SS0__USBH1_TXDM,
  128. MX31_PIN_CSPI1_SS1__USBH1_TXDP,
  129. MX31_PIN_CSPI1_SS2__USBH1_RCV,
  130. MX31_PIN_CSPI1_SCLK__USBH1_OEB,
  131. MX31_PIN_CSPI1_SPI_RDY__USBH1_FS,
  132. };
  133. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");
  134. mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI, USB_PAD_CFG);
  135. mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO, USB_PAD_CFG);
  136. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0, USB_PAD_CFG);
  137. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1, USB_PAD_CFG);
  138. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2, USB_PAD_CFG);
  139. mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK, USB_PAD_CFG);
  140. mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY, USB_PAD_CFG);
  141. mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND, true);
  142. mdelay(10);
  143. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
  144. MXC_EHCI_INTERFACE_SINGLE_UNI);
  145. }
  146. static int usbh2_init(struct platform_device *pdev)
  147. {
  148. int pins[] = {
  149. MX31_PIN_USBH2_DATA0__USBH2_DATA0,
  150. MX31_PIN_USBH2_DATA1__USBH2_DATA1,
  151. MX31_PIN_USBH2_CLK__USBH2_CLK,
  152. MX31_PIN_USBH2_DIR__USBH2_DIR,
  153. MX31_PIN_USBH2_NXT__USBH2_NXT,
  154. MX31_PIN_USBH2_STP__USBH2_STP,
  155. };
  156. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
  157. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  158. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  159. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  160. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  161. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  162. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  163. mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
  164. mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
  165. mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
  166. mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
  167. mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
  168. mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
  169. mxc_iomux_set_gpr(MUX_PGP_UH2, true);
  170. /* chip select */
  171. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
  172. "USBH2_CS");
  173. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
  174. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
  175. mdelay(10);
  176. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  177. }
  178. static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {
  179. .init = usbh1_init,
  180. .portsc = MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,
  181. };
  182. static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
  183. .init = usbh2_init,
  184. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  185. };
  186. static void __init lilly1131_usb_init(void)
  187. {
  188. imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
  189. usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  190. ULPI_OTG_DRVVBUS_EXT);
  191. if (usbh2_pdata.otg)
  192. imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
  193. }
  194. /* SPI */
  195. static int spi_internal_chipselect[] = {
  196. MXC_SPI_CS(0),
  197. MXC_SPI_CS(1),
  198. MXC_SPI_CS(2),
  199. };
  200. static const struct spi_imx_master spi0_pdata __initconst = {
  201. .chipselect = spi_internal_chipselect,
  202. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  203. };
  204. static const struct spi_imx_master spi1_pdata __initconst = {
  205. .chipselect = spi_internal_chipselect,
  206. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  207. };
  208. static struct mc13xxx_platform_data mc13783_pdata __initdata = {
  209. .flags = MC13XXX_USE_RTC | MC13XXX_USE_TOUCHSCREEN,
  210. };
  211. static struct spi_board_info mc13783_dev __initdata = {
  212. .modalias = "mc13783",
  213. .max_speed_hz = 1000000,
  214. .bus_num = 1,
  215. .chip_select = 0,
  216. .platform_data = &mc13783_pdata,
  217. /* irq number is run-time assigned */
  218. };
  219. static struct platform_device *devices[] __initdata = {
  220. &smsc91x_device,
  221. &physmap_flash_device,
  222. };
  223. static int mx31lilly_baseboard;
  224. core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
  225. static struct regulator_consumer_supply dummy_supplies[] = {
  226. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  227. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  228. };
  229. static void __init mx31lilly_board_init(void)
  230. {
  231. imx31_soc_init();
  232. mxc_iomux_setup_multiple_pins(mx31lilly_pins,
  233. ARRAY_SIZE(mx31lilly_pins), "mx31lily");
  234. imx31_add_imx_uart0(&uart_pdata);
  235. imx31_add_imx_uart1(&uart_pdata);
  236. imx31_add_imx_uart2(&uart_pdata);
  237. mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
  238. /* SPI */
  239. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
  240. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
  241. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
  242. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
  243. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
  244. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
  245. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
  246. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
  247. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
  248. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
  249. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
  250. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
  251. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
  252. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
  253. imx31_add_spi_imx0(&spi0_pdata);
  254. imx31_add_spi_imx1(&spi1_pdata);
  255. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  256. }
  257. static void __init mx31lilly_late_init(void)
  258. {
  259. if (mx31lilly_baseboard == MX31LILLY_DB)
  260. mx31lilly_db_init();
  261. mc13783_dev.irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
  262. spi_register_board_info(&mc13783_dev, 1);
  263. smsc91x_resources[1].start =
  264. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
  265. smsc91x_resources[1].end =
  266. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
  267. platform_add_devices(devices, ARRAY_SIZE(devices));
  268. /* USB */
  269. lilly1131_usb_init();
  270. }
  271. static void __init mx31lilly_timer_init(void)
  272. {
  273. mx31_clocks_init(26000000);
  274. }
  275. MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
  276. .atag_offset = 0x100,
  277. .map_io = mx31_map_io,
  278. .init_early = imx31_init_early,
  279. .init_irq = mx31_init_irq,
  280. .init_time = mx31lilly_timer_init,
  281. .init_machine = mx31lilly_board_init,
  282. .init_late = mx31lilly_late_init,
  283. .restart = mxc_restart,
  284. MACHINE_END