board-marzen.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/leds.h>
  28. #include <linux/dma-mapping.h>
  29. #include <linux/pinctrl/machine.h>
  30. #include <linux/platform_data/gpio-rcar.h>
  31. #include <linux/regulator/fixed.h>
  32. #include <linux/regulator/machine.h>
  33. #include <linux/smsc911x.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/sh_hspi.h>
  36. #include <linux/mmc/host.h>
  37. #include <linux/mmc/sh_mobile_sdhi.h>
  38. #include <linux/mfd/tmio.h>
  39. #include <mach/hardware.h>
  40. #include <mach/r8a7779.h>
  41. #include <mach/common.h>
  42. #include <mach/irqs.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/traps.h>
  46. /* Fixed 3.3V regulator to be used by SDHI0 */
  47. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  48. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  49. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  50. };
  51. /* Dummy supplies, where voltage doesn't matter */
  52. static struct regulator_consumer_supply dummy_supplies[] = {
  53. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  54. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  55. };
  56. /* SMSC LAN89218 */
  57. static struct resource smsc911x_resources[] = {
  58. [0] = {
  59. .start = 0x18000000, /* ExCS0 */
  60. .end = 0x180000ff, /* A1->A7 */
  61. .flags = IORESOURCE_MEM,
  62. },
  63. [1] = {
  64. .start = gic_iid(0x3c), /* IRQ 1 */
  65. .flags = IORESOURCE_IRQ,
  66. },
  67. };
  68. static struct smsc911x_platform_config smsc911x_platdata = {
  69. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  70. .phy_interface = PHY_INTERFACE_MODE_MII,
  71. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  72. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  73. };
  74. static struct platform_device eth_device = {
  75. .name = "smsc911x",
  76. .id = -1,
  77. .dev = {
  78. .platform_data = &smsc911x_platdata,
  79. },
  80. .resource = smsc911x_resources,
  81. .num_resources = ARRAY_SIZE(smsc911x_resources),
  82. };
  83. static struct resource sdhi0_resources[] = {
  84. [0] = {
  85. .name = "sdhi0",
  86. .start = 0xffe4c000,
  87. .end = 0xffe4c0ff,
  88. .flags = IORESOURCE_MEM,
  89. },
  90. [1] = {
  91. .start = gic_iid(0x88),
  92. .flags = IORESOURCE_IRQ,
  93. },
  94. };
  95. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  96. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  97. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  98. };
  99. static struct platform_device sdhi0_device = {
  100. .name = "sh_mobile_sdhi",
  101. .num_resources = ARRAY_SIZE(sdhi0_resources),
  102. .resource = sdhi0_resources,
  103. .id = 0,
  104. .dev = {
  105. .platform_data = &sdhi0_platform_data,
  106. }
  107. };
  108. /* Thermal */
  109. static struct resource thermal_resources[] = {
  110. [0] = {
  111. .start = 0xFFC48000,
  112. .end = 0xFFC48038 - 1,
  113. .flags = IORESOURCE_MEM,
  114. },
  115. };
  116. static struct platform_device thermal_device = {
  117. .name = "rcar_thermal",
  118. .resource = thermal_resources,
  119. .num_resources = ARRAY_SIZE(thermal_resources),
  120. };
  121. /* HSPI */
  122. static struct resource hspi_resources[] = {
  123. [0] = {
  124. .start = 0xFFFC7000,
  125. .end = 0xFFFC7018 - 1,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. };
  129. static struct platform_device hspi_device = {
  130. .name = "sh-hspi",
  131. .id = 0,
  132. .resource = hspi_resources,
  133. .num_resources = ARRAY_SIZE(hspi_resources),
  134. };
  135. /* LEDS */
  136. static struct gpio_led marzen_leds[] = {
  137. {
  138. .name = "led2",
  139. .gpio = RCAR_GP_PIN(4, 29),
  140. .default_state = LEDS_GPIO_DEFSTATE_ON,
  141. }, {
  142. .name = "led3",
  143. .gpio = RCAR_GP_PIN(4, 30),
  144. .default_state = LEDS_GPIO_DEFSTATE_ON,
  145. }, {
  146. .name = "led4",
  147. .gpio = RCAR_GP_PIN(4, 31),
  148. .default_state = LEDS_GPIO_DEFSTATE_ON,
  149. },
  150. };
  151. static struct gpio_led_platform_data marzen_leds_pdata = {
  152. .leds = marzen_leds,
  153. .num_leds = ARRAY_SIZE(marzen_leds),
  154. };
  155. static struct platform_device leds_device = {
  156. .name = "leds-gpio",
  157. .id = 0,
  158. .dev = {
  159. .platform_data = &marzen_leds_pdata,
  160. },
  161. };
  162. static struct platform_device *marzen_devices[] __initdata = {
  163. &eth_device,
  164. &sdhi0_device,
  165. &thermal_device,
  166. &hspi_device,
  167. &leds_device,
  168. };
  169. static const struct pinctrl_map marzen_pinctrl_map[] = {
  170. /* HSPI0 */
  171. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
  172. "hspi0", "hspi0"),
  173. /* SCIF2 (CN18: DEBUG0) */
  174. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  175. "scif2_data_c", "scif2"),
  176. /* SCIF4 (CN19: DEBUG1) */
  177. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  178. "scif4_data", "scif4"),
  179. /* SDHI0 */
  180. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  181. "sdhi0_data4", "sdhi0"),
  182. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  183. "sdhi0_ctrl", "sdhi0"),
  184. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  185. "sdhi0_cd", "sdhi0"),
  186. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  187. "sdhi0_wp", "sdhi0"),
  188. /* SMSC */
  189. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  190. "intc_irq1_b", "intc"),
  191. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  192. "lbsc_ex_cs0", "lbsc"),
  193. /* USB0 */
  194. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  195. "usb0", "usb0"),
  196. /* USB1 */
  197. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  198. "usb1", "usb1"),
  199. /* USB2 */
  200. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
  201. "usb2", "usb2"),
  202. };
  203. static void __init marzen_init(void)
  204. {
  205. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  206. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  207. regulator_register_fixed(1, dummy_supplies,
  208. ARRAY_SIZE(dummy_supplies));
  209. pinctrl_register_mappings(marzen_pinctrl_map,
  210. ARRAY_SIZE(marzen_pinctrl_map));
  211. r8a7779_pinmux_init();
  212. r8a7779_add_standard_devices();
  213. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  214. }
  215. MACHINE_START(MARZEN, "marzen")
  216. .smp = smp_ops(r8a7779_smp_ops),
  217. .map_io = r8a7779_map_io,
  218. .init_early = r8a7779_add_early_devices,
  219. .nr_irqs = NR_IRQS_LEGACY,
  220. .init_irq = r8a7779_init_irq,
  221. .init_machine = marzen_init,
  222. .init_late = r8a7779_init_late,
  223. .init_time = r8a7779_earlytimer_init,
  224. MACHINE_END