setup-sh7372.c 26 KB

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