setup-sh73a0.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. /*
  2. * sh73a0 processor support
  3. *
  4. * Copyright (C) 2010 Takashi Yoshii
  5. * Copyright (C) 2010 Magnus Damm
  6. * Copyright (C) 2008 Yoshihiro Shimoda
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/delay.h>
  28. #include <linux/input.h>
  29. #include <linux/io.h>
  30. #include <linux/serial_sci.h>
  31. #include <linux/sh_dma.h>
  32. #include <linux/sh_intc.h>
  33. #include <linux/sh_timer.h>
  34. #include <mach/dma-register.h>
  35. #include <mach/hardware.h>
  36. #include <mach/irqs.h>
  37. #include <mach/sh73a0.h>
  38. #include <mach/common.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/map.h>
  41. #include <asm/mach/arch.h>
  42. #include <asm/mach/time.h>
  43. static struct map_desc sh73a0_io_desc[] __initdata = {
  44. /* create a 1:1 entity map for 0xe6xxxxxx
  45. * used by CPGA, INTC and PFC.
  46. */
  47. {
  48. .virtual = 0xe6000000,
  49. .pfn = __phys_to_pfn(0xe6000000),
  50. .length = 256 << 20,
  51. .type = MT_DEVICE_NONSHARED
  52. },
  53. };
  54. void __init sh73a0_map_io(void)
  55. {
  56. iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
  57. }
  58. static struct plat_sci_port scif0_platform_data = {
  59. .mapbase = 0xe6c40000,
  60. .flags = UPF_BOOT_AUTOCONF,
  61. .scscr = SCSCR_RE | SCSCR_TE,
  62. .scbrr_algo_id = SCBRR_ALGO_4,
  63. .type = PORT_SCIFA,
  64. .irqs = { gic_spi(72), gic_spi(72),
  65. gic_spi(72), gic_spi(72) },
  66. };
  67. static struct platform_device scif0_device = {
  68. .name = "sh-sci",
  69. .id = 0,
  70. .dev = {
  71. .platform_data = &scif0_platform_data,
  72. },
  73. };
  74. static struct plat_sci_port scif1_platform_data = {
  75. .mapbase = 0xe6c50000,
  76. .flags = UPF_BOOT_AUTOCONF,
  77. .scscr = SCSCR_RE | SCSCR_TE,
  78. .scbrr_algo_id = SCBRR_ALGO_4,
  79. .type = PORT_SCIFA,
  80. .irqs = { gic_spi(73), gic_spi(73),
  81. gic_spi(73), gic_spi(73) },
  82. };
  83. static struct platform_device scif1_device = {
  84. .name = "sh-sci",
  85. .id = 1,
  86. .dev = {
  87. .platform_data = &scif1_platform_data,
  88. },
  89. };
  90. static struct plat_sci_port scif2_platform_data = {
  91. .mapbase = 0xe6c60000,
  92. .flags = UPF_BOOT_AUTOCONF,
  93. .scscr = SCSCR_RE | SCSCR_TE,
  94. .scbrr_algo_id = SCBRR_ALGO_4,
  95. .type = PORT_SCIFA,
  96. .irqs = { gic_spi(74), gic_spi(74),
  97. gic_spi(74), gic_spi(74) },
  98. };
  99. static struct platform_device scif2_device = {
  100. .name = "sh-sci",
  101. .id = 2,
  102. .dev = {
  103. .platform_data = &scif2_platform_data,
  104. },
  105. };
  106. static struct plat_sci_port scif3_platform_data = {
  107. .mapbase = 0xe6c70000,
  108. .flags = UPF_BOOT_AUTOCONF,
  109. .scscr = SCSCR_RE | SCSCR_TE,
  110. .scbrr_algo_id = SCBRR_ALGO_4,
  111. .type = PORT_SCIFA,
  112. .irqs = { gic_spi(75), gic_spi(75),
  113. gic_spi(75), gic_spi(75) },
  114. };
  115. static struct platform_device scif3_device = {
  116. .name = "sh-sci",
  117. .id = 3,
  118. .dev = {
  119. .platform_data = &scif3_platform_data,
  120. },
  121. };
  122. static struct plat_sci_port scif4_platform_data = {
  123. .mapbase = 0xe6c80000,
  124. .flags = UPF_BOOT_AUTOCONF,
  125. .scscr = SCSCR_RE | SCSCR_TE,
  126. .scbrr_algo_id = SCBRR_ALGO_4,
  127. .type = PORT_SCIFA,
  128. .irqs = { gic_spi(78), gic_spi(78),
  129. gic_spi(78), gic_spi(78) },
  130. };
  131. static struct platform_device scif4_device = {
  132. .name = "sh-sci",
  133. .id = 4,
  134. .dev = {
  135. .platform_data = &scif4_platform_data,
  136. },
  137. };
  138. static struct plat_sci_port scif5_platform_data = {
  139. .mapbase = 0xe6cb0000,
  140. .flags = UPF_BOOT_AUTOCONF,
  141. .scscr = SCSCR_RE | SCSCR_TE,
  142. .scbrr_algo_id = SCBRR_ALGO_4,
  143. .type = PORT_SCIFA,
  144. .irqs = { gic_spi(79), gic_spi(79),
  145. gic_spi(79), gic_spi(79) },
  146. };
  147. static struct platform_device scif5_device = {
  148. .name = "sh-sci",
  149. .id = 5,
  150. .dev = {
  151. .platform_data = &scif5_platform_data,
  152. },
  153. };
  154. static struct plat_sci_port scif6_platform_data = {
  155. .mapbase = 0xe6cc0000,
  156. .flags = UPF_BOOT_AUTOCONF,
  157. .scscr = SCSCR_RE | SCSCR_TE,
  158. .scbrr_algo_id = SCBRR_ALGO_4,
  159. .type = PORT_SCIFA,
  160. .irqs = { gic_spi(156), gic_spi(156),
  161. gic_spi(156), gic_spi(156) },
  162. };
  163. static struct platform_device scif6_device = {
  164. .name = "sh-sci",
  165. .id = 6,
  166. .dev = {
  167. .platform_data = &scif6_platform_data,
  168. },
  169. };
  170. static struct plat_sci_port scif7_platform_data = {
  171. .mapbase = 0xe6cd0000,
  172. .flags = UPF_BOOT_AUTOCONF,
  173. .scscr = SCSCR_RE | SCSCR_TE,
  174. .scbrr_algo_id = SCBRR_ALGO_4,
  175. .type = PORT_SCIFA,
  176. .irqs = { gic_spi(143), gic_spi(143),
  177. gic_spi(143), gic_spi(143) },
  178. };
  179. static struct platform_device scif7_device = {
  180. .name = "sh-sci",
  181. .id = 7,
  182. .dev = {
  183. .platform_data = &scif7_platform_data,
  184. },
  185. };
  186. static struct plat_sci_port scif8_platform_data = {
  187. .mapbase = 0xe6c30000,
  188. .flags = UPF_BOOT_AUTOCONF,
  189. .scscr = SCSCR_RE | SCSCR_TE,
  190. .scbrr_algo_id = SCBRR_ALGO_4,
  191. .type = PORT_SCIFB,
  192. .irqs = { gic_spi(80), gic_spi(80),
  193. gic_spi(80), gic_spi(80) },
  194. };
  195. static struct platform_device scif8_device = {
  196. .name = "sh-sci",
  197. .id = 8,
  198. .dev = {
  199. .platform_data = &scif8_platform_data,
  200. },
  201. };
  202. static struct sh_timer_config cmt10_platform_data = {
  203. .name = "CMT10",
  204. .channel_offset = 0x10,
  205. .timer_bit = 0,
  206. .clockevent_rating = 125,
  207. .clocksource_rating = 125,
  208. };
  209. static struct resource cmt10_resources[] = {
  210. [0] = {
  211. .name = "CMT10",
  212. .start = 0xe6138010,
  213. .end = 0xe613801b,
  214. .flags = IORESOURCE_MEM,
  215. },
  216. [1] = {
  217. .start = gic_spi(65),
  218. .flags = IORESOURCE_IRQ,
  219. },
  220. };
  221. static struct platform_device cmt10_device = {
  222. .name = "sh_cmt",
  223. .id = 10,
  224. .dev = {
  225. .platform_data = &cmt10_platform_data,
  226. },
  227. .resource = cmt10_resources,
  228. .num_resources = ARRAY_SIZE(cmt10_resources),
  229. };
  230. /* TMU */
  231. static struct sh_timer_config tmu00_platform_data = {
  232. .name = "TMU00",
  233. .channel_offset = 0x4,
  234. .timer_bit = 0,
  235. .clockevent_rating = 200,
  236. };
  237. static struct resource tmu00_resources[] = {
  238. [0] = {
  239. .name = "TMU00",
  240. .start = 0xfff60008,
  241. .end = 0xfff60013,
  242. .flags = IORESOURCE_MEM,
  243. },
  244. [1] = {
  245. .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. };
  249. static struct platform_device tmu00_device = {
  250. .name = "sh_tmu",
  251. .id = 0,
  252. .dev = {
  253. .platform_data = &tmu00_platform_data,
  254. },
  255. .resource = tmu00_resources,
  256. .num_resources = ARRAY_SIZE(tmu00_resources),
  257. };
  258. static struct sh_timer_config tmu01_platform_data = {
  259. .name = "TMU01",
  260. .channel_offset = 0x10,
  261. .timer_bit = 1,
  262. .clocksource_rating = 200,
  263. };
  264. static struct resource tmu01_resources[] = {
  265. [0] = {
  266. .name = "TMU01",
  267. .start = 0xfff60014,
  268. .end = 0xfff6001f,
  269. .flags = IORESOURCE_MEM,
  270. },
  271. [1] = {
  272. .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
  273. .flags = IORESOURCE_IRQ,
  274. },
  275. };
  276. static struct platform_device tmu01_device = {
  277. .name = "sh_tmu",
  278. .id = 1,
  279. .dev = {
  280. .platform_data = &tmu01_platform_data,
  281. },
  282. .resource = tmu01_resources,
  283. .num_resources = ARRAY_SIZE(tmu01_resources),
  284. };
  285. static struct resource i2c0_resources[] = {
  286. [0] = {
  287. .name = "IIC0",
  288. .start = 0xe6820000,
  289. .end = 0xe6820425 - 1,
  290. .flags = IORESOURCE_MEM,
  291. },
  292. [1] = {
  293. .start = gic_spi(167),
  294. .end = gic_spi(170),
  295. .flags = IORESOURCE_IRQ,
  296. },
  297. };
  298. static struct resource i2c1_resources[] = {
  299. [0] = {
  300. .name = "IIC1",
  301. .start = 0xe6822000,
  302. .end = 0xe6822425 - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .start = gic_spi(51),
  307. .end = gic_spi(54),
  308. .flags = IORESOURCE_IRQ,
  309. },
  310. };
  311. static struct resource i2c2_resources[] = {
  312. [0] = {
  313. .name = "IIC2",
  314. .start = 0xe6824000,
  315. .end = 0xe6824425 - 1,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. [1] = {
  319. .start = gic_spi(171),
  320. .end = gic_spi(174),
  321. .flags = IORESOURCE_IRQ,
  322. },
  323. };
  324. static struct resource i2c3_resources[] = {
  325. [0] = {
  326. .name = "IIC3",
  327. .start = 0xe6826000,
  328. .end = 0xe6826425 - 1,
  329. .flags = IORESOURCE_MEM,
  330. },
  331. [1] = {
  332. .start = gic_spi(183),
  333. .end = gic_spi(186),
  334. .flags = IORESOURCE_IRQ,
  335. },
  336. };
  337. static struct resource i2c4_resources[] = {
  338. [0] = {
  339. .name = "IIC4",
  340. .start = 0xe6828000,
  341. .end = 0xe6828425 - 1,
  342. .flags = IORESOURCE_MEM,
  343. },
  344. [1] = {
  345. .start = gic_spi(187),
  346. .end = gic_spi(190),
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. };
  350. static struct platform_device i2c0_device = {
  351. .name = "i2c-sh_mobile",
  352. .id = 0,
  353. .resource = i2c0_resources,
  354. .num_resources = ARRAY_SIZE(i2c0_resources),
  355. };
  356. static struct platform_device i2c1_device = {
  357. .name = "i2c-sh_mobile",
  358. .id = 1,
  359. .resource = i2c1_resources,
  360. .num_resources = ARRAY_SIZE(i2c1_resources),
  361. };
  362. static struct platform_device i2c2_device = {
  363. .name = "i2c-sh_mobile",
  364. .id = 2,
  365. .resource = i2c2_resources,
  366. .num_resources = ARRAY_SIZE(i2c2_resources),
  367. };
  368. static struct platform_device i2c3_device = {
  369. .name = "i2c-sh_mobile",
  370. .id = 3,
  371. .resource = i2c3_resources,
  372. .num_resources = ARRAY_SIZE(i2c3_resources),
  373. };
  374. static struct platform_device i2c4_device = {
  375. .name = "i2c-sh_mobile",
  376. .id = 4,
  377. .resource = i2c4_resources,
  378. .num_resources = ARRAY_SIZE(i2c4_resources),
  379. };
  380. static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
  381. {
  382. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  383. .addr = 0xe6c40020,
  384. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  385. .mid_rid = 0x21,
  386. }, {
  387. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  388. .addr = 0xe6c40024,
  389. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  390. .mid_rid = 0x22,
  391. }, {
  392. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  393. .addr = 0xe6c50020,
  394. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  395. .mid_rid = 0x25,
  396. }, {
  397. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  398. .addr = 0xe6c50024,
  399. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  400. .mid_rid = 0x26,
  401. }, {
  402. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  403. .addr = 0xe6c60020,
  404. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  405. .mid_rid = 0x29,
  406. }, {
  407. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  408. .addr = 0xe6c60024,
  409. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  410. .mid_rid = 0x2a,
  411. }, {
  412. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  413. .addr = 0xe6c70020,
  414. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  415. .mid_rid = 0x2d,
  416. }, {
  417. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  418. .addr = 0xe6c70024,
  419. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  420. .mid_rid = 0x2e,
  421. }, {
  422. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  423. .addr = 0xe6c80020,
  424. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  425. .mid_rid = 0x39,
  426. }, {
  427. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  428. .addr = 0xe6c80024,
  429. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  430. .mid_rid = 0x3a,
  431. }, {
  432. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  433. .addr = 0xe6cb0020,
  434. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  435. .mid_rid = 0x35,
  436. }, {
  437. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  438. .addr = 0xe6cb0024,
  439. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  440. .mid_rid = 0x36,
  441. }, {
  442. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  443. .addr = 0xe6cc0020,
  444. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  445. .mid_rid = 0x1d,
  446. }, {
  447. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  448. .addr = 0xe6cc0024,
  449. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  450. .mid_rid = 0x1e,
  451. }, {
  452. .slave_id = SHDMA_SLAVE_SCIF7_TX,
  453. .addr = 0xe6cd0020,
  454. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  455. .mid_rid = 0x19,
  456. }, {
  457. .slave_id = SHDMA_SLAVE_SCIF7_RX,
  458. .addr = 0xe6cd0024,
  459. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  460. .mid_rid = 0x1a,
  461. }, {
  462. .slave_id = SHDMA_SLAVE_SCIF8_TX,
  463. .addr = 0xe6c30040,
  464. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  465. .mid_rid = 0x3d,
  466. }, {
  467. .slave_id = SHDMA_SLAVE_SCIF8_RX,
  468. .addr = 0xe6c30060,
  469. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  470. .mid_rid = 0x3e,
  471. }, {
  472. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  473. .addr = 0xee100030,
  474. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  475. .mid_rid = 0xc1,
  476. }, {
  477. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  478. .addr = 0xee100030,
  479. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  480. .mid_rid = 0xc2,
  481. }, {
  482. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  483. .addr = 0xee120030,
  484. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  485. .mid_rid = 0xc9,
  486. }, {
  487. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  488. .addr = 0xee120030,
  489. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  490. .mid_rid = 0xca,
  491. }, {
  492. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  493. .addr = 0xee140030,
  494. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  495. .mid_rid = 0xcd,
  496. }, {
  497. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  498. .addr = 0xee140030,
  499. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  500. .mid_rid = 0xce,
  501. }, {
  502. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  503. .addr = 0xe6bd0034,
  504. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  505. .mid_rid = 0xd1,
  506. }, {
  507. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  508. .addr = 0xe6bd0034,
  509. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  510. .mid_rid = 0xd2,
  511. },
  512. };
  513. #define DMAE_CHANNEL(_offset) \
  514. { \
  515. .offset = _offset - 0x20, \
  516. .dmars = _offset - 0x20 + 0x40, \
  517. }
  518. static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
  519. DMAE_CHANNEL(0x8000),
  520. DMAE_CHANNEL(0x8080),
  521. DMAE_CHANNEL(0x8100),
  522. DMAE_CHANNEL(0x8180),
  523. DMAE_CHANNEL(0x8200),
  524. DMAE_CHANNEL(0x8280),
  525. DMAE_CHANNEL(0x8300),
  526. DMAE_CHANNEL(0x8380),
  527. DMAE_CHANNEL(0x8400),
  528. DMAE_CHANNEL(0x8480),
  529. DMAE_CHANNEL(0x8500),
  530. DMAE_CHANNEL(0x8580),
  531. DMAE_CHANNEL(0x8600),
  532. DMAE_CHANNEL(0x8680),
  533. DMAE_CHANNEL(0x8700),
  534. DMAE_CHANNEL(0x8780),
  535. DMAE_CHANNEL(0x8800),
  536. DMAE_CHANNEL(0x8880),
  537. DMAE_CHANNEL(0x8900),
  538. DMAE_CHANNEL(0x8980),
  539. };
  540. static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
  541. .slave = sh73a0_dmae_slaves,
  542. .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
  543. .channel = sh73a0_dmae_channels,
  544. .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
  545. .ts_low_shift = TS_LOW_SHIFT,
  546. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  547. .ts_high_shift = TS_HI_SHIFT,
  548. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  549. .ts_shift = dma_ts_shift,
  550. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  551. .dmaor_init = DMAOR_DME,
  552. };
  553. static struct resource sh73a0_dmae_resources[] = {
  554. {
  555. /* Registers including DMAOR and channels including DMARSx */
  556. .start = 0xfe000020,
  557. .end = 0xfe008a00 - 1,
  558. .flags = IORESOURCE_MEM,
  559. },
  560. {
  561. .name = "error_irq",
  562. .start = gic_spi(129),
  563. .end = gic_spi(129),
  564. .flags = IORESOURCE_IRQ,
  565. },
  566. {
  567. /* IRQ for channels 0-19 */
  568. .start = gic_spi(109),
  569. .end = gic_spi(128),
  570. .flags = IORESOURCE_IRQ,
  571. },
  572. };
  573. static struct platform_device dma0_device = {
  574. .name = "sh-dma-engine",
  575. .id = 0,
  576. .resource = sh73a0_dmae_resources,
  577. .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
  578. .dev = {
  579. .platform_data = &sh73a0_dmae_platform_data,
  580. },
  581. };
  582. /* MPDMAC */
  583. static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
  584. {
  585. .slave_id = SHDMA_SLAVE_FSI2A_RX,
  586. .addr = 0xec230020,
  587. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  588. .mid_rid = 0xd6, /* CHECK ME */
  589. }, {
  590. .slave_id = SHDMA_SLAVE_FSI2A_TX,
  591. .addr = 0xec230024,
  592. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  593. .mid_rid = 0xd5, /* CHECK ME */
  594. }, {
  595. .slave_id = SHDMA_SLAVE_FSI2C_RX,
  596. .addr = 0xec230060,
  597. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  598. .mid_rid = 0xda, /* CHECK ME */
  599. }, {
  600. .slave_id = SHDMA_SLAVE_FSI2C_TX,
  601. .addr = 0xec230064,
  602. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  603. .mid_rid = 0xd9, /* CHECK ME */
  604. }, {
  605. .slave_id = SHDMA_SLAVE_FSI2B_RX,
  606. .addr = 0xec240020,
  607. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  608. .mid_rid = 0x8e, /* CHECK ME */
  609. }, {
  610. .slave_id = SHDMA_SLAVE_FSI2B_TX,
  611. .addr = 0xec240024,
  612. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  613. .mid_rid = 0x8d, /* CHECK ME */
  614. }, {
  615. .slave_id = SHDMA_SLAVE_FSI2D_RX,
  616. .addr = 0xec240060,
  617. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  618. .mid_rid = 0x9a, /* CHECK ME */
  619. },
  620. };
  621. #define MPDMA_CHANNEL(a, b, c) \
  622. { \
  623. .offset = a, \
  624. .dmars = b, \
  625. .dmars_bit = c, \
  626. .chclr_offset = (0x220 - 0x20) + a \
  627. }
  628. static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
  629. MPDMA_CHANNEL(0x00, 0, 0),
  630. MPDMA_CHANNEL(0x10, 0, 8),
  631. MPDMA_CHANNEL(0x20, 4, 0),
  632. MPDMA_CHANNEL(0x30, 4, 8),
  633. MPDMA_CHANNEL(0x50, 8, 0),
  634. MPDMA_CHANNEL(0x70, 8, 8),
  635. };
  636. static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
  637. .slave = sh73a0_mpdma_slaves,
  638. .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
  639. .channel = sh73a0_mpdma_channels,
  640. .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
  641. .ts_low_shift = TS_LOW_SHIFT,
  642. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  643. .ts_high_shift = TS_HI_SHIFT,
  644. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  645. .ts_shift = dma_ts_shift,
  646. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  647. .dmaor_init = DMAOR_DME,
  648. .chclr_present = 1,
  649. };
  650. /* Resource order important! */
  651. static struct resource sh73a0_mpdma_resources[] = {
  652. {
  653. /* Channel registers and DMAOR */
  654. .start = 0xec618020,
  655. .end = 0xec61828f,
  656. .flags = IORESOURCE_MEM,
  657. },
  658. {
  659. /* DMARSx */
  660. .start = 0xec619000,
  661. .end = 0xec61900b,
  662. .flags = IORESOURCE_MEM,
  663. },
  664. {
  665. .name = "error_irq",
  666. .start = gic_spi(181),
  667. .end = gic_spi(181),
  668. .flags = IORESOURCE_IRQ,
  669. },
  670. {
  671. /* IRQ for channels 0-5 */
  672. .start = gic_spi(175),
  673. .end = gic_spi(180),
  674. .flags = IORESOURCE_IRQ,
  675. },
  676. };
  677. static struct platform_device mpdma0_device = {
  678. .name = "sh-dma-engine",
  679. .id = 1,
  680. .resource = sh73a0_mpdma_resources,
  681. .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
  682. .dev = {
  683. .platform_data = &sh73a0_mpdma_platform_data,
  684. },
  685. };
  686. static struct resource pmu_resources[] = {
  687. [0] = {
  688. .start = gic_spi(55),
  689. .end = gic_spi(55),
  690. .flags = IORESOURCE_IRQ,
  691. },
  692. [1] = {
  693. .start = gic_spi(56),
  694. .end = gic_spi(56),
  695. .flags = IORESOURCE_IRQ,
  696. },
  697. };
  698. static struct platform_device pmu_device = {
  699. .name = "arm-pmu",
  700. .id = -1,
  701. .num_resources = ARRAY_SIZE(pmu_resources),
  702. .resource = pmu_resources,
  703. };
  704. static struct platform_device *sh73a0_early_devices_dt[] __initdata = {
  705. &scif0_device,
  706. &scif1_device,
  707. &scif2_device,
  708. &scif3_device,
  709. &scif4_device,
  710. &scif5_device,
  711. &scif6_device,
  712. &scif7_device,
  713. &scif8_device,
  714. &cmt10_device,
  715. };
  716. static struct platform_device *sh73a0_early_devices[] __initdata = {
  717. &tmu00_device,
  718. &tmu01_device,
  719. };
  720. static struct platform_device *sh73a0_late_devices[] __initdata = {
  721. &i2c0_device,
  722. &i2c1_device,
  723. &i2c2_device,
  724. &i2c3_device,
  725. &i2c4_device,
  726. &dma0_device,
  727. &mpdma0_device,
  728. &pmu_device,
  729. };
  730. #define SRCR2 IOMEM(0xe61580b0)
  731. void __init sh73a0_add_standard_devices(void)
  732. {
  733. /* Clear software reset bit on SY-DMAC module */
  734. __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
  735. platform_add_devices(sh73a0_early_devices_dt,
  736. ARRAY_SIZE(sh73a0_early_devices_dt));
  737. platform_add_devices(sh73a0_early_devices,
  738. ARRAY_SIZE(sh73a0_early_devices));
  739. platform_add_devices(sh73a0_late_devices,
  740. ARRAY_SIZE(sh73a0_late_devices));
  741. }
  742. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  743. void __init __weak sh73a0_register_twd(void) { }
  744. void __init sh73a0_earlytimer_init(void)
  745. {
  746. sh73a0_clock_init();
  747. shmobile_earlytimer_init();
  748. sh73a0_register_twd();
  749. }
  750. void __init sh73a0_add_early_devices(void)
  751. {
  752. early_platform_add_devices(sh73a0_early_devices_dt,
  753. ARRAY_SIZE(sh73a0_early_devices_dt));
  754. early_platform_add_devices(sh73a0_early_devices,
  755. ARRAY_SIZE(sh73a0_early_devices));
  756. /* setup early console here as well */
  757. shmobile_setup_console();
  758. }
  759. #ifdef CONFIG_USE_OF
  760. /* Please note that the clock initialisation shcheme used in
  761. * sh73a0_add_early_devices_dt() and sh73a0_add_standard_devices_dt()
  762. * does not work with SMP as there is a yet to be resolved lock-up in
  763. * workqueue initialisation.
  764. *
  765. * CONFIG_SMP should be disabled when using this code.
  766. */
  767. void __init sh73a0_add_early_devices_dt(void)
  768. {
  769. shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
  770. early_platform_add_devices(sh73a0_early_devices_dt,
  771. ARRAY_SIZE(sh73a0_early_devices_dt));
  772. /* setup early console here as well */
  773. shmobile_setup_console();
  774. }
  775. static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
  776. {},
  777. };
  778. void __init sh73a0_add_standard_devices_dt(void)
  779. {
  780. /* clocks are setup late during boot in the case of DT */
  781. sh73a0_clock_init();
  782. platform_add_devices(sh73a0_early_devices_dt,
  783. ARRAY_SIZE(sh73a0_early_devices_dt));
  784. of_platform_populate(NULL, of_default_bus_match_table,
  785. sh73a0_auxdata_lookup, NULL);
  786. }
  787. static const char *sh73a0_boards_compat_dt[] __initdata = {
  788. "renesas,sh73a0",
  789. NULL,
  790. };
  791. DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
  792. .map_io = sh73a0_map_io,
  793. .init_early = sh73a0_add_early_devices_dt,
  794. .nr_irqs = NR_IRQS_LEGACY,
  795. .init_irq = sh73a0_init_irq_dt,
  796. .init_machine = sh73a0_add_standard_devices_dt,
  797. .init_time = shmobile_timer_init,
  798. .dt_compat = sh73a0_boards_compat_dt,
  799. MACHINE_END
  800. #endif /* CONFIG_USE_OF */