setup-sh7724.c 31 KB

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