setup-sh7372.c 24 KB

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