setup-r8a7778.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * r8a7778 processor support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. * Copyright (C) 2013 Cogent Embedded, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/io.h>
  23. #include <linux/irqchip/arm-gic.h>
  24. #include <linux/of.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/platform_data/dma-rcar-hpbdma.h>
  27. #include <linux/platform_data/gpio-rcar.h>
  28. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/irqchip.h>
  31. #include <linux/serial_sci.h>
  32. #include <linux/sh_timer.h>
  33. #include <linux/pm_runtime.h>
  34. #include <linux/usb/phy.h>
  35. #include <linux/usb/hcd.h>
  36. #include <linux/usb/ehci_pdriver.h>
  37. #include <linux/usb/ohci_pdriver.h>
  38. #include <linux/dma-mapping.h>
  39. #include <mach/irqs.h>
  40. #include <mach/r8a7778.h>
  41. #include <mach/common.h>
  42. #include <asm/mach/arch.h>
  43. #include <asm/hardware/cache-l2x0.h>
  44. /* SCIF */
  45. #define R8A7778_SCIF(index, baseaddr, irq) \
  46. static struct plat_sci_port scif##index##_platform_data = { \
  47. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  48. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
  49. .type = PORT_SCIF, \
  50. }; \
  51. \
  52. static struct resource scif##index##_resources[] = { \
  53. DEFINE_RES_MEM(baseaddr, 0x100), \
  54. DEFINE_RES_IRQ(irq), \
  55. }
  56. R8A7778_SCIF(0, 0xffe40000, gic_iid(0x66));
  57. R8A7778_SCIF(1, 0xffe41000, gic_iid(0x67));
  58. R8A7778_SCIF(2, 0xffe42000, gic_iid(0x68));
  59. R8A7778_SCIF(3, 0xffe43000, gic_iid(0x69));
  60. R8A7778_SCIF(4, 0xffe44000, gic_iid(0x6a));
  61. R8A7778_SCIF(5, 0xffe45000, gic_iid(0x6b));
  62. #define r8a7778_register_scif(index) \
  63. platform_device_register_resndata(&platform_bus, "sh-sci", index, \
  64. scif##index##_resources, \
  65. ARRAY_SIZE(scif##index##_resources), \
  66. &scif##index##_platform_data, \
  67. sizeof(scif##index##_platform_data))
  68. /* TMU */
  69. static struct sh_timer_config sh_tmu0_platform_data = {
  70. .channels_mask = 7,
  71. };
  72. static struct resource sh_tmu0_resources[] = {
  73. DEFINE_RES_MEM(0xffd80000, 0x30),
  74. DEFINE_RES_IRQ(gic_iid(0x40)),
  75. DEFINE_RES_IRQ(gic_iid(0x41)),
  76. DEFINE_RES_IRQ(gic_iid(0x42)),
  77. };
  78. #define r8a7778_register_tmu(idx) \
  79. platform_device_register_resndata( \
  80. &platform_bus, "sh-tmu", idx, \
  81. sh_tmu##idx##_resources, \
  82. ARRAY_SIZE(sh_tmu##idx##_resources), \
  83. &sh_tmu##idx##_platform_data, \
  84. sizeof(sh_tmu##idx##_platform_data))
  85. int r8a7778_usb_phy_power(bool enable)
  86. {
  87. static struct usb_phy *phy = NULL;
  88. int ret = 0;
  89. if (!phy)
  90. phy = usb_get_phy(USB_PHY_TYPE_USB2);
  91. if (IS_ERR(phy)) {
  92. pr_err("kernel doesn't have usb phy driver\n");
  93. return PTR_ERR(phy);
  94. }
  95. if (enable)
  96. ret = usb_phy_init(phy);
  97. else
  98. usb_phy_shutdown(phy);
  99. return ret;
  100. }
  101. /* USB */
  102. static int usb_power_on(struct platform_device *pdev)
  103. {
  104. int ret = r8a7778_usb_phy_power(true);
  105. if (ret)
  106. return ret;
  107. pm_runtime_enable(&pdev->dev);
  108. pm_runtime_get_sync(&pdev->dev);
  109. return 0;
  110. }
  111. static void usb_power_off(struct platform_device *pdev)
  112. {
  113. if (r8a7778_usb_phy_power(false))
  114. return;
  115. pm_runtime_put_sync(&pdev->dev);
  116. pm_runtime_disable(&pdev->dev);
  117. }
  118. static int ehci_init_internal_buffer(struct usb_hcd *hcd)
  119. {
  120. /*
  121. * Below are recommended values from the datasheet;
  122. * see [USB :: Setting of EHCI Internal Buffer].
  123. */
  124. /* EHCI IP internal buffer setting */
  125. iowrite32(0x00ff0040, hcd->regs + 0x0094);
  126. /* EHCI IP internal buffer enable */
  127. iowrite32(0x00000001, hcd->regs + 0x009C);
  128. return 0;
  129. }
  130. static struct usb_ehci_pdata ehci_pdata __initdata = {
  131. .power_on = usb_power_on,
  132. .power_off = usb_power_off,
  133. .power_suspend = usb_power_off,
  134. .pre_setup = ehci_init_internal_buffer,
  135. };
  136. static struct resource ehci_resources[] __initdata = {
  137. DEFINE_RES_MEM(0xffe70000, 0x400),
  138. DEFINE_RES_IRQ(gic_iid(0x4c)),
  139. };
  140. static struct usb_ohci_pdata ohci_pdata __initdata = {
  141. .power_on = usb_power_on,
  142. .power_off = usb_power_off,
  143. .power_suspend = usb_power_off,
  144. };
  145. static struct resource ohci_resources[] __initdata = {
  146. DEFINE_RES_MEM(0xffe70400, 0x400),
  147. DEFINE_RES_IRQ(gic_iid(0x4c)),
  148. };
  149. #define USB_PLATFORM_INFO(hci) \
  150. static struct platform_device_info hci##_info __initdata = { \
  151. .parent = &platform_bus, \
  152. .name = #hci "-platform", \
  153. .id = -1, \
  154. .res = hci##_resources, \
  155. .num_res = ARRAY_SIZE(hci##_resources), \
  156. .data = &hci##_pdata, \
  157. .size_data = sizeof(hci##_pdata), \
  158. .dma_mask = DMA_BIT_MASK(32), \
  159. }
  160. USB_PLATFORM_INFO(ehci);
  161. USB_PLATFORM_INFO(ohci);
  162. /* PFC/GPIO */
  163. static struct resource pfc_resources[] __initdata = {
  164. DEFINE_RES_MEM(0xfffc0000, 0x118),
  165. };
  166. #define R8A7778_GPIO(idx) \
  167. static struct resource r8a7778_gpio##idx##_resources[] __initdata = { \
  168. DEFINE_RES_MEM(0xffc40000 + 0x1000 * (idx), 0x30), \
  169. DEFINE_RES_IRQ(gic_iid(0x87)), \
  170. }; \
  171. \
  172. static struct gpio_rcar_config r8a7778_gpio##idx##_platform_data __initdata = { \
  173. .gpio_base = 32 * (idx), \
  174. .irq_base = GPIO_IRQ_BASE(idx), \
  175. .number_of_pins = 32, \
  176. .pctl_name = "pfc-r8a7778", \
  177. }
  178. R8A7778_GPIO(0);
  179. R8A7778_GPIO(1);
  180. R8A7778_GPIO(2);
  181. R8A7778_GPIO(3);
  182. R8A7778_GPIO(4);
  183. #define r8a7778_register_gpio(idx) \
  184. platform_device_register_resndata( \
  185. &platform_bus, "gpio_rcar", idx, \
  186. r8a7778_gpio##idx##_resources, \
  187. ARRAY_SIZE(r8a7778_gpio##idx##_resources), \
  188. &r8a7778_gpio##idx##_platform_data, \
  189. sizeof(r8a7778_gpio##idx##_platform_data))
  190. void __init r8a7778_pinmux_init(void)
  191. {
  192. platform_device_register_simple(
  193. "pfc-r8a7778", -1,
  194. pfc_resources,
  195. ARRAY_SIZE(pfc_resources));
  196. r8a7778_register_gpio(0);
  197. r8a7778_register_gpio(1);
  198. r8a7778_register_gpio(2);
  199. r8a7778_register_gpio(3);
  200. r8a7778_register_gpio(4);
  201. };
  202. /* I2C */
  203. static struct resource i2c_resources[] __initdata = {
  204. /* I2C0 */
  205. DEFINE_RES_MEM(0xffc70000, 0x1000),
  206. DEFINE_RES_IRQ(gic_iid(0x63)),
  207. /* I2C1 */
  208. DEFINE_RES_MEM(0xffc71000, 0x1000),
  209. DEFINE_RES_IRQ(gic_iid(0x6e)),
  210. /* I2C2 */
  211. DEFINE_RES_MEM(0xffc72000, 0x1000),
  212. DEFINE_RES_IRQ(gic_iid(0x6c)),
  213. /* I2C3 */
  214. DEFINE_RES_MEM(0xffc73000, 0x1000),
  215. DEFINE_RES_IRQ(gic_iid(0x6d)),
  216. };
  217. static void __init r8a7778_register_i2c(int id)
  218. {
  219. BUG_ON(id < 0 || id > 3);
  220. platform_device_register_simple(
  221. "i2c-rcar", id,
  222. i2c_resources + (2 * id), 2);
  223. }
  224. /* HSPI */
  225. static struct resource hspi_resources[] __initdata = {
  226. /* HSPI0 */
  227. DEFINE_RES_MEM(0xfffc7000, 0x18),
  228. DEFINE_RES_IRQ(gic_iid(0x5f)),
  229. /* HSPI1 */
  230. DEFINE_RES_MEM(0xfffc8000, 0x18),
  231. DEFINE_RES_IRQ(gic_iid(0x74)),
  232. /* HSPI2 */
  233. DEFINE_RES_MEM(0xfffc6000, 0x18),
  234. DEFINE_RES_IRQ(gic_iid(0x75)),
  235. };
  236. static void __init r8a7778_register_hspi(int id)
  237. {
  238. BUG_ON(id < 0 || id > 2);
  239. platform_device_register_simple(
  240. "sh-hspi", id,
  241. hspi_resources + (2 * id), 2);
  242. }
  243. void __init r8a7778_add_dt_devices(void)
  244. {
  245. #ifdef CONFIG_CACHE_L2X0
  246. void __iomem *base = ioremap_nocache(0xf0100000, 0x1000);
  247. if (base) {
  248. /*
  249. * Shared attribute override enable, 64K*16way
  250. * don't call iounmap(base)
  251. */
  252. l2x0_init(base, 0x00400000, 0xc20f0fff);
  253. }
  254. #endif
  255. r8a7778_register_scif(0);
  256. r8a7778_register_scif(1);
  257. r8a7778_register_scif(2);
  258. r8a7778_register_scif(3);
  259. r8a7778_register_scif(4);
  260. r8a7778_register_scif(5);
  261. r8a7778_register_tmu(0);
  262. }
  263. /* HPB-DMA */
  264. /* Asynchronous mode register (ASYNCMDR) bits */
  265. #define HPB_DMAE_ASYNCMDR_ASMD22_MASK BIT(2) /* SDHI0 */
  266. #define HPB_DMAE_ASYNCMDR_ASMD22_SINGLE BIT(2) /* SDHI0 */
  267. #define HPB_DMAE_ASYNCMDR_ASMD22_MULTI 0 /* SDHI0 */
  268. #define HPB_DMAE_ASYNCMDR_ASMD21_MASK BIT(1) /* SDHI0 */
  269. #define HPB_DMAE_ASYNCMDR_ASMD21_SINGLE BIT(1) /* SDHI0 */
  270. #define HPB_DMAE_ASYNCMDR_ASMD21_MULTI 0 /* SDHI0 */
  271. #define HPBDMA_SSI(_id) \
  272. { \
  273. .id = HPBDMA_SLAVE_SSI## _id ##_TX, \
  274. .addr = 0xffd91008 + (_id * 0x40), \
  275. .dcr = HPB_DMAE_DCR_CT | \
  276. HPB_DMAE_DCR_DIP | \
  277. HPB_DMAE_DCR_SPDS_32BIT | \
  278. HPB_DMAE_DCR_DMDL | \
  279. HPB_DMAE_DCR_DPDS_32BIT, \
  280. .port = _id + (_id << 8), \
  281. .dma_ch = (28 + _id), \
  282. }, { \
  283. .id = HPBDMA_SLAVE_SSI## _id ##_RX, \
  284. .addr = 0xffd9100c + (_id * 0x40), \
  285. .dcr = HPB_DMAE_DCR_CT | \
  286. HPB_DMAE_DCR_DIP | \
  287. HPB_DMAE_DCR_SMDL | \
  288. HPB_DMAE_DCR_SPDS_32BIT | \
  289. HPB_DMAE_DCR_DPDS_32BIT, \
  290. .port = _id + (_id << 8), \
  291. .dma_ch = (28 + _id), \
  292. }
  293. #define HPBDMA_HPBIF(_id) \
  294. { \
  295. .id = HPBDMA_SLAVE_HPBIF## _id ##_TX, \
  296. .addr = 0xffda0000 + (_id * 0x1000), \
  297. .dcr = HPB_DMAE_DCR_CT | \
  298. HPB_DMAE_DCR_DIP | \
  299. HPB_DMAE_DCR_SPDS_32BIT | \
  300. HPB_DMAE_DCR_DMDL | \
  301. HPB_DMAE_DCR_DPDS_32BIT, \
  302. .port = 0x1111, \
  303. .dma_ch = (28 + _id), \
  304. }, { \
  305. .id = HPBDMA_SLAVE_HPBIF## _id ##_RX, \
  306. .addr = 0xffda0000 + (_id * 0x1000), \
  307. .dcr = HPB_DMAE_DCR_CT | \
  308. HPB_DMAE_DCR_DIP | \
  309. HPB_DMAE_DCR_SMDL | \
  310. HPB_DMAE_DCR_SPDS_32BIT | \
  311. HPB_DMAE_DCR_DPDS_32BIT, \
  312. .port = 0x1111, \
  313. .dma_ch = (28 + _id), \
  314. }
  315. static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
  316. {
  317. .id = HPBDMA_SLAVE_SDHI0_TX,
  318. .addr = 0xffe4c000 + 0x30,
  319. .dcr = HPB_DMAE_DCR_SPDS_16BIT |
  320. HPB_DMAE_DCR_DMDL |
  321. HPB_DMAE_DCR_DPDS_16BIT,
  322. .rstr = HPB_DMAE_ASYNCRSTR_ASRST21 |
  323. HPB_DMAE_ASYNCRSTR_ASRST22 |
  324. HPB_DMAE_ASYNCRSTR_ASRST23,
  325. .mdr = HPB_DMAE_ASYNCMDR_ASMD21_MULTI,
  326. .mdm = HPB_DMAE_ASYNCMDR_ASMD21_MASK,
  327. .port = 0x0D0C,
  328. .flags = HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
  329. .dma_ch = 21,
  330. }, {
  331. .id = HPBDMA_SLAVE_SDHI0_RX,
  332. .addr = 0xffe4c000 + 0x30,
  333. .dcr = HPB_DMAE_DCR_SMDL |
  334. HPB_DMAE_DCR_SPDS_16BIT |
  335. HPB_DMAE_DCR_DPDS_16BIT,
  336. .rstr = HPB_DMAE_ASYNCRSTR_ASRST21 |
  337. HPB_DMAE_ASYNCRSTR_ASRST22 |
  338. HPB_DMAE_ASYNCRSTR_ASRST23,
  339. .mdr = HPB_DMAE_ASYNCMDR_ASMD22_MULTI,
  340. .mdm = HPB_DMAE_ASYNCMDR_ASMD22_MASK,
  341. .port = 0x0D0C,
  342. .flags = HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
  343. .dma_ch = 22,
  344. }, {
  345. .id = HPBDMA_SLAVE_USBFUNC_TX, /* for D0 */
  346. .addr = 0xffe60018,
  347. .dcr = HPB_DMAE_DCR_SPDS_32BIT |
  348. HPB_DMAE_DCR_DMDL |
  349. HPB_DMAE_DCR_DPDS_32BIT,
  350. .port = 0x0000,
  351. .dma_ch = 14,
  352. }, {
  353. .id = HPBDMA_SLAVE_USBFUNC_RX, /* for D1 */
  354. .addr = 0xffe6001c,
  355. .dcr = HPB_DMAE_DCR_SMDL |
  356. HPB_DMAE_DCR_SPDS_32BIT |
  357. HPB_DMAE_DCR_DPDS_32BIT,
  358. .port = 0x0101,
  359. .dma_ch = 15,
  360. },
  361. HPBDMA_SSI(0),
  362. HPBDMA_SSI(1),
  363. HPBDMA_SSI(2),
  364. HPBDMA_SSI(3),
  365. HPBDMA_SSI(4),
  366. HPBDMA_SSI(5),
  367. HPBDMA_SSI(6),
  368. HPBDMA_SSI(7),
  369. HPBDMA_SSI(8),
  370. HPBDMA_HPBIF(0),
  371. HPBDMA_HPBIF(1),
  372. HPBDMA_HPBIF(2),
  373. HPBDMA_HPBIF(3),
  374. HPBDMA_HPBIF(4),
  375. HPBDMA_HPBIF(5),
  376. HPBDMA_HPBIF(6),
  377. HPBDMA_HPBIF(7),
  378. HPBDMA_HPBIF(8),
  379. };
  380. static const struct hpb_dmae_channel hpb_dmae_channels[] = {
  381. HPB_DMAE_CHANNEL(0x7c, HPBDMA_SLAVE_USBFUNC_TX), /* ch. 14 */
  382. HPB_DMAE_CHANNEL(0x7c, HPBDMA_SLAVE_USBFUNC_RX), /* ch. 15 */
  383. HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch. 21 */
  384. HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch. 22 */
  385. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI0_TX), /* ch. 28 */
  386. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI0_RX), /* ch. 28 */
  387. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF0_TX), /* ch. 28 */
  388. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF0_RX), /* ch. 28 */
  389. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI1_TX), /* ch. 29 */
  390. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI1_RX), /* ch. 29 */
  391. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF1_TX), /* ch. 29 */
  392. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF1_RX), /* ch. 29 */
  393. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI2_TX), /* ch. 30 */
  394. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI2_RX), /* ch. 30 */
  395. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF2_TX), /* ch. 30 */
  396. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF2_RX), /* ch. 30 */
  397. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI3_TX), /* ch. 31 */
  398. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI3_RX), /* ch. 31 */
  399. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF3_TX), /* ch. 31 */
  400. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF3_RX), /* ch. 31 */
  401. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI4_TX), /* ch. 32 */
  402. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI4_RX), /* ch. 32 */
  403. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF4_TX), /* ch. 32 */
  404. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF4_RX), /* ch. 32 */
  405. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI5_TX), /* ch. 33 */
  406. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI5_RX), /* ch. 33 */
  407. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF5_TX), /* ch. 33 */
  408. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF5_RX), /* ch. 33 */
  409. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI6_TX), /* ch. 34 */
  410. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI6_RX), /* ch. 34 */
  411. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF6_TX), /* ch. 34 */
  412. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF6_RX), /* ch. 34 */
  413. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI7_TX), /* ch. 35 */
  414. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI7_RX), /* ch. 35 */
  415. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF7_TX), /* ch. 35 */
  416. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF7_RX), /* ch. 35 */
  417. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI8_TX), /* ch. 36 */
  418. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI8_RX), /* ch. 36 */
  419. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF8_TX), /* ch. 36 */
  420. HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF8_RX), /* ch. 36 */
  421. };
  422. static struct hpb_dmae_pdata dma_platform_data __initdata = {
  423. .slaves = hpb_dmae_slaves,
  424. .num_slaves = ARRAY_SIZE(hpb_dmae_slaves),
  425. .channels = hpb_dmae_channels,
  426. .num_channels = ARRAY_SIZE(hpb_dmae_channels),
  427. .ts_shift = {
  428. [XMIT_SZ_8BIT] = 0,
  429. [XMIT_SZ_16BIT] = 1,
  430. [XMIT_SZ_32BIT] = 2,
  431. },
  432. .num_hw_channels = 39,
  433. };
  434. static struct resource hpb_dmae_resources[] __initdata = {
  435. /* Channel registers */
  436. DEFINE_RES_MEM(0xffc08000, 0x1000),
  437. /* Common registers */
  438. DEFINE_RES_MEM(0xffc09000, 0x170),
  439. /* Asynchronous reset registers */
  440. DEFINE_RES_MEM(0xffc00300, 4),
  441. /* Asynchronous mode registers */
  442. DEFINE_RES_MEM(0xffc00400, 4),
  443. /* IRQ for DMA channels */
  444. DEFINE_RES_NAMED(gic_iid(0x7b), 5, NULL, IORESOURCE_IRQ),
  445. };
  446. static void __init r8a7778_register_hpb_dmae(void)
  447. {
  448. platform_device_register_resndata(&platform_bus, "hpb-dma-engine", -1,
  449. hpb_dmae_resources,
  450. ARRAY_SIZE(hpb_dmae_resources),
  451. &dma_platform_data,
  452. sizeof(dma_platform_data));
  453. }
  454. void __init r8a7778_add_standard_devices(void)
  455. {
  456. r8a7778_add_dt_devices();
  457. r8a7778_register_i2c(0);
  458. r8a7778_register_i2c(1);
  459. r8a7778_register_i2c(2);
  460. r8a7778_register_i2c(3);
  461. r8a7778_register_hspi(0);
  462. r8a7778_register_hspi(1);
  463. r8a7778_register_hspi(2);
  464. r8a7778_register_hpb_dmae();
  465. }
  466. void __init r8a7778_init_late(void)
  467. {
  468. platform_device_register_full(&ehci_info);
  469. platform_device_register_full(&ohci_info);
  470. }
  471. static struct renesas_intc_irqpin_config irqpin_platform_data __initdata = {
  472. .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
  473. .sense_bitfield_width = 2,
  474. };
  475. static struct resource irqpin_resources[] __initdata = {
  476. DEFINE_RES_MEM(0xfe78001c, 4), /* ICR1 */
  477. DEFINE_RES_MEM(0xfe780010, 4), /* INTPRI */
  478. DEFINE_RES_MEM(0xfe780024, 4), /* INTREQ */
  479. DEFINE_RES_MEM(0xfe780044, 4), /* INTMSK0 */
  480. DEFINE_RES_MEM(0xfe780064, 4), /* INTMSKCLR0 */
  481. DEFINE_RES_IRQ(gic_iid(0x3b)), /* IRQ0 */
  482. DEFINE_RES_IRQ(gic_iid(0x3c)), /* IRQ1 */
  483. DEFINE_RES_IRQ(gic_iid(0x3d)), /* IRQ2 */
  484. DEFINE_RES_IRQ(gic_iid(0x3e)), /* IRQ3 */
  485. };
  486. void __init r8a7778_init_irq_extpin_dt(int irlm)
  487. {
  488. void __iomem *icr0 = ioremap_nocache(0xfe780000, PAGE_SIZE);
  489. unsigned long tmp;
  490. if (!icr0) {
  491. pr_warn("r8a7778: unable to setup external irq pin mode\n");
  492. return;
  493. }
  494. tmp = ioread32(icr0);
  495. if (irlm)
  496. tmp |= 1 << 23; /* IRQ0 -> IRQ3 as individual pins */
  497. else
  498. tmp &= ~(1 << 23); /* IRL mode - not supported */
  499. tmp |= (1 << 21); /* LVLMODE = 1 */
  500. iowrite32(tmp, icr0);
  501. iounmap(icr0);
  502. }
  503. void __init r8a7778_init_irq_extpin(int irlm)
  504. {
  505. r8a7778_init_irq_extpin_dt(irlm);
  506. if (irlm)
  507. platform_device_register_resndata(
  508. &platform_bus, "renesas_intc_irqpin", -1,
  509. irqpin_resources, ARRAY_SIZE(irqpin_resources),
  510. &irqpin_platform_data, sizeof(irqpin_platform_data));
  511. }
  512. void __init r8a7778_init_delay(void)
  513. {
  514. shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
  515. }
  516. #ifdef CONFIG_USE_OF
  517. #define INT2SMSKCR0 0x82288 /* 0xfe782288 */
  518. #define INT2SMSKCR1 0x8228c /* 0xfe78228c */
  519. #define INT2NTSR0 0x00018 /* 0xfe700018 */
  520. #define INT2NTSR1 0x0002c /* 0xfe70002c */
  521. void __init r8a7778_init_irq_dt(void)
  522. {
  523. void __iomem *base = ioremap_nocache(0xfe700000, 0x00100000);
  524. BUG_ON(!base);
  525. irqchip_init();
  526. /* route all interrupts to ARM */
  527. __raw_writel(0x73ffffff, base + INT2NTSR0);
  528. __raw_writel(0xffffffff, base + INT2NTSR1);
  529. /* unmask all known interrupts in INTCS2 */
  530. __raw_writel(0x08330773, base + INT2SMSKCR0);
  531. __raw_writel(0x00311110, base + INT2SMSKCR1);
  532. iounmap(base);
  533. }
  534. static const char *r8a7778_compat_dt[] __initdata = {
  535. "renesas,r8a7778",
  536. NULL,
  537. };
  538. DT_MACHINE_START(R8A7778_DT, "Generic R8A7778 (Flattened Device Tree)")
  539. .init_early = r8a7778_init_delay,
  540. .init_irq = r8a7778_init_irq_dt,
  541. .dt_compat = r8a7778_compat_dt,
  542. .init_late = r8a7778_init_late,
  543. MACHINE_END
  544. #endif /* CONFIG_USE_OF */