setup-sh73a0.c 18 KB

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