setup-sh7372.c 25 KB

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