setup-r8a7779.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. /*
  2. * r8a7779 processor support
  3. *
  4. * Copyright (C) 2011, 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  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/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/irqchip.h>
  26. #include <linux/irqchip/arm-gic.h>
  27. #include <linux/of_platform.h>
  28. #include <linux/platform_data/gpio-rcar.h>
  29. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/delay.h>
  32. #include <linux/input.h>
  33. #include <linux/io.h>
  34. #include <linux/serial_sci.h>
  35. #include <linux/sh_timer.h>
  36. #include <linux/dma-mapping.h>
  37. #include <linux/usb/otg.h>
  38. #include <linux/usb/hcd.h>
  39. #include <linux/usb/ehci_pdriver.h>
  40. #include <linux/usb/ohci_pdriver.h>
  41. #include <linux/pm_runtime.h>
  42. #include <mach/irqs.h>
  43. #include <mach/r8a7779.h>
  44. #include <mach/common.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/mach/arch.h>
  47. #include <asm/mach/time.h>
  48. #include <asm/mach/map.h>
  49. #include <asm/hardware/cache-l2x0.h>
  50. static struct map_desc r8a7779_io_desc[] __initdata = {
  51. /* 2M entity map for 0xf0000000 (MPCORE) */
  52. {
  53. .virtual = 0xf0000000,
  54. .pfn = __phys_to_pfn(0xf0000000),
  55. .length = SZ_2M,
  56. .type = MT_DEVICE_NONSHARED
  57. },
  58. /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
  59. {
  60. .virtual = 0xfe000000,
  61. .pfn = __phys_to_pfn(0xfe000000),
  62. .length = SZ_16M,
  63. .type = MT_DEVICE_NONSHARED
  64. },
  65. };
  66. void __init r8a7779_map_io(void)
  67. {
  68. iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
  69. }
  70. /* IRQ */
  71. #define INT2SMSKCR0 IOMEM(0xfe7822a0)
  72. #define INT2SMSKCR1 IOMEM(0xfe7822a4)
  73. #define INT2SMSKCR2 IOMEM(0xfe7822a8)
  74. #define INT2SMSKCR3 IOMEM(0xfe7822ac)
  75. #define INT2SMSKCR4 IOMEM(0xfe7822b0)
  76. #define INT2NTSR0 IOMEM(0xfe700060)
  77. #define INT2NTSR1 IOMEM(0xfe700064)
  78. static struct renesas_intc_irqpin_config irqpin0_platform_data __initdata = {
  79. .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
  80. .sense_bitfield_width = 2,
  81. };
  82. static struct resource irqpin0_resources[] __initdata = {
  83. DEFINE_RES_MEM(0xfe78001c, 4), /* ICR1 */
  84. DEFINE_RES_MEM(0xfe780010, 4), /* INTPRI */
  85. DEFINE_RES_MEM(0xfe780024, 4), /* INTREQ */
  86. DEFINE_RES_MEM(0xfe780044, 4), /* INTMSK0 */
  87. DEFINE_RES_MEM(0xfe780064, 4), /* INTMSKCLR0 */
  88. DEFINE_RES_IRQ(gic_spi(27)), /* IRQ0 */
  89. DEFINE_RES_IRQ(gic_spi(28)), /* IRQ1 */
  90. DEFINE_RES_IRQ(gic_spi(29)), /* IRQ2 */
  91. DEFINE_RES_IRQ(gic_spi(30)), /* IRQ3 */
  92. };
  93. void __init r8a7779_init_irq_extpin(int irlm)
  94. {
  95. void __iomem *icr0 = ioremap_nocache(0xfe780000, PAGE_SIZE);
  96. u32 tmp;
  97. if (!icr0) {
  98. pr_warn("r8a7779: unable to setup external irq pin mode\n");
  99. return;
  100. }
  101. tmp = ioread32(icr0);
  102. if (irlm)
  103. tmp |= 1 << 23; /* IRQ0 -> IRQ3 as individual pins */
  104. else
  105. tmp &= ~(1 << 23); /* IRL mode - not supported */
  106. tmp |= (1 << 21); /* LVLMODE = 1 */
  107. iowrite32(tmp, icr0);
  108. iounmap(icr0);
  109. if (irlm)
  110. platform_device_register_resndata(
  111. &platform_bus, "renesas_intc_irqpin", -1,
  112. irqpin0_resources, ARRAY_SIZE(irqpin0_resources),
  113. &irqpin0_platform_data, sizeof(irqpin0_platform_data));
  114. }
  115. /* PFC/GPIO */
  116. static struct resource r8a7779_pfc_resources[] = {
  117. DEFINE_RES_MEM(0xfffc0000, 0x023c),
  118. };
  119. static struct platform_device r8a7779_pfc_device = {
  120. .name = "pfc-r8a7779",
  121. .id = -1,
  122. .resource = r8a7779_pfc_resources,
  123. .num_resources = ARRAY_SIZE(r8a7779_pfc_resources),
  124. };
  125. #define R8A7779_GPIO(idx, npins) \
  126. static struct resource r8a7779_gpio##idx##_resources[] = { \
  127. DEFINE_RES_MEM(0xffc40000 + (0x1000 * (idx)), 0x002c), \
  128. DEFINE_RES_IRQ(gic_iid(0xad + (idx))), \
  129. }; \
  130. \
  131. static struct gpio_rcar_config r8a7779_gpio##idx##_platform_data = { \
  132. .gpio_base = 32 * (idx), \
  133. .irq_base = 0, \
  134. .number_of_pins = npins, \
  135. .pctl_name = "pfc-r8a7779", \
  136. }; \
  137. \
  138. static struct platform_device r8a7779_gpio##idx##_device = { \
  139. .name = "gpio_rcar", \
  140. .id = idx, \
  141. .resource = r8a7779_gpio##idx##_resources, \
  142. .num_resources = ARRAY_SIZE(r8a7779_gpio##idx##_resources), \
  143. .dev = { \
  144. .platform_data = &r8a7779_gpio##idx##_platform_data, \
  145. }, \
  146. }
  147. R8A7779_GPIO(0, 32);
  148. R8A7779_GPIO(1, 32);
  149. R8A7779_GPIO(2, 32);
  150. R8A7779_GPIO(3, 32);
  151. R8A7779_GPIO(4, 32);
  152. R8A7779_GPIO(5, 32);
  153. R8A7779_GPIO(6, 9);
  154. static struct platform_device *r8a7779_pinctrl_devices[] __initdata = {
  155. &r8a7779_pfc_device,
  156. &r8a7779_gpio0_device,
  157. &r8a7779_gpio1_device,
  158. &r8a7779_gpio2_device,
  159. &r8a7779_gpio3_device,
  160. &r8a7779_gpio4_device,
  161. &r8a7779_gpio5_device,
  162. &r8a7779_gpio6_device,
  163. };
  164. void __init r8a7779_pinmux_init(void)
  165. {
  166. platform_add_devices(r8a7779_pinctrl_devices,
  167. ARRAY_SIZE(r8a7779_pinctrl_devices));
  168. }
  169. static struct plat_sci_port scif0_platform_data = {
  170. .mapbase = 0xffe40000,
  171. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  172. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  173. .scbrr_algo_id = SCBRR_ALGO_2,
  174. .type = PORT_SCIF,
  175. .irqs = SCIx_IRQ_MUXED(gic_iid(0x78)),
  176. };
  177. static struct platform_device scif0_device = {
  178. .name = "sh-sci",
  179. .id = 0,
  180. .dev = {
  181. .platform_data = &scif0_platform_data,
  182. },
  183. };
  184. static struct plat_sci_port scif1_platform_data = {
  185. .mapbase = 0xffe41000,
  186. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  187. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  188. .scbrr_algo_id = SCBRR_ALGO_2,
  189. .type = PORT_SCIF,
  190. .irqs = SCIx_IRQ_MUXED(gic_iid(0x79)),
  191. };
  192. static struct platform_device scif1_device = {
  193. .name = "sh-sci",
  194. .id = 1,
  195. .dev = {
  196. .platform_data = &scif1_platform_data,
  197. },
  198. };
  199. static struct plat_sci_port scif2_platform_data = {
  200. .mapbase = 0xffe42000,
  201. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  202. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  203. .scbrr_algo_id = SCBRR_ALGO_2,
  204. .type = PORT_SCIF,
  205. .irqs = SCIx_IRQ_MUXED(gic_iid(0x7a)),
  206. };
  207. static struct platform_device scif2_device = {
  208. .name = "sh-sci",
  209. .id = 2,
  210. .dev = {
  211. .platform_data = &scif2_platform_data,
  212. },
  213. };
  214. static struct plat_sci_port scif3_platform_data = {
  215. .mapbase = 0xffe43000,
  216. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  217. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  218. .scbrr_algo_id = SCBRR_ALGO_2,
  219. .type = PORT_SCIF,
  220. .irqs = SCIx_IRQ_MUXED(gic_iid(0x7b)),
  221. };
  222. static struct platform_device scif3_device = {
  223. .name = "sh-sci",
  224. .id = 3,
  225. .dev = {
  226. .platform_data = &scif3_platform_data,
  227. },
  228. };
  229. static struct plat_sci_port scif4_platform_data = {
  230. .mapbase = 0xffe44000,
  231. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  232. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  233. .scbrr_algo_id = SCBRR_ALGO_2,
  234. .type = PORT_SCIF,
  235. .irqs = SCIx_IRQ_MUXED(gic_iid(0x7c)),
  236. };
  237. static struct platform_device scif4_device = {
  238. .name = "sh-sci",
  239. .id = 4,
  240. .dev = {
  241. .platform_data = &scif4_platform_data,
  242. },
  243. };
  244. static struct plat_sci_port scif5_platform_data = {
  245. .mapbase = 0xffe45000,
  246. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  247. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  248. .scbrr_algo_id = SCBRR_ALGO_2,
  249. .type = PORT_SCIF,
  250. .irqs = SCIx_IRQ_MUXED(gic_iid(0x7d)),
  251. };
  252. static struct platform_device scif5_device = {
  253. .name = "sh-sci",
  254. .id = 5,
  255. .dev = {
  256. .platform_data = &scif5_platform_data,
  257. },
  258. };
  259. /* TMU */
  260. static struct sh_timer_config tmu00_platform_data = {
  261. .name = "TMU00",
  262. .channel_offset = 0x4,
  263. .timer_bit = 0,
  264. .clockevent_rating = 200,
  265. };
  266. static struct resource tmu00_resources[] = {
  267. [0] = {
  268. .name = "TMU00",
  269. .start = 0xffd80008,
  270. .end = 0xffd80013,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. [1] = {
  274. .start = gic_iid(0x40),
  275. .flags = IORESOURCE_IRQ,
  276. },
  277. };
  278. static struct platform_device tmu00_device = {
  279. .name = "sh_tmu",
  280. .id = 0,
  281. .dev = {
  282. .platform_data = &tmu00_platform_data,
  283. },
  284. .resource = tmu00_resources,
  285. .num_resources = ARRAY_SIZE(tmu00_resources),
  286. };
  287. static struct sh_timer_config tmu01_platform_data = {
  288. .name = "TMU01",
  289. .channel_offset = 0x10,
  290. .timer_bit = 1,
  291. .clocksource_rating = 200,
  292. };
  293. static struct resource tmu01_resources[] = {
  294. [0] = {
  295. .name = "TMU01",
  296. .start = 0xffd80014,
  297. .end = 0xffd8001f,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. [1] = {
  301. .start = gic_iid(0x41),
  302. .flags = IORESOURCE_IRQ,
  303. },
  304. };
  305. static struct platform_device tmu01_device = {
  306. .name = "sh_tmu",
  307. .id = 1,
  308. .dev = {
  309. .platform_data = &tmu01_platform_data,
  310. },
  311. .resource = tmu01_resources,
  312. .num_resources = ARRAY_SIZE(tmu01_resources),
  313. };
  314. /* I2C */
  315. static struct resource rcar_i2c0_res[] = {
  316. {
  317. .start = 0xffc70000,
  318. .end = 0xffc70fff,
  319. .flags = IORESOURCE_MEM,
  320. }, {
  321. .start = gic_iid(0x6f),
  322. .flags = IORESOURCE_IRQ,
  323. },
  324. };
  325. static struct platform_device i2c0_device = {
  326. .name = "i2c-rcar",
  327. .id = 0,
  328. .resource = rcar_i2c0_res,
  329. .num_resources = ARRAY_SIZE(rcar_i2c0_res),
  330. };
  331. static struct resource rcar_i2c1_res[] = {
  332. {
  333. .start = 0xffc71000,
  334. .end = 0xffc71fff,
  335. .flags = IORESOURCE_MEM,
  336. }, {
  337. .start = gic_iid(0x72),
  338. .flags = IORESOURCE_IRQ,
  339. },
  340. };
  341. static struct platform_device i2c1_device = {
  342. .name = "i2c-rcar",
  343. .id = 1,
  344. .resource = rcar_i2c1_res,
  345. .num_resources = ARRAY_SIZE(rcar_i2c1_res),
  346. };
  347. static struct resource rcar_i2c2_res[] = {
  348. {
  349. .start = 0xffc72000,
  350. .end = 0xffc72fff,
  351. .flags = IORESOURCE_MEM,
  352. }, {
  353. .start = gic_iid(0x70),
  354. .flags = IORESOURCE_IRQ,
  355. },
  356. };
  357. static struct platform_device i2c2_device = {
  358. .name = "i2c-rcar",
  359. .id = 2,
  360. .resource = rcar_i2c2_res,
  361. .num_resources = ARRAY_SIZE(rcar_i2c2_res),
  362. };
  363. static struct resource rcar_i2c3_res[] = {
  364. {
  365. .start = 0xffc73000,
  366. .end = 0xffc73fff,
  367. .flags = IORESOURCE_MEM,
  368. }, {
  369. .start = gic_iid(0x71),
  370. .flags = IORESOURCE_IRQ,
  371. },
  372. };
  373. static struct platform_device i2c3_device = {
  374. .name = "i2c-rcar",
  375. .id = 3,
  376. .resource = rcar_i2c3_res,
  377. .num_resources = ARRAY_SIZE(rcar_i2c3_res),
  378. };
  379. static struct resource sata_resources[] = {
  380. [0] = {
  381. .name = "rcar-sata",
  382. .start = 0xfc600000,
  383. .end = 0xfc601fff,
  384. .flags = IORESOURCE_MEM,
  385. },
  386. [1] = {
  387. .start = gic_iid(0x84),
  388. .flags = IORESOURCE_IRQ,
  389. },
  390. };
  391. static struct platform_device sata_device = {
  392. .name = "sata_rcar",
  393. .id = -1,
  394. .resource = sata_resources,
  395. .num_resources = ARRAY_SIZE(sata_resources),
  396. .dev = {
  397. .dma_mask = &sata_device.dev.coherent_dma_mask,
  398. .coherent_dma_mask = DMA_BIT_MASK(32),
  399. },
  400. };
  401. /* USB */
  402. static struct usb_phy *phy;
  403. static int usb_power_on(struct platform_device *pdev)
  404. {
  405. if (IS_ERR(phy))
  406. return PTR_ERR(phy);
  407. pm_runtime_enable(&pdev->dev);
  408. pm_runtime_get_sync(&pdev->dev);
  409. usb_phy_init(phy);
  410. return 0;
  411. }
  412. static void usb_power_off(struct platform_device *pdev)
  413. {
  414. if (IS_ERR(phy))
  415. return;
  416. usb_phy_shutdown(phy);
  417. pm_runtime_put_sync(&pdev->dev);
  418. pm_runtime_disable(&pdev->dev);
  419. }
  420. static int ehci_init_internal_buffer(struct usb_hcd *hcd)
  421. {
  422. /*
  423. * Below are recommended values from the datasheet;
  424. * see [USB :: Setting of EHCI Internal Buffer].
  425. */
  426. /* EHCI IP internal buffer setting */
  427. iowrite32(0x00ff0040, hcd->regs + 0x0094);
  428. /* EHCI IP internal buffer enable */
  429. iowrite32(0x00000001, hcd->regs + 0x009C);
  430. return 0;
  431. }
  432. static struct usb_ehci_pdata ehcix_pdata = {
  433. .power_on = usb_power_on,
  434. .power_off = usb_power_off,
  435. .power_suspend = usb_power_off,
  436. .pre_setup = ehci_init_internal_buffer,
  437. };
  438. static struct resource ehci0_resources[] = {
  439. [0] = {
  440. .start = 0xffe70000,
  441. .end = 0xffe70400 - 1,
  442. .flags = IORESOURCE_MEM,
  443. },
  444. [1] = {
  445. .start = gic_iid(0x4c),
  446. .flags = IORESOURCE_IRQ,
  447. },
  448. };
  449. static struct platform_device ehci0_device = {
  450. .name = "ehci-platform",
  451. .id = 0,
  452. .dev = {
  453. .dma_mask = &ehci0_device.dev.coherent_dma_mask,
  454. .coherent_dma_mask = 0xffffffff,
  455. .platform_data = &ehcix_pdata,
  456. },
  457. .num_resources = ARRAY_SIZE(ehci0_resources),
  458. .resource = ehci0_resources,
  459. };
  460. static struct resource ehci1_resources[] = {
  461. [0] = {
  462. .start = 0xfff70000,
  463. .end = 0xfff70400 - 1,
  464. .flags = IORESOURCE_MEM,
  465. },
  466. [1] = {
  467. .start = gic_iid(0x4d),
  468. .flags = IORESOURCE_IRQ,
  469. },
  470. };
  471. static struct platform_device ehci1_device = {
  472. .name = "ehci-platform",
  473. .id = 1,
  474. .dev = {
  475. .dma_mask = &ehci1_device.dev.coherent_dma_mask,
  476. .coherent_dma_mask = 0xffffffff,
  477. .platform_data = &ehcix_pdata,
  478. },
  479. .num_resources = ARRAY_SIZE(ehci1_resources),
  480. .resource = ehci1_resources,
  481. };
  482. static struct usb_ohci_pdata ohcix_pdata = {
  483. .power_on = usb_power_on,
  484. .power_off = usb_power_off,
  485. .power_suspend = usb_power_off,
  486. };
  487. static struct resource ohci0_resources[] = {
  488. [0] = {
  489. .start = 0xffe70400,
  490. .end = 0xffe70800 - 1,
  491. .flags = IORESOURCE_MEM,
  492. },
  493. [1] = {
  494. .start = gic_iid(0x4c),
  495. .flags = IORESOURCE_IRQ,
  496. },
  497. };
  498. static struct platform_device ohci0_device = {
  499. .name = "ohci-platform",
  500. .id = 0,
  501. .dev = {
  502. .dma_mask = &ohci0_device.dev.coherent_dma_mask,
  503. .coherent_dma_mask = 0xffffffff,
  504. .platform_data = &ohcix_pdata,
  505. },
  506. .num_resources = ARRAY_SIZE(ohci0_resources),
  507. .resource = ohci0_resources,
  508. };
  509. static struct resource ohci1_resources[] = {
  510. [0] = {
  511. .start = 0xfff70400,
  512. .end = 0xfff70800 - 1,
  513. .flags = IORESOURCE_MEM,
  514. },
  515. [1] = {
  516. .start = gic_iid(0x4d),
  517. .flags = IORESOURCE_IRQ,
  518. },
  519. };
  520. static struct platform_device ohci1_device = {
  521. .name = "ohci-platform",
  522. .id = 1,
  523. .dev = {
  524. .dma_mask = &ohci1_device.dev.coherent_dma_mask,
  525. .coherent_dma_mask = 0xffffffff,
  526. .platform_data = &ohcix_pdata,
  527. },
  528. .num_resources = ARRAY_SIZE(ohci1_resources),
  529. .resource = ohci1_resources,
  530. };
  531. /* Ether */
  532. static struct resource ether_resources[] __initdata = {
  533. {
  534. .start = 0xfde00000,
  535. .end = 0xfde003ff,
  536. .flags = IORESOURCE_MEM,
  537. }, {
  538. .start = gic_iid(0xb4),
  539. .flags = IORESOURCE_IRQ,
  540. },
  541. };
  542. #define R8A7779_VIN(idx) \
  543. static struct resource vin##idx##_resources[] __initdata = { \
  544. DEFINE_RES_MEM(0xffc50000 + 0x1000 * (idx), 0x1000), \
  545. DEFINE_RES_IRQ(gic_iid(0x5f + (idx))), \
  546. }; \
  547. \
  548. static struct platform_device_info vin##idx##_info __initdata = { \
  549. .parent = &platform_bus, \
  550. .name = "r8a7779-vin", \
  551. .id = idx, \
  552. .res = vin##idx##_resources, \
  553. .num_res = ARRAY_SIZE(vin##idx##_resources), \
  554. .dma_mask = DMA_BIT_MASK(32), \
  555. }
  556. R8A7779_VIN(0);
  557. R8A7779_VIN(1);
  558. R8A7779_VIN(2);
  559. R8A7779_VIN(3);
  560. static struct platform_device_info *vin_info_table[] __initdata = {
  561. &vin0_info,
  562. &vin1_info,
  563. &vin2_info,
  564. &vin3_info,
  565. };
  566. static struct platform_device *r8a7779_devices_dt[] __initdata = {
  567. &scif0_device,
  568. &scif1_device,
  569. &scif2_device,
  570. &scif3_device,
  571. &scif4_device,
  572. &scif5_device,
  573. &tmu00_device,
  574. &tmu01_device,
  575. };
  576. static struct platform_device *r8a7779_standard_devices[] __initdata = {
  577. &i2c0_device,
  578. &i2c1_device,
  579. &i2c2_device,
  580. &i2c3_device,
  581. &sata_device,
  582. };
  583. void __init r8a7779_add_standard_devices(void)
  584. {
  585. #ifdef CONFIG_CACHE_L2X0
  586. /* Early BRESP enable, Shared attribute override enable, 64K*16way */
  587. l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
  588. #endif
  589. r8a7779_pm_init();
  590. r8a7779_init_pm_domains();
  591. platform_add_devices(r8a7779_devices_dt,
  592. ARRAY_SIZE(r8a7779_devices_dt));
  593. platform_add_devices(r8a7779_standard_devices,
  594. ARRAY_SIZE(r8a7779_standard_devices));
  595. }
  596. void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata)
  597. {
  598. platform_device_register_resndata(&platform_bus, "r8a777x-ether", -1,
  599. ether_resources,
  600. ARRAY_SIZE(ether_resources),
  601. pdata, sizeof(*pdata));
  602. }
  603. void __init r8a7779_add_vin_device(int id, struct rcar_vin_platform_data *pdata)
  604. {
  605. BUG_ON(id < 0 || id > 3);
  606. vin_info_table[id]->data = pdata;
  607. vin_info_table[id]->size_data = sizeof(*pdata);
  608. platform_device_register_full(vin_info_table[id]);
  609. }
  610. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  611. void __init __weak r8a7779_register_twd(void) { }
  612. void __init r8a7779_earlytimer_init(void)
  613. {
  614. r8a7779_clock_init();
  615. r8a7779_register_twd();
  616. shmobile_earlytimer_init();
  617. }
  618. void __init r8a7779_add_early_devices(void)
  619. {
  620. early_platform_add_devices(r8a7779_devices_dt,
  621. ARRAY_SIZE(r8a7779_devices_dt));
  622. /* Early serial console setup is not included here due to
  623. * memory map collisions. The SCIF serial ports in r8a7779
  624. * are difficult to entity map 1:1 due to collision with the
  625. * virtual memory range used by the coherent DMA code on ARM.
  626. *
  627. * Anyone wanting to debug early can remove UPF_IOREMAP from
  628. * the sh-sci serial console platform data, adjust mapbase
  629. * to a static M:N virt:phys mapping that needs to be added to
  630. * the mappings passed with iotable_init() above.
  631. *
  632. * Then add a call to shmobile_setup_console() from this function.
  633. *
  634. * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
  635. * command line in case of the marzen board.
  636. */
  637. }
  638. static struct platform_device *r8a7779_late_devices[] __initdata = {
  639. &ehci0_device,
  640. &ehci1_device,
  641. &ohci0_device,
  642. &ohci1_device,
  643. };
  644. void __init r8a7779_init_late(void)
  645. {
  646. /* get USB PHY */
  647. phy = usb_get_phy(USB_PHY_TYPE_USB2);
  648. shmobile_init_late();
  649. platform_add_devices(r8a7779_late_devices,
  650. ARRAY_SIZE(r8a7779_late_devices));
  651. }
  652. #ifdef CONFIG_USE_OF
  653. static int r8a7779_set_wake(struct irq_data *data, unsigned int on)
  654. {
  655. return 0; /* always allow wakeup */
  656. }
  657. void __init r8a7779_init_irq_dt(void)
  658. {
  659. gic_arch_extn.irq_set_wake = r8a7779_set_wake;
  660. irqchip_init();
  661. /* route all interrupts to ARM */
  662. __raw_writel(0xffffffff, INT2NTSR0);
  663. __raw_writel(0x3fffffff, INT2NTSR1);
  664. /* unmask all known interrupts in INTCS2 */
  665. __raw_writel(0xfffffff0, INT2SMSKCR0);
  666. __raw_writel(0xfff7ffff, INT2SMSKCR1);
  667. __raw_writel(0xfffbffdf, INT2SMSKCR2);
  668. __raw_writel(0xbffffffc, INT2SMSKCR3);
  669. __raw_writel(0x003fee3f, INT2SMSKCR4);
  670. }
  671. void __init r8a7779_init_delay(void)
  672. {
  673. shmobile_setup_delay(1000, 2, 4); /* Cortex-A9 @ 1000MHz */
  674. }
  675. void __init r8a7779_add_standard_devices_dt(void)
  676. {
  677. /* clocks are setup late during boot in the case of DT */
  678. r8a7779_clock_init();
  679. platform_add_devices(r8a7779_devices_dt,
  680. ARRAY_SIZE(r8a7779_devices_dt));
  681. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  682. }
  683. static const char *r8a7779_compat_dt[] __initdata = {
  684. "renesas,r8a7779",
  685. NULL,
  686. };
  687. DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
  688. .map_io = r8a7779_map_io,
  689. .init_early = r8a7779_init_delay,
  690. .nr_irqs = NR_IRQS_LEGACY,
  691. .init_irq = r8a7779_init_irq_dt,
  692. .init_machine = r8a7779_add_standard_devices_dt,
  693. .init_late = r8a7779_init_late,
  694. .dt_compat = r8a7779_compat_dt,
  695. MACHINE_END
  696. #endif /* CONFIG_USE_OF */