setup-sh7372.c 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  417. {
  418. .offset = 0,
  419. .dmars = 0,
  420. .dmars_bit = 0,
  421. }, {
  422. .offset = 0x10,
  423. .dmars = 0,
  424. .dmars_bit = 8,
  425. }, {
  426. .offset = 0x20,
  427. .dmars = 4,
  428. .dmars_bit = 0,
  429. }, {
  430. .offset = 0x30,
  431. .dmars = 4,
  432. .dmars_bit = 8,
  433. }, {
  434. .offset = 0x50,
  435. .dmars = 8,
  436. .dmars_bit = 0,
  437. }, {
  438. .offset = 0x60,
  439. .dmars = 8,
  440. .dmars_bit = 8,
  441. }
  442. };
  443. static const unsigned int ts_shift[] = TS_SHIFT;
  444. static struct sh_dmae_pdata dma_platform_data = {
  445. .slave = sh7372_dmae_slaves,
  446. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  447. .channel = sh7372_dmae_channels,
  448. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  449. .ts_low_shift = 3,
  450. .ts_low_mask = 0x18,
  451. .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
  452. .ts_high_mask = 0x00300000,
  453. .ts_shift = ts_shift,
  454. .ts_shift_num = ARRAY_SIZE(ts_shift),
  455. .dmaor_init = DMAOR_DME,
  456. };
  457. /* Resource order important! */
  458. static struct resource sh7372_dmae0_resources[] = {
  459. {
  460. /* Channel registers and DMAOR */
  461. .start = 0xfe008020,
  462. .end = 0xfe00808f,
  463. .flags = IORESOURCE_MEM,
  464. },
  465. {
  466. /* DMARSx */
  467. .start = 0xfe009000,
  468. .end = 0xfe00900b,
  469. .flags = IORESOURCE_MEM,
  470. },
  471. {
  472. /* DMA error IRQ */
  473. .start = evt2irq(0x20c0),
  474. .end = evt2irq(0x20c0),
  475. .flags = IORESOURCE_IRQ,
  476. },
  477. {
  478. /* IRQ for channels 0-5 */
  479. .start = evt2irq(0x2000),
  480. .end = evt2irq(0x20a0),
  481. .flags = IORESOURCE_IRQ,
  482. },
  483. };
  484. /* Resource order important! */
  485. static struct resource sh7372_dmae1_resources[] = {
  486. {
  487. /* Channel registers and DMAOR */
  488. .start = 0xfe018020,
  489. .end = 0xfe01808f,
  490. .flags = IORESOURCE_MEM,
  491. },
  492. {
  493. /* DMARSx */
  494. .start = 0xfe019000,
  495. .end = 0xfe01900b,
  496. .flags = IORESOURCE_MEM,
  497. },
  498. {
  499. /* DMA error IRQ */
  500. .start = evt2irq(0x21c0),
  501. .end = evt2irq(0x21c0),
  502. .flags = IORESOURCE_IRQ,
  503. },
  504. {
  505. /* IRQ for channels 0-5 */
  506. .start = evt2irq(0x2100),
  507. .end = evt2irq(0x21a0),
  508. .flags = IORESOURCE_IRQ,
  509. },
  510. };
  511. /* Resource order important! */
  512. static struct resource sh7372_dmae2_resources[] = {
  513. {
  514. /* Channel registers and DMAOR */
  515. .start = 0xfe028020,
  516. .end = 0xfe02808f,
  517. .flags = IORESOURCE_MEM,
  518. },
  519. {
  520. /* DMARSx */
  521. .start = 0xfe029000,
  522. .end = 0xfe02900b,
  523. .flags = IORESOURCE_MEM,
  524. },
  525. {
  526. /* DMA error IRQ */
  527. .start = evt2irq(0x22c0),
  528. .end = evt2irq(0x22c0),
  529. .flags = IORESOURCE_IRQ,
  530. },
  531. {
  532. /* IRQ for channels 0-5 */
  533. .start = evt2irq(0x2200),
  534. .end = evt2irq(0x22a0),
  535. .flags = IORESOURCE_IRQ,
  536. },
  537. };
  538. static struct platform_device dma0_device = {
  539. .name = "sh-dma-engine",
  540. .id = 0,
  541. .resource = sh7372_dmae0_resources,
  542. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  543. .dev = {
  544. .platform_data = &dma_platform_data,
  545. },
  546. };
  547. static struct platform_device dma1_device = {
  548. .name = "sh-dma-engine",
  549. .id = 1,
  550. .resource = sh7372_dmae1_resources,
  551. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  552. .dev = {
  553. .platform_data = &dma_platform_data,
  554. },
  555. };
  556. static struct platform_device dma2_device = {
  557. .name = "sh-dma-engine",
  558. .id = 2,
  559. .resource = sh7372_dmae2_resources,
  560. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  561. .dev = {
  562. .platform_data = &dma_platform_data,
  563. },
  564. };
  565. /*
  566. * USB-DMAC
  567. */
  568. unsigned int usbts_shift[] = {3, 4, 5};
  569. enum {
  570. XMIT_SZ_8BYTE = 0,
  571. XMIT_SZ_16BYTE = 1,
  572. XMIT_SZ_32BYTE = 2,
  573. };
  574. #define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
  575. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  576. {
  577. .offset = 0,
  578. }, {
  579. .offset = 0x20,
  580. },
  581. };
  582. /* USB DMAC0 */
  583. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  584. {
  585. .slave_id = SHDMA_SLAVE_USB0_TX,
  586. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  587. }, {
  588. .slave_id = SHDMA_SLAVE_USB0_RX,
  589. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  590. },
  591. };
  592. static struct sh_dmae_pdata usb_dma0_platform_data = {
  593. .slave = sh7372_usb_dmae0_slaves,
  594. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  595. .channel = sh7372_usb_dmae_channels,
  596. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  597. .ts_low_shift = 6,
  598. .ts_low_mask = 0xc0,
  599. .ts_high_shift = 0,
  600. .ts_high_mask = 0,
  601. .ts_shift = usbts_shift,
  602. .ts_shift_num = ARRAY_SIZE(usbts_shift),
  603. .dmaor_init = DMAOR_DME,
  604. .chcr_offset = 0x14,
  605. .chcr_ie_bit = 1 << 5,
  606. .dmaor_is_32bit = 1,
  607. .needs_tend_set = 1,
  608. .no_dmars = 1,
  609. };
  610. static struct resource sh7372_usb_dmae0_resources[] = {
  611. {
  612. /* Channel registers and DMAOR */
  613. .start = 0xe68a0020,
  614. .end = 0xe68a0064 - 1,
  615. .flags = IORESOURCE_MEM,
  616. },
  617. {
  618. /* VCR/SWR/DMICR */
  619. .start = 0xe68a0000,
  620. .end = 0xe68a0014 - 1,
  621. .flags = IORESOURCE_MEM,
  622. },
  623. {
  624. /* IRQ for channels */
  625. .start = evt2irq(0x0a00),
  626. .end = evt2irq(0x0a00),
  627. .flags = IORESOURCE_IRQ,
  628. },
  629. };
  630. static struct platform_device usb_dma0_device = {
  631. .name = "sh-dma-engine",
  632. .id = 3,
  633. .resource = sh7372_usb_dmae0_resources,
  634. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  635. .dev = {
  636. .platform_data = &usb_dma0_platform_data,
  637. },
  638. };
  639. /* USB DMAC1 */
  640. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  641. {
  642. .slave_id = SHDMA_SLAVE_USB1_TX,
  643. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  644. }, {
  645. .slave_id = SHDMA_SLAVE_USB1_RX,
  646. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  647. },
  648. };
  649. static struct sh_dmae_pdata usb_dma1_platform_data = {
  650. .slave = sh7372_usb_dmae1_slaves,
  651. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  652. .channel = sh7372_usb_dmae_channels,
  653. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  654. .ts_low_shift = 6,
  655. .ts_low_mask = 0xc0,
  656. .ts_high_shift = 0,
  657. .ts_high_mask = 0,
  658. .ts_shift = usbts_shift,
  659. .ts_shift_num = ARRAY_SIZE(usbts_shift),
  660. .dmaor_init = DMAOR_DME,
  661. .chcr_offset = 0x14,
  662. .chcr_ie_bit = 1 << 5,
  663. .dmaor_is_32bit = 1,
  664. .needs_tend_set = 1,
  665. .no_dmars = 1,
  666. };
  667. static struct resource sh7372_usb_dmae1_resources[] = {
  668. {
  669. /* Channel registers and DMAOR */
  670. .start = 0xe68c0020,
  671. .end = 0xe68c0064 - 1,
  672. .flags = IORESOURCE_MEM,
  673. },
  674. {
  675. /* VCR/SWR/DMICR */
  676. .start = 0xe68c0000,
  677. .end = 0xe68c0014 - 1,
  678. .flags = IORESOURCE_MEM,
  679. },
  680. {
  681. /* IRQ for channels */
  682. .start = evt2irq(0x1d00),
  683. .end = evt2irq(0x1d00),
  684. .flags = IORESOURCE_IRQ,
  685. },
  686. };
  687. static struct platform_device usb_dma1_device = {
  688. .name = "sh-dma-engine",
  689. .id = 4,
  690. .resource = sh7372_usb_dmae1_resources,
  691. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  692. .dev = {
  693. .platform_data = &usb_dma1_platform_data,
  694. },
  695. };
  696. /* VPU */
  697. static struct uio_info vpu_platform_data = {
  698. .name = "VPU5HG",
  699. .version = "0",
  700. .irq = intcs_evt2irq(0x980),
  701. };
  702. static struct resource vpu_resources[] = {
  703. [0] = {
  704. .name = "VPU",
  705. .start = 0xfe900000,
  706. .end = 0xfe900157,
  707. .flags = IORESOURCE_MEM,
  708. },
  709. };
  710. static struct platform_device vpu_device = {
  711. .name = "uio_pdrv_genirq",
  712. .id = 0,
  713. .dev = {
  714. .platform_data = &vpu_platform_data,
  715. },
  716. .resource = vpu_resources,
  717. .num_resources = ARRAY_SIZE(vpu_resources),
  718. };
  719. /* VEU0 */
  720. static struct uio_info veu0_platform_data = {
  721. .name = "VEU0",
  722. .version = "0",
  723. .irq = intcs_evt2irq(0x700),
  724. };
  725. static struct resource veu0_resources[] = {
  726. [0] = {
  727. .name = "VEU0",
  728. .start = 0xfe920000,
  729. .end = 0xfe9200cb,
  730. .flags = IORESOURCE_MEM,
  731. },
  732. };
  733. static struct platform_device veu0_device = {
  734. .name = "uio_pdrv_genirq",
  735. .id = 1,
  736. .dev = {
  737. .platform_data = &veu0_platform_data,
  738. },
  739. .resource = veu0_resources,
  740. .num_resources = ARRAY_SIZE(veu0_resources),
  741. };
  742. /* VEU1 */
  743. static struct uio_info veu1_platform_data = {
  744. .name = "VEU1",
  745. .version = "0",
  746. .irq = intcs_evt2irq(0x720),
  747. };
  748. static struct resource veu1_resources[] = {
  749. [0] = {
  750. .name = "VEU1",
  751. .start = 0xfe924000,
  752. .end = 0xfe9240cb,
  753. .flags = IORESOURCE_MEM,
  754. },
  755. };
  756. static struct platform_device veu1_device = {
  757. .name = "uio_pdrv_genirq",
  758. .id = 2,
  759. .dev = {
  760. .platform_data = &veu1_platform_data,
  761. },
  762. .resource = veu1_resources,
  763. .num_resources = ARRAY_SIZE(veu1_resources),
  764. };
  765. /* VEU2 */
  766. static struct uio_info veu2_platform_data = {
  767. .name = "VEU2",
  768. .version = "0",
  769. .irq = intcs_evt2irq(0x740),
  770. };
  771. static struct resource veu2_resources[] = {
  772. [0] = {
  773. .name = "VEU2",
  774. .start = 0xfe928000,
  775. .end = 0xfe928307,
  776. .flags = IORESOURCE_MEM,
  777. },
  778. };
  779. static struct platform_device veu2_device = {
  780. .name = "uio_pdrv_genirq",
  781. .id = 3,
  782. .dev = {
  783. .platform_data = &veu2_platform_data,
  784. },
  785. .resource = veu2_resources,
  786. .num_resources = ARRAY_SIZE(veu2_resources),
  787. };
  788. /* VEU3 */
  789. static struct uio_info veu3_platform_data = {
  790. .name = "VEU3",
  791. .version = "0",
  792. .irq = intcs_evt2irq(0x760),
  793. };
  794. static struct resource veu3_resources[] = {
  795. [0] = {
  796. .name = "VEU3",
  797. .start = 0xfe92c000,
  798. .end = 0xfe92c307,
  799. .flags = IORESOURCE_MEM,
  800. },
  801. };
  802. static struct platform_device veu3_device = {
  803. .name = "uio_pdrv_genirq",
  804. .id = 4,
  805. .dev = {
  806. .platform_data = &veu3_platform_data,
  807. },
  808. .resource = veu3_resources,
  809. .num_resources = ARRAY_SIZE(veu3_resources),
  810. };
  811. /* JPU */
  812. static struct uio_info jpu_platform_data = {
  813. .name = "JPU",
  814. .version = "0",
  815. .irq = intcs_evt2irq(0x560),
  816. };
  817. static struct resource jpu_resources[] = {
  818. [0] = {
  819. .name = "JPU",
  820. .start = 0xfe980000,
  821. .end = 0xfe9902d3,
  822. .flags = IORESOURCE_MEM,
  823. },
  824. };
  825. static struct platform_device jpu_device = {
  826. .name = "uio_pdrv_genirq",
  827. .id = 5,
  828. .dev = {
  829. .platform_data = &jpu_platform_data,
  830. },
  831. .resource = jpu_resources,
  832. .num_resources = ARRAY_SIZE(jpu_resources),
  833. };
  834. /* SPU2DSP0 */
  835. static struct uio_info spu0_platform_data = {
  836. .name = "SPU2DSP0",
  837. .version = "0",
  838. .irq = evt2irq(0x1800),
  839. };
  840. static struct resource spu0_resources[] = {
  841. [0] = {
  842. .name = "SPU2DSP0",
  843. .start = 0xfe200000,
  844. .end = 0xfe2fffff,
  845. .flags = IORESOURCE_MEM,
  846. },
  847. };
  848. static struct platform_device spu0_device = {
  849. .name = "uio_pdrv_genirq",
  850. .id = 6,
  851. .dev = {
  852. .platform_data = &spu0_platform_data,
  853. },
  854. .resource = spu0_resources,
  855. .num_resources = ARRAY_SIZE(spu0_resources),
  856. };
  857. /* SPU2DSP1 */
  858. static struct uio_info spu1_platform_data = {
  859. .name = "SPU2DSP1",
  860. .version = "0",
  861. .irq = evt2irq(0x1820),
  862. };
  863. static struct resource spu1_resources[] = {
  864. [0] = {
  865. .name = "SPU2DSP1",
  866. .start = 0xfe300000,
  867. .end = 0xfe3fffff,
  868. .flags = IORESOURCE_MEM,
  869. },
  870. };
  871. static struct platform_device spu1_device = {
  872. .name = "uio_pdrv_genirq",
  873. .id = 7,
  874. .dev = {
  875. .platform_data = &spu1_platform_data,
  876. },
  877. .resource = spu1_resources,
  878. .num_resources = ARRAY_SIZE(spu1_resources),
  879. };
  880. static struct platform_device *sh7372_early_devices[] __initdata = {
  881. &scif0_device,
  882. &scif1_device,
  883. &scif2_device,
  884. &scif3_device,
  885. &scif4_device,
  886. &scif5_device,
  887. &scif6_device,
  888. &cmt2_device,
  889. &tmu00_device,
  890. &tmu01_device,
  891. };
  892. static struct platform_device *sh7372_late_devices[] __initdata = {
  893. &iic0_device,
  894. &iic1_device,
  895. &dma0_device,
  896. &dma1_device,
  897. &dma2_device,
  898. &usb_dma0_device,
  899. &usb_dma1_device,
  900. &vpu_device,
  901. &veu0_device,
  902. &veu1_device,
  903. &veu2_device,
  904. &veu3_device,
  905. &jpu_device,
  906. &spu0_device,
  907. &spu1_device,
  908. };
  909. void __init sh7372_add_standard_devices(void)
  910. {
  911. sh7372_init_pm_domain(&sh7372_a4lc);
  912. sh7372_init_pm_domain(&sh7372_a4mp);
  913. sh7372_init_pm_domain(&sh7372_d4);
  914. sh7372_init_pm_domain(&sh7372_a4r);
  915. sh7372_init_pm_domain(&sh7372_a3rv);
  916. sh7372_init_pm_domain(&sh7372_a3ri);
  917. sh7372_init_pm_domain(&sh7372_a3sg);
  918. sh7372_init_pm_domain(&sh7372_a3sp);
  919. sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
  920. sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc);
  921. platform_add_devices(sh7372_early_devices,
  922. ARRAY_SIZE(sh7372_early_devices));
  923. platform_add_devices(sh7372_late_devices,
  924. ARRAY_SIZE(sh7372_late_devices));
  925. sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
  926. sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
  927. sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
  928. sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
  929. sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
  930. sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
  931. sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
  932. sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
  933. sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
  934. sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
  935. sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
  936. sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
  937. sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
  938. sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
  939. sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
  940. sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
  941. sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device);
  942. sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device);
  943. sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device);
  944. sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device);
  945. sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device);
  946. sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device);
  947. }
  948. void __init sh7372_add_early_devices(void)
  949. {
  950. early_platform_add_devices(sh7372_early_devices,
  951. ARRAY_SIZE(sh7372_early_devices));
  952. }