setup-sh7372.c 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. /*
  2. * sh7372 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/uio_driver.h>
  27. #include <linux/delay.h>
  28. #include <linux/input.h>
  29. #include <linux/io.h>
  30. #include <linux/serial_sci.h>
  31. #include <linux/sh_dma.h>
  32. #include <linux/sh_intc.h>
  33. #include <linux/sh_timer.h>
  34. #include <linux/pm_domain.h>
  35. #include <linux/dma-mapping.h>
  36. #include <linux/platform_data/sh_ipmmu.h>
  37. #include <mach/dma-register.h>
  38. #include <mach/irqs.h>
  39. #include <mach/sh7372.h>
  40. #include <mach/common.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach-types.h>
  43. #include <asm/mach/arch.h>
  44. #include <asm/mach/time.h>
  45. static struct map_desc sh7372_io_desc[] __initdata = {
  46. /* create a 1:1 entity map for 0xe6xxxxxx
  47. * used by CPGA, INTC and PFC.
  48. */
  49. {
  50. .virtual = 0xe6000000,
  51. .pfn = __phys_to_pfn(0xe6000000),
  52. .length = 256 << 20,
  53. .type = MT_DEVICE_NONSHARED
  54. },
  55. };
  56. void __init sh7372_map_io(void)
  57. {
  58. iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
  59. }
  60. /* PFC */
  61. static struct resource sh7372_pfc_resources[] = {
  62. [0] = {
  63. .start = 0xe6050000,
  64. .end = 0xe6057fff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = 0xe605800c,
  69. .end = 0xe6058027,
  70. .flags = IORESOURCE_MEM,
  71. }
  72. };
  73. static struct platform_device sh7372_pfc_device = {
  74. .name = "pfc-sh7372",
  75. .id = -1,
  76. .resource = sh7372_pfc_resources,
  77. .num_resources = ARRAY_SIZE(sh7372_pfc_resources),
  78. };
  79. void __init sh7372_pinmux_init(void)
  80. {
  81. platform_device_register(&sh7372_pfc_device);
  82. }
  83. /* SCIF */
  84. #define SH7372_SCIF(scif_type, index, baseaddr, irq) \
  85. static struct plat_sci_port scif##index##_platform_data = { \
  86. .type = scif_type, \
  87. .flags = UPF_BOOT_AUTOCONF, \
  88. .scscr = SCSCR_RE | SCSCR_TE, \
  89. }; \
  90. \
  91. static struct resource scif##index##_resources[] = { \
  92. DEFINE_RES_MEM(baseaddr, 0x100), \
  93. DEFINE_RES_IRQ(irq), \
  94. }; \
  95. \
  96. static struct platform_device scif##index##_device = { \
  97. .name = "sh-sci", \
  98. .id = index, \
  99. .resource = scif##index##_resources, \
  100. .num_resources = ARRAY_SIZE(scif##index##_resources), \
  101. .dev = { \
  102. .platform_data = &scif##index##_platform_data, \
  103. }, \
  104. }
  105. SH7372_SCIF(PORT_SCIFA, 0, 0xe6c40000, evt2irq(0x0c00));
  106. SH7372_SCIF(PORT_SCIFA, 1, 0xe6c50000, evt2irq(0x0c20));
  107. SH7372_SCIF(PORT_SCIFA, 2, 0xe6c60000, evt2irq(0x0c40));
  108. SH7372_SCIF(PORT_SCIFA, 3, 0xe6c70000, evt2irq(0x0c60));
  109. SH7372_SCIF(PORT_SCIFA, 4, 0xe6c80000, evt2irq(0x0d20));
  110. SH7372_SCIF(PORT_SCIFA, 5, 0xe6cb0000, evt2irq(0x0d40));
  111. SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60));
  112. /* CMT */
  113. static struct sh_timer_config cmt2_platform_data = {
  114. .channels_mask = 0x20,
  115. };
  116. static struct resource cmt2_resources[] = {
  117. DEFINE_RES_MEM(0xe6130000, 0x50),
  118. DEFINE_RES_IRQ(evt2irq(0x0b80)),
  119. };
  120. static struct platform_device cmt2_device = {
  121. .name = "sh-cmt-32-fast",
  122. .id = 2,
  123. .dev = {
  124. .platform_data = &cmt2_platform_data,
  125. },
  126. .resource = cmt2_resources,
  127. .num_resources = ARRAY_SIZE(cmt2_resources),
  128. };
  129. /* TMU */
  130. static struct sh_timer_config tmu0_platform_data = {
  131. .channels_mask = 7,
  132. };
  133. static struct resource tmu0_resources[] = {
  134. DEFINE_RES_MEM(0xfff60000, 0x2c),
  135. DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
  136. DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
  137. DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
  138. };
  139. static struct platform_device tmu0_device = {
  140. .name = "sh-tmu",
  141. .id = 0,
  142. .dev = {
  143. .platform_data = &tmu0_platform_data,
  144. },
  145. .resource = tmu0_resources,
  146. .num_resources = ARRAY_SIZE(tmu0_resources),
  147. };
  148. /* I2C */
  149. static struct resource iic0_resources[] = {
  150. [0] = {
  151. .name = "IIC0",
  152. .start = 0xFFF20000,
  153. .end = 0xFFF20425 - 1,
  154. .flags = IORESOURCE_MEM,
  155. },
  156. [1] = {
  157. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  158. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  159. .flags = IORESOURCE_IRQ,
  160. },
  161. };
  162. static struct platform_device iic0_device = {
  163. .name = "i2c-sh_mobile",
  164. .id = 0, /* "i2c0" clock */
  165. .num_resources = ARRAY_SIZE(iic0_resources),
  166. .resource = iic0_resources,
  167. };
  168. static struct resource iic1_resources[] = {
  169. [0] = {
  170. .name = "IIC1",
  171. .start = 0xE6C20000,
  172. .end = 0xE6C20425 - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. [1] = {
  176. .start = evt2irq(0x780), /* IIC1_ALI1 */
  177. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  178. .flags = IORESOURCE_IRQ,
  179. },
  180. };
  181. static struct platform_device iic1_device = {
  182. .name = "i2c-sh_mobile",
  183. .id = 1, /* "i2c1" clock */
  184. .num_resources = ARRAY_SIZE(iic1_resources),
  185. .resource = iic1_resources,
  186. };
  187. /* DMA */
  188. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  189. {
  190. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  191. .addr = 0xe6c40020,
  192. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  193. .mid_rid = 0x21,
  194. }, {
  195. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  196. .addr = 0xe6c40024,
  197. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  198. .mid_rid = 0x22,
  199. }, {
  200. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  201. .addr = 0xe6c50020,
  202. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  203. .mid_rid = 0x25,
  204. }, {
  205. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  206. .addr = 0xe6c50024,
  207. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  208. .mid_rid = 0x26,
  209. }, {
  210. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  211. .addr = 0xe6c60020,
  212. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  213. .mid_rid = 0x29,
  214. }, {
  215. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  216. .addr = 0xe6c60024,
  217. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  218. .mid_rid = 0x2a,
  219. }, {
  220. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  221. .addr = 0xe6c70020,
  222. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  223. .mid_rid = 0x2d,
  224. }, {
  225. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  226. .addr = 0xe6c70024,
  227. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  228. .mid_rid = 0x2e,
  229. }, {
  230. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  231. .addr = 0xe6c80020,
  232. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  233. .mid_rid = 0x39,
  234. }, {
  235. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  236. .addr = 0xe6c80024,
  237. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  238. .mid_rid = 0x3a,
  239. }, {
  240. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  241. .addr = 0xe6cb0020,
  242. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  243. .mid_rid = 0x35,
  244. }, {
  245. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  246. .addr = 0xe6cb0024,
  247. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  248. .mid_rid = 0x36,
  249. }, {
  250. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  251. .addr = 0xe6c30040,
  252. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  253. .mid_rid = 0x3d,
  254. }, {
  255. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  256. .addr = 0xe6c30060,
  257. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  258. .mid_rid = 0x3e,
  259. }, {
  260. .slave_id = SHDMA_SLAVE_FLCTL0_TX,
  261. .addr = 0xe6a30050,
  262. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  263. .mid_rid = 0x83,
  264. }, {
  265. .slave_id = SHDMA_SLAVE_FLCTL0_RX,
  266. .addr = 0xe6a30050,
  267. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  268. .mid_rid = 0x83,
  269. }, {
  270. .slave_id = SHDMA_SLAVE_FLCTL1_TX,
  271. .addr = 0xe6a30060,
  272. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  273. .mid_rid = 0x87,
  274. }, {
  275. .slave_id = SHDMA_SLAVE_FLCTL1_RX,
  276. .addr = 0xe6a30060,
  277. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  278. .mid_rid = 0x87,
  279. }, {
  280. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  281. .addr = 0xe6850030,
  282. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  283. .mid_rid = 0xc1,
  284. }, {
  285. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  286. .addr = 0xe6850030,
  287. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  288. .mid_rid = 0xc2,
  289. }, {
  290. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  291. .addr = 0xe6860030,
  292. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  293. .mid_rid = 0xc9,
  294. }, {
  295. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  296. .addr = 0xe6860030,
  297. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  298. .mid_rid = 0xca,
  299. }, {
  300. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  301. .addr = 0xe6870030,
  302. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  303. .mid_rid = 0xcd,
  304. }, {
  305. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  306. .addr = 0xe6870030,
  307. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  308. .mid_rid = 0xce,
  309. }, {
  310. .slave_id = SHDMA_SLAVE_FSIA_TX,
  311. .addr = 0xfe1f0024,
  312. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  313. .mid_rid = 0xb1,
  314. }, {
  315. .slave_id = SHDMA_SLAVE_FSIA_RX,
  316. .addr = 0xfe1f0020,
  317. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  318. .mid_rid = 0xb2,
  319. }, {
  320. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  321. .addr = 0xe6bd0034,
  322. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  323. .mid_rid = 0xd1,
  324. }, {
  325. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  326. .addr = 0xe6bd0034,
  327. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  328. .mid_rid = 0xd2,
  329. },
  330. };
  331. #define SH7372_CHCLR (0x220 - 0x20)
  332. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  333. {
  334. .offset = 0,
  335. .dmars = 0,
  336. .dmars_bit = 0,
  337. .chclr_offset = SH7372_CHCLR + 0,
  338. }, {
  339. .offset = 0x10,
  340. .dmars = 0,
  341. .dmars_bit = 8,
  342. .chclr_offset = SH7372_CHCLR + 0x10,
  343. }, {
  344. .offset = 0x20,
  345. .dmars = 4,
  346. .dmars_bit = 0,
  347. .chclr_offset = SH7372_CHCLR + 0x20,
  348. }, {
  349. .offset = 0x30,
  350. .dmars = 4,
  351. .dmars_bit = 8,
  352. .chclr_offset = SH7372_CHCLR + 0x30,
  353. }, {
  354. .offset = 0x50,
  355. .dmars = 8,
  356. .dmars_bit = 0,
  357. .chclr_offset = SH7372_CHCLR + 0x50,
  358. }, {
  359. .offset = 0x60,
  360. .dmars = 8,
  361. .dmars_bit = 8,
  362. .chclr_offset = SH7372_CHCLR + 0x60,
  363. }
  364. };
  365. static struct sh_dmae_pdata dma_platform_data = {
  366. .slave = sh7372_dmae_slaves,
  367. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  368. .channel = sh7372_dmae_channels,
  369. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  370. .ts_low_shift = TS_LOW_SHIFT,
  371. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  372. .ts_high_shift = TS_HI_SHIFT,
  373. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  374. .ts_shift = dma_ts_shift,
  375. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  376. .dmaor_init = DMAOR_DME,
  377. .chclr_present = 1,
  378. };
  379. /* Resource order important! */
  380. static struct resource sh7372_dmae0_resources[] = {
  381. {
  382. /* Channel registers and DMAOR */
  383. .start = 0xfe008020,
  384. .end = 0xfe00828f,
  385. .flags = IORESOURCE_MEM,
  386. },
  387. {
  388. /* DMARSx */
  389. .start = 0xfe009000,
  390. .end = 0xfe00900b,
  391. .flags = IORESOURCE_MEM,
  392. },
  393. {
  394. .name = "error_irq",
  395. .start = evt2irq(0x20c0),
  396. .end = evt2irq(0x20c0),
  397. .flags = IORESOURCE_IRQ,
  398. },
  399. {
  400. /* IRQ for channels 0-5 */
  401. .start = evt2irq(0x2000),
  402. .end = evt2irq(0x20a0),
  403. .flags = IORESOURCE_IRQ,
  404. },
  405. };
  406. /* Resource order important! */
  407. static struct resource sh7372_dmae1_resources[] = {
  408. {
  409. /* Channel registers and DMAOR */
  410. .start = 0xfe018020,
  411. .end = 0xfe01828f,
  412. .flags = IORESOURCE_MEM,
  413. },
  414. {
  415. /* DMARSx */
  416. .start = 0xfe019000,
  417. .end = 0xfe01900b,
  418. .flags = IORESOURCE_MEM,
  419. },
  420. {
  421. .name = "error_irq",
  422. .start = evt2irq(0x21c0),
  423. .end = evt2irq(0x21c0),
  424. .flags = IORESOURCE_IRQ,
  425. },
  426. {
  427. /* IRQ for channels 0-5 */
  428. .start = evt2irq(0x2100),
  429. .end = evt2irq(0x21a0),
  430. .flags = IORESOURCE_IRQ,
  431. },
  432. };
  433. /* Resource order important! */
  434. static struct resource sh7372_dmae2_resources[] = {
  435. {
  436. /* Channel registers and DMAOR */
  437. .start = 0xfe028020,
  438. .end = 0xfe02828f,
  439. .flags = IORESOURCE_MEM,
  440. },
  441. {
  442. /* DMARSx */
  443. .start = 0xfe029000,
  444. .end = 0xfe02900b,
  445. .flags = IORESOURCE_MEM,
  446. },
  447. {
  448. .name = "error_irq",
  449. .start = evt2irq(0x22c0),
  450. .end = evt2irq(0x22c0),
  451. .flags = IORESOURCE_IRQ,
  452. },
  453. {
  454. /* IRQ for channels 0-5 */
  455. .start = evt2irq(0x2200),
  456. .end = evt2irq(0x22a0),
  457. .flags = IORESOURCE_IRQ,
  458. },
  459. };
  460. static struct platform_device dma0_device = {
  461. .name = "sh-dma-engine",
  462. .id = 0,
  463. .resource = sh7372_dmae0_resources,
  464. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  465. .dev = {
  466. .platform_data = &dma_platform_data,
  467. },
  468. };
  469. static struct platform_device dma1_device = {
  470. .name = "sh-dma-engine",
  471. .id = 1,
  472. .resource = sh7372_dmae1_resources,
  473. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  474. .dev = {
  475. .platform_data = &dma_platform_data,
  476. },
  477. };
  478. static struct platform_device dma2_device = {
  479. .name = "sh-dma-engine",
  480. .id = 2,
  481. .resource = sh7372_dmae2_resources,
  482. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  483. .dev = {
  484. .platform_data = &dma_platform_data,
  485. },
  486. };
  487. /*
  488. * USB-DMAC
  489. */
  490. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  491. {
  492. .offset = 0,
  493. }, {
  494. .offset = 0x20,
  495. },
  496. };
  497. /* USB DMAC0 */
  498. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  499. {
  500. .slave_id = SHDMA_SLAVE_USB0_TX,
  501. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  502. }, {
  503. .slave_id = SHDMA_SLAVE_USB0_RX,
  504. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  505. },
  506. };
  507. static struct sh_dmae_pdata usb_dma0_platform_data = {
  508. .slave = sh7372_usb_dmae0_slaves,
  509. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  510. .channel = sh7372_usb_dmae_channels,
  511. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  512. .ts_low_shift = USBTS_LOW_SHIFT,
  513. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  514. .ts_high_shift = USBTS_HI_SHIFT,
  515. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  516. .ts_shift = dma_usbts_shift,
  517. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  518. .dmaor_init = DMAOR_DME,
  519. .chcr_offset = 0x14,
  520. .chcr_ie_bit = 1 << 5,
  521. .dmaor_is_32bit = 1,
  522. .needs_tend_set = 1,
  523. .no_dmars = 1,
  524. .slave_only = 1,
  525. };
  526. static struct resource sh7372_usb_dmae0_resources[] = {
  527. {
  528. /* Channel registers and DMAOR */
  529. .start = 0xe68a0020,
  530. .end = 0xe68a0064 - 1,
  531. .flags = IORESOURCE_MEM,
  532. },
  533. {
  534. /* VCR/SWR/DMICR */
  535. .start = 0xe68a0000,
  536. .end = 0xe68a0014 - 1,
  537. .flags = IORESOURCE_MEM,
  538. },
  539. {
  540. /* IRQ for channels */
  541. .start = evt2irq(0x0a00),
  542. .end = evt2irq(0x0a00),
  543. .flags = IORESOURCE_IRQ,
  544. },
  545. };
  546. static struct platform_device usb_dma0_device = {
  547. .name = "sh-dma-engine",
  548. .id = 3,
  549. .resource = sh7372_usb_dmae0_resources,
  550. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  551. .dev = {
  552. .platform_data = &usb_dma0_platform_data,
  553. },
  554. };
  555. /* USB DMAC1 */
  556. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  557. {
  558. .slave_id = SHDMA_SLAVE_USB1_TX,
  559. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  560. }, {
  561. .slave_id = SHDMA_SLAVE_USB1_RX,
  562. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  563. },
  564. };
  565. static struct sh_dmae_pdata usb_dma1_platform_data = {
  566. .slave = sh7372_usb_dmae1_slaves,
  567. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  568. .channel = sh7372_usb_dmae_channels,
  569. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  570. .ts_low_shift = USBTS_LOW_SHIFT,
  571. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  572. .ts_high_shift = USBTS_HI_SHIFT,
  573. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  574. .ts_shift = dma_usbts_shift,
  575. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  576. .dmaor_init = DMAOR_DME,
  577. .chcr_offset = 0x14,
  578. .chcr_ie_bit = 1 << 5,
  579. .dmaor_is_32bit = 1,
  580. .needs_tend_set = 1,
  581. .no_dmars = 1,
  582. .slave_only = 1,
  583. };
  584. static struct resource sh7372_usb_dmae1_resources[] = {
  585. {
  586. /* Channel registers and DMAOR */
  587. .start = 0xe68c0020,
  588. .end = 0xe68c0064 - 1,
  589. .flags = IORESOURCE_MEM,
  590. },
  591. {
  592. /* VCR/SWR/DMICR */
  593. .start = 0xe68c0000,
  594. .end = 0xe68c0014 - 1,
  595. .flags = IORESOURCE_MEM,
  596. },
  597. {
  598. /* IRQ for channels */
  599. .start = evt2irq(0x1d00),
  600. .end = evt2irq(0x1d00),
  601. .flags = IORESOURCE_IRQ,
  602. },
  603. };
  604. static struct platform_device usb_dma1_device = {
  605. .name = "sh-dma-engine",
  606. .id = 4,
  607. .resource = sh7372_usb_dmae1_resources,
  608. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  609. .dev = {
  610. .platform_data = &usb_dma1_platform_data,
  611. },
  612. };
  613. /* VPU */
  614. static struct uio_info vpu_platform_data = {
  615. .name = "VPU5HG",
  616. .version = "0",
  617. .irq = intcs_evt2irq(0x980),
  618. };
  619. static struct resource vpu_resources[] = {
  620. [0] = {
  621. .name = "VPU",
  622. .start = 0xfe900000,
  623. .end = 0xfe900157,
  624. .flags = IORESOURCE_MEM,
  625. },
  626. };
  627. static struct platform_device vpu_device = {
  628. .name = "uio_pdrv_genirq",
  629. .id = 0,
  630. .dev = {
  631. .platform_data = &vpu_platform_data,
  632. },
  633. .resource = vpu_resources,
  634. .num_resources = ARRAY_SIZE(vpu_resources),
  635. };
  636. /* VEU0 */
  637. static struct uio_info veu0_platform_data = {
  638. .name = "VEU0",
  639. .version = "0",
  640. .irq = intcs_evt2irq(0x700),
  641. };
  642. static struct resource veu0_resources[] = {
  643. [0] = {
  644. .name = "VEU0",
  645. .start = 0xfe920000,
  646. .end = 0xfe9200cb,
  647. .flags = IORESOURCE_MEM,
  648. },
  649. };
  650. static struct platform_device veu0_device = {
  651. .name = "uio_pdrv_genirq",
  652. .id = 1,
  653. .dev = {
  654. .platform_data = &veu0_platform_data,
  655. },
  656. .resource = veu0_resources,
  657. .num_resources = ARRAY_SIZE(veu0_resources),
  658. };
  659. /* VEU1 */
  660. static struct uio_info veu1_platform_data = {
  661. .name = "VEU1",
  662. .version = "0",
  663. .irq = intcs_evt2irq(0x720),
  664. };
  665. static struct resource veu1_resources[] = {
  666. [0] = {
  667. .name = "VEU1",
  668. .start = 0xfe924000,
  669. .end = 0xfe9240cb,
  670. .flags = IORESOURCE_MEM,
  671. },
  672. };
  673. static struct platform_device veu1_device = {
  674. .name = "uio_pdrv_genirq",
  675. .id = 2,
  676. .dev = {
  677. .platform_data = &veu1_platform_data,
  678. },
  679. .resource = veu1_resources,
  680. .num_resources = ARRAY_SIZE(veu1_resources),
  681. };
  682. /* VEU2 */
  683. static struct uio_info veu2_platform_data = {
  684. .name = "VEU2",
  685. .version = "0",
  686. .irq = intcs_evt2irq(0x740),
  687. };
  688. static struct resource veu2_resources[] = {
  689. [0] = {
  690. .name = "VEU2",
  691. .start = 0xfe928000,
  692. .end = 0xfe928307,
  693. .flags = IORESOURCE_MEM,
  694. },
  695. };
  696. static struct platform_device veu2_device = {
  697. .name = "uio_pdrv_genirq",
  698. .id = 3,
  699. .dev = {
  700. .platform_data = &veu2_platform_data,
  701. },
  702. .resource = veu2_resources,
  703. .num_resources = ARRAY_SIZE(veu2_resources),
  704. };
  705. /* VEU3 */
  706. static struct uio_info veu3_platform_data = {
  707. .name = "VEU3",
  708. .version = "0",
  709. .irq = intcs_evt2irq(0x760),
  710. };
  711. static struct resource veu3_resources[] = {
  712. [0] = {
  713. .name = "VEU3",
  714. .start = 0xfe92c000,
  715. .end = 0xfe92c307,
  716. .flags = IORESOURCE_MEM,
  717. },
  718. };
  719. static struct platform_device veu3_device = {
  720. .name = "uio_pdrv_genirq",
  721. .id = 4,
  722. .dev = {
  723. .platform_data = &veu3_platform_data,
  724. },
  725. .resource = veu3_resources,
  726. .num_resources = ARRAY_SIZE(veu3_resources),
  727. };
  728. /* JPU */
  729. static struct uio_info jpu_platform_data = {
  730. .name = "JPU",
  731. .version = "0",
  732. .irq = intcs_evt2irq(0x560),
  733. };
  734. static struct resource jpu_resources[] = {
  735. [0] = {
  736. .name = "JPU",
  737. .start = 0xfe980000,
  738. .end = 0xfe9902d3,
  739. .flags = IORESOURCE_MEM,
  740. },
  741. };
  742. static struct platform_device jpu_device = {
  743. .name = "uio_pdrv_genirq",
  744. .id = 5,
  745. .dev = {
  746. .platform_data = &jpu_platform_data,
  747. },
  748. .resource = jpu_resources,
  749. .num_resources = ARRAY_SIZE(jpu_resources),
  750. };
  751. /* SPU2DSP0 */
  752. static struct uio_info spu0_platform_data = {
  753. .name = "SPU2DSP0",
  754. .version = "0",
  755. .irq = evt2irq(0x1800),
  756. };
  757. static struct resource spu0_resources[] = {
  758. [0] = {
  759. .name = "SPU2DSP0",
  760. .start = 0xfe200000,
  761. .end = 0xfe2fffff,
  762. .flags = IORESOURCE_MEM,
  763. },
  764. };
  765. static struct platform_device spu0_device = {
  766. .name = "uio_pdrv_genirq",
  767. .id = 6,
  768. .dev = {
  769. .platform_data = &spu0_platform_data,
  770. },
  771. .resource = spu0_resources,
  772. .num_resources = ARRAY_SIZE(spu0_resources),
  773. };
  774. /* SPU2DSP1 */
  775. static struct uio_info spu1_platform_data = {
  776. .name = "SPU2DSP1",
  777. .version = "0",
  778. .irq = evt2irq(0x1820),
  779. };
  780. static struct resource spu1_resources[] = {
  781. [0] = {
  782. .name = "SPU2DSP1",
  783. .start = 0xfe300000,
  784. .end = 0xfe3fffff,
  785. .flags = IORESOURCE_MEM,
  786. },
  787. };
  788. static struct platform_device spu1_device = {
  789. .name = "uio_pdrv_genirq",
  790. .id = 7,
  791. .dev = {
  792. .platform_data = &spu1_platform_data,
  793. },
  794. .resource = spu1_resources,
  795. .num_resources = ARRAY_SIZE(spu1_resources),
  796. };
  797. /* IPMMUI (an IPMMU module for ICB/LMB) */
  798. static struct resource ipmmu_resources[] = {
  799. [0] = {
  800. .name = "IPMMUI",
  801. .start = 0xfe951000,
  802. .end = 0xfe9510ff,
  803. .flags = IORESOURCE_MEM,
  804. },
  805. };
  806. static const char * const ipmmu_dev_names[] = {
  807. "sh_mobile_lcdc_fb.0",
  808. "sh_mobile_lcdc_fb.1",
  809. "sh_mobile_ceu.0",
  810. "uio_pdrv_genirq.0",
  811. "uio_pdrv_genirq.1",
  812. "uio_pdrv_genirq.2",
  813. "uio_pdrv_genirq.3",
  814. "uio_pdrv_genirq.4",
  815. "uio_pdrv_genirq.5",
  816. };
  817. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  818. .dev_names = ipmmu_dev_names,
  819. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  820. };
  821. static struct platform_device ipmmu_device = {
  822. .name = "ipmmu",
  823. .id = -1,
  824. .dev = {
  825. .platform_data = &ipmmu_platform_data,
  826. },
  827. .resource = ipmmu_resources,
  828. .num_resources = ARRAY_SIZE(ipmmu_resources),
  829. };
  830. static struct platform_device *sh7372_early_devices[] __initdata = {
  831. &scif0_device,
  832. &scif1_device,
  833. &scif2_device,
  834. &scif3_device,
  835. &scif4_device,
  836. &scif5_device,
  837. &scif6_device,
  838. &cmt2_device,
  839. &tmu0_device,
  840. &ipmmu_device,
  841. };
  842. static struct platform_device *sh7372_late_devices[] __initdata = {
  843. &iic0_device,
  844. &iic1_device,
  845. &dma0_device,
  846. &dma1_device,
  847. &dma2_device,
  848. &usb_dma0_device,
  849. &usb_dma1_device,
  850. &vpu_device,
  851. &veu0_device,
  852. &veu1_device,
  853. &veu2_device,
  854. &veu3_device,
  855. &jpu_device,
  856. &spu0_device,
  857. &spu1_device,
  858. };
  859. void __init sh7372_add_standard_devices(void)
  860. {
  861. struct pm_domain_device domain_devices[] = {
  862. { "A3RV", &vpu_device, },
  863. { "A4MP", &spu0_device, },
  864. { "A4MP", &spu1_device, },
  865. { "A3SP", &scif0_device, },
  866. { "A3SP", &scif1_device, },
  867. { "A3SP", &scif2_device, },
  868. { "A3SP", &scif3_device, },
  869. { "A3SP", &scif4_device, },
  870. { "A3SP", &scif5_device, },
  871. { "A3SP", &scif6_device, },
  872. { "A3SP", &iic1_device, },
  873. { "A3SP", &dma0_device, },
  874. { "A3SP", &dma1_device, },
  875. { "A3SP", &dma2_device, },
  876. { "A3SP", &usb_dma0_device, },
  877. { "A3SP", &usb_dma1_device, },
  878. { "A4R", &iic0_device, },
  879. { "A4R", &veu0_device, },
  880. { "A4R", &veu1_device, },
  881. { "A4R", &veu2_device, },
  882. { "A4R", &veu3_device, },
  883. { "A4R", &jpu_device, },
  884. { "A4R", &tmu0_device, },
  885. };
  886. sh7372_init_pm_domains();
  887. platform_add_devices(sh7372_early_devices,
  888. ARRAY_SIZE(sh7372_early_devices));
  889. platform_add_devices(sh7372_late_devices,
  890. ARRAY_SIZE(sh7372_late_devices));
  891. rmobile_add_devices_to_domains(domain_devices,
  892. ARRAY_SIZE(domain_devices));
  893. }
  894. void __init sh7372_earlytimer_init(void)
  895. {
  896. sh7372_clock_init();
  897. shmobile_earlytimer_init();
  898. }
  899. void __init sh7372_add_early_devices(void)
  900. {
  901. early_platform_add_devices(sh7372_early_devices,
  902. ARRAY_SIZE(sh7372_early_devices));
  903. /* setup early console here as well */
  904. shmobile_setup_console();
  905. }
  906. #ifdef CONFIG_USE_OF
  907. void __init sh7372_add_early_devices_dt(void)
  908. {
  909. shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */
  910. sh7372_add_early_devices();
  911. }
  912. void __init sh7372_add_standard_devices_dt(void)
  913. {
  914. /* clocks are setup late during boot in the case of DT */
  915. sh7372_clock_init();
  916. platform_add_devices(sh7372_early_devices,
  917. ARRAY_SIZE(sh7372_early_devices));
  918. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  919. }
  920. static const char *sh7372_boards_compat_dt[] __initdata = {
  921. "renesas,sh7372",
  922. NULL,
  923. };
  924. DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
  925. .map_io = sh7372_map_io,
  926. .init_early = sh7372_add_early_devices_dt,
  927. .nr_irqs = NR_IRQS_LEGACY,
  928. .init_irq = sh7372_init_irq,
  929. .handle_irq = shmobile_handle_irq_intc,
  930. .init_machine = sh7372_add_standard_devices_dt,
  931. .dt_compat = sh7372_boards_compat_dt,
  932. MACHINE_END
  933. #endif /* CONFIG_USE_OF */