setup-sh73a0.c 21 KB

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