setup-sh7372.c 24 KB

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