mach-mx31lilly.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/types.h>
  27. #include <linux/init.h>
  28. #include <linux/clk.h>
  29. #include <linux/gpio.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/smsc911x.h>
  33. #include <linux/mtd/physmap.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/mfd/mc13783.h>
  36. #include <linux/usb/otg.h>
  37. #include <linux/usb/ulpi.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 <mach/hardware.h>
  43. #include <mach/common.h>
  44. #include <mach/iomux-mx3.h>
  45. #include <mach/board-mx31lilly.h>
  46. #include <mach/spi.h>
  47. #include <mach/mxc_ehci.h>
  48. #include <mach/ulpi.h>
  49. #include "devices.h"
  50. /*
  51. * This file contains module-specific initialization routines for LILLY-1131.
  52. * Initialization of peripherals found on the baseboard is implemented in the
  53. * appropriate baseboard support code.
  54. */
  55. /* SMSC ethernet support */
  56. static struct resource smsc91x_resources[] = {
  57. {
  58. .start = MX31_CS4_BASE_ADDR,
  59. .end = MX31_CS4_BASE_ADDR + 0xffff,
  60. .flags = IORESOURCE_MEM,
  61. },
  62. {
  63. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  64. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  65. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  66. }
  67. };
  68. static struct smsc911x_platform_config smsc911x_config = {
  69. .phy_interface = PHY_INTERFACE_MODE_MII,
  70. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  71. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  72. .flags = SMSC911X_USE_32BIT |
  73. SMSC911X_SAVE_MAC_ADDRESS |
  74. SMSC911X_FORCE_INTERNAL_PHY,
  75. };
  76. static struct platform_device smsc91x_device = {
  77. .name = "smsc911x",
  78. .id = -1,
  79. .num_resources = ARRAY_SIZE(smsc91x_resources),
  80. .resource = smsc91x_resources,
  81. .dev = {
  82. .platform_data = &smsc911x_config,
  83. }
  84. };
  85. /* NOR flash */
  86. static struct physmap_flash_data nor_flash_data = {
  87. .width = 2,
  88. };
  89. static struct resource nor_flash_resource = {
  90. .start = 0xa0000000,
  91. .end = 0xa1ffffff,
  92. .flags = IORESOURCE_MEM,
  93. };
  94. static struct platform_device physmap_flash_device = {
  95. .name = "physmap-flash",
  96. .id = 0,
  97. .dev = {
  98. .platform_data = &nor_flash_data,
  99. },
  100. .resource = &nor_flash_resource,
  101. .num_resources = 1,
  102. };
  103. /* USB */
  104. #if defined(CONFIG_USB_ULPI)
  105. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  106. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  107. static int usbotg_init(struct platform_device *pdev)
  108. {
  109. unsigned int pins[] = {
  110. MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
  111. MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
  112. MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
  113. MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
  114. MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
  115. MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
  116. MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
  117. MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
  118. MX31_PIN_USBOTG_CLK__USBOTG_CLK,
  119. MX31_PIN_USBOTG_DIR__USBOTG_DIR,
  120. MX31_PIN_USBOTG_NXT__USBOTG_NXT,
  121. MX31_PIN_USBOTG_STP__USBOTG_STP,
  122. };
  123. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB OTG");
  124. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);
  125. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);
  126. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);
  127. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);
  128. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);
  129. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);
  130. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);
  131. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);
  132. mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);
  133. mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);
  134. mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);
  135. mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);
  136. mxc_iomux_set_gpr(MUX_PGP_USB_4WIRE, true);
  137. mxc_iomux_set_gpr(MUX_PGP_USB_COMMON, true);
  138. /* chip select */
  139. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE2, IOMUX_CONFIG_GPIO),
  140. "USBOTG_CS");
  141. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE2), "USBH1 CS");
  142. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE2), 0);
  143. return 0;
  144. }
  145. static int usbh1_init(struct platform_device *pdev)
  146. {
  147. int pins[] = {
  148. MX31_PIN_CSPI1_MOSI__USBH1_RXDM,
  149. MX31_PIN_CSPI1_MISO__USBH1_RXDP,
  150. MX31_PIN_CSPI1_SS0__USBH1_TXDM,
  151. MX31_PIN_CSPI1_SS1__USBH1_TXDP,
  152. MX31_PIN_CSPI1_SS2__USBH1_RCV,
  153. MX31_PIN_CSPI1_SCLK__USBH1_OEB,
  154. MX31_PIN_CSPI1_SPI_RDY__USBH1_FS,
  155. };
  156. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");
  157. mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI, USB_PAD_CFG);
  158. mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO, USB_PAD_CFG);
  159. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0, USB_PAD_CFG);
  160. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1, USB_PAD_CFG);
  161. mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2, USB_PAD_CFG);
  162. mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK, USB_PAD_CFG);
  163. mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY, USB_PAD_CFG);
  164. mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND, true);
  165. return 0;
  166. }
  167. static int usbh2_init(struct platform_device *pdev)
  168. {
  169. int pins[] = {
  170. MX31_PIN_USBH2_DATA0__USBH2_DATA0,
  171. MX31_PIN_USBH2_DATA1__USBH2_DATA1,
  172. MX31_PIN_USBH2_CLK__USBH2_CLK,
  173. MX31_PIN_USBH2_DIR__USBH2_DIR,
  174. MX31_PIN_USBH2_NXT__USBH2_NXT,
  175. MX31_PIN_USBH2_STP__USBH2_STP,
  176. };
  177. mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
  178. mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
  179. mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
  180. mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
  181. mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
  182. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
  183. mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
  184. mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
  185. mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
  186. mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
  187. mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
  188. mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
  189. mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
  190. mxc_iomux_set_gpr(MUX_PGP_UH2, true);
  191. /* chip select */
  192. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
  193. "USBH2_CS");
  194. gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
  195. gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
  196. return 0;
  197. }
  198. static struct mxc_usbh_platform_data usbotg_pdata = {
  199. .init = usbotg_init,
  200. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  201. .flags = MXC_EHCI_POWER_PINS_ENABLED,
  202. };
  203. static struct mxc_usbh_platform_data usbh1_pdata = {
  204. .init = usbh1_init,
  205. .portsc = MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,
  206. .flags = MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_INTERFACE_SINGLE_UNI,
  207. };
  208. static struct mxc_usbh_platform_data usbh2_pdata = {
  209. .init = usbh2_init,
  210. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  211. .flags = MXC_EHCI_POWER_PINS_ENABLED,
  212. };
  213. static void lilly1131_usb_init(void)
  214. {
  215. usbotg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  216. USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
  217. usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  218. USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
  219. mxc_register_device(&mxc_usbh1, &usbh1_pdata);
  220. mxc_register_device(&mxc_usbh2, &usbh2_pdata);
  221. }
  222. #else
  223. static inline void lilly1131_usb_init(void) {}
  224. #endif /* CONFIG_USB_ULPI */
  225. /* SPI */
  226. static int spi_internal_chipselect[] = {
  227. MXC_SPI_CS(0),
  228. MXC_SPI_CS(1),
  229. MXC_SPI_CS(2),
  230. };
  231. static struct spi_imx_master spi0_pdata = {
  232. .chipselect = spi_internal_chipselect,
  233. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  234. };
  235. static struct spi_imx_master spi1_pdata = {
  236. .chipselect = spi_internal_chipselect,
  237. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  238. };
  239. static struct mc13783_platform_data mc13783_pdata __initdata = {
  240. .flags = MC13783_USE_RTC | MC13783_USE_TOUCHSCREEN,
  241. };
  242. static struct spi_board_info mc13783_dev __initdata = {
  243. .modalias = "mc13783",
  244. .max_speed_hz = 1000000,
  245. .bus_num = 1,
  246. .chip_select = 0,
  247. .platform_data = &mc13783_pdata,
  248. };
  249. static struct platform_device *devices[] __initdata = {
  250. &smsc91x_device,
  251. &physmap_flash_device,
  252. };
  253. static int mx31lilly_baseboard;
  254. core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
  255. static void __init mx31lilly_board_init(void)
  256. {
  257. switch (mx31lilly_baseboard) {
  258. case MX31LILLY_NOBOARD:
  259. break;
  260. case MX31LILLY_DB:
  261. mx31lilly_db_init();
  262. break;
  263. default:
  264. printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
  265. mx31lilly_baseboard);
  266. }
  267. mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
  268. /* SPI */
  269. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
  270. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
  271. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
  272. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
  273. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
  274. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
  275. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
  276. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
  277. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
  278. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
  279. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
  280. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
  281. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
  282. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
  283. mxc_register_device(&mxc_spi_device0, &spi0_pdata);
  284. mxc_register_device(&mxc_spi_device1, &spi1_pdata);
  285. spi_register_board_info(&mc13783_dev, 1);
  286. platform_add_devices(devices, ARRAY_SIZE(devices));
  287. /* USB */
  288. lilly1131_usb_init();
  289. }
  290. static void __init mx31lilly_timer_init(void)
  291. {
  292. mx31_clocks_init(26000000);
  293. }
  294. static struct sys_timer mx31lilly_timer = {
  295. .init = mx31lilly_timer_init,
  296. };
  297. MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
  298. .phys_io = MX31_AIPS1_BASE_ADDR,
  299. .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
  300. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  301. .map_io = mx31_map_io,
  302. .init_irq = mx31_init_irq,
  303. .init_machine = mx31lilly_board_init,
  304. .timer = &mx31lilly_timer,
  305. MACHINE_END