setup-sh73a0.c 21 KB

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