setup-sh7372.c 26 KB

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