setup-sh7724.c 33 KB

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