setup-sh7724.c 35 KB

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