board-marzen.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 <linux/usb/otg.h>
  37. #include <linux/usb/ehci_pdriver.h>
  38. #include <linux/pm_runtime.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/hardware/gic.h>
  46. #include <asm/traps.h>
  47. /* Fixed 3.3V regulator to be used by SDHI0 */
  48. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  49. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  50. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  51. };
  52. /* Dummy supplies, where voltage doesn't matter */
  53. static struct regulator_consumer_supply dummy_supplies[] = {
  54. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  55. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  56. };
  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 = gic_spi(28), /* 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_spi(104),
  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. /* USB PHY */
  137. static struct resource usb_phy_resources[] = {
  138. [0] = {
  139. .start = 0xffe70000,
  140. .end = 0xffe70900 - 1,
  141. .flags = IORESOURCE_MEM,
  142. },
  143. [1] = {
  144. .start = 0xfff70000,
  145. .end = 0xfff70900 - 1,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. };
  149. static struct platform_device usb_phy_device = {
  150. .name = "rcar_usb_phy",
  151. .resource = usb_phy_resources,
  152. .num_resources = ARRAY_SIZE(usb_phy_resources),
  153. };
  154. static struct platform_device *marzen_devices[] __initdata = {
  155. &eth_device,
  156. &sdhi0_device,
  157. &thermal_device,
  158. &hspi_device,
  159. &usb_phy_device,
  160. };
  161. /* USB */
  162. static struct usb_phy *phy;
  163. static int usb_power_on(struct platform_device *pdev)
  164. {
  165. if (!phy)
  166. return -EIO;
  167. pm_runtime_enable(&pdev->dev);
  168. pm_runtime_get_sync(&pdev->dev);
  169. usb_phy_init(phy);
  170. return 0;
  171. }
  172. static void usb_power_off(struct platform_device *pdev)
  173. {
  174. if (!phy)
  175. return;
  176. usb_phy_shutdown(phy);
  177. pm_runtime_put_sync(&pdev->dev);
  178. pm_runtime_disable(&pdev->dev);
  179. }
  180. static struct usb_ehci_pdata ehcix_pdata = {
  181. .power_on = usb_power_on,
  182. .power_off = usb_power_off,
  183. .power_suspend = usb_power_off,
  184. };
  185. static struct resource ehci0_resources[] = {
  186. [0] = {
  187. .start = 0xffe70000,
  188. .end = 0xffe70400 - 1,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. [1] = {
  192. .start = gic_spi(44),
  193. .flags = IORESOURCE_IRQ,
  194. },
  195. };
  196. static struct platform_device ehci0_device = {
  197. .name = "ehci-platform",
  198. .id = 0,
  199. .dev = {
  200. .dma_mask = &ehci0_device.dev.coherent_dma_mask,
  201. .coherent_dma_mask = 0xffffffff,
  202. .platform_data = &ehcix_pdata,
  203. },
  204. .num_resources = ARRAY_SIZE(ehci0_resources),
  205. .resource = ehci0_resources,
  206. };
  207. static struct resource ehci1_resources[] = {
  208. [0] = {
  209. .start = 0xfff70000,
  210. .end = 0xfff70400 - 1,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. [1] = {
  214. .start = gic_spi(45),
  215. .flags = IORESOURCE_IRQ,
  216. },
  217. };
  218. static struct platform_device ehci1_device = {
  219. .name = "ehci-platform",
  220. .id = 1,
  221. .dev = {
  222. .dma_mask = &ehci1_device.dev.coherent_dma_mask,
  223. .coherent_dma_mask = 0xffffffff,
  224. .platform_data = &ehcix_pdata,
  225. },
  226. .num_resources = ARRAY_SIZE(ehci1_resources),
  227. .resource = ehci1_resources,
  228. };
  229. static struct platform_device *marzen_late_devices[] __initdata = {
  230. &ehci0_device,
  231. &ehci1_device,
  232. };
  233. void __init marzen_init_late(void)
  234. {
  235. /* get usb phy */
  236. phy = usb_get_phy(USB_PHY_TYPE_USB2);
  237. shmobile_init_late();
  238. platform_add_devices(marzen_late_devices,
  239. ARRAY_SIZE(marzen_late_devices));
  240. }
  241. static void __init marzen_init(void)
  242. {
  243. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  244. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  245. regulator_register_fixed(1, dummy_supplies,
  246. ARRAY_SIZE(dummy_supplies));
  247. r8a7779_pinmux_init();
  248. /* SCIF2 (CN18: DEBUG0) */
  249. gpio_request(GPIO_FN_TX2_C, NULL);
  250. gpio_request(GPIO_FN_RX2_C, NULL);
  251. /* SCIF4 (CN19: DEBUG1) */
  252. gpio_request(GPIO_FN_TX4, NULL);
  253. gpio_request(GPIO_FN_RX4, NULL);
  254. /* LAN89218 */
  255. gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
  256. gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
  257. /* SD0 (CN20) */
  258. gpio_request(GPIO_FN_SD0_CLK, NULL);
  259. gpio_request(GPIO_FN_SD0_CMD, NULL);
  260. gpio_request(GPIO_FN_SD0_DAT0, NULL);
  261. gpio_request(GPIO_FN_SD0_DAT1, NULL);
  262. gpio_request(GPIO_FN_SD0_DAT2, NULL);
  263. gpio_request(GPIO_FN_SD0_DAT3, NULL);
  264. gpio_request(GPIO_FN_SD0_CD, NULL);
  265. gpio_request(GPIO_FN_SD0_WP, NULL);
  266. /* HSPI 0 */
  267. gpio_request(GPIO_FN_HSPI_CLK0, NULL);
  268. gpio_request(GPIO_FN_HSPI_CS0, NULL);
  269. gpio_request(GPIO_FN_HSPI_TX0, NULL);
  270. gpio_request(GPIO_FN_HSPI_RX0, NULL);
  271. /* USB (CN21) */
  272. gpio_request(GPIO_FN_USB_OVC0, NULL);
  273. gpio_request(GPIO_FN_USB_OVC1, NULL);
  274. gpio_request(GPIO_FN_USB_OVC2, NULL);
  275. /* USB (CN22) */
  276. gpio_request(GPIO_FN_USB_PENC2, NULL);
  277. r8a7779_add_standard_devices();
  278. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  279. }
  280. MACHINE_START(MARZEN, "marzen")
  281. .smp = smp_ops(r8a7779_smp_ops),
  282. .map_io = r8a7779_map_io,
  283. .init_early = r8a7779_add_early_devices,
  284. .nr_irqs = NR_IRQS_LEGACY,
  285. .init_irq = r8a7779_init_irq,
  286. .handle_irq = gic_handle_irq,
  287. .init_machine = marzen_init,
  288. .init_late = marzen_init_late,
  289. .timer = &shmobile_timer,
  290. MACHINE_END