board-marzen.c 6.7 KB

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