setup-sh7372.c 25 KB

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