setup-sh7372.c 25 KB

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