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