board-marzen.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * marzen board support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  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; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/io.h>
  27. #include <linux/gpio.h>
  28. #include <linux/dma-mapping.h>
  29. #include <linux/regulator/fixed.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/smsc911x.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/spi/sh_hspi.h>
  34. #include <linux/mmc/sh_mobile_sdhi.h>
  35. #include <linux/mfd/tmio.h>
  36. #include <mach/hardware.h>
  37. #include <mach/r8a7779.h>
  38. #include <mach/common.h>
  39. #include <mach/irqs.h>
  40. #include <asm/mach-types.h>
  41. #include <asm/mach/arch.h>
  42. #include <asm/hardware/gic.h>
  43. #include <asm/traps.h>
  44. /* Fixed 3.3V regulator to be used by SDHI0 */
  45. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  46. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  47. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  48. };
  49. /* Dummy supplies, where voltage doesn't matter */
  50. static struct regulator_consumer_supply dummy_supplies[] = {
  51. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  52. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  53. };
  54. /* SMSC LAN89218 */
  55. static struct resource smsc911x_resources[] = {
  56. [0] = {
  57. .start = 0x18000000, /* ExCS0 */
  58. .end = 0x180000ff, /* A1->A7 */
  59. .flags = IORESOURCE_MEM,
  60. },
  61. [1] = {
  62. .start = gic_spi(28), /* IRQ 1 */
  63. .flags = IORESOURCE_IRQ,
  64. },
  65. };
  66. static struct smsc911x_platform_config smsc911x_platdata = {
  67. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  68. .phy_interface = PHY_INTERFACE_MODE_MII,
  69. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  70. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  71. };
  72. static struct platform_device eth_device = {
  73. .name = "smsc911x",
  74. .id = -1,
  75. .dev = {
  76. .platform_data = &smsc911x_platdata,
  77. },
  78. .resource = smsc911x_resources,
  79. .num_resources = ARRAY_SIZE(smsc911x_resources),
  80. };
  81. static struct resource sdhi0_resources[] = {
  82. [0] = {
  83. .name = "sdhi0",
  84. .start = 0xffe4c000,
  85. .end = 0xffe4c0ff,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. [1] = {
  89. .start = gic_spi(104),
  90. .flags = IORESOURCE_IRQ,
  91. },
  92. };
  93. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  94. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  95. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  96. };
  97. static struct platform_device sdhi0_device = {
  98. .name = "sh_mobile_sdhi",
  99. .num_resources = ARRAY_SIZE(sdhi0_resources),
  100. .resource = sdhi0_resources,
  101. .id = 0,
  102. .dev = {
  103. .platform_data = &sdhi0_platform_data,
  104. }
  105. };
  106. /* Thermal */
  107. static struct resource thermal_resources[] = {
  108. [0] = {
  109. .start = 0xFFC48000,
  110. .end = 0xFFC48038 - 1,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. };
  114. static struct platform_device thermal_device = {
  115. .name = "rcar_thermal",
  116. .resource = thermal_resources,
  117. .num_resources = ARRAY_SIZE(thermal_resources),
  118. };
  119. /* HSPI */
  120. static struct resource hspi_resources[] = {
  121. [0] = {
  122. .start = 0xFFFC7000,
  123. .end = 0xFFFC7018 - 1,
  124. .flags = IORESOURCE_MEM,
  125. },
  126. };
  127. static struct platform_device hspi_device = {
  128. .name = "sh-hspi",
  129. .id = 0,
  130. .resource = hspi_resources,
  131. .num_resources = ARRAY_SIZE(hspi_resources),
  132. };
  133. /* USB PHY */
  134. static struct resource usb_phy_resources[] = {
  135. [0] = {
  136. .start = 0xffe70000,
  137. .end = 0xffe70900 - 1,
  138. .flags = IORESOURCE_MEM,
  139. },
  140. [1] = {
  141. .start = 0xfff70000,
  142. .end = 0xfff70900 - 1,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. };
  146. static struct platform_device usb_phy_device = {
  147. .name = "rcar_usb_phy",
  148. .resource = usb_phy_resources,
  149. .num_resources = ARRAY_SIZE(usb_phy_resources),
  150. };
  151. static struct platform_device *marzen_devices[] __initdata = {
  152. &eth_device,
  153. &sdhi0_device,
  154. &thermal_device,
  155. &hspi_device,
  156. &usb_phy_device,
  157. };
  158. static void __init marzen_init(void)
  159. {
  160. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  161. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  162. regulator_register_fixed(1, dummy_supplies,
  163. ARRAY_SIZE(dummy_supplies));
  164. r8a7779_pinmux_init();
  165. /* SCIF2 (CN18: DEBUG0) */
  166. gpio_request(GPIO_FN_TX2_C, NULL);
  167. gpio_request(GPIO_FN_RX2_C, NULL);
  168. /* SCIF4 (CN19: DEBUG1) */
  169. gpio_request(GPIO_FN_TX4, NULL);
  170. gpio_request(GPIO_FN_RX4, NULL);
  171. /* LAN89218 */
  172. gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
  173. gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
  174. /* SD0 (CN20) */
  175. gpio_request(GPIO_FN_SD0_CLK, NULL);
  176. gpio_request(GPIO_FN_SD0_CMD, NULL);
  177. gpio_request(GPIO_FN_SD0_DAT0, NULL);
  178. gpio_request(GPIO_FN_SD0_DAT1, NULL);
  179. gpio_request(GPIO_FN_SD0_DAT2, NULL);
  180. gpio_request(GPIO_FN_SD0_DAT3, NULL);
  181. gpio_request(GPIO_FN_SD0_CD, NULL);
  182. gpio_request(GPIO_FN_SD0_WP, NULL);
  183. /* HSPI 0 */
  184. gpio_request(GPIO_FN_HSPI_CLK0, NULL);
  185. gpio_request(GPIO_FN_HSPI_CS0, NULL);
  186. gpio_request(GPIO_FN_HSPI_TX0, NULL);
  187. gpio_request(GPIO_FN_HSPI_RX0, NULL);
  188. r8a7779_add_standard_devices();
  189. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  190. }
  191. MACHINE_START(MARZEN, "marzen")
  192. .smp = smp_ops(r8a7779_smp_ops),
  193. .map_io = r8a7779_map_io,
  194. .init_early = r8a7779_add_early_devices,
  195. .nr_irqs = NR_IRQS_LEGACY,
  196. .init_irq = r8a7779_init_irq,
  197. .handle_irq = gic_handle_irq,
  198. .init_machine = marzen_init,
  199. .init_late = shmobile_init_late,
  200. .timer = &shmobile_timer,
  201. MACHINE_END