board-marzen.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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/pinctrl/machine.h>
  30. #include <linux/regulator/fixed.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/smsc911x.h>
  33. #include <linux/spi/spi.h>
  34. #include <linux/spi/sh_hspi.h>
  35. #include <linux/mmc/host.h>
  36. #include <linux/mmc/sh_mobile_sdhi.h>
  37. #include <linux/mfd/tmio.h>
  38. #include <linux/usb/otg.h>
  39. #include <linux/usb/ehci_pdriver.h>
  40. #include <linux/usb/ohci_pdriver.h>
  41. #include <linux/pm_runtime.h>
  42. #include <mach/hardware.h>
  43. #include <mach/r8a7779.h>
  44. #include <mach/common.h>
  45. #include <mach/irqs.h>
  46. #include <asm/mach-types.h>
  47. #include <asm/mach/arch.h>
  48. #include <asm/traps.h>
  49. /* Fixed 3.3V regulator to be used by SDHI0 */
  50. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  51. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  52. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  53. };
  54. /* Dummy supplies, where voltage doesn't matter */
  55. static struct regulator_consumer_supply dummy_supplies[] = {
  56. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  57. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  58. };
  59. /* SMSC LAN89218 */
  60. static struct resource smsc911x_resources[] = {
  61. [0] = {
  62. .start = 0x18000000, /* ExCS0 */
  63. .end = 0x180000ff, /* A1->A7 */
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = gic_spi(28), /* IRQ 1 */
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct smsc911x_platform_config smsc911x_platdata = {
  72. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  73. .phy_interface = PHY_INTERFACE_MODE_MII,
  74. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  75. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  76. };
  77. static struct platform_device eth_device = {
  78. .name = "smsc911x",
  79. .id = -1,
  80. .dev = {
  81. .platform_data = &smsc911x_platdata,
  82. },
  83. .resource = smsc911x_resources,
  84. .num_resources = ARRAY_SIZE(smsc911x_resources),
  85. };
  86. static struct resource sdhi0_resources[] = {
  87. [0] = {
  88. .name = "sdhi0",
  89. .start = 0xffe4c000,
  90. .end = 0xffe4c0ff,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. [1] = {
  94. .start = gic_spi(104),
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  99. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  100. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  101. };
  102. static struct platform_device sdhi0_device = {
  103. .name = "sh_mobile_sdhi",
  104. .num_resources = ARRAY_SIZE(sdhi0_resources),
  105. .resource = sdhi0_resources,
  106. .id = 0,
  107. .dev = {
  108. .platform_data = &sdhi0_platform_data,
  109. }
  110. };
  111. /* Thermal */
  112. static struct resource thermal_resources[] = {
  113. [0] = {
  114. .start = 0xFFC48000,
  115. .end = 0xFFC48038 - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. };
  119. static struct platform_device thermal_device = {
  120. .name = "rcar_thermal",
  121. .resource = thermal_resources,
  122. .num_resources = ARRAY_SIZE(thermal_resources),
  123. };
  124. /* HSPI */
  125. static struct resource hspi_resources[] = {
  126. [0] = {
  127. .start = 0xFFFC7000,
  128. .end = 0xFFFC7018 - 1,
  129. .flags = IORESOURCE_MEM,
  130. },
  131. };
  132. static struct platform_device hspi_device = {
  133. .name = "sh-hspi",
  134. .id = 0,
  135. .resource = hspi_resources,
  136. .num_resources = ARRAY_SIZE(hspi_resources),
  137. };
  138. /* USB PHY */
  139. static struct resource usb_phy_resources[] = {
  140. [0] = {
  141. .start = 0xffe70000,
  142. .end = 0xffe70900 - 1,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [1] = {
  146. .start = 0xfff70000,
  147. .end = 0xfff70900 - 1,
  148. .flags = IORESOURCE_MEM,
  149. },
  150. };
  151. static struct platform_device usb_phy_device = {
  152. .name = "rcar_usb_phy",
  153. .resource = usb_phy_resources,
  154. .num_resources = ARRAY_SIZE(usb_phy_resources),
  155. };
  156. static struct platform_device *marzen_devices[] __initdata = {
  157. &eth_device,
  158. &sdhi0_device,
  159. &thermal_device,
  160. &hspi_device,
  161. &usb_phy_device,
  162. };
  163. /* USB */
  164. static struct usb_phy *phy;
  165. static int usb_power_on(struct platform_device *pdev)
  166. {
  167. if (!phy)
  168. return -EIO;
  169. pm_runtime_enable(&pdev->dev);
  170. pm_runtime_get_sync(&pdev->dev);
  171. usb_phy_init(phy);
  172. return 0;
  173. }
  174. static void usb_power_off(struct platform_device *pdev)
  175. {
  176. if (!phy)
  177. return;
  178. usb_phy_shutdown(phy);
  179. pm_runtime_put_sync(&pdev->dev);
  180. pm_runtime_disable(&pdev->dev);
  181. }
  182. static struct usb_ehci_pdata ehcix_pdata = {
  183. .power_on = usb_power_on,
  184. .power_off = usb_power_off,
  185. .power_suspend = usb_power_off,
  186. };
  187. static struct resource ehci0_resources[] = {
  188. [0] = {
  189. .start = 0xffe70000,
  190. .end = 0xffe70400 - 1,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = gic_spi(44),
  195. .flags = IORESOURCE_IRQ,
  196. },
  197. };
  198. static struct platform_device ehci0_device = {
  199. .name = "ehci-platform",
  200. .id = 0,
  201. .dev = {
  202. .dma_mask = &ehci0_device.dev.coherent_dma_mask,
  203. .coherent_dma_mask = 0xffffffff,
  204. .platform_data = &ehcix_pdata,
  205. },
  206. .num_resources = ARRAY_SIZE(ehci0_resources),
  207. .resource = ehci0_resources,
  208. };
  209. static struct resource ehci1_resources[] = {
  210. [0] = {
  211. .start = 0xfff70000,
  212. .end = 0xfff70400 - 1,
  213. .flags = IORESOURCE_MEM,
  214. },
  215. [1] = {
  216. .start = gic_spi(45),
  217. .flags = IORESOURCE_IRQ,
  218. },
  219. };
  220. static struct platform_device ehci1_device = {
  221. .name = "ehci-platform",
  222. .id = 1,
  223. .dev = {
  224. .dma_mask = &ehci1_device.dev.coherent_dma_mask,
  225. .coherent_dma_mask = 0xffffffff,
  226. .platform_data = &ehcix_pdata,
  227. },
  228. .num_resources = ARRAY_SIZE(ehci1_resources),
  229. .resource = ehci1_resources,
  230. };
  231. static struct usb_ohci_pdata ohcix_pdata = {
  232. .power_on = usb_power_on,
  233. .power_off = usb_power_off,
  234. .power_suspend = usb_power_off,
  235. };
  236. static struct resource ohci0_resources[] = {
  237. [0] = {
  238. .start = 0xffe70400,
  239. .end = 0xffe70800 - 1,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. [1] = {
  243. .start = gic_spi(44),
  244. .flags = IORESOURCE_IRQ,
  245. },
  246. };
  247. static struct platform_device ohci0_device = {
  248. .name = "ohci-platform",
  249. .id = 0,
  250. .dev = {
  251. .dma_mask = &ohci0_device.dev.coherent_dma_mask,
  252. .coherent_dma_mask = 0xffffffff,
  253. .platform_data = &ohcix_pdata,
  254. },
  255. .num_resources = ARRAY_SIZE(ohci0_resources),
  256. .resource = ohci0_resources,
  257. };
  258. static struct resource ohci1_resources[] = {
  259. [0] = {
  260. .start = 0xfff70400,
  261. .end = 0xfff70800 - 1,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. [1] = {
  265. .start = gic_spi(45),
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. };
  269. static struct platform_device ohci1_device = {
  270. .name = "ohci-platform",
  271. .id = 1,
  272. .dev = {
  273. .dma_mask = &ohci1_device.dev.coherent_dma_mask,
  274. .coherent_dma_mask = 0xffffffff,
  275. .platform_data = &ohcix_pdata,
  276. },
  277. .num_resources = ARRAY_SIZE(ohci1_resources),
  278. .resource = ohci1_resources,
  279. };
  280. static struct platform_device *marzen_late_devices[] __initdata = {
  281. &ehci0_device,
  282. &ehci1_device,
  283. &ohci0_device,
  284. &ohci1_device,
  285. };
  286. void __init marzen_init_late(void)
  287. {
  288. /* get usb phy */
  289. phy = usb_get_phy(USB_PHY_TYPE_USB2);
  290. shmobile_init_late();
  291. platform_add_devices(marzen_late_devices,
  292. ARRAY_SIZE(marzen_late_devices));
  293. }
  294. static const struct pinctrl_map marzen_pinctrl_map[] = {
  295. /* SCIF2 (CN18: DEBUG0) */
  296. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  297. "scif2_data_c", "scif2"),
  298. /* SCIF4 (CN19: DEBUG1) */
  299. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  300. "scif4_data", "scif4"),
  301. /* SDHI0 */
  302. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  303. "sdhi0_data4", "sdhi0"),
  304. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  305. "sdhi0_ctrl", "sdhi0"),
  306. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  307. "sdhi0_cd", "sdhi0"),
  308. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  309. "sdhi0_wp", "sdhi0"),
  310. };
  311. static void __init marzen_init(void)
  312. {
  313. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  314. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  315. regulator_register_fixed(1, dummy_supplies,
  316. ARRAY_SIZE(dummy_supplies));
  317. pinctrl_register_mappings(marzen_pinctrl_map,
  318. ARRAY_SIZE(marzen_pinctrl_map));
  319. r8a7779_pinmux_init();
  320. /* LAN89218 */
  321. gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
  322. gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
  323. /* HSPI 0 */
  324. gpio_request(GPIO_FN_HSPI_CLK0, NULL);
  325. gpio_request(GPIO_FN_HSPI_CS0, NULL);
  326. gpio_request(GPIO_FN_HSPI_TX0, NULL);
  327. gpio_request(GPIO_FN_HSPI_RX0, NULL);
  328. /* USB (CN21) */
  329. gpio_request(GPIO_FN_USB_OVC0, NULL);
  330. gpio_request(GPIO_FN_USB_OVC1, NULL);
  331. gpio_request(GPIO_FN_USB_OVC2, NULL);
  332. /* USB (CN22) */
  333. gpio_request(GPIO_FN_USB_PENC2, NULL);
  334. r8a7779_add_standard_devices();
  335. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  336. }
  337. MACHINE_START(MARZEN, "marzen")
  338. .smp = smp_ops(r8a7779_smp_ops),
  339. .map_io = r8a7779_map_io,
  340. .init_early = r8a7779_add_early_devices,
  341. .nr_irqs = NR_IRQS_LEGACY,
  342. .init_irq = r8a7779_init_irq,
  343. .init_machine = marzen_init,
  344. .init_late = marzen_init_late,
  345. .init_time = r8a7779_earlytimer_init,
  346. MACHINE_END