setup-sh7372.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. /*
  2. * sh7372 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/uio_driver.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/pm_domain.h>
  35. #include <linux/dma-mapping.h>
  36. #include <mach/dma-register.h>
  37. #include <mach/hardware.h>
  38. #include <mach/irqs.h>
  39. #include <mach/sh7372.h>
  40. #include <mach/common.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach-types.h>
  43. #include <asm/mach/arch.h>
  44. #include <asm/mach/time.h>
  45. static struct map_desc sh7372_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 sh7372_map_io(void)
  57. {
  58. iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
  59. }
  60. /* PFC */
  61. static struct resource sh7372_pfc_resources[] = {
  62. [0] = {
  63. .start = 0xe6050000,
  64. .end = 0xe6057fff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = 0xe605800c,
  69. .end = 0xe6058027,
  70. .flags = IORESOURCE_MEM,
  71. }
  72. };
  73. static struct platform_device sh7372_pfc_device = {
  74. .name = "pfc-sh7372",
  75. .id = -1,
  76. .resource = sh7372_pfc_resources,
  77. .num_resources = ARRAY_SIZE(sh7372_pfc_resources),
  78. };
  79. void __init sh7372_pinmux_init(void)
  80. {
  81. platform_device_register(&sh7372_pfc_device);
  82. }
  83. /* SCIFA0 */
  84. static struct plat_sci_port scif0_platform_data = {
  85. .mapbase = 0xe6c40000,
  86. .flags = UPF_BOOT_AUTOCONF,
  87. .scscr = SCSCR_RE | SCSCR_TE,
  88. .scbrr_algo_id = SCBRR_ALGO_4,
  89. .type = PORT_SCIFA,
  90. .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
  91. evt2irq(0x0c00), evt2irq(0x0c00) },
  92. };
  93. static struct platform_device scif0_device = {
  94. .name = "sh-sci",
  95. .id = 0,
  96. .dev = {
  97. .platform_data = &scif0_platform_data,
  98. },
  99. };
  100. /* SCIFA1 */
  101. static struct plat_sci_port scif1_platform_data = {
  102. .mapbase = 0xe6c50000,
  103. .flags = UPF_BOOT_AUTOCONF,
  104. .scscr = SCSCR_RE | SCSCR_TE,
  105. .scbrr_algo_id = SCBRR_ALGO_4,
  106. .type = PORT_SCIFA,
  107. .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
  108. evt2irq(0x0c20), evt2irq(0x0c20) },
  109. };
  110. static struct platform_device scif1_device = {
  111. .name = "sh-sci",
  112. .id = 1,
  113. .dev = {
  114. .platform_data = &scif1_platform_data,
  115. },
  116. };
  117. /* SCIFA2 */
  118. static struct plat_sci_port scif2_platform_data = {
  119. .mapbase = 0xe6c60000,
  120. .flags = UPF_BOOT_AUTOCONF,
  121. .scscr = SCSCR_RE | SCSCR_TE,
  122. .scbrr_algo_id = SCBRR_ALGO_4,
  123. .type = PORT_SCIFA,
  124. .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
  125. evt2irq(0x0c40), evt2irq(0x0c40) },
  126. };
  127. static struct platform_device scif2_device = {
  128. .name = "sh-sci",
  129. .id = 2,
  130. .dev = {
  131. .platform_data = &scif2_platform_data,
  132. },
  133. };
  134. /* SCIFA3 */
  135. static struct plat_sci_port scif3_platform_data = {
  136. .mapbase = 0xe6c70000,
  137. .flags = UPF_BOOT_AUTOCONF,
  138. .scscr = SCSCR_RE | SCSCR_TE,
  139. .scbrr_algo_id = SCBRR_ALGO_4,
  140. .type = PORT_SCIFA,
  141. .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
  142. evt2irq(0x0c60), evt2irq(0x0c60) },
  143. };
  144. static struct platform_device scif3_device = {
  145. .name = "sh-sci",
  146. .id = 3,
  147. .dev = {
  148. .platform_data = &scif3_platform_data,
  149. },
  150. };
  151. /* SCIFA4 */
  152. static struct plat_sci_port scif4_platform_data = {
  153. .mapbase = 0xe6c80000,
  154. .flags = UPF_BOOT_AUTOCONF,
  155. .scscr = SCSCR_RE | SCSCR_TE,
  156. .scbrr_algo_id = SCBRR_ALGO_4,
  157. .type = PORT_SCIFA,
  158. .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
  159. evt2irq(0x0d20), evt2irq(0x0d20) },
  160. };
  161. static struct platform_device scif4_device = {
  162. .name = "sh-sci",
  163. .id = 4,
  164. .dev = {
  165. .platform_data = &scif4_platform_data,
  166. },
  167. };
  168. /* SCIFA5 */
  169. static struct plat_sci_port scif5_platform_data = {
  170. .mapbase = 0xe6cb0000,
  171. .flags = UPF_BOOT_AUTOCONF,
  172. .scscr = SCSCR_RE | SCSCR_TE,
  173. .scbrr_algo_id = SCBRR_ALGO_4,
  174. .type = PORT_SCIFA,
  175. .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
  176. evt2irq(0x0d40), evt2irq(0x0d40) },
  177. };
  178. static struct platform_device scif5_device = {
  179. .name = "sh-sci",
  180. .id = 5,
  181. .dev = {
  182. .platform_data = &scif5_platform_data,
  183. },
  184. };
  185. /* SCIFB */
  186. static struct plat_sci_port scif6_platform_data = {
  187. .mapbase = 0xe6c30000,
  188. .flags = UPF_BOOT_AUTOCONF,
  189. .scscr = SCSCR_RE | SCSCR_TE,
  190. .scbrr_algo_id = SCBRR_ALGO_4,
  191. .type = PORT_SCIFB,
  192. .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
  193. evt2irq(0x0d60), evt2irq(0x0d60) },
  194. };
  195. static struct platform_device scif6_device = {
  196. .name = "sh-sci",
  197. .id = 6,
  198. .dev = {
  199. .platform_data = &scif6_platform_data,
  200. },
  201. };
  202. /* CMT */
  203. static struct sh_timer_config cmt2_platform_data = {
  204. .name = "CMT2",
  205. .channel_offset = 0x40,
  206. .timer_bit = 5,
  207. .clockevent_rating = 125,
  208. .clocksource_rating = 125,
  209. };
  210. static struct resource cmt2_resources[] = {
  211. [0] = {
  212. .name = "CMT2",
  213. .start = 0xe6130040,
  214. .end = 0xe613004b,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. [1] = {
  218. .start = evt2irq(0x0b80), /* CMT2 */
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device cmt2_device = {
  223. .name = "sh_cmt",
  224. .id = 2,
  225. .dev = {
  226. .platform_data = &cmt2_platform_data,
  227. },
  228. .resource = cmt2_resources,
  229. .num_resources = ARRAY_SIZE(cmt2_resources),
  230. };
  231. /* TMU */
  232. static struct sh_timer_config tmu00_platform_data = {
  233. .name = "TMU00",
  234. .channel_offset = 0x4,
  235. .timer_bit = 0,
  236. .clockevent_rating = 200,
  237. };
  238. static struct resource tmu00_resources[] = {
  239. [0] = {
  240. .name = "TMU00",
  241. .start = 0xfff60008,
  242. .end = 0xfff60013,
  243. .flags = IORESOURCE_MEM,
  244. },
  245. [1] = {
  246. .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
  247. .flags = IORESOURCE_IRQ,
  248. },
  249. };
  250. static struct platform_device tmu00_device = {
  251. .name = "sh_tmu",
  252. .id = 0,
  253. .dev = {
  254. .platform_data = &tmu00_platform_data,
  255. },
  256. .resource = tmu00_resources,
  257. .num_resources = ARRAY_SIZE(tmu00_resources),
  258. };
  259. static struct sh_timer_config tmu01_platform_data = {
  260. .name = "TMU01",
  261. .channel_offset = 0x10,
  262. .timer_bit = 1,
  263. .clocksource_rating = 200,
  264. };
  265. static struct resource tmu01_resources[] = {
  266. [0] = {
  267. .name = "TMU01",
  268. .start = 0xfff60014,
  269. .end = 0xfff6001f,
  270. .flags = IORESOURCE_MEM,
  271. },
  272. [1] = {
  273. .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
  274. .flags = IORESOURCE_IRQ,
  275. },
  276. };
  277. static struct platform_device tmu01_device = {
  278. .name = "sh_tmu",
  279. .id = 1,
  280. .dev = {
  281. .platform_data = &tmu01_platform_data,
  282. },
  283. .resource = tmu01_resources,
  284. .num_resources = ARRAY_SIZE(tmu01_resources),
  285. };
  286. /* I2C */
  287. static struct resource iic0_resources[] = {
  288. [0] = {
  289. .name = "IIC0",
  290. .start = 0xFFF20000,
  291. .end = 0xFFF20425 - 1,
  292. .flags = IORESOURCE_MEM,
  293. },
  294. [1] = {
  295. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  296. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. };
  300. static struct platform_device iic0_device = {
  301. .name = "i2c-sh_mobile",
  302. .id = 0, /* "i2c0" clock */
  303. .num_resources = ARRAY_SIZE(iic0_resources),
  304. .resource = iic0_resources,
  305. };
  306. static struct resource iic1_resources[] = {
  307. [0] = {
  308. .name = "IIC1",
  309. .start = 0xE6C20000,
  310. .end = 0xE6C20425 - 1,
  311. .flags = IORESOURCE_MEM,
  312. },
  313. [1] = {
  314. .start = evt2irq(0x780), /* IIC1_ALI1 */
  315. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  316. .flags = IORESOURCE_IRQ,
  317. },
  318. };
  319. static struct platform_device iic1_device = {
  320. .name = "i2c-sh_mobile",
  321. .id = 1, /* "i2c1" clock */
  322. .num_resources = ARRAY_SIZE(iic1_resources),
  323. .resource = iic1_resources,
  324. };
  325. /* DMA */
  326. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  327. {
  328. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  329. .addr = 0xe6c40020,
  330. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  331. .mid_rid = 0x21,
  332. }, {
  333. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  334. .addr = 0xe6c40024,
  335. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  336. .mid_rid = 0x22,
  337. }, {
  338. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  339. .addr = 0xe6c50020,
  340. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  341. .mid_rid = 0x25,
  342. }, {
  343. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  344. .addr = 0xe6c50024,
  345. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  346. .mid_rid = 0x26,
  347. }, {
  348. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  349. .addr = 0xe6c60020,
  350. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  351. .mid_rid = 0x29,
  352. }, {
  353. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  354. .addr = 0xe6c60024,
  355. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  356. .mid_rid = 0x2a,
  357. }, {
  358. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  359. .addr = 0xe6c70020,
  360. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  361. .mid_rid = 0x2d,
  362. }, {
  363. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  364. .addr = 0xe6c70024,
  365. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  366. .mid_rid = 0x2e,
  367. }, {
  368. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  369. .addr = 0xe6c80020,
  370. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  371. .mid_rid = 0x39,
  372. }, {
  373. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  374. .addr = 0xe6c80024,
  375. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  376. .mid_rid = 0x3a,
  377. }, {
  378. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  379. .addr = 0xe6cb0020,
  380. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  381. .mid_rid = 0x35,
  382. }, {
  383. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  384. .addr = 0xe6cb0024,
  385. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  386. .mid_rid = 0x36,
  387. }, {
  388. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  389. .addr = 0xe6c30040,
  390. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  391. .mid_rid = 0x3d,
  392. }, {
  393. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  394. .addr = 0xe6c30060,
  395. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  396. .mid_rid = 0x3e,
  397. }, {
  398. .slave_id = SHDMA_SLAVE_FLCTL0_TX,
  399. .addr = 0xe6a30050,
  400. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  401. .mid_rid = 0x83,
  402. }, {
  403. .slave_id = SHDMA_SLAVE_FLCTL0_RX,
  404. .addr = 0xe6a30050,
  405. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  406. .mid_rid = 0x83,
  407. }, {
  408. .slave_id = SHDMA_SLAVE_FLCTL1_TX,
  409. .addr = 0xe6a30060,
  410. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  411. .mid_rid = 0x87,
  412. }, {
  413. .slave_id = SHDMA_SLAVE_FLCTL1_RX,
  414. .addr = 0xe6a30060,
  415. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  416. .mid_rid = 0x87,
  417. }, {
  418. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  419. .addr = 0xe6850030,
  420. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  421. .mid_rid = 0xc1,
  422. }, {
  423. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  424. .addr = 0xe6850030,
  425. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  426. .mid_rid = 0xc2,
  427. }, {
  428. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  429. .addr = 0xe6860030,
  430. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  431. .mid_rid = 0xc9,
  432. }, {
  433. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  434. .addr = 0xe6860030,
  435. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  436. .mid_rid = 0xca,
  437. }, {
  438. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  439. .addr = 0xe6870030,
  440. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  441. .mid_rid = 0xcd,
  442. }, {
  443. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  444. .addr = 0xe6870030,
  445. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  446. .mid_rid = 0xce,
  447. }, {
  448. .slave_id = SHDMA_SLAVE_FSIA_TX,
  449. .addr = 0xfe1f0024,
  450. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  451. .mid_rid = 0xb1,
  452. }, {
  453. .slave_id = SHDMA_SLAVE_FSIA_RX,
  454. .addr = 0xfe1f0020,
  455. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  456. .mid_rid = 0xb2,
  457. }, {
  458. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  459. .addr = 0xe6bd0034,
  460. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  461. .mid_rid = 0xd1,
  462. }, {
  463. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  464. .addr = 0xe6bd0034,
  465. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  466. .mid_rid = 0xd2,
  467. },
  468. };
  469. #define SH7372_CHCLR (0x220 - 0x20)
  470. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  471. {
  472. .offset = 0,
  473. .dmars = 0,
  474. .dmars_bit = 0,
  475. .chclr_offset = SH7372_CHCLR + 0,
  476. }, {
  477. .offset = 0x10,
  478. .dmars = 0,
  479. .dmars_bit = 8,
  480. .chclr_offset = SH7372_CHCLR + 0x10,
  481. }, {
  482. .offset = 0x20,
  483. .dmars = 4,
  484. .dmars_bit = 0,
  485. .chclr_offset = SH7372_CHCLR + 0x20,
  486. }, {
  487. .offset = 0x30,
  488. .dmars = 4,
  489. .dmars_bit = 8,
  490. .chclr_offset = SH7372_CHCLR + 0x30,
  491. }, {
  492. .offset = 0x50,
  493. .dmars = 8,
  494. .dmars_bit = 0,
  495. .chclr_offset = SH7372_CHCLR + 0x50,
  496. }, {
  497. .offset = 0x60,
  498. .dmars = 8,
  499. .dmars_bit = 8,
  500. .chclr_offset = SH7372_CHCLR + 0x60,
  501. }
  502. };
  503. static struct sh_dmae_pdata dma_platform_data = {
  504. .slave = sh7372_dmae_slaves,
  505. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  506. .channel = sh7372_dmae_channels,
  507. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  508. .ts_low_shift = TS_LOW_SHIFT,
  509. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  510. .ts_high_shift = TS_HI_SHIFT,
  511. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  512. .ts_shift = dma_ts_shift,
  513. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  514. .dmaor_init = DMAOR_DME,
  515. .chclr_present = 1,
  516. };
  517. /* Resource order important! */
  518. static struct resource sh7372_dmae0_resources[] = {
  519. {
  520. /* Channel registers and DMAOR */
  521. .start = 0xfe008020,
  522. .end = 0xfe00828f,
  523. .flags = IORESOURCE_MEM,
  524. },
  525. {
  526. /* DMARSx */
  527. .start = 0xfe009000,
  528. .end = 0xfe00900b,
  529. .flags = IORESOURCE_MEM,
  530. },
  531. {
  532. .name = "error_irq",
  533. .start = evt2irq(0x20c0),
  534. .end = evt2irq(0x20c0),
  535. .flags = IORESOURCE_IRQ,
  536. },
  537. {
  538. /* IRQ for channels 0-5 */
  539. .start = evt2irq(0x2000),
  540. .end = evt2irq(0x20a0),
  541. .flags = IORESOURCE_IRQ,
  542. },
  543. };
  544. /* Resource order important! */
  545. static struct resource sh7372_dmae1_resources[] = {
  546. {
  547. /* Channel registers and DMAOR */
  548. .start = 0xfe018020,
  549. .end = 0xfe01828f,
  550. .flags = IORESOURCE_MEM,
  551. },
  552. {
  553. /* DMARSx */
  554. .start = 0xfe019000,
  555. .end = 0xfe01900b,
  556. .flags = IORESOURCE_MEM,
  557. },
  558. {
  559. .name = "error_irq",
  560. .start = evt2irq(0x21c0),
  561. .end = evt2irq(0x21c0),
  562. .flags = IORESOURCE_IRQ,
  563. },
  564. {
  565. /* IRQ for channels 0-5 */
  566. .start = evt2irq(0x2100),
  567. .end = evt2irq(0x21a0),
  568. .flags = IORESOURCE_IRQ,
  569. },
  570. };
  571. /* Resource order important! */
  572. static struct resource sh7372_dmae2_resources[] = {
  573. {
  574. /* Channel registers and DMAOR */
  575. .start = 0xfe028020,
  576. .end = 0xfe02828f,
  577. .flags = IORESOURCE_MEM,
  578. },
  579. {
  580. /* DMARSx */
  581. .start = 0xfe029000,
  582. .end = 0xfe02900b,
  583. .flags = IORESOURCE_MEM,
  584. },
  585. {
  586. .name = "error_irq",
  587. .start = evt2irq(0x22c0),
  588. .end = evt2irq(0x22c0),
  589. .flags = IORESOURCE_IRQ,
  590. },
  591. {
  592. /* IRQ for channels 0-5 */
  593. .start = evt2irq(0x2200),
  594. .end = evt2irq(0x22a0),
  595. .flags = IORESOURCE_IRQ,
  596. },
  597. };
  598. static struct platform_device dma0_device = {
  599. .name = "sh-dma-engine",
  600. .id = 0,
  601. .resource = sh7372_dmae0_resources,
  602. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  603. .dev = {
  604. .platform_data = &dma_platform_data,
  605. },
  606. };
  607. static struct platform_device dma1_device = {
  608. .name = "sh-dma-engine",
  609. .id = 1,
  610. .resource = sh7372_dmae1_resources,
  611. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  612. .dev = {
  613. .platform_data = &dma_platform_data,
  614. },
  615. };
  616. static struct platform_device dma2_device = {
  617. .name = "sh-dma-engine",
  618. .id = 2,
  619. .resource = sh7372_dmae2_resources,
  620. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  621. .dev = {
  622. .platform_data = &dma_platform_data,
  623. },
  624. };
  625. /*
  626. * USB-DMAC
  627. */
  628. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  629. {
  630. .offset = 0,
  631. }, {
  632. .offset = 0x20,
  633. },
  634. };
  635. /* USB DMAC0 */
  636. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  637. {
  638. .slave_id = SHDMA_SLAVE_USB0_TX,
  639. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  640. }, {
  641. .slave_id = SHDMA_SLAVE_USB0_RX,
  642. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  643. },
  644. };
  645. static struct sh_dmae_pdata usb_dma0_platform_data = {
  646. .slave = sh7372_usb_dmae0_slaves,
  647. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  648. .channel = sh7372_usb_dmae_channels,
  649. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  650. .ts_low_shift = USBTS_LOW_SHIFT,
  651. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  652. .ts_high_shift = USBTS_HI_SHIFT,
  653. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  654. .ts_shift = dma_usbts_shift,
  655. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  656. .dmaor_init = DMAOR_DME,
  657. .chcr_offset = 0x14,
  658. .chcr_ie_bit = 1 << 5,
  659. .dmaor_is_32bit = 1,
  660. .needs_tend_set = 1,
  661. .no_dmars = 1,
  662. .slave_only = 1,
  663. };
  664. static struct resource sh7372_usb_dmae0_resources[] = {
  665. {
  666. /* Channel registers and DMAOR */
  667. .start = 0xe68a0020,
  668. .end = 0xe68a0064 - 1,
  669. .flags = IORESOURCE_MEM,
  670. },
  671. {
  672. /* VCR/SWR/DMICR */
  673. .start = 0xe68a0000,
  674. .end = 0xe68a0014 - 1,
  675. .flags = IORESOURCE_MEM,
  676. },
  677. {
  678. /* IRQ for channels */
  679. .start = evt2irq(0x0a00),
  680. .end = evt2irq(0x0a00),
  681. .flags = IORESOURCE_IRQ,
  682. },
  683. };
  684. static struct platform_device usb_dma0_device = {
  685. .name = "sh-dma-engine",
  686. .id = 3,
  687. .resource = sh7372_usb_dmae0_resources,
  688. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  689. .dev = {
  690. .platform_data = &usb_dma0_platform_data,
  691. },
  692. };
  693. /* USB DMAC1 */
  694. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  695. {
  696. .slave_id = SHDMA_SLAVE_USB1_TX,
  697. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  698. }, {
  699. .slave_id = SHDMA_SLAVE_USB1_RX,
  700. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  701. },
  702. };
  703. static struct sh_dmae_pdata usb_dma1_platform_data = {
  704. .slave = sh7372_usb_dmae1_slaves,
  705. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  706. .channel = sh7372_usb_dmae_channels,
  707. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  708. .ts_low_shift = USBTS_LOW_SHIFT,
  709. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  710. .ts_high_shift = USBTS_HI_SHIFT,
  711. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  712. .ts_shift = dma_usbts_shift,
  713. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  714. .dmaor_init = DMAOR_DME,
  715. .chcr_offset = 0x14,
  716. .chcr_ie_bit = 1 << 5,
  717. .dmaor_is_32bit = 1,
  718. .needs_tend_set = 1,
  719. .no_dmars = 1,
  720. .slave_only = 1,
  721. };
  722. static struct resource sh7372_usb_dmae1_resources[] = {
  723. {
  724. /* Channel registers and DMAOR */
  725. .start = 0xe68c0020,
  726. .end = 0xe68c0064 - 1,
  727. .flags = IORESOURCE_MEM,
  728. },
  729. {
  730. /* VCR/SWR/DMICR */
  731. .start = 0xe68c0000,
  732. .end = 0xe68c0014 - 1,
  733. .flags = IORESOURCE_MEM,
  734. },
  735. {
  736. /* IRQ for channels */
  737. .start = evt2irq(0x1d00),
  738. .end = evt2irq(0x1d00),
  739. .flags = IORESOURCE_IRQ,
  740. },
  741. };
  742. static struct platform_device usb_dma1_device = {
  743. .name = "sh-dma-engine",
  744. .id = 4,
  745. .resource = sh7372_usb_dmae1_resources,
  746. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  747. .dev = {
  748. .platform_data = &usb_dma1_platform_data,
  749. },
  750. };
  751. /* VPU */
  752. static struct uio_info vpu_platform_data = {
  753. .name = "VPU5HG",
  754. .version = "0",
  755. .irq = intcs_evt2irq(0x980),
  756. };
  757. static struct resource vpu_resources[] = {
  758. [0] = {
  759. .name = "VPU",
  760. .start = 0xfe900000,
  761. .end = 0xfe900157,
  762. .flags = IORESOURCE_MEM,
  763. },
  764. };
  765. static struct platform_device vpu_device = {
  766. .name = "uio_pdrv_genirq",
  767. .id = 0,
  768. .dev = {
  769. .platform_data = &vpu_platform_data,
  770. },
  771. .resource = vpu_resources,
  772. .num_resources = ARRAY_SIZE(vpu_resources),
  773. };
  774. /* VEU0 */
  775. static struct uio_info veu0_platform_data = {
  776. .name = "VEU0",
  777. .version = "0",
  778. .irq = intcs_evt2irq(0x700),
  779. };
  780. static struct resource veu0_resources[] = {
  781. [0] = {
  782. .name = "VEU0",
  783. .start = 0xfe920000,
  784. .end = 0xfe9200cb,
  785. .flags = IORESOURCE_MEM,
  786. },
  787. };
  788. static struct platform_device veu0_device = {
  789. .name = "uio_pdrv_genirq",
  790. .id = 1,
  791. .dev = {
  792. .platform_data = &veu0_platform_data,
  793. },
  794. .resource = veu0_resources,
  795. .num_resources = ARRAY_SIZE(veu0_resources),
  796. };
  797. /* VEU1 */
  798. static struct uio_info veu1_platform_data = {
  799. .name = "VEU1",
  800. .version = "0",
  801. .irq = intcs_evt2irq(0x720),
  802. };
  803. static struct resource veu1_resources[] = {
  804. [0] = {
  805. .name = "VEU1",
  806. .start = 0xfe924000,
  807. .end = 0xfe9240cb,
  808. .flags = IORESOURCE_MEM,
  809. },
  810. };
  811. static struct platform_device veu1_device = {
  812. .name = "uio_pdrv_genirq",
  813. .id = 2,
  814. .dev = {
  815. .platform_data = &veu1_platform_data,
  816. },
  817. .resource = veu1_resources,
  818. .num_resources = ARRAY_SIZE(veu1_resources),
  819. };
  820. /* VEU2 */
  821. static struct uio_info veu2_platform_data = {
  822. .name = "VEU2",
  823. .version = "0",
  824. .irq = intcs_evt2irq(0x740),
  825. };
  826. static struct resource veu2_resources[] = {
  827. [0] = {
  828. .name = "VEU2",
  829. .start = 0xfe928000,
  830. .end = 0xfe928307,
  831. .flags = IORESOURCE_MEM,
  832. },
  833. };
  834. static struct platform_device veu2_device = {
  835. .name = "uio_pdrv_genirq",
  836. .id = 3,
  837. .dev = {
  838. .platform_data = &veu2_platform_data,
  839. },
  840. .resource = veu2_resources,
  841. .num_resources = ARRAY_SIZE(veu2_resources),
  842. };
  843. /* VEU3 */
  844. static struct uio_info veu3_platform_data = {
  845. .name = "VEU3",
  846. .version = "0",
  847. .irq = intcs_evt2irq(0x760),
  848. };
  849. static struct resource veu3_resources[] = {
  850. [0] = {
  851. .name = "VEU3",
  852. .start = 0xfe92c000,
  853. .end = 0xfe92c307,
  854. .flags = IORESOURCE_MEM,
  855. },
  856. };
  857. static struct platform_device veu3_device = {
  858. .name = "uio_pdrv_genirq",
  859. .id = 4,
  860. .dev = {
  861. .platform_data = &veu3_platform_data,
  862. },
  863. .resource = veu3_resources,
  864. .num_resources = ARRAY_SIZE(veu3_resources),
  865. };
  866. /* JPU */
  867. static struct uio_info jpu_platform_data = {
  868. .name = "JPU",
  869. .version = "0",
  870. .irq = intcs_evt2irq(0x560),
  871. };
  872. static struct resource jpu_resources[] = {
  873. [0] = {
  874. .name = "JPU",
  875. .start = 0xfe980000,
  876. .end = 0xfe9902d3,
  877. .flags = IORESOURCE_MEM,
  878. },
  879. };
  880. static struct platform_device jpu_device = {
  881. .name = "uio_pdrv_genirq",
  882. .id = 5,
  883. .dev = {
  884. .platform_data = &jpu_platform_data,
  885. },
  886. .resource = jpu_resources,
  887. .num_resources = ARRAY_SIZE(jpu_resources),
  888. };
  889. /* SPU2DSP0 */
  890. static struct uio_info spu0_platform_data = {
  891. .name = "SPU2DSP0",
  892. .version = "0",
  893. .irq = evt2irq(0x1800),
  894. };
  895. static struct resource spu0_resources[] = {
  896. [0] = {
  897. .name = "SPU2DSP0",
  898. .start = 0xfe200000,
  899. .end = 0xfe2fffff,
  900. .flags = IORESOURCE_MEM,
  901. },
  902. };
  903. static struct platform_device spu0_device = {
  904. .name = "uio_pdrv_genirq",
  905. .id = 6,
  906. .dev = {
  907. .platform_data = &spu0_platform_data,
  908. },
  909. .resource = spu0_resources,
  910. .num_resources = ARRAY_SIZE(spu0_resources),
  911. };
  912. /* SPU2DSP1 */
  913. static struct uio_info spu1_platform_data = {
  914. .name = "SPU2DSP1",
  915. .version = "0",
  916. .irq = evt2irq(0x1820),
  917. };
  918. static struct resource spu1_resources[] = {
  919. [0] = {
  920. .name = "SPU2DSP1",
  921. .start = 0xfe300000,
  922. .end = 0xfe3fffff,
  923. .flags = IORESOURCE_MEM,
  924. },
  925. };
  926. static struct platform_device spu1_device = {
  927. .name = "uio_pdrv_genirq",
  928. .id = 7,
  929. .dev = {
  930. .platform_data = &spu1_platform_data,
  931. },
  932. .resource = spu1_resources,
  933. .num_resources = ARRAY_SIZE(spu1_resources),
  934. };
  935. static struct platform_device *sh7372_early_devices[] __initdata = {
  936. &scif0_device,
  937. &scif1_device,
  938. &scif2_device,
  939. &scif3_device,
  940. &scif4_device,
  941. &scif5_device,
  942. &scif6_device,
  943. &cmt2_device,
  944. &tmu00_device,
  945. &tmu01_device,
  946. };
  947. static struct platform_device *sh7372_late_devices[] __initdata = {
  948. &iic0_device,
  949. &iic1_device,
  950. &dma0_device,
  951. &dma1_device,
  952. &dma2_device,
  953. &usb_dma0_device,
  954. &usb_dma1_device,
  955. &vpu_device,
  956. &veu0_device,
  957. &veu1_device,
  958. &veu2_device,
  959. &veu3_device,
  960. &jpu_device,
  961. &spu0_device,
  962. &spu1_device,
  963. };
  964. void __init sh7372_add_standard_devices(void)
  965. {
  966. struct pm_domain_device domain_devices[] = {
  967. { "A3RV", &vpu_device, },
  968. { "A4MP", &spu0_device, },
  969. { "A4MP", &spu1_device, },
  970. { "A3SP", &scif0_device, },
  971. { "A3SP", &scif1_device, },
  972. { "A3SP", &scif2_device, },
  973. { "A3SP", &scif3_device, },
  974. { "A3SP", &scif4_device, },
  975. { "A3SP", &scif5_device, },
  976. { "A3SP", &scif6_device, },
  977. { "A3SP", &iic1_device, },
  978. { "A3SP", &dma0_device, },
  979. { "A3SP", &dma1_device, },
  980. { "A3SP", &dma2_device, },
  981. { "A3SP", &usb_dma0_device, },
  982. { "A3SP", &usb_dma1_device, },
  983. { "A4R", &iic0_device, },
  984. { "A4R", &veu0_device, },
  985. { "A4R", &veu1_device, },
  986. { "A4R", &veu2_device, },
  987. { "A4R", &veu3_device, },
  988. { "A4R", &jpu_device, },
  989. { "A4R", &tmu00_device, },
  990. { "A4R", &tmu01_device, },
  991. };
  992. sh7372_init_pm_domains();
  993. platform_add_devices(sh7372_early_devices,
  994. ARRAY_SIZE(sh7372_early_devices));
  995. platform_add_devices(sh7372_late_devices,
  996. ARRAY_SIZE(sh7372_late_devices));
  997. rmobile_add_devices_to_domains(domain_devices,
  998. ARRAY_SIZE(domain_devices));
  999. }
  1000. static void __init sh7372_earlytimer_init(void)
  1001. {
  1002. sh7372_clock_init();
  1003. shmobile_earlytimer_init();
  1004. }
  1005. void __init sh7372_add_early_devices(void)
  1006. {
  1007. early_platform_add_devices(sh7372_early_devices,
  1008. ARRAY_SIZE(sh7372_early_devices));
  1009. /* setup early console here as well */
  1010. shmobile_setup_console();
  1011. /* override timer setup with soc-specific code */
  1012. shmobile_timer.init = sh7372_earlytimer_init;
  1013. }
  1014. #ifdef CONFIG_USE_OF
  1015. void __init sh7372_add_early_devices_dt(void)
  1016. {
  1017. shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */
  1018. early_platform_add_devices(sh7372_early_devices,
  1019. ARRAY_SIZE(sh7372_early_devices));
  1020. /* setup early console here as well */
  1021. shmobile_setup_console();
  1022. }
  1023. static const struct of_dev_auxdata sh7372_auxdata_lookup[] __initconst = {
  1024. { }
  1025. };
  1026. void __init sh7372_add_standard_devices_dt(void)
  1027. {
  1028. /* clocks are setup late during boot in the case of DT */
  1029. sh7372_clock_init();
  1030. platform_add_devices(sh7372_early_devices,
  1031. ARRAY_SIZE(sh7372_early_devices));
  1032. of_platform_populate(NULL, of_default_bus_match_table,
  1033. sh7372_auxdata_lookup, NULL);
  1034. }
  1035. static const char *sh7372_boards_compat_dt[] __initdata = {
  1036. "renesas,sh7372",
  1037. NULL,
  1038. };
  1039. DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
  1040. .map_io = sh7372_map_io,
  1041. .init_early = sh7372_add_early_devices_dt,
  1042. .nr_irqs = NR_IRQS_LEGACY,
  1043. .init_irq = sh7372_init_irq,
  1044. .handle_irq = shmobile_handle_irq_intc,
  1045. .init_machine = sh7372_add_standard_devices_dt,
  1046. .timer = &shmobile_timer,
  1047. .dt_compat = sh7372_boards_compat_dt,
  1048. MACHINE_END
  1049. #endif /* CONFIG_USE_OF */