board-marzen.c 7.0 KB

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