setup-sh73a0.c 24 KB

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