setup-sh73a0.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. /*
  2. * sh73a0 processor support
  3. *
  4. * Copyright (C) 2010 Takashi Yoshii
  5. * Copyright (C) 2010 Magnus Damm
  6. * Copyright (C) 2008 Yoshihiro Shimoda
  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/platform_device.h>
  27. #include <linux/of_platform.h>
  28. #include <linux/delay.h>
  29. #include <linux/input.h>
  30. #include <linux/io.h>
  31. #include <linux/serial_sci.h>
  32. #include <linux/sh_dma.h>
  33. #include <linux/sh_intc.h>
  34. #include <linux/sh_timer.h>
  35. #include <linux/platform_data/sh_ipmmu.h>
  36. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  37. #include <mach/dma-register.h>
  38. #include <mach/hardware.h>
  39. #include <mach/irqs.h>
  40. #include <mach/sh73a0.h>
  41. #include <mach/common.h>
  42. #include <asm/mach-types.h>
  43. #include <asm/mach/map.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/mach/time.h>
  46. static struct map_desc sh73a0_io_desc[] __initdata = {
  47. /* create a 1:1 entity map for 0xe6xxxxxx
  48. * used by CPGA, INTC and PFC.
  49. */
  50. {
  51. .virtual = 0xe6000000,
  52. .pfn = __phys_to_pfn(0xe6000000),
  53. .length = 256 << 20,
  54. .type = MT_DEVICE_NONSHARED
  55. },
  56. };
  57. void __init sh73a0_map_io(void)
  58. {
  59. iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
  60. }
  61. /* PFC */
  62. static struct resource pfc_resources[] __initdata = {
  63. DEFINE_RES_MEM(0xe6050000, 0x8000),
  64. DEFINE_RES_MEM(0xe605801c, 0x000c),
  65. };
  66. void __init sh73a0_pinmux_init(void)
  67. {
  68. platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
  69. ARRAY_SIZE(pfc_resources));
  70. }
  71. static struct plat_sci_port scif0_platform_data = {
  72. .mapbase = 0xe6c40000,
  73. .flags = UPF_BOOT_AUTOCONF,
  74. .scscr = SCSCR_RE | SCSCR_TE,
  75. .scbrr_algo_id = SCBRR_ALGO_4,
  76. .type = PORT_SCIFA,
  77. .irqs = { gic_spi(72), gic_spi(72),
  78. gic_spi(72), gic_spi(72) },
  79. };
  80. static struct platform_device scif0_device = {
  81. .name = "sh-sci",
  82. .id = 0,
  83. .dev = {
  84. .platform_data = &scif0_platform_data,
  85. },
  86. };
  87. static struct plat_sci_port scif1_platform_data = {
  88. .mapbase = 0xe6c50000,
  89. .flags = UPF_BOOT_AUTOCONF,
  90. .scscr = SCSCR_RE | SCSCR_TE,
  91. .scbrr_algo_id = SCBRR_ALGO_4,
  92. .type = PORT_SCIFA,
  93. .irqs = { gic_spi(73), gic_spi(73),
  94. gic_spi(73), gic_spi(73) },
  95. };
  96. static struct platform_device scif1_device = {
  97. .name = "sh-sci",
  98. .id = 1,
  99. .dev = {
  100. .platform_data = &scif1_platform_data,
  101. },
  102. };
  103. static struct plat_sci_port scif2_platform_data = {
  104. .mapbase = 0xe6c60000,
  105. .flags = UPF_BOOT_AUTOCONF,
  106. .scscr = SCSCR_RE | SCSCR_TE,
  107. .scbrr_algo_id = SCBRR_ALGO_4,
  108. .type = PORT_SCIFA,
  109. .irqs = { gic_spi(74), gic_spi(74),
  110. gic_spi(74), gic_spi(74) },
  111. };
  112. static struct platform_device scif2_device = {
  113. .name = "sh-sci",
  114. .id = 2,
  115. .dev = {
  116. .platform_data = &scif2_platform_data,
  117. },
  118. };
  119. static struct plat_sci_port scif3_platform_data = {
  120. .mapbase = 0xe6c70000,
  121. .flags = UPF_BOOT_AUTOCONF,
  122. .scscr = SCSCR_RE | SCSCR_TE,
  123. .scbrr_algo_id = SCBRR_ALGO_4,
  124. .type = PORT_SCIFA,
  125. .irqs = { gic_spi(75), gic_spi(75),
  126. gic_spi(75), gic_spi(75) },
  127. };
  128. static struct platform_device scif3_device = {
  129. .name = "sh-sci",
  130. .id = 3,
  131. .dev = {
  132. .platform_data = &scif3_platform_data,
  133. },
  134. };
  135. static struct plat_sci_port scif4_platform_data = {
  136. .mapbase = 0xe6c80000,
  137. .flags = UPF_BOOT_AUTOCONF,
  138. .scscr = SCSCR_RE | SCSCR_TE,
  139. .scbrr_algo_id = SCBRR_ALGO_4,
  140. .type = PORT_SCIFA,
  141. .irqs = { gic_spi(78), gic_spi(78),
  142. gic_spi(78), gic_spi(78) },
  143. };
  144. static struct platform_device scif4_device = {
  145. .name = "sh-sci",
  146. .id = 4,
  147. .dev = {
  148. .platform_data = &scif4_platform_data,
  149. },
  150. };
  151. static struct plat_sci_port scif5_platform_data = {
  152. .mapbase = 0xe6cb0000,
  153. .flags = UPF_BOOT_AUTOCONF,
  154. .scscr = SCSCR_RE | SCSCR_TE,
  155. .scbrr_algo_id = SCBRR_ALGO_4,
  156. .type = PORT_SCIFA,
  157. .irqs = { gic_spi(79), gic_spi(79),
  158. gic_spi(79), gic_spi(79) },
  159. };
  160. static struct platform_device scif5_device = {
  161. .name = "sh-sci",
  162. .id = 5,
  163. .dev = {
  164. .platform_data = &scif5_platform_data,
  165. },
  166. };
  167. static struct plat_sci_port scif6_platform_data = {
  168. .mapbase = 0xe6cc0000,
  169. .flags = UPF_BOOT_AUTOCONF,
  170. .scscr = SCSCR_RE | SCSCR_TE,
  171. .scbrr_algo_id = SCBRR_ALGO_4,
  172. .type = PORT_SCIFA,
  173. .irqs = { gic_spi(156), gic_spi(156),
  174. gic_spi(156), gic_spi(156) },
  175. };
  176. static struct platform_device scif6_device = {
  177. .name = "sh-sci",
  178. .id = 6,
  179. .dev = {
  180. .platform_data = &scif6_platform_data,
  181. },
  182. };
  183. static struct plat_sci_port scif7_platform_data = {
  184. .mapbase = 0xe6cd0000,
  185. .flags = UPF_BOOT_AUTOCONF,
  186. .scscr = SCSCR_RE | SCSCR_TE,
  187. .scbrr_algo_id = SCBRR_ALGO_4,
  188. .type = PORT_SCIFA,
  189. .irqs = { gic_spi(143), gic_spi(143),
  190. gic_spi(143), gic_spi(143) },
  191. };
  192. static struct platform_device scif7_device = {
  193. .name = "sh-sci",
  194. .id = 7,
  195. .dev = {
  196. .platform_data = &scif7_platform_data,
  197. },
  198. };
  199. static struct plat_sci_port scif8_platform_data = {
  200. .mapbase = 0xe6c30000,
  201. .flags = UPF_BOOT_AUTOCONF,
  202. .scscr = SCSCR_RE | SCSCR_TE,
  203. .scbrr_algo_id = SCBRR_ALGO_4,
  204. .type = PORT_SCIFB,
  205. .irqs = { gic_spi(80), gic_spi(80),
  206. gic_spi(80), gic_spi(80) },
  207. };
  208. static struct platform_device scif8_device = {
  209. .name = "sh-sci",
  210. .id = 8,
  211. .dev = {
  212. .platform_data = &scif8_platform_data,
  213. },
  214. };
  215. static struct sh_timer_config cmt10_platform_data = {
  216. .name = "CMT10",
  217. .channel_offset = 0x10,
  218. .timer_bit = 0,
  219. .clockevent_rating = 80,
  220. .clocksource_rating = 125,
  221. };
  222. static struct resource cmt10_resources[] = {
  223. [0] = {
  224. .name = "CMT10",
  225. .start = 0xe6138010,
  226. .end = 0xe613801b,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. [1] = {
  230. .start = gic_spi(65),
  231. .flags = IORESOURCE_IRQ,
  232. },
  233. };
  234. static struct platform_device cmt10_device = {
  235. .name = "sh_cmt",
  236. .id = 10,
  237. .dev = {
  238. .platform_data = &cmt10_platform_data,
  239. },
  240. .resource = cmt10_resources,
  241. .num_resources = ARRAY_SIZE(cmt10_resources),
  242. };
  243. /* TMU */
  244. static struct sh_timer_config tmu00_platform_data = {
  245. .name = "TMU00",
  246. .channel_offset = 0x4,
  247. .timer_bit = 0,
  248. .clockevent_rating = 200,
  249. };
  250. static struct resource tmu00_resources[] = {
  251. [0] = DEFINE_RES_MEM_NAMED(0xfff60008, 0xc, "TMU00"),
  252. [1] = {
  253. .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
  254. .flags = IORESOURCE_IRQ,
  255. },
  256. };
  257. static struct platform_device tmu00_device = {
  258. .name = "sh_tmu",
  259. .id = 0,
  260. .dev = {
  261. .platform_data = &tmu00_platform_data,
  262. },
  263. .resource = tmu00_resources,
  264. .num_resources = ARRAY_SIZE(tmu00_resources),
  265. };
  266. static struct sh_timer_config tmu01_platform_data = {
  267. .name = "TMU01",
  268. .channel_offset = 0x10,
  269. .timer_bit = 1,
  270. .clocksource_rating = 200,
  271. };
  272. static struct resource tmu01_resources[] = {
  273. [0] = DEFINE_RES_MEM_NAMED(0xfff60014, 0xc, "TMU00"),
  274. [1] = {
  275. .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. };
  279. static struct platform_device tmu01_device = {
  280. .name = "sh_tmu",
  281. .id = 1,
  282. .dev = {
  283. .platform_data = &tmu01_platform_data,
  284. },
  285. .resource = tmu01_resources,
  286. .num_resources = ARRAY_SIZE(tmu01_resources),
  287. };
  288. static struct resource i2c0_resources[] = {
  289. [0] = DEFINE_RES_MEM_NAMED(0xe6820000, 0x426, "IIC0"),
  290. [1] = {
  291. .start = gic_spi(167),
  292. .end = gic_spi(170),
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static struct resource i2c1_resources[] = {
  297. [0] = DEFINE_RES_MEM_NAMED(0xe6822000, 0x426, "IIC1"),
  298. [1] = {
  299. .start = gic_spi(51),
  300. .end = gic_spi(54),
  301. .flags = IORESOURCE_IRQ,
  302. },
  303. };
  304. static struct resource i2c2_resources[] = {
  305. [0] = DEFINE_RES_MEM_NAMED(0xe6824000, 0x426, "IIC2"),
  306. [1] = {
  307. .start = gic_spi(171),
  308. .end = gic_spi(174),
  309. .flags = IORESOURCE_IRQ,
  310. },
  311. };
  312. static struct resource i2c3_resources[] = {
  313. [0] = DEFINE_RES_MEM_NAMED(0xe6826000, 0x426, "IIC3"),
  314. [1] = {
  315. .start = gic_spi(183),
  316. .end = gic_spi(186),
  317. .flags = IORESOURCE_IRQ,
  318. },
  319. };
  320. static struct resource i2c4_resources[] = {
  321. [0] = DEFINE_RES_MEM_NAMED(0xe6828000, 0x426, "IIC4"),
  322. [1] = {
  323. .start = gic_spi(187),
  324. .end = gic_spi(190),
  325. .flags = IORESOURCE_IRQ,
  326. },
  327. };
  328. static struct platform_device i2c0_device = {
  329. .name = "i2c-sh_mobile",
  330. .id = 0,
  331. .resource = i2c0_resources,
  332. .num_resources = ARRAY_SIZE(i2c0_resources),
  333. };
  334. static struct platform_device i2c1_device = {
  335. .name = "i2c-sh_mobile",
  336. .id = 1,
  337. .resource = i2c1_resources,
  338. .num_resources = ARRAY_SIZE(i2c1_resources),
  339. };
  340. static struct platform_device i2c2_device = {
  341. .name = "i2c-sh_mobile",
  342. .id = 2,
  343. .resource = i2c2_resources,
  344. .num_resources = ARRAY_SIZE(i2c2_resources),
  345. };
  346. static struct platform_device i2c3_device = {
  347. .name = "i2c-sh_mobile",
  348. .id = 3,
  349. .resource = i2c3_resources,
  350. .num_resources = ARRAY_SIZE(i2c3_resources),
  351. };
  352. static struct platform_device i2c4_device = {
  353. .name = "i2c-sh_mobile",
  354. .id = 4,
  355. .resource = i2c4_resources,
  356. .num_resources = ARRAY_SIZE(i2c4_resources),
  357. };
  358. static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
  359. {
  360. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  361. .addr = 0xe6c40020,
  362. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  363. .mid_rid = 0x21,
  364. }, {
  365. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  366. .addr = 0xe6c40024,
  367. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  368. .mid_rid = 0x22,
  369. }, {
  370. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  371. .addr = 0xe6c50020,
  372. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  373. .mid_rid = 0x25,
  374. }, {
  375. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  376. .addr = 0xe6c50024,
  377. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  378. .mid_rid = 0x26,
  379. }, {
  380. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  381. .addr = 0xe6c60020,
  382. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  383. .mid_rid = 0x29,
  384. }, {
  385. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  386. .addr = 0xe6c60024,
  387. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  388. .mid_rid = 0x2a,
  389. }, {
  390. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  391. .addr = 0xe6c70020,
  392. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  393. .mid_rid = 0x2d,
  394. }, {
  395. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  396. .addr = 0xe6c70024,
  397. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  398. .mid_rid = 0x2e,
  399. }, {
  400. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  401. .addr = 0xe6c80020,
  402. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  403. .mid_rid = 0x39,
  404. }, {
  405. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  406. .addr = 0xe6c80024,
  407. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  408. .mid_rid = 0x3a,
  409. }, {
  410. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  411. .addr = 0xe6cb0020,
  412. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  413. .mid_rid = 0x35,
  414. }, {
  415. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  416. .addr = 0xe6cb0024,
  417. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  418. .mid_rid = 0x36,
  419. }, {
  420. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  421. .addr = 0xe6cc0020,
  422. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  423. .mid_rid = 0x1d,
  424. }, {
  425. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  426. .addr = 0xe6cc0024,
  427. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  428. .mid_rid = 0x1e,
  429. }, {
  430. .slave_id = SHDMA_SLAVE_SCIF7_TX,
  431. .addr = 0xe6cd0020,
  432. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  433. .mid_rid = 0x19,
  434. }, {
  435. .slave_id = SHDMA_SLAVE_SCIF7_RX,
  436. .addr = 0xe6cd0024,
  437. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  438. .mid_rid = 0x1a,
  439. }, {
  440. .slave_id = SHDMA_SLAVE_SCIF8_TX,
  441. .addr = 0xe6c30040,
  442. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  443. .mid_rid = 0x3d,
  444. }, {
  445. .slave_id = SHDMA_SLAVE_SCIF8_RX,
  446. .addr = 0xe6c30060,
  447. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  448. .mid_rid = 0x3e,
  449. }, {
  450. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  451. .addr = 0xee100030,
  452. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  453. .mid_rid = 0xc1,
  454. }, {
  455. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  456. .addr = 0xee100030,
  457. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  458. .mid_rid = 0xc2,
  459. }, {
  460. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  461. .addr = 0xee120030,
  462. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  463. .mid_rid = 0xc9,
  464. }, {
  465. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  466. .addr = 0xee120030,
  467. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  468. .mid_rid = 0xca,
  469. }, {
  470. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  471. .addr = 0xee140030,
  472. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  473. .mid_rid = 0xcd,
  474. }, {
  475. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  476. .addr = 0xee140030,
  477. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  478. .mid_rid = 0xce,
  479. }, {
  480. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  481. .addr = 0xe6bd0034,
  482. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  483. .mid_rid = 0xd1,
  484. }, {
  485. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  486. .addr = 0xe6bd0034,
  487. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  488. .mid_rid = 0xd2,
  489. },
  490. };
  491. #define DMAE_CHANNEL(_offset) \
  492. { \
  493. .offset = _offset - 0x20, \
  494. .dmars = _offset - 0x20 + 0x40, \
  495. }
  496. static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
  497. DMAE_CHANNEL(0x8000),
  498. DMAE_CHANNEL(0x8080),
  499. DMAE_CHANNEL(0x8100),
  500. DMAE_CHANNEL(0x8180),
  501. DMAE_CHANNEL(0x8200),
  502. DMAE_CHANNEL(0x8280),
  503. DMAE_CHANNEL(0x8300),
  504. DMAE_CHANNEL(0x8380),
  505. DMAE_CHANNEL(0x8400),
  506. DMAE_CHANNEL(0x8480),
  507. DMAE_CHANNEL(0x8500),
  508. DMAE_CHANNEL(0x8580),
  509. DMAE_CHANNEL(0x8600),
  510. DMAE_CHANNEL(0x8680),
  511. DMAE_CHANNEL(0x8700),
  512. DMAE_CHANNEL(0x8780),
  513. DMAE_CHANNEL(0x8800),
  514. DMAE_CHANNEL(0x8880),
  515. DMAE_CHANNEL(0x8900),
  516. DMAE_CHANNEL(0x8980),
  517. };
  518. static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
  519. .slave = sh73a0_dmae_slaves,
  520. .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
  521. .channel = sh73a0_dmae_channels,
  522. .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
  523. .ts_low_shift = TS_LOW_SHIFT,
  524. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  525. .ts_high_shift = TS_HI_SHIFT,
  526. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  527. .ts_shift = dma_ts_shift,
  528. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  529. .dmaor_init = DMAOR_DME,
  530. };
  531. static struct resource sh73a0_dmae_resources[] = {
  532. DEFINE_RES_MEM(0xfe000020, 0x89e0),
  533. {
  534. .name = "error_irq",
  535. .start = gic_spi(129),
  536. .end = gic_spi(129),
  537. .flags = IORESOURCE_IRQ,
  538. },
  539. {
  540. /* IRQ for channels 0-19 */
  541. .start = gic_spi(109),
  542. .end = gic_spi(128),
  543. .flags = IORESOURCE_IRQ,
  544. },
  545. };
  546. static struct platform_device dma0_device = {
  547. .name = "sh-dma-engine",
  548. .id = 0,
  549. .resource = sh73a0_dmae_resources,
  550. .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
  551. .dev = {
  552. .platform_data = &sh73a0_dmae_platform_data,
  553. },
  554. };
  555. /* MPDMAC */
  556. static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
  557. {
  558. .slave_id = SHDMA_SLAVE_FSI2A_RX,
  559. .addr = 0xec230020,
  560. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  561. .mid_rid = 0xd6, /* CHECK ME */
  562. }, {
  563. .slave_id = SHDMA_SLAVE_FSI2A_TX,
  564. .addr = 0xec230024,
  565. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  566. .mid_rid = 0xd5, /* CHECK ME */
  567. }, {
  568. .slave_id = SHDMA_SLAVE_FSI2C_RX,
  569. .addr = 0xec230060,
  570. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  571. .mid_rid = 0xda, /* CHECK ME */
  572. }, {
  573. .slave_id = SHDMA_SLAVE_FSI2C_TX,
  574. .addr = 0xec230064,
  575. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  576. .mid_rid = 0xd9, /* CHECK ME */
  577. }, {
  578. .slave_id = SHDMA_SLAVE_FSI2B_RX,
  579. .addr = 0xec240020,
  580. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  581. .mid_rid = 0x8e, /* CHECK ME */
  582. }, {
  583. .slave_id = SHDMA_SLAVE_FSI2B_TX,
  584. .addr = 0xec240024,
  585. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  586. .mid_rid = 0x8d, /* CHECK ME */
  587. }, {
  588. .slave_id = SHDMA_SLAVE_FSI2D_RX,
  589. .addr = 0xec240060,
  590. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  591. .mid_rid = 0x9a, /* CHECK ME */
  592. },
  593. };
  594. #define MPDMA_CHANNEL(a, b, c) \
  595. { \
  596. .offset = a, \
  597. .dmars = b, \
  598. .dmars_bit = c, \
  599. .chclr_offset = (0x220 - 0x20) + a \
  600. }
  601. static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
  602. MPDMA_CHANNEL(0x00, 0, 0),
  603. MPDMA_CHANNEL(0x10, 0, 8),
  604. MPDMA_CHANNEL(0x20, 4, 0),
  605. MPDMA_CHANNEL(0x30, 4, 8),
  606. MPDMA_CHANNEL(0x50, 8, 0),
  607. MPDMA_CHANNEL(0x70, 8, 8),
  608. };
  609. static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
  610. .slave = sh73a0_mpdma_slaves,
  611. .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
  612. .channel = sh73a0_mpdma_channels,
  613. .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
  614. .ts_low_shift = TS_LOW_SHIFT,
  615. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  616. .ts_high_shift = TS_HI_SHIFT,
  617. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  618. .ts_shift = dma_ts_shift,
  619. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  620. .dmaor_init = DMAOR_DME,
  621. .chclr_present = 1,
  622. };
  623. /* Resource order important! */
  624. static struct resource sh73a0_mpdma_resources[] = {
  625. /* Channel registers and DMAOR */
  626. DEFINE_RES_MEM(0xec618020, 0x270),
  627. /* DMARSx */
  628. DEFINE_RES_MEM(0xec619000, 0xc),
  629. {
  630. .name = "error_irq",
  631. .start = gic_spi(181),
  632. .end = gic_spi(181),
  633. .flags = IORESOURCE_IRQ,
  634. },
  635. {
  636. /* IRQ for channels 0-5 */
  637. .start = gic_spi(175),
  638. .end = gic_spi(180),
  639. .flags = IORESOURCE_IRQ,
  640. },
  641. };
  642. static struct platform_device mpdma0_device = {
  643. .name = "sh-dma-engine",
  644. .id = 1,
  645. .resource = sh73a0_mpdma_resources,
  646. .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
  647. .dev = {
  648. .platform_data = &sh73a0_mpdma_platform_data,
  649. },
  650. };
  651. static struct resource pmu_resources[] = {
  652. [0] = {
  653. .start = gic_spi(55),
  654. .end = gic_spi(55),
  655. .flags = IORESOURCE_IRQ,
  656. },
  657. [1] = {
  658. .start = gic_spi(56),
  659. .end = gic_spi(56),
  660. .flags = IORESOURCE_IRQ,
  661. },
  662. };
  663. static struct platform_device pmu_device = {
  664. .name = "arm-pmu",
  665. .id = -1,
  666. .num_resources = ARRAY_SIZE(pmu_resources),
  667. .resource = pmu_resources,
  668. };
  669. /* an IPMMU module for ICB */
  670. static struct resource ipmmu_resources[] = {
  671. DEFINE_RES_MEM_NAMED(0xfe951000, 0x100, "IPMMU"),
  672. };
  673. static const char * const ipmmu_dev_names[] = {
  674. "sh_mobile_lcdc_fb.0",
  675. };
  676. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  677. .dev_names = ipmmu_dev_names,
  678. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  679. };
  680. static struct platform_device ipmmu_device = {
  681. .name = "ipmmu",
  682. .id = -1,
  683. .dev = {
  684. .platform_data = &ipmmu_platform_data,
  685. },
  686. .resource = ipmmu_resources,
  687. .num_resources = ARRAY_SIZE(ipmmu_resources),
  688. };
  689. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  690. .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
  691. };
  692. static struct resource irqpin0_resources[] = {
  693. DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
  694. DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
  695. DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
  696. DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
  697. DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
  698. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
  699. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
  700. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
  701. DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
  702. DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
  703. DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
  704. DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
  705. DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
  706. };
  707. static struct platform_device irqpin0_device = {
  708. .name = "renesas_intc_irqpin",
  709. .id = 0,
  710. .resource = irqpin0_resources,
  711. .num_resources = ARRAY_SIZE(irqpin0_resources),
  712. .dev = {
  713. .platform_data = &irqpin0_platform_data,
  714. },
  715. };
  716. static struct renesas_intc_irqpin_config irqpin1_platform_data = {
  717. .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
  718. .control_parent = true, /* Disable spurious IRQ10 */
  719. };
  720. static struct resource irqpin1_resources[] = {
  721. DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
  722. DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
  723. DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
  724. DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
  725. DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
  726. DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
  727. DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
  728. DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
  729. DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
  730. DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
  731. DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
  732. DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
  733. DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
  734. };
  735. static struct platform_device irqpin1_device = {
  736. .name = "renesas_intc_irqpin",
  737. .id = 1,
  738. .resource = irqpin1_resources,
  739. .num_resources = ARRAY_SIZE(irqpin1_resources),
  740. .dev = {
  741. .platform_data = &irqpin1_platform_data,
  742. },
  743. };
  744. static struct renesas_intc_irqpin_config irqpin2_platform_data = {
  745. .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
  746. };
  747. static struct resource irqpin2_resources[] = {
  748. DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
  749. DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
  750. DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
  751. DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
  752. DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
  753. DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
  754. DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
  755. DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
  756. DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
  757. DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
  758. DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
  759. DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
  760. DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
  761. };
  762. static struct platform_device irqpin2_device = {
  763. .name = "renesas_intc_irqpin",
  764. .id = 2,
  765. .resource = irqpin2_resources,
  766. .num_resources = ARRAY_SIZE(irqpin2_resources),
  767. .dev = {
  768. .platform_data = &irqpin2_platform_data,
  769. },
  770. };
  771. static struct renesas_intc_irqpin_config irqpin3_platform_data = {
  772. .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
  773. };
  774. static struct resource irqpin3_resources[] = {
  775. DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
  776. DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
  777. DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
  778. DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
  779. DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
  780. DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
  781. DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
  782. DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
  783. DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
  784. DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
  785. DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
  786. DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
  787. DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
  788. };
  789. static struct platform_device irqpin3_device = {
  790. .name = "renesas_intc_irqpin",
  791. .id = 3,
  792. .resource = irqpin3_resources,
  793. .num_resources = ARRAY_SIZE(irqpin3_resources),
  794. .dev = {
  795. .platform_data = &irqpin3_platform_data,
  796. },
  797. };
  798. static struct platform_device *sh73a0_devices_dt[] __initdata = {
  799. &scif0_device,
  800. &scif1_device,
  801. &scif2_device,
  802. &scif3_device,
  803. &scif4_device,
  804. &scif5_device,
  805. &scif6_device,
  806. &scif7_device,
  807. &scif8_device,
  808. &cmt10_device,
  809. };
  810. static struct platform_device *sh73a0_early_devices[] __initdata = {
  811. &tmu00_device,
  812. &tmu01_device,
  813. &ipmmu_device,
  814. };
  815. static struct platform_device *sh73a0_late_devices[] __initdata = {
  816. &i2c0_device,
  817. &i2c1_device,
  818. &i2c2_device,
  819. &i2c3_device,
  820. &i2c4_device,
  821. &dma0_device,
  822. &mpdma0_device,
  823. &pmu_device,
  824. &irqpin0_device,
  825. &irqpin1_device,
  826. &irqpin2_device,
  827. &irqpin3_device,
  828. };
  829. #define SRCR2 IOMEM(0xe61580b0)
  830. void __init sh73a0_add_standard_devices(void)
  831. {
  832. /* Clear software reset bit on SY-DMAC module */
  833. __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
  834. platform_add_devices(sh73a0_devices_dt,
  835. ARRAY_SIZE(sh73a0_devices_dt));
  836. platform_add_devices(sh73a0_early_devices,
  837. ARRAY_SIZE(sh73a0_early_devices));
  838. platform_add_devices(sh73a0_late_devices,
  839. ARRAY_SIZE(sh73a0_late_devices));
  840. }
  841. void __init sh73a0_init_delay(void)
  842. {
  843. shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
  844. }
  845. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  846. void __init __weak sh73a0_register_twd(void) { }
  847. void __init sh73a0_earlytimer_init(void)
  848. {
  849. sh73a0_init_delay();
  850. sh73a0_clock_init();
  851. shmobile_earlytimer_init();
  852. sh73a0_register_twd();
  853. }
  854. void __init sh73a0_add_early_devices(void)
  855. {
  856. early_platform_add_devices(sh73a0_devices_dt,
  857. ARRAY_SIZE(sh73a0_devices_dt));
  858. early_platform_add_devices(sh73a0_early_devices,
  859. ARRAY_SIZE(sh73a0_early_devices));
  860. /* setup early console here as well */
  861. shmobile_setup_console();
  862. }
  863. #ifdef CONFIG_USE_OF
  864. static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
  865. {},
  866. };
  867. void __init sh73a0_add_standard_devices_dt(void)
  868. {
  869. struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
  870. /* clocks are setup late during boot in the case of DT */
  871. sh73a0_clock_init();
  872. platform_add_devices(sh73a0_devices_dt,
  873. ARRAY_SIZE(sh73a0_devices_dt));
  874. of_platform_populate(NULL, of_default_bus_match_table,
  875. sh73a0_auxdata_lookup, NULL);
  876. /* Instantiate cpufreq-cpu0 */
  877. platform_device_register_full(&devinfo);
  878. }
  879. static const char *sh73a0_boards_compat_dt[] __initdata = {
  880. "renesas,sh73a0",
  881. NULL,
  882. };
  883. DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
  884. .smp = smp_ops(sh73a0_smp_ops),
  885. .map_io = sh73a0_map_io,
  886. .init_early = sh73a0_init_delay,
  887. .nr_irqs = NR_IRQS_LEGACY,
  888. .init_irq = irqchip_init,
  889. .init_machine = sh73a0_add_standard_devices_dt,
  890. .dt_compat = sh73a0_boards_compat_dt,
  891. MACHINE_END
  892. #endif /* CONFIG_USE_OF */