setup-sh7724.c 36 KB

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