setup-sh7372.c 24 KB

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