setup-r8a7778.c 17 KB

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