mx31lilly.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/platform_device.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/smsc911x.h>
  32. #include <linux/mtd/physmap.h>
  33. #include <linux/spi/spi.h>
  34. #include <linux/mfd/mc13783.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/time.h>
  38. #include <asm/mach/map.h>
  39. #include <mach/hardware.h>
  40. #include <mach/common.h>
  41. #include <mach/iomux-mx3.h>
  42. #include <mach/board-mx31lilly.h>
  43. #include <mach/spi.h>
  44. #include "devices.h"
  45. /*
  46. * This file contains module-specific initialization routines for LILLY-1131.
  47. * Initialization of peripherals found on the baseboard is implemented in the
  48. * appropriate baseboard support code.
  49. */
  50. /* SMSC ethernet support */
  51. static struct resource smsc91x_resources[] = {
  52. {
  53. .start = CS4_BASE_ADDR,
  54. .end = CS4_BASE_ADDR + 0xffff,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. {
  58. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  59. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  60. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  61. }
  62. };
  63. static struct smsc911x_platform_config smsc911x_config = {
  64. .phy_interface = PHY_INTERFACE_MODE_MII,
  65. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  66. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  67. .flags = SMSC911X_USE_32BIT |
  68. SMSC911X_SAVE_MAC_ADDRESS |
  69. SMSC911X_FORCE_INTERNAL_PHY,
  70. };
  71. static struct platform_device smsc91x_device = {
  72. .name = "smsc911x",
  73. .id = -1,
  74. .num_resources = ARRAY_SIZE(smsc91x_resources),
  75. .resource = smsc91x_resources,
  76. .dev = {
  77. .platform_data = &smsc911x_config,
  78. }
  79. };
  80. /* NOR flash */
  81. static struct physmap_flash_data nor_flash_data = {
  82. .width = 2,
  83. };
  84. static struct resource nor_flash_resource = {
  85. .start = 0xa0000000,
  86. .end = 0xa1ffffff,
  87. .flags = IORESOURCE_MEM,
  88. };
  89. static struct platform_device physmap_flash_device = {
  90. .name = "physmap-flash",
  91. .id = 0,
  92. .dev = {
  93. .platform_data = &nor_flash_data,
  94. },
  95. .resource = &nor_flash_resource,
  96. .num_resources = 1,
  97. };
  98. static struct platform_device *devices[] __initdata = {
  99. &smsc91x_device,
  100. &physmap_flash_device,
  101. };
  102. /* SPI */
  103. static int spi_internal_chipselect[] = {
  104. MXC_SPI_CS(0),
  105. MXC_SPI_CS(1),
  106. MXC_SPI_CS(2),
  107. };
  108. static struct spi_imx_master spi0_pdata = {
  109. .chipselect = spi_internal_chipselect,
  110. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  111. };
  112. static struct spi_imx_master spi1_pdata = {
  113. .chipselect = spi_internal_chipselect,
  114. .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
  115. };
  116. static struct mc13783_platform_data mc13783_pdata __initdata = {
  117. .flags = MC13783_USE_RTC | MC13783_USE_TOUCHSCREEN,
  118. };
  119. static struct spi_board_info mc13783_dev __initdata = {
  120. .modalias = "mc13783",
  121. .max_speed_hz = 1000000,
  122. .bus_num = 1,
  123. .chip_select = 0,
  124. .platform_data = &mc13783_pdata,
  125. };
  126. static int mx31lilly_baseboard;
  127. core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
  128. static void __init mx31lilly_board_init(void)
  129. {
  130. switch (mx31lilly_baseboard) {
  131. case MX31LILLY_NOBOARD:
  132. break;
  133. case MX31LILLY_DB:
  134. mx31lilly_db_init();
  135. break;
  136. default:
  137. printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
  138. mx31lilly_baseboard);
  139. }
  140. mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
  141. /* SPI */
  142. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
  143. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
  144. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
  145. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
  146. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
  147. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
  148. mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
  149. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
  150. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
  151. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
  152. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
  153. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
  154. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
  155. mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
  156. mxc_register_device(&mxc_spi_device0, &spi0_pdata);
  157. mxc_register_device(&mxc_spi_device1, &spi1_pdata);
  158. spi_register_board_info(&mc13783_dev, 1);
  159. platform_add_devices(devices, ARRAY_SIZE(devices));
  160. }
  161. static void __init mx31lilly_timer_init(void)
  162. {
  163. mx31_clocks_init(26000000);
  164. }
  165. static struct sys_timer mx31lilly_timer = {
  166. .init = mx31lilly_timer_init,
  167. };
  168. MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
  169. .phys_io = AIPS1_BASE_ADDR,
  170. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  171. .boot_params = PHYS_OFFSET + 0x100,
  172. .map_io = mx31_map_io,
  173. .init_irq = mx31_init_irq,
  174. .init_machine = mx31lilly_board_init,
  175. .timer = &mx31lilly_timer,
  176. MACHINE_END