setup-sh7372.c 26 KB

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