setup-sh73a0.c 24 KB

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