setup-sh7372.c 24 KB

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