board-marzen.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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/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 usb_ohci_pdata ohcix_pdata = {
  230. .power_on = usb_power_on,
  231. .power_off = usb_power_off,
  232. .power_suspend = usb_power_off,
  233. };
  234. static struct resource ohci0_resources[] = {
  235. [0] = {
  236. .start = 0xffe70400,
  237. .end = 0xffe70800 - 1,
  238. .flags = IORESOURCE_MEM,
  239. },
  240. [1] = {
  241. .start = gic_spi(44),
  242. .flags = IORESOURCE_IRQ,
  243. },
  244. };
  245. static struct platform_device ohci0_device = {
  246. .name = "ohci-platform",
  247. .id = 0,
  248. .dev = {
  249. .dma_mask = &ohci0_device.dev.coherent_dma_mask,
  250. .coherent_dma_mask = 0xffffffff,
  251. .platform_data = &ohcix_pdata,
  252. },
  253. .num_resources = ARRAY_SIZE(ohci0_resources),
  254. .resource = ohci0_resources,
  255. };
  256. static struct resource ohci1_resources[] = {
  257. [0] = {
  258. .start = 0xfff70400,
  259. .end = 0xfff70800 - 1,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = gic_spi(45),
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static struct platform_device ohci1_device = {
  268. .name = "ohci-platform",
  269. .id = 1,
  270. .dev = {
  271. .dma_mask = &ohci1_device.dev.coherent_dma_mask,
  272. .coherent_dma_mask = 0xffffffff,
  273. .platform_data = &ohcix_pdata,
  274. },
  275. .num_resources = ARRAY_SIZE(ohci1_resources),
  276. .resource = ohci1_resources,
  277. };
  278. static struct platform_device *marzen_late_devices[] __initdata = {
  279. &ehci0_device,
  280. &ehci1_device,
  281. &ohci0_device,
  282. &ohci1_device,
  283. };
  284. void __init marzen_init_late(void)
  285. {
  286. /* get usb phy */
  287. phy = usb_get_phy(USB_PHY_TYPE_USB2);
  288. shmobile_init_late();
  289. platform_add_devices(marzen_late_devices,
  290. ARRAY_SIZE(marzen_late_devices));
  291. }
  292. static void __init marzen_init(void)
  293. {
  294. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  295. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  296. regulator_register_fixed(1, dummy_supplies,
  297. ARRAY_SIZE(dummy_supplies));
  298. r8a7779_pinmux_init();
  299. /* SCIF2 (CN18: DEBUG0) */
  300. gpio_request(GPIO_FN_TX2_C, NULL);
  301. gpio_request(GPIO_FN_RX2_C, NULL);
  302. /* SCIF4 (CN19: DEBUG1) */
  303. gpio_request(GPIO_FN_TX4, NULL);
  304. gpio_request(GPIO_FN_RX4, NULL);
  305. /* LAN89218 */
  306. gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
  307. gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
  308. /* SD0 (CN20) */
  309. gpio_request(GPIO_FN_SD0_CLK, NULL);
  310. gpio_request(GPIO_FN_SD0_CMD, NULL);
  311. gpio_request(GPIO_FN_SD0_DAT0, NULL);
  312. gpio_request(GPIO_FN_SD0_DAT1, NULL);
  313. gpio_request(GPIO_FN_SD0_DAT2, NULL);
  314. gpio_request(GPIO_FN_SD0_DAT3, NULL);
  315. gpio_request(GPIO_FN_SD0_CD, NULL);
  316. gpio_request(GPIO_FN_SD0_WP, NULL);
  317. /* HSPI 0 */
  318. gpio_request(GPIO_FN_HSPI_CLK0, NULL);
  319. gpio_request(GPIO_FN_HSPI_CS0, NULL);
  320. gpio_request(GPIO_FN_HSPI_TX0, NULL);
  321. gpio_request(GPIO_FN_HSPI_RX0, NULL);
  322. /* USB (CN21) */
  323. gpio_request(GPIO_FN_USB_OVC0, NULL);
  324. gpio_request(GPIO_FN_USB_OVC1, NULL);
  325. gpio_request(GPIO_FN_USB_OVC2, NULL);
  326. /* USB (CN22) */
  327. gpio_request(GPIO_FN_USB_PENC2, NULL);
  328. r8a7779_add_standard_devices();
  329. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  330. }
  331. MACHINE_START(MARZEN, "marzen")
  332. .smp = smp_ops(r8a7779_smp_ops),
  333. .map_io = r8a7779_map_io,
  334. .init_early = r8a7779_add_early_devices,
  335. .nr_irqs = NR_IRQS_LEGACY,
  336. .init_irq = r8a7779_init_irq,
  337. .init_machine = marzen_init,
  338. .init_late = marzen_init_late,
  339. .init_time = r8a7779_earlytimer_init,
  340. MACHINE_END