setup-sh7724.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478
  1. /*
  2. * SH7724 Setup
  3. *
  4. * Copyright (C) 2009 Renesas Solutions Corp.
  5. *
  6. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  7. *
  8. * Based on SH7723 Setup
  9. * Copyright (C) 2008 Paul Mundt
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/platform_device.h>
  16. #include <linux/init.h>
  17. #include <linux/serial.h>
  18. #include <linux/mm.h>
  19. #include <linux/serial_sci.h>
  20. #include <linux/uio_driver.h>
  21. #include <linux/sh_dma.h>
  22. #include <linux/sh_timer.h>
  23. #include <linux/io.h>
  24. #include <linux/notifier.h>
  25. #include <asm/suspend.h>
  26. #include <asm/clock.h>
  27. #include <asm/mmzone.h>
  28. #include <cpu/dma-register.h>
  29. #include <cpu/sh7724.h>
  30. /* DMA */
  31. static const struct sh_dmae_slave_config sh7724_dmae_slaves[] = {
  32. {
  33. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  34. .addr = 0xffe0000c,
  35. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  36. .mid_rid = 0x21,
  37. }, {
  38. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  39. .addr = 0xffe00014,
  40. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  41. .mid_rid = 0x22,
  42. }, {
  43. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  44. .addr = 0xffe1000c,
  45. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  46. .mid_rid = 0x25,
  47. }, {
  48. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  49. .addr = 0xffe10014,
  50. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  51. .mid_rid = 0x26,
  52. }, {
  53. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  54. .addr = 0xffe2000c,
  55. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  56. .mid_rid = 0x29,
  57. }, {
  58. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  59. .addr = 0xffe20014,
  60. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  61. .mid_rid = 0x2a,
  62. }, {
  63. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  64. .addr = 0xa4e30020,
  65. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  66. .mid_rid = 0x2d,
  67. }, {
  68. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  69. .addr = 0xa4e30024,
  70. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  71. .mid_rid = 0x2e,
  72. }, {
  73. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  74. .addr = 0xa4e40020,
  75. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  76. .mid_rid = 0x31,
  77. }, {
  78. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  79. .addr = 0xa4e40024,
  80. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  81. .mid_rid = 0x32,
  82. }, {
  83. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  84. .addr = 0xa4e50020,
  85. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  86. .mid_rid = 0x35,
  87. }, {
  88. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  89. .addr = 0xa4e50024,
  90. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  91. .mid_rid = 0x36,
  92. }, {
  93. .slave_id = SHDMA_SLAVE_USB0D0_TX,
  94. .addr = 0xA4D80100,
  95. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  96. .mid_rid = 0x73,
  97. }, {
  98. .slave_id = SHDMA_SLAVE_USB0D0_RX,
  99. .addr = 0xA4D80100,
  100. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  101. .mid_rid = 0x73,
  102. }, {
  103. .slave_id = SHDMA_SLAVE_USB0D1_TX,
  104. .addr = 0xA4D80120,
  105. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  106. .mid_rid = 0x77,
  107. }, {
  108. .slave_id = SHDMA_SLAVE_USB0D1_RX,
  109. .addr = 0xA4D80120,
  110. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  111. .mid_rid = 0x77,
  112. }, {
  113. .slave_id = SHDMA_SLAVE_USB1D0_TX,
  114. .addr = 0xA4D90100,
  115. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  116. .mid_rid = 0xab,
  117. }, {
  118. .slave_id = SHDMA_SLAVE_USB1D0_RX,
  119. .addr = 0xA4D90100,
  120. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  121. .mid_rid = 0xab,
  122. }, {
  123. .slave_id = SHDMA_SLAVE_USB1D1_TX,
  124. .addr = 0xA4D90120,
  125. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  126. .mid_rid = 0xaf,
  127. }, {
  128. .slave_id = SHDMA_SLAVE_USB1D1_RX,
  129. .addr = 0xA4D90120,
  130. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  131. .mid_rid = 0xaf,
  132. }, {
  133. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  134. .addr = 0x04ce0030,
  135. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  136. .mid_rid = 0xc1,
  137. }, {
  138. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  139. .addr = 0x04ce0030,
  140. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  141. .mid_rid = 0xc2,
  142. }, {
  143. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  144. .addr = 0x04cf0030,
  145. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  146. .mid_rid = 0xc9,
  147. }, {
  148. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  149. .addr = 0x04cf0030,
  150. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  151. .mid_rid = 0xca,
  152. },
  153. };
  154. static const struct sh_dmae_channel sh7724_dmae_channels[] = {
  155. {
  156. .offset = 0,
  157. .dmars = 0,
  158. .dmars_bit = 0,
  159. }, {
  160. .offset = 0x10,
  161. .dmars = 0,
  162. .dmars_bit = 8,
  163. }, {
  164. .offset = 0x20,
  165. .dmars = 4,
  166. .dmars_bit = 0,
  167. }, {
  168. .offset = 0x30,
  169. .dmars = 4,
  170. .dmars_bit = 8,
  171. }, {
  172. .offset = 0x50,
  173. .dmars = 8,
  174. .dmars_bit = 0,
  175. }, {
  176. .offset = 0x60,
  177. .dmars = 8,
  178. .dmars_bit = 8,
  179. }
  180. };
  181. static const unsigned int ts_shift[] = TS_SHIFT;
  182. static struct sh_dmae_pdata dma_platform_data = {
  183. .slave = sh7724_dmae_slaves,
  184. .slave_num = ARRAY_SIZE(sh7724_dmae_slaves),
  185. .channel = sh7724_dmae_channels,
  186. .channel_num = ARRAY_SIZE(sh7724_dmae_channels),
  187. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  188. .ts_low_mask = CHCR_TS_LOW_MASK,
  189. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  190. .ts_high_mask = CHCR_TS_HIGH_MASK,
  191. .ts_shift = ts_shift,
  192. .ts_shift_num = ARRAY_SIZE(ts_shift),
  193. .dmaor_init = DMAOR_INIT,
  194. };
  195. /* Resource order important! */
  196. static struct resource sh7724_dmae0_resources[] = {
  197. {
  198. /* Channel registers and DMAOR */
  199. .start = 0xfe008020,
  200. .end = 0xfe00808f,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. {
  204. /* DMARSx */
  205. .start = 0xfe009000,
  206. .end = 0xfe00900b,
  207. .flags = IORESOURCE_MEM,
  208. },
  209. {
  210. /* DMA error IRQ */
  211. .start = 78,
  212. .end = 78,
  213. .flags = IORESOURCE_IRQ,
  214. },
  215. {
  216. /* IRQ for channels 0-3 */
  217. .start = 48,
  218. .end = 51,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. {
  222. /* IRQ for channels 4-5 */
  223. .start = 76,
  224. .end = 77,
  225. .flags = IORESOURCE_IRQ,
  226. },
  227. };
  228. /* Resource order important! */
  229. static struct resource sh7724_dmae1_resources[] = {
  230. {
  231. /* Channel registers and DMAOR */
  232. .start = 0xfdc08020,
  233. .end = 0xfdc0808f,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. {
  237. /* DMARSx */
  238. .start = 0xfdc09000,
  239. .end = 0xfdc0900b,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. {
  243. /* DMA error IRQ */
  244. .start = 74,
  245. .end = 74,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. {
  249. /* IRQ for channels 0-3 */
  250. .start = 40,
  251. .end = 43,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. {
  255. /* IRQ for channels 4-5 */
  256. .start = 72,
  257. .end = 73,
  258. .flags = IORESOURCE_IRQ,
  259. },
  260. };
  261. static struct platform_device dma0_device = {
  262. .name = "sh-dma-engine",
  263. .id = 0,
  264. .resource = sh7724_dmae0_resources,
  265. .num_resources = ARRAY_SIZE(sh7724_dmae0_resources),
  266. .dev = {
  267. .platform_data = &dma_platform_data,
  268. },
  269. .archdata = {
  270. .hwblk_id = HWBLK_DMAC0,
  271. },
  272. };
  273. static struct platform_device dma1_device = {
  274. .name = "sh-dma-engine",
  275. .id = 1,
  276. .resource = sh7724_dmae1_resources,
  277. .num_resources = ARRAY_SIZE(sh7724_dmae1_resources),
  278. .dev = {
  279. .platform_data = &dma_platform_data,
  280. },
  281. .archdata = {
  282. .hwblk_id = HWBLK_DMAC1,
  283. },
  284. };
  285. /* Serial */
  286. static struct plat_sci_port scif0_platform_data = {
  287. .mapbase = 0xffe00000,
  288. .port_reg = SCIx_NOT_SUPPORTED,
  289. .flags = UPF_BOOT_AUTOCONF,
  290. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  291. .scbrr_algo_id = SCBRR_ALGO_2,
  292. .type = PORT_SCIF,
  293. .irqs = { 80, 80, 80, 80 },
  294. .regtype = SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
  295. };
  296. static struct platform_device scif0_device = {
  297. .name = "sh-sci",
  298. .id = 0,
  299. .dev = {
  300. .platform_data = &scif0_platform_data,
  301. },
  302. };
  303. static struct plat_sci_port scif1_platform_data = {
  304. .mapbase = 0xffe10000,
  305. .port_reg = SCIx_NOT_SUPPORTED,
  306. .flags = UPF_BOOT_AUTOCONF,
  307. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  308. .scbrr_algo_id = SCBRR_ALGO_2,
  309. .type = PORT_SCIF,
  310. .irqs = { 81, 81, 81, 81 },
  311. .regtype = SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
  312. };
  313. static struct platform_device scif1_device = {
  314. .name = "sh-sci",
  315. .id = 1,
  316. .dev = {
  317. .platform_data = &scif1_platform_data,
  318. },
  319. };
  320. static struct plat_sci_port scif2_platform_data = {
  321. .mapbase = 0xffe20000,
  322. .port_reg = SCIx_NOT_SUPPORTED,
  323. .flags = UPF_BOOT_AUTOCONF,
  324. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  325. .scbrr_algo_id = SCBRR_ALGO_2,
  326. .type = PORT_SCIF,
  327. .irqs = { 82, 82, 82, 82 },
  328. .regtype = SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
  329. };
  330. static struct platform_device scif2_device = {
  331. .name = "sh-sci",
  332. .id = 2,
  333. .dev = {
  334. .platform_data = &scif2_platform_data,
  335. },
  336. };
  337. static struct plat_sci_port scif3_platform_data = {
  338. .mapbase = 0xa4e30000,
  339. .port_reg = SCIx_NOT_SUPPORTED,
  340. .flags = UPF_BOOT_AUTOCONF,
  341. .scscr = SCSCR_RE | SCSCR_TE,
  342. .scbrr_algo_id = SCBRR_ALGO_3,
  343. .type = PORT_SCIFA,
  344. .irqs = { 56, 56, 56, 56 },
  345. };
  346. static struct platform_device scif3_device = {
  347. .name = "sh-sci",
  348. .id = 3,
  349. .dev = {
  350. .platform_data = &scif3_platform_data,
  351. },
  352. };
  353. static struct plat_sci_port scif4_platform_data = {
  354. .mapbase = 0xa4e40000,
  355. .port_reg = SCIx_NOT_SUPPORTED,
  356. .flags = UPF_BOOT_AUTOCONF,
  357. .scscr = SCSCR_RE | SCSCR_TE,
  358. .scbrr_algo_id = SCBRR_ALGO_3,
  359. .type = PORT_SCIFA,
  360. .irqs = { 88, 88, 88, 88 },
  361. };
  362. static struct platform_device scif4_device = {
  363. .name = "sh-sci",
  364. .id = 4,
  365. .dev = {
  366. .platform_data = &scif4_platform_data,
  367. },
  368. };
  369. static struct plat_sci_port scif5_platform_data = {
  370. .mapbase = 0xa4e50000,
  371. .port_reg = SCIx_NOT_SUPPORTED,
  372. .flags = UPF_BOOT_AUTOCONF,
  373. .scscr = SCSCR_RE | SCSCR_TE,
  374. .scbrr_algo_id = SCBRR_ALGO_3,
  375. .type = PORT_SCIFA,
  376. .irqs = { 109, 109, 109, 109 },
  377. };
  378. static struct platform_device scif5_device = {
  379. .name = "sh-sci",
  380. .id = 5,
  381. .dev = {
  382. .platform_data = &scif5_platform_data,
  383. },
  384. };
  385. /* RTC */
  386. static struct resource rtc_resources[] = {
  387. [0] = {
  388. .start = 0xa465fec0,
  389. .end = 0xa465fec0 + 0x58 - 1,
  390. .flags = IORESOURCE_IO,
  391. },
  392. [1] = {
  393. /* Period IRQ */
  394. .start = 69,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. [2] = {
  398. /* Carry IRQ */
  399. .start = 70,
  400. .flags = IORESOURCE_IRQ,
  401. },
  402. [3] = {
  403. /* Alarm IRQ */
  404. .start = 68,
  405. .flags = IORESOURCE_IRQ,
  406. },
  407. };
  408. static struct platform_device rtc_device = {
  409. .name = "sh-rtc",
  410. .id = -1,
  411. .num_resources = ARRAY_SIZE(rtc_resources),
  412. .resource = rtc_resources,
  413. .archdata = {
  414. .hwblk_id = HWBLK_RTC,
  415. },
  416. };
  417. /* I2C0 */
  418. static struct resource iic0_resources[] = {
  419. [0] = {
  420. .name = "IIC0",
  421. .start = 0x04470000,
  422. .end = 0x04470018 - 1,
  423. .flags = IORESOURCE_MEM,
  424. },
  425. [1] = {
  426. .start = 96,
  427. .end = 99,
  428. .flags = IORESOURCE_IRQ,
  429. },
  430. };
  431. static struct platform_device iic0_device = {
  432. .name = "i2c-sh_mobile",
  433. .id = 0, /* "i2c0" clock */
  434. .num_resources = ARRAY_SIZE(iic0_resources),
  435. .resource = iic0_resources,
  436. .archdata = {
  437. .hwblk_id = HWBLK_IIC0,
  438. },
  439. };
  440. /* I2C1 */
  441. static struct resource iic1_resources[] = {
  442. [0] = {
  443. .name = "IIC1",
  444. .start = 0x04750000,
  445. .end = 0x04750018 - 1,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. [1] = {
  449. .start = 92,
  450. .end = 95,
  451. .flags = IORESOURCE_IRQ,
  452. },
  453. };
  454. static struct platform_device iic1_device = {
  455. .name = "i2c-sh_mobile",
  456. .id = 1, /* "i2c1" clock */
  457. .num_resources = ARRAY_SIZE(iic1_resources),
  458. .resource = iic1_resources,
  459. .archdata = {
  460. .hwblk_id = HWBLK_IIC1,
  461. },
  462. };
  463. /* VPU */
  464. static struct uio_info vpu_platform_data = {
  465. .name = "VPU5F",
  466. .version = "0",
  467. .irq = 60,
  468. };
  469. static struct resource vpu_resources[] = {
  470. [0] = {
  471. .name = "VPU",
  472. .start = 0xfe900000,
  473. .end = 0xfe902807,
  474. .flags = IORESOURCE_MEM,
  475. },
  476. [1] = {
  477. /* place holder for contiguous memory */
  478. },
  479. };
  480. static struct platform_device vpu_device = {
  481. .name = "uio_pdrv_genirq",
  482. .id = 0,
  483. .dev = {
  484. .platform_data = &vpu_platform_data,
  485. },
  486. .resource = vpu_resources,
  487. .num_resources = ARRAY_SIZE(vpu_resources),
  488. .archdata = {
  489. .hwblk_id = HWBLK_VPU,
  490. },
  491. };
  492. /* VEU0 */
  493. static struct uio_info veu0_platform_data = {
  494. .name = "VEU3F0",
  495. .version = "0",
  496. .irq = 83,
  497. };
  498. static struct resource veu0_resources[] = {
  499. [0] = {
  500. .name = "VEU3F0",
  501. .start = 0xfe920000,
  502. .end = 0xfe9200cb,
  503. .flags = IORESOURCE_MEM,
  504. },
  505. [1] = {
  506. /* place holder for contiguous memory */
  507. },
  508. };
  509. static struct platform_device veu0_device = {
  510. .name = "uio_pdrv_genirq",
  511. .id = 1,
  512. .dev = {
  513. .platform_data = &veu0_platform_data,
  514. },
  515. .resource = veu0_resources,
  516. .num_resources = ARRAY_SIZE(veu0_resources),
  517. .archdata = {
  518. .hwblk_id = HWBLK_VEU0,
  519. },
  520. };
  521. /* VEU1 */
  522. static struct uio_info veu1_platform_data = {
  523. .name = "VEU3F1",
  524. .version = "0",
  525. .irq = 54,
  526. };
  527. static struct resource veu1_resources[] = {
  528. [0] = {
  529. .name = "VEU3F1",
  530. .start = 0xfe924000,
  531. .end = 0xfe9240cb,
  532. .flags = IORESOURCE_MEM,
  533. },
  534. [1] = {
  535. /* place holder for contiguous memory */
  536. },
  537. };
  538. static struct platform_device veu1_device = {
  539. .name = "uio_pdrv_genirq",
  540. .id = 2,
  541. .dev = {
  542. .platform_data = &veu1_platform_data,
  543. },
  544. .resource = veu1_resources,
  545. .num_resources = ARRAY_SIZE(veu1_resources),
  546. .archdata = {
  547. .hwblk_id = HWBLK_VEU1,
  548. },
  549. };
  550. /* BEU0 */
  551. static struct uio_info beu0_platform_data = {
  552. .name = "BEU0",
  553. .version = "0",
  554. .irq = evt2irq(0x8A0),
  555. };
  556. static struct resource beu0_resources[] = {
  557. [0] = {
  558. .name = "BEU0",
  559. .start = 0xfe930000,
  560. .end = 0xfe933400,
  561. .flags = IORESOURCE_MEM,
  562. },
  563. [1] = {
  564. /* place holder for contiguous memory */
  565. },
  566. };
  567. static struct platform_device beu0_device = {
  568. .name = "uio_pdrv_genirq",
  569. .id = 6,
  570. .dev = {
  571. .platform_data = &beu0_platform_data,
  572. },
  573. .resource = beu0_resources,
  574. .num_resources = ARRAY_SIZE(beu0_resources),
  575. .archdata = {
  576. .hwblk_id = HWBLK_BEU0,
  577. },
  578. };
  579. /* BEU1 */
  580. static struct uio_info beu1_platform_data = {
  581. .name = "BEU1",
  582. .version = "0",
  583. .irq = evt2irq(0xA00),
  584. };
  585. static struct resource beu1_resources[] = {
  586. [0] = {
  587. .name = "BEU1",
  588. .start = 0xfe940000,
  589. .end = 0xfe943400,
  590. .flags = IORESOURCE_MEM,
  591. },
  592. [1] = {
  593. /* place holder for contiguous memory */
  594. },
  595. };
  596. static struct platform_device beu1_device = {
  597. .name = "uio_pdrv_genirq",
  598. .id = 7,
  599. .dev = {
  600. .platform_data = &beu1_platform_data,
  601. },
  602. .resource = beu1_resources,
  603. .num_resources = ARRAY_SIZE(beu1_resources),
  604. .archdata = {
  605. .hwblk_id = HWBLK_BEU1,
  606. },
  607. };
  608. static struct sh_timer_config cmt_platform_data = {
  609. .channel_offset = 0x60,
  610. .timer_bit = 5,
  611. .clockevent_rating = 125,
  612. .clocksource_rating = 200,
  613. };
  614. static struct resource cmt_resources[] = {
  615. [0] = {
  616. .start = 0x044a0060,
  617. .end = 0x044a006b,
  618. .flags = IORESOURCE_MEM,
  619. },
  620. [1] = {
  621. .start = 104,
  622. .flags = IORESOURCE_IRQ,
  623. },
  624. };
  625. static struct platform_device cmt_device = {
  626. .name = "sh_cmt",
  627. .id = 0,
  628. .dev = {
  629. .platform_data = &cmt_platform_data,
  630. },
  631. .resource = cmt_resources,
  632. .num_resources = ARRAY_SIZE(cmt_resources),
  633. .archdata = {
  634. .hwblk_id = HWBLK_CMT,
  635. },
  636. };
  637. static struct sh_timer_config tmu0_platform_data = {
  638. .channel_offset = 0x04,
  639. .timer_bit = 0,
  640. .clockevent_rating = 200,
  641. };
  642. static struct resource tmu0_resources[] = {
  643. [0] = {
  644. .start = 0xffd80008,
  645. .end = 0xffd80013,
  646. .flags = IORESOURCE_MEM,
  647. },
  648. [1] = {
  649. .start = 16,
  650. .flags = IORESOURCE_IRQ,
  651. },
  652. };
  653. static struct platform_device tmu0_device = {
  654. .name = "sh_tmu",
  655. .id = 0,
  656. .dev = {
  657. .platform_data = &tmu0_platform_data,
  658. },
  659. .resource = tmu0_resources,
  660. .num_resources = ARRAY_SIZE(tmu0_resources),
  661. .archdata = {
  662. .hwblk_id = HWBLK_TMU0,
  663. },
  664. };
  665. static struct sh_timer_config tmu1_platform_data = {
  666. .channel_offset = 0x10,
  667. .timer_bit = 1,
  668. .clocksource_rating = 200,
  669. };
  670. static struct resource tmu1_resources[] = {
  671. [0] = {
  672. .start = 0xffd80014,
  673. .end = 0xffd8001f,
  674. .flags = IORESOURCE_MEM,
  675. },
  676. [1] = {
  677. .start = 17,
  678. .flags = IORESOURCE_IRQ,
  679. },
  680. };
  681. static struct platform_device tmu1_device = {
  682. .name = "sh_tmu",
  683. .id = 1,
  684. .dev = {
  685. .platform_data = &tmu1_platform_data,
  686. },
  687. .resource = tmu1_resources,
  688. .num_resources = ARRAY_SIZE(tmu1_resources),
  689. .archdata = {
  690. .hwblk_id = HWBLK_TMU0,
  691. },
  692. };
  693. static struct sh_timer_config tmu2_platform_data = {
  694. .channel_offset = 0x1c,
  695. .timer_bit = 2,
  696. };
  697. static struct resource tmu2_resources[] = {
  698. [0] = {
  699. .start = 0xffd80020,
  700. .end = 0xffd8002b,
  701. .flags = IORESOURCE_MEM,
  702. },
  703. [1] = {
  704. .start = 18,
  705. .flags = IORESOURCE_IRQ,
  706. },
  707. };
  708. static struct platform_device tmu2_device = {
  709. .name = "sh_tmu",
  710. .id = 2,
  711. .dev = {
  712. .platform_data = &tmu2_platform_data,
  713. },
  714. .resource = tmu2_resources,
  715. .num_resources = ARRAY_SIZE(tmu2_resources),
  716. .archdata = {
  717. .hwblk_id = HWBLK_TMU0,
  718. },
  719. };
  720. static struct sh_timer_config tmu3_platform_data = {
  721. .channel_offset = 0x04,
  722. .timer_bit = 0,
  723. };
  724. static struct resource tmu3_resources[] = {
  725. [0] = {
  726. .start = 0xffd90008,
  727. .end = 0xffd90013,
  728. .flags = IORESOURCE_MEM,
  729. },
  730. [1] = {
  731. .start = 57,
  732. .flags = IORESOURCE_IRQ,
  733. },
  734. };
  735. static struct platform_device tmu3_device = {
  736. .name = "sh_tmu",
  737. .id = 3,
  738. .dev = {
  739. .platform_data = &tmu3_platform_data,
  740. },
  741. .resource = tmu3_resources,
  742. .num_resources = ARRAY_SIZE(tmu3_resources),
  743. .archdata = {
  744. .hwblk_id = HWBLK_TMU1,
  745. },
  746. };
  747. static struct sh_timer_config tmu4_platform_data = {
  748. .channel_offset = 0x10,
  749. .timer_bit = 1,
  750. };
  751. static struct resource tmu4_resources[] = {
  752. [0] = {
  753. .start = 0xffd90014,
  754. .end = 0xffd9001f,
  755. .flags = IORESOURCE_MEM,
  756. },
  757. [1] = {
  758. .start = 58,
  759. .flags = IORESOURCE_IRQ,
  760. },
  761. };
  762. static struct platform_device tmu4_device = {
  763. .name = "sh_tmu",
  764. .id = 4,
  765. .dev = {
  766. .platform_data = &tmu4_platform_data,
  767. },
  768. .resource = tmu4_resources,
  769. .num_resources = ARRAY_SIZE(tmu4_resources),
  770. .archdata = {
  771. .hwblk_id = HWBLK_TMU1,
  772. },
  773. };
  774. static struct sh_timer_config tmu5_platform_data = {
  775. .channel_offset = 0x1c,
  776. .timer_bit = 2,
  777. };
  778. static struct resource tmu5_resources[] = {
  779. [0] = {
  780. .start = 0xffd90020,
  781. .end = 0xffd9002b,
  782. .flags = IORESOURCE_MEM,
  783. },
  784. [1] = {
  785. .start = 57,
  786. .flags = IORESOURCE_IRQ,
  787. },
  788. };
  789. static struct platform_device tmu5_device = {
  790. .name = "sh_tmu",
  791. .id = 5,
  792. .dev = {
  793. .platform_data = &tmu5_platform_data,
  794. },
  795. .resource = tmu5_resources,
  796. .num_resources = ARRAY_SIZE(tmu5_resources),
  797. .archdata = {
  798. .hwblk_id = HWBLK_TMU1,
  799. },
  800. };
  801. /* JPU */
  802. static struct uio_info jpu_platform_data = {
  803. .name = "JPU",
  804. .version = "0",
  805. .irq = 27,
  806. };
  807. static struct resource jpu_resources[] = {
  808. [0] = {
  809. .name = "JPU",
  810. .start = 0xfe980000,
  811. .end = 0xfe9902d3,
  812. .flags = IORESOURCE_MEM,
  813. },
  814. [1] = {
  815. /* place holder for contiguous memory */
  816. },
  817. };
  818. static struct platform_device jpu_device = {
  819. .name = "uio_pdrv_genirq",
  820. .id = 3,
  821. .dev = {
  822. .platform_data = &jpu_platform_data,
  823. },
  824. .resource = jpu_resources,
  825. .num_resources = ARRAY_SIZE(jpu_resources),
  826. .archdata = {
  827. .hwblk_id = HWBLK_JPU,
  828. },
  829. };
  830. /* SPU2DSP0 */
  831. static struct uio_info spu0_platform_data = {
  832. .name = "SPU2DSP0",
  833. .version = "0",
  834. .irq = 86,
  835. };
  836. static struct resource spu0_resources[] = {
  837. [0] = {
  838. .name = "SPU2DSP0",
  839. .start = 0xFE200000,
  840. .end = 0xFE2FFFFF,
  841. .flags = IORESOURCE_MEM,
  842. },
  843. [1] = {
  844. /* place holder for contiguous memory */
  845. },
  846. };
  847. static struct platform_device spu0_device = {
  848. .name = "uio_pdrv_genirq",
  849. .id = 4,
  850. .dev = {
  851. .platform_data = &spu0_platform_data,
  852. },
  853. .resource = spu0_resources,
  854. .num_resources = ARRAY_SIZE(spu0_resources),
  855. .archdata = {
  856. .hwblk_id = HWBLK_SPU,
  857. },
  858. };
  859. /* SPU2DSP1 */
  860. static struct uio_info spu1_platform_data = {
  861. .name = "SPU2DSP1",
  862. .version = "0",
  863. .irq = 87,
  864. };
  865. static struct resource spu1_resources[] = {
  866. [0] = {
  867. .name = "SPU2DSP1",
  868. .start = 0xFE300000,
  869. .end = 0xFE3FFFFF,
  870. .flags = IORESOURCE_MEM,
  871. },
  872. [1] = {
  873. /* place holder for contiguous memory */
  874. },
  875. };
  876. static struct platform_device spu1_device = {
  877. .name = "uio_pdrv_genirq",
  878. .id = 5,
  879. .dev = {
  880. .platform_data = &spu1_platform_data,
  881. },
  882. .resource = spu1_resources,
  883. .num_resources = ARRAY_SIZE(spu1_resources),
  884. .archdata = {
  885. .hwblk_id = HWBLK_SPU,
  886. },
  887. };
  888. static struct platform_device *sh7724_devices[] __initdata = {
  889. &scif0_device,
  890. &scif1_device,
  891. &scif2_device,
  892. &scif3_device,
  893. &scif4_device,
  894. &scif5_device,
  895. &cmt_device,
  896. &tmu0_device,
  897. &tmu1_device,
  898. &tmu2_device,
  899. &tmu3_device,
  900. &tmu4_device,
  901. &tmu5_device,
  902. &dma0_device,
  903. &dma1_device,
  904. &rtc_device,
  905. &iic0_device,
  906. &iic1_device,
  907. &vpu_device,
  908. &veu0_device,
  909. &veu1_device,
  910. &beu0_device,
  911. &beu1_device,
  912. &jpu_device,
  913. &spu0_device,
  914. &spu1_device,
  915. };
  916. static int __init sh7724_devices_setup(void)
  917. {
  918. platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20);
  919. platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20);
  920. platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
  921. platform_resource_setup_memory(&jpu_device, "jpu", 2 << 20);
  922. platform_resource_setup_memory(&spu0_device, "spu0", 2 << 20);
  923. platform_resource_setup_memory(&spu1_device, "spu1", 2 << 20);
  924. return platform_add_devices(sh7724_devices,
  925. ARRAY_SIZE(sh7724_devices));
  926. }
  927. arch_initcall(sh7724_devices_setup);
  928. static struct platform_device *sh7724_early_devices[] __initdata = {
  929. &scif0_device,
  930. &scif1_device,
  931. &scif2_device,
  932. &scif3_device,
  933. &scif4_device,
  934. &scif5_device,
  935. &cmt_device,
  936. &tmu0_device,
  937. &tmu1_device,
  938. &tmu2_device,
  939. &tmu3_device,
  940. &tmu4_device,
  941. &tmu5_device,
  942. };
  943. void __init plat_early_device_setup(void)
  944. {
  945. early_platform_add_devices(sh7724_early_devices,
  946. ARRAY_SIZE(sh7724_early_devices));
  947. }
  948. #define RAMCR_CACHE_L2FC 0x0002
  949. #define RAMCR_CACHE_L2E 0x0001
  950. #define L2_CACHE_ENABLE (RAMCR_CACHE_L2E|RAMCR_CACHE_L2FC)
  951. void l2_cache_init(void)
  952. {
  953. /* Enable L2 cache */
  954. __raw_writel(L2_CACHE_ENABLE, RAMCR);
  955. }
  956. enum {
  957. UNUSED = 0,
  958. ENABLED,
  959. DISABLED,
  960. /* interrupt sources */
  961. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  962. HUDI,
  963. DMAC1A_DEI0, DMAC1A_DEI1, DMAC1A_DEI2, DMAC1A_DEI3,
  964. _2DG_TRI, _2DG_INI, _2DG_CEI,
  965. DMAC0A_DEI0, DMAC0A_DEI1, DMAC0A_DEI2, DMAC0A_DEI3,
  966. VIO_CEU0, VIO_BEU0, VIO_VEU1, VIO_VOU,
  967. SCIFA3,
  968. VPU,
  969. TPU,
  970. CEU1,
  971. BEU1,
  972. USB0, USB1,
  973. ATAPI,
  974. RTC_ATI, RTC_PRI, RTC_CUI,
  975. DMAC1B_DEI4, DMAC1B_DEI5, DMAC1B_DADERR,
  976. DMAC0B_DEI4, DMAC0B_DEI5, DMAC0B_DADERR,
  977. KEYSC,
  978. SCIF_SCIF0, SCIF_SCIF1, SCIF_SCIF2,
  979. VEU0,
  980. MSIOF_MSIOFI0, MSIOF_MSIOFI1,
  981. SPU_SPUI0, SPU_SPUI1,
  982. SCIFA4,
  983. ICB,
  984. ETHI,
  985. I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI,
  986. I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI,
  987. CMT,
  988. TSIF,
  989. FSI,
  990. SCIFA5,
  991. TMU0_TUNI0, TMU0_TUNI1, TMU0_TUNI2,
  992. IRDA,
  993. JPU,
  994. _2DDMAC,
  995. MMC_MMC2I, MMC_MMC3I,
  996. LCDC,
  997. TMU1_TUNI0, TMU1_TUNI1, TMU1_TUNI2,
  998. /* interrupt groups */
  999. DMAC1A, _2DG, DMAC0A, VIO, USB, RTC,
  1000. DMAC1B, DMAC0B, I2C0, I2C1, SDHI0, SDHI1, SPU, MMCIF,
  1001. };
  1002. static struct intc_vect vectors[] __initdata = {
  1003. INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
  1004. INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
  1005. INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
  1006. INTC_VECT(IRQ6, 0x6c0), INTC_VECT(IRQ7, 0x6e0),
  1007. INTC_VECT(DMAC1A_DEI0, 0x700),
  1008. INTC_VECT(DMAC1A_DEI1, 0x720),
  1009. INTC_VECT(DMAC1A_DEI2, 0x740),
  1010. INTC_VECT(DMAC1A_DEI3, 0x760),
  1011. INTC_VECT(_2DG_TRI, 0x780),
  1012. INTC_VECT(_2DG_INI, 0x7A0),
  1013. INTC_VECT(_2DG_CEI, 0x7C0),
  1014. INTC_VECT(DMAC0A_DEI0, 0x800),
  1015. INTC_VECT(DMAC0A_DEI1, 0x820),
  1016. INTC_VECT(DMAC0A_DEI2, 0x840),
  1017. INTC_VECT(DMAC0A_DEI3, 0x860),
  1018. INTC_VECT(VIO_CEU0, 0x880),
  1019. INTC_VECT(VIO_BEU0, 0x8A0),
  1020. INTC_VECT(VIO_VEU1, 0x8C0),
  1021. INTC_VECT(VIO_VOU, 0x8E0),
  1022. INTC_VECT(SCIFA3, 0x900),
  1023. INTC_VECT(VPU, 0x980),
  1024. INTC_VECT(TPU, 0x9A0),
  1025. INTC_VECT(CEU1, 0x9E0),
  1026. INTC_VECT(BEU1, 0xA00),
  1027. INTC_VECT(USB0, 0xA20),
  1028. INTC_VECT(USB1, 0xA40),
  1029. INTC_VECT(ATAPI, 0xA60),
  1030. INTC_VECT(RTC_ATI, 0xA80),
  1031. INTC_VECT(RTC_PRI, 0xAA0),
  1032. INTC_VECT(RTC_CUI, 0xAC0),
  1033. INTC_VECT(DMAC1B_DEI4, 0xB00),
  1034. INTC_VECT(DMAC1B_DEI5, 0xB20),
  1035. INTC_VECT(DMAC1B_DADERR, 0xB40),
  1036. INTC_VECT(DMAC0B_DEI4, 0xB80),
  1037. INTC_VECT(DMAC0B_DEI5, 0xBA0),
  1038. INTC_VECT(DMAC0B_DADERR, 0xBC0),
  1039. INTC_VECT(KEYSC, 0xBE0),
  1040. INTC_VECT(SCIF_SCIF0, 0xC00),
  1041. INTC_VECT(SCIF_SCIF1, 0xC20),
  1042. INTC_VECT(SCIF_SCIF2, 0xC40),
  1043. INTC_VECT(VEU0, 0xC60),
  1044. INTC_VECT(MSIOF_MSIOFI0, 0xC80),
  1045. INTC_VECT(MSIOF_MSIOFI1, 0xCA0),
  1046. INTC_VECT(SPU_SPUI0, 0xCC0),
  1047. INTC_VECT(SPU_SPUI1, 0xCE0),
  1048. INTC_VECT(SCIFA4, 0xD00),
  1049. INTC_VECT(ICB, 0xD20),
  1050. INTC_VECT(ETHI, 0xD60),
  1051. INTC_VECT(I2C1_ALI, 0xD80),
  1052. INTC_VECT(I2C1_TACKI, 0xDA0),
  1053. INTC_VECT(I2C1_WAITI, 0xDC0),
  1054. INTC_VECT(I2C1_DTEI, 0xDE0),
  1055. INTC_VECT(I2C0_ALI, 0xE00),
  1056. INTC_VECT(I2C0_TACKI, 0xE20),
  1057. INTC_VECT(I2C0_WAITI, 0xE40),
  1058. INTC_VECT(I2C0_DTEI, 0xE60),
  1059. INTC_VECT(SDHI0, 0xE80),
  1060. INTC_VECT(SDHI0, 0xEA0),
  1061. INTC_VECT(SDHI0, 0xEC0),
  1062. INTC_VECT(SDHI0, 0xEE0),
  1063. INTC_VECT(CMT, 0xF00),
  1064. INTC_VECT(TSIF, 0xF20),
  1065. INTC_VECT(FSI, 0xF80),
  1066. INTC_VECT(SCIFA5, 0xFA0),
  1067. INTC_VECT(TMU0_TUNI0, 0x400),
  1068. INTC_VECT(TMU0_TUNI1, 0x420),
  1069. INTC_VECT(TMU0_TUNI2, 0x440),
  1070. INTC_VECT(IRDA, 0x480),
  1071. INTC_VECT(SDHI1, 0x4E0),
  1072. INTC_VECT(SDHI1, 0x500),
  1073. INTC_VECT(SDHI1, 0x520),
  1074. INTC_VECT(JPU, 0x560),
  1075. INTC_VECT(_2DDMAC, 0x4A0),
  1076. INTC_VECT(MMC_MMC2I, 0x5A0),
  1077. INTC_VECT(MMC_MMC3I, 0x5C0),
  1078. INTC_VECT(LCDC, 0xF40),
  1079. INTC_VECT(TMU1_TUNI0, 0x920),
  1080. INTC_VECT(TMU1_TUNI1, 0x940),
  1081. INTC_VECT(TMU1_TUNI2, 0x960),
  1082. };
  1083. static struct intc_group groups[] __initdata = {
  1084. INTC_GROUP(DMAC1A, DMAC1A_DEI0, DMAC1A_DEI1, DMAC1A_DEI2, DMAC1A_DEI3),
  1085. INTC_GROUP(_2DG, _2DG_TRI, _2DG_INI, _2DG_CEI),
  1086. INTC_GROUP(DMAC0A, DMAC0A_DEI0, DMAC0A_DEI1, DMAC0A_DEI2, DMAC0A_DEI3),
  1087. INTC_GROUP(VIO, VIO_CEU0, VIO_BEU0, VIO_VEU1, VIO_VOU),
  1088. INTC_GROUP(USB, USB0, USB1),
  1089. INTC_GROUP(RTC, RTC_ATI, RTC_PRI, RTC_CUI),
  1090. INTC_GROUP(DMAC1B, DMAC1B_DEI4, DMAC1B_DEI5, DMAC1B_DADERR),
  1091. INTC_GROUP(DMAC0B, DMAC0B_DEI4, DMAC0B_DEI5, DMAC0B_DADERR),
  1092. INTC_GROUP(I2C0, I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI),
  1093. INTC_GROUP(I2C1, I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI),
  1094. INTC_GROUP(SPU, SPU_SPUI0, SPU_SPUI1),
  1095. INTC_GROUP(MMCIF, MMC_MMC2I, MMC_MMC3I),
  1096. };
  1097. static struct intc_mask_reg mask_registers[] __initdata = {
  1098. { 0xa4080080, 0xa40800c0, 8, /* IMR0 / IMCR0 */
  1099. { 0, TMU1_TUNI2, TMU1_TUNI1, TMU1_TUNI0,
  1100. 0, ENABLED, ENABLED, ENABLED } },
  1101. { 0xa4080084, 0xa40800c4, 8, /* IMR1 / IMCR1 */
  1102. { VIO_VOU, VIO_VEU1, VIO_BEU0, VIO_CEU0,
  1103. DMAC0A_DEI3, DMAC0A_DEI2, DMAC0A_DEI1, DMAC0A_DEI0 } },
  1104. { 0xa4080088, 0xa40800c8, 8, /* IMR2 / IMCR2 */
  1105. { 0, 0, 0, VPU, ATAPI, ETHI, 0, SCIFA3 } },
  1106. { 0xa408008c, 0xa40800cc, 8, /* IMR3 / IMCR3 */
  1107. { DMAC1A_DEI3, DMAC1A_DEI2, DMAC1A_DEI1, DMAC1A_DEI0,
  1108. SPU_SPUI1, SPU_SPUI0, BEU1, IRDA } },
  1109. { 0xa4080090, 0xa40800d0, 8, /* IMR4 / IMCR4 */
  1110. { 0, TMU0_TUNI2, TMU0_TUNI1, TMU0_TUNI0,
  1111. JPU, 0, 0, LCDC } },
  1112. { 0xa4080094, 0xa40800d4, 8, /* IMR5 / IMCR5 */
  1113. { KEYSC, DMAC0B_DADERR, DMAC0B_DEI5, DMAC0B_DEI4,
  1114. VEU0, SCIF_SCIF2, SCIF_SCIF1, SCIF_SCIF0 } },
  1115. { 0xa4080098, 0xa40800d8, 8, /* IMR6 / IMCR6 */
  1116. { 0, 0, ICB, SCIFA4,
  1117. CEU1, 0, MSIOF_MSIOFI1, MSIOF_MSIOFI0 } },
  1118. { 0xa408009c, 0xa40800dc, 8, /* IMR7 / IMCR7 */
  1119. { I2C0_DTEI, I2C0_WAITI, I2C0_TACKI, I2C0_ALI,
  1120. I2C1_DTEI, I2C1_WAITI, I2C1_TACKI, I2C1_ALI } },
  1121. { 0xa40800a0, 0xa40800e0, 8, /* IMR8 / IMCR8 */
  1122. { DISABLED, ENABLED, ENABLED, ENABLED,
  1123. 0, 0, SCIFA5, FSI } },
  1124. { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */
  1125. { 0, 0, 0, CMT, 0, USB1, USB0, 0 } },
  1126. { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
  1127. { 0, DMAC1B_DADERR, DMAC1B_DEI5, DMAC1B_DEI4,
  1128. 0, RTC_CUI, RTC_PRI, RTC_ATI } },
  1129. { 0xa40800ac, 0xa40800ec, 8, /* IMR11 / IMCR11 */
  1130. { 0, _2DG_CEI, _2DG_INI, _2DG_TRI,
  1131. 0, TPU, 0, TSIF } },
  1132. { 0xa40800b0, 0xa40800f0, 8, /* IMR12 / IMCR12 */
  1133. { 0, 0, MMC_MMC3I, MMC_MMC2I, 0, 0, 0, _2DDMAC } },
  1134. { 0xa4140044, 0xa4140064, 8, /* INTMSK00 / INTMSKCLR00 */
  1135. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  1136. };
  1137. static struct intc_prio_reg prio_registers[] __initdata = {
  1138. { 0xa4080000, 0, 16, 4, /* IPRA */ { TMU0_TUNI0, TMU0_TUNI1,
  1139. TMU0_TUNI2, IRDA } },
  1140. { 0xa4080004, 0, 16, 4, /* IPRB */ { JPU, LCDC, DMAC1A, BEU1 } },
  1141. { 0xa4080008, 0, 16, 4, /* IPRC */ { TMU1_TUNI0, TMU1_TUNI1,
  1142. TMU1_TUNI2, SPU } },
  1143. { 0xa408000c, 0, 16, 4, /* IPRD */ { 0, MMCIF, 0, ATAPI } },
  1144. { 0xa4080010, 0, 16, 4, /* IPRE */ { DMAC0A, VIO, SCIFA3, VPU } },
  1145. { 0xa4080014, 0, 16, 4, /* IPRF */ { KEYSC, DMAC0B, USB, CMT } },
  1146. { 0xa4080018, 0, 16, 4, /* IPRG */ { SCIF_SCIF0, SCIF_SCIF1,
  1147. SCIF_SCIF2, VEU0 } },
  1148. { 0xa408001c, 0, 16, 4, /* IPRH */ { MSIOF_MSIOFI0, MSIOF_MSIOFI1,
  1149. I2C1, I2C0 } },
  1150. { 0xa4080020, 0, 16, 4, /* IPRI */ { SCIFA4, ICB, TSIF, _2DG } },
  1151. { 0xa4080024, 0, 16, 4, /* IPRJ */ { CEU1, ETHI, FSI, SDHI1 } },
  1152. { 0xa4080028, 0, 16, 4, /* IPRK */ { RTC, DMAC1B, 0, SDHI0 } },
  1153. { 0xa408002c, 0, 16, 4, /* IPRL */ { SCIFA5, 0, TPU, _2DDMAC } },
  1154. { 0xa4140010, 0, 32, 4, /* INTPRI00 */
  1155. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  1156. };
  1157. static struct intc_sense_reg sense_registers[] __initdata = {
  1158. { 0xa414001c, 16, 2, /* ICR1 */
  1159. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  1160. };
  1161. static struct intc_mask_reg ack_registers[] __initdata = {
  1162. { 0xa4140024, 0, 8, /* INTREQ00 */
  1163. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  1164. };
  1165. static struct intc_desc intc_desc __initdata = {
  1166. .name = "sh7724",
  1167. .force_enable = ENABLED,
  1168. .force_disable = DISABLED,
  1169. .hw = INTC_HW_DESC(vectors, groups, mask_registers,
  1170. prio_registers, sense_registers, ack_registers),
  1171. };
  1172. void __init plat_irq_setup(void)
  1173. {
  1174. register_intc_controller(&intc_desc);
  1175. }
  1176. static struct {
  1177. /* BSC */
  1178. unsigned long mmselr;
  1179. unsigned long cs0bcr;
  1180. unsigned long cs4bcr;
  1181. unsigned long cs5abcr;
  1182. unsigned long cs5bbcr;
  1183. unsigned long cs6abcr;
  1184. unsigned long cs6bbcr;
  1185. unsigned long cs4wcr;
  1186. unsigned long cs5awcr;
  1187. unsigned long cs5bwcr;
  1188. unsigned long cs6awcr;
  1189. unsigned long cs6bwcr;
  1190. /* INTC */
  1191. unsigned short ipra;
  1192. unsigned short iprb;
  1193. unsigned short iprc;
  1194. unsigned short iprd;
  1195. unsigned short ipre;
  1196. unsigned short iprf;
  1197. unsigned short iprg;
  1198. unsigned short iprh;
  1199. unsigned short ipri;
  1200. unsigned short iprj;
  1201. unsigned short iprk;
  1202. unsigned short iprl;
  1203. unsigned char imr0;
  1204. unsigned char imr1;
  1205. unsigned char imr2;
  1206. unsigned char imr3;
  1207. unsigned char imr4;
  1208. unsigned char imr5;
  1209. unsigned char imr6;
  1210. unsigned char imr7;
  1211. unsigned char imr8;
  1212. unsigned char imr9;
  1213. unsigned char imr10;
  1214. unsigned char imr11;
  1215. unsigned char imr12;
  1216. /* RWDT */
  1217. unsigned short rwtcnt;
  1218. unsigned short rwtcsr;
  1219. /* CPG */
  1220. unsigned long irdaclk;
  1221. unsigned long spuclk;
  1222. } sh7724_rstandby_state;
  1223. static int sh7724_pre_sleep_notifier_call(struct notifier_block *nb,
  1224. unsigned long flags, void *unused)
  1225. {
  1226. if (!(flags & SUSP_SH_RSTANDBY))
  1227. return NOTIFY_DONE;
  1228. /* BCR */
  1229. sh7724_rstandby_state.mmselr = __raw_readl(0xff800020); /* MMSELR */
  1230. sh7724_rstandby_state.mmselr |= 0xa5a50000;
  1231. sh7724_rstandby_state.cs0bcr = __raw_readl(0xfec10004); /* CS0BCR */
  1232. sh7724_rstandby_state.cs4bcr = __raw_readl(0xfec10010); /* CS4BCR */
  1233. sh7724_rstandby_state.cs5abcr = __raw_readl(0xfec10014); /* CS5ABCR */
  1234. sh7724_rstandby_state.cs5bbcr = __raw_readl(0xfec10018); /* CS5BBCR */
  1235. sh7724_rstandby_state.cs6abcr = __raw_readl(0xfec1001c); /* CS6ABCR */
  1236. sh7724_rstandby_state.cs6bbcr = __raw_readl(0xfec10020); /* CS6BBCR */
  1237. sh7724_rstandby_state.cs4wcr = __raw_readl(0xfec10030); /* CS4WCR */
  1238. sh7724_rstandby_state.cs5awcr = __raw_readl(0xfec10034); /* CS5AWCR */
  1239. sh7724_rstandby_state.cs5bwcr = __raw_readl(0xfec10038); /* CS5BWCR */
  1240. sh7724_rstandby_state.cs6awcr = __raw_readl(0xfec1003c); /* CS6AWCR */
  1241. sh7724_rstandby_state.cs6bwcr = __raw_readl(0xfec10040); /* CS6BWCR */
  1242. /* INTC */
  1243. sh7724_rstandby_state.ipra = __raw_readw(0xa4080000); /* IPRA */
  1244. sh7724_rstandby_state.iprb = __raw_readw(0xa4080004); /* IPRB */
  1245. sh7724_rstandby_state.iprc = __raw_readw(0xa4080008); /* IPRC */
  1246. sh7724_rstandby_state.iprd = __raw_readw(0xa408000c); /* IPRD */
  1247. sh7724_rstandby_state.ipre = __raw_readw(0xa4080010); /* IPRE */
  1248. sh7724_rstandby_state.iprf = __raw_readw(0xa4080014); /* IPRF */
  1249. sh7724_rstandby_state.iprg = __raw_readw(0xa4080018); /* IPRG */
  1250. sh7724_rstandby_state.iprh = __raw_readw(0xa408001c); /* IPRH */
  1251. sh7724_rstandby_state.ipri = __raw_readw(0xa4080020); /* IPRI */
  1252. sh7724_rstandby_state.iprj = __raw_readw(0xa4080024); /* IPRJ */
  1253. sh7724_rstandby_state.iprk = __raw_readw(0xa4080028); /* IPRK */
  1254. sh7724_rstandby_state.iprl = __raw_readw(0xa408002c); /* IPRL */
  1255. sh7724_rstandby_state.imr0 = __raw_readb(0xa4080080); /* IMR0 */
  1256. sh7724_rstandby_state.imr1 = __raw_readb(0xa4080084); /* IMR1 */
  1257. sh7724_rstandby_state.imr2 = __raw_readb(0xa4080088); /* IMR2 */
  1258. sh7724_rstandby_state.imr3 = __raw_readb(0xa408008c); /* IMR3 */
  1259. sh7724_rstandby_state.imr4 = __raw_readb(0xa4080090); /* IMR4 */
  1260. sh7724_rstandby_state.imr5 = __raw_readb(0xa4080094); /* IMR5 */
  1261. sh7724_rstandby_state.imr6 = __raw_readb(0xa4080098); /* IMR6 */
  1262. sh7724_rstandby_state.imr7 = __raw_readb(0xa408009c); /* IMR7 */
  1263. sh7724_rstandby_state.imr8 = __raw_readb(0xa40800a0); /* IMR8 */
  1264. sh7724_rstandby_state.imr9 = __raw_readb(0xa40800a4); /* IMR9 */
  1265. sh7724_rstandby_state.imr10 = __raw_readb(0xa40800a8); /* IMR10 */
  1266. sh7724_rstandby_state.imr11 = __raw_readb(0xa40800ac); /* IMR11 */
  1267. sh7724_rstandby_state.imr12 = __raw_readb(0xa40800b0); /* IMR12 */
  1268. /* RWDT */
  1269. sh7724_rstandby_state.rwtcnt = __raw_readb(0xa4520000); /* RWTCNT */
  1270. sh7724_rstandby_state.rwtcnt |= 0x5a00;
  1271. sh7724_rstandby_state.rwtcsr = __raw_readb(0xa4520004); /* RWTCSR */
  1272. sh7724_rstandby_state.rwtcsr |= 0xa500;
  1273. __raw_writew(sh7724_rstandby_state.rwtcsr & 0x07, 0xa4520004);
  1274. /* CPG */
  1275. sh7724_rstandby_state.irdaclk = __raw_readl(0xa4150018); /* IRDACLKCR */
  1276. sh7724_rstandby_state.spuclk = __raw_readl(0xa415003c); /* SPUCLKCR */
  1277. return NOTIFY_DONE;
  1278. }
  1279. static int sh7724_post_sleep_notifier_call(struct notifier_block *nb,
  1280. unsigned long flags, void *unused)
  1281. {
  1282. if (!(flags & SUSP_SH_RSTANDBY))
  1283. return NOTIFY_DONE;
  1284. /* BCR */
  1285. __raw_writel(sh7724_rstandby_state.mmselr, 0xff800020); /* MMSELR */
  1286. __raw_writel(sh7724_rstandby_state.cs0bcr, 0xfec10004); /* CS0BCR */
  1287. __raw_writel(sh7724_rstandby_state.cs4bcr, 0xfec10010); /* CS4BCR */
  1288. __raw_writel(sh7724_rstandby_state.cs5abcr, 0xfec10014); /* CS5ABCR */
  1289. __raw_writel(sh7724_rstandby_state.cs5bbcr, 0xfec10018); /* CS5BBCR */
  1290. __raw_writel(sh7724_rstandby_state.cs6abcr, 0xfec1001c); /* CS6ABCR */
  1291. __raw_writel(sh7724_rstandby_state.cs6bbcr, 0xfec10020); /* CS6BBCR */
  1292. __raw_writel(sh7724_rstandby_state.cs4wcr, 0xfec10030); /* CS4WCR */
  1293. __raw_writel(sh7724_rstandby_state.cs5awcr, 0xfec10034); /* CS5AWCR */
  1294. __raw_writel(sh7724_rstandby_state.cs5bwcr, 0xfec10038); /* CS5BWCR */
  1295. __raw_writel(sh7724_rstandby_state.cs6awcr, 0xfec1003c); /* CS6AWCR */
  1296. __raw_writel(sh7724_rstandby_state.cs6bwcr, 0xfec10040); /* CS6BWCR */
  1297. /* INTC */
  1298. __raw_writew(sh7724_rstandby_state.ipra, 0xa4080000); /* IPRA */
  1299. __raw_writew(sh7724_rstandby_state.iprb, 0xa4080004); /* IPRB */
  1300. __raw_writew(sh7724_rstandby_state.iprc, 0xa4080008); /* IPRC */
  1301. __raw_writew(sh7724_rstandby_state.iprd, 0xa408000c); /* IPRD */
  1302. __raw_writew(sh7724_rstandby_state.ipre, 0xa4080010); /* IPRE */
  1303. __raw_writew(sh7724_rstandby_state.iprf, 0xa4080014); /* IPRF */
  1304. __raw_writew(sh7724_rstandby_state.iprg, 0xa4080018); /* IPRG */
  1305. __raw_writew(sh7724_rstandby_state.iprh, 0xa408001c); /* IPRH */
  1306. __raw_writew(sh7724_rstandby_state.ipri, 0xa4080020); /* IPRI */
  1307. __raw_writew(sh7724_rstandby_state.iprj, 0xa4080024); /* IPRJ */
  1308. __raw_writew(sh7724_rstandby_state.iprk, 0xa4080028); /* IPRK */
  1309. __raw_writew(sh7724_rstandby_state.iprl, 0xa408002c); /* IPRL */
  1310. __raw_writeb(sh7724_rstandby_state.imr0, 0xa4080080); /* IMR0 */
  1311. __raw_writeb(sh7724_rstandby_state.imr1, 0xa4080084); /* IMR1 */
  1312. __raw_writeb(sh7724_rstandby_state.imr2, 0xa4080088); /* IMR2 */
  1313. __raw_writeb(sh7724_rstandby_state.imr3, 0xa408008c); /* IMR3 */
  1314. __raw_writeb(sh7724_rstandby_state.imr4, 0xa4080090); /* IMR4 */
  1315. __raw_writeb(sh7724_rstandby_state.imr5, 0xa4080094); /* IMR5 */
  1316. __raw_writeb(sh7724_rstandby_state.imr6, 0xa4080098); /* IMR6 */
  1317. __raw_writeb(sh7724_rstandby_state.imr7, 0xa408009c); /* IMR7 */
  1318. __raw_writeb(sh7724_rstandby_state.imr8, 0xa40800a0); /* IMR8 */
  1319. __raw_writeb(sh7724_rstandby_state.imr9, 0xa40800a4); /* IMR9 */
  1320. __raw_writeb(sh7724_rstandby_state.imr10, 0xa40800a8); /* IMR10 */
  1321. __raw_writeb(sh7724_rstandby_state.imr11, 0xa40800ac); /* IMR11 */
  1322. __raw_writeb(sh7724_rstandby_state.imr12, 0xa40800b0); /* IMR12 */
  1323. /* RWDT */
  1324. __raw_writew(sh7724_rstandby_state.rwtcnt, 0xa4520000); /* RWTCNT */
  1325. __raw_writew(sh7724_rstandby_state.rwtcsr, 0xa4520004); /* RWTCSR */
  1326. /* CPG */
  1327. __raw_writel(sh7724_rstandby_state.irdaclk, 0xa4150018); /* IRDACLKCR */
  1328. __raw_writel(sh7724_rstandby_state.spuclk, 0xa415003c); /* SPUCLKCR */
  1329. return NOTIFY_DONE;
  1330. }
  1331. static struct notifier_block sh7724_pre_sleep_notifier = {
  1332. .notifier_call = sh7724_pre_sleep_notifier_call,
  1333. .priority = SH_MOBILE_PRE(SH_MOBILE_SLEEP_CPU),
  1334. };
  1335. static struct notifier_block sh7724_post_sleep_notifier = {
  1336. .notifier_call = sh7724_post_sleep_notifier_call,
  1337. .priority = SH_MOBILE_POST(SH_MOBILE_SLEEP_CPU),
  1338. };
  1339. static int __init sh7724_sleep_setup(void)
  1340. {
  1341. atomic_notifier_chain_register(&sh_mobile_pre_sleep_notifier_list,
  1342. &sh7724_pre_sleep_notifier);
  1343. atomic_notifier_chain_register(&sh_mobile_post_sleep_notifier_list,
  1344. &sh7724_post_sleep_notifier);
  1345. return 0;
  1346. }
  1347. arch_initcall(sh7724_sleep_setup);