board-marzen.c 9.0 KB

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