setup-sh73a0.c 19 KB

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