setup-sh7372.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*
  2. * sh7372 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/input.h>
  27. #include <linux/io.h>
  28. #include <linux/serial_sci.h>
  29. #include <linux/sh_dma.h>
  30. #include <linux/sh_intc.h>
  31. #include <linux/sh_timer.h>
  32. #include <mach/hardware.h>
  33. #include <mach/sh7372.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. /* SCIFA0 */
  37. static struct plat_sci_port scif0_platform_data = {
  38. .mapbase = 0xe6c40000,
  39. .flags = UPF_BOOT_AUTOCONF,
  40. .type = PORT_SCIFA,
  41. .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
  42. evt2irq(0x0c00), evt2irq(0x0c00) },
  43. };
  44. static struct platform_device scif0_device = {
  45. .name = "sh-sci",
  46. .id = 0,
  47. .dev = {
  48. .platform_data = &scif0_platform_data,
  49. },
  50. };
  51. /* SCIFA1 */
  52. static struct plat_sci_port scif1_platform_data = {
  53. .mapbase = 0xe6c50000,
  54. .flags = UPF_BOOT_AUTOCONF,
  55. .type = PORT_SCIFA,
  56. .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
  57. evt2irq(0x0c20), evt2irq(0x0c20) },
  58. };
  59. static struct platform_device scif1_device = {
  60. .name = "sh-sci",
  61. .id = 1,
  62. .dev = {
  63. .platform_data = &scif1_platform_data,
  64. },
  65. };
  66. /* SCIFA2 */
  67. static struct plat_sci_port scif2_platform_data = {
  68. .mapbase = 0xe6c60000,
  69. .flags = UPF_BOOT_AUTOCONF,
  70. .type = PORT_SCIFA,
  71. .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
  72. evt2irq(0x0c40), evt2irq(0x0c40) },
  73. };
  74. static struct platform_device scif2_device = {
  75. .name = "sh-sci",
  76. .id = 2,
  77. .dev = {
  78. .platform_data = &scif2_platform_data,
  79. },
  80. };
  81. /* SCIFA3 */
  82. static struct plat_sci_port scif3_platform_data = {
  83. .mapbase = 0xe6c70000,
  84. .flags = UPF_BOOT_AUTOCONF,
  85. .type = PORT_SCIFA,
  86. .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
  87. evt2irq(0x0c60), evt2irq(0x0c60) },
  88. };
  89. static struct platform_device scif3_device = {
  90. .name = "sh-sci",
  91. .id = 3,
  92. .dev = {
  93. .platform_data = &scif3_platform_data,
  94. },
  95. };
  96. /* SCIFA4 */
  97. static struct plat_sci_port scif4_platform_data = {
  98. .mapbase = 0xe6c80000,
  99. .flags = UPF_BOOT_AUTOCONF,
  100. .type = PORT_SCIFA,
  101. .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
  102. evt2irq(0x0d20), evt2irq(0x0d20) },
  103. };
  104. static struct platform_device scif4_device = {
  105. .name = "sh-sci",
  106. .id = 4,
  107. .dev = {
  108. .platform_data = &scif4_platform_data,
  109. },
  110. };
  111. /* SCIFA5 */
  112. static struct plat_sci_port scif5_platform_data = {
  113. .mapbase = 0xe6cb0000,
  114. .flags = UPF_BOOT_AUTOCONF,
  115. .type = PORT_SCIFA,
  116. .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
  117. evt2irq(0x0d40), evt2irq(0x0d40) },
  118. };
  119. static struct platform_device scif5_device = {
  120. .name = "sh-sci",
  121. .id = 5,
  122. .dev = {
  123. .platform_data = &scif5_platform_data,
  124. },
  125. };
  126. /* SCIFB */
  127. static struct plat_sci_port scif6_platform_data = {
  128. .mapbase = 0xe6c30000,
  129. .flags = UPF_BOOT_AUTOCONF,
  130. .type = PORT_SCIFB,
  131. .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
  132. evt2irq(0x0d60), evt2irq(0x0d60) },
  133. };
  134. static struct platform_device scif6_device = {
  135. .name = "sh-sci",
  136. .id = 6,
  137. .dev = {
  138. .platform_data = &scif6_platform_data,
  139. },
  140. };
  141. /* CMT */
  142. static struct sh_timer_config cmt10_platform_data = {
  143. .name = "CMT10",
  144. .channel_offset = 0x10,
  145. .timer_bit = 0,
  146. .clk = "cmt1",
  147. .clockevent_rating = 125,
  148. .clocksource_rating = 125,
  149. };
  150. static struct resource cmt10_resources[] = {
  151. [0] = {
  152. .name = "CMT10",
  153. .start = 0xe6138010,
  154. .end = 0xe613801b,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. [1] = {
  158. .start = evt2irq(0x0b00), /* CMT1_CMT10 */
  159. .flags = IORESOURCE_IRQ,
  160. },
  161. };
  162. static struct platform_device cmt10_device = {
  163. .name = "sh_cmt",
  164. .id = 10,
  165. .dev = {
  166. .platform_data = &cmt10_platform_data,
  167. },
  168. .resource = cmt10_resources,
  169. .num_resources = ARRAY_SIZE(cmt10_resources),
  170. };
  171. /* I2C */
  172. static struct resource iic0_resources[] = {
  173. [0] = {
  174. .name = "IIC0",
  175. .start = 0xFFF20000,
  176. .end = 0xFFF20425 - 1,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  181. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. };
  185. static struct platform_device iic0_device = {
  186. .name = "i2c-sh_mobile",
  187. .id = 0, /* "i2c0" clock */
  188. .num_resources = ARRAY_SIZE(iic0_resources),
  189. .resource = iic0_resources,
  190. };
  191. static struct resource iic1_resources[] = {
  192. [0] = {
  193. .name = "IIC1",
  194. .start = 0xE6C20000,
  195. .end = 0xE6C20425 - 1,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. [1] = {
  199. .start = evt2irq(0x780), /* IIC1_ALI1 */
  200. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  201. .flags = IORESOURCE_IRQ,
  202. },
  203. };
  204. static struct platform_device iic1_device = {
  205. .name = "i2c-sh_mobile",
  206. .id = 1, /* "i2c1" clock */
  207. .num_resources = ARRAY_SIZE(iic1_resources),
  208. .resource = iic1_resources,
  209. };
  210. /* DMA */
  211. /* Transmit sizes and respective CHCR register values */
  212. enum {
  213. XMIT_SZ_8BIT = 0,
  214. XMIT_SZ_16BIT = 1,
  215. XMIT_SZ_32BIT = 2,
  216. XMIT_SZ_64BIT = 7,
  217. XMIT_SZ_128BIT = 3,
  218. XMIT_SZ_256BIT = 4,
  219. XMIT_SZ_512BIT = 5,
  220. };
  221. /* log2(size / 8) - used to calculate number of transfers */
  222. #define TS_SHIFT { \
  223. [XMIT_SZ_8BIT] = 0, \
  224. [XMIT_SZ_16BIT] = 1, \
  225. [XMIT_SZ_32BIT] = 2, \
  226. [XMIT_SZ_64BIT] = 3, \
  227. [XMIT_SZ_128BIT] = 4, \
  228. [XMIT_SZ_256BIT] = 5, \
  229. [XMIT_SZ_512BIT] = 6, \
  230. }
  231. #define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
  232. (((i) & 0xc) << (20 - 2)))
  233. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  234. {
  235. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  236. .addr = 0xe6c40020,
  237. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  238. .mid_rid = 0x21,
  239. }, {
  240. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  241. .addr = 0xe6c40024,
  242. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  243. .mid_rid = 0x22,
  244. }, {
  245. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  246. .addr = 0xe6c50020,
  247. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  248. .mid_rid = 0x25,
  249. }, {
  250. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  251. .addr = 0xe6c50024,
  252. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  253. .mid_rid = 0x26,
  254. }, {
  255. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  256. .addr = 0xe6c60020,
  257. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  258. .mid_rid = 0x29,
  259. }, {
  260. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  261. .addr = 0xe6c60024,
  262. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  263. .mid_rid = 0x2a,
  264. }, {
  265. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  266. .addr = 0xe6c70020,
  267. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  268. .mid_rid = 0x2d,
  269. }, {
  270. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  271. .addr = 0xe6c70024,
  272. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  273. .mid_rid = 0x2e,
  274. }, {
  275. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  276. .addr = 0xe6c80020,
  277. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  278. .mid_rid = 0x39,
  279. }, {
  280. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  281. .addr = 0xe6c80024,
  282. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  283. .mid_rid = 0x3a,
  284. }, {
  285. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  286. .addr = 0xe6cb0020,
  287. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  288. .mid_rid = 0x35,
  289. }, {
  290. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  291. .addr = 0xe6cb0024,
  292. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  293. .mid_rid = 0x36,
  294. }, {
  295. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  296. .addr = 0xe6c30040,
  297. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  298. .mid_rid = 0x3d,
  299. }, {
  300. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  301. .addr = 0xe6c30060,
  302. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  303. .mid_rid = 0x3e,
  304. }, {
  305. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  306. .addr = 0xe6850030,
  307. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  308. .mid_rid = 0xc1,
  309. }, {
  310. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  311. .addr = 0xe6850030,
  312. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  313. .mid_rid = 0xc2,
  314. }, {
  315. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  316. .addr = 0xe6860030,
  317. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  318. .mid_rid = 0xc9,
  319. }, {
  320. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  321. .addr = 0xe6860030,
  322. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  323. .mid_rid = 0xca,
  324. }, {
  325. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  326. .addr = 0xe6870030,
  327. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  328. .mid_rid = 0xcd,
  329. }, {
  330. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  331. .addr = 0xe6870030,
  332. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  333. .mid_rid = 0xce,
  334. },
  335. };
  336. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  337. {
  338. .offset = 0,
  339. .dmars = 0,
  340. .dmars_bit = 0,
  341. }, {
  342. .offset = 0x10,
  343. .dmars = 0,
  344. .dmars_bit = 8,
  345. }, {
  346. .offset = 0x20,
  347. .dmars = 4,
  348. .dmars_bit = 0,
  349. }, {
  350. .offset = 0x30,
  351. .dmars = 4,
  352. .dmars_bit = 8,
  353. }, {
  354. .offset = 0x50,
  355. .dmars = 8,
  356. .dmars_bit = 0,
  357. }, {
  358. .offset = 0x60,
  359. .dmars = 8,
  360. .dmars_bit = 8,
  361. }
  362. };
  363. static const unsigned int ts_shift[] = TS_SHIFT;
  364. static struct sh_dmae_pdata dma_platform_data = {
  365. .slave = sh7372_dmae_slaves,
  366. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  367. .channel = sh7372_dmae_channels,
  368. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  369. .ts_low_shift = 3,
  370. .ts_low_mask = 0x18,
  371. .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
  372. .ts_high_mask = 0x00300000,
  373. .ts_shift = ts_shift,
  374. .ts_shift_num = ARRAY_SIZE(ts_shift),
  375. .dmaor_init = DMAOR_DME,
  376. };
  377. /* Resource order important! */
  378. static struct resource sh7372_dmae0_resources[] = {
  379. {
  380. /* Channel registers and DMAOR */
  381. .start = 0xfe008020,
  382. .end = 0xfe00808f,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. {
  386. /* DMARSx */
  387. .start = 0xfe009000,
  388. .end = 0xfe00900b,
  389. .flags = IORESOURCE_MEM,
  390. },
  391. {
  392. /* DMA error IRQ */
  393. .start = 246,
  394. .end = 246,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. {
  398. /* IRQ for channels 0-5 */
  399. .start = 240,
  400. .end = 245,
  401. .flags = IORESOURCE_IRQ,
  402. },
  403. };
  404. /* Resource order important! */
  405. static struct resource sh7372_dmae1_resources[] = {
  406. {
  407. /* Channel registers and DMAOR */
  408. .start = 0xfe018020,
  409. .end = 0xfe01808f,
  410. .flags = IORESOURCE_MEM,
  411. },
  412. {
  413. /* DMARSx */
  414. .start = 0xfe019000,
  415. .end = 0xfe01900b,
  416. .flags = IORESOURCE_MEM,
  417. },
  418. {
  419. /* DMA error IRQ */
  420. .start = 254,
  421. .end = 254,
  422. .flags = IORESOURCE_IRQ,
  423. },
  424. {
  425. /* IRQ for channels 0-5 */
  426. .start = 248,
  427. .end = 253,
  428. .flags = IORESOURCE_IRQ,
  429. },
  430. };
  431. /* Resource order important! */
  432. static struct resource sh7372_dmae2_resources[] = {
  433. {
  434. /* Channel registers and DMAOR */
  435. .start = 0xfe028020,
  436. .end = 0xfe02808f,
  437. .flags = IORESOURCE_MEM,
  438. },
  439. {
  440. /* DMARSx */
  441. .start = 0xfe029000,
  442. .end = 0xfe02900b,
  443. .flags = IORESOURCE_MEM,
  444. },
  445. {
  446. /* DMA error IRQ */
  447. .start = 262,
  448. .end = 262,
  449. .flags = IORESOURCE_IRQ,
  450. },
  451. {
  452. /* IRQ for channels 0-5 */
  453. .start = 256,
  454. .end = 261,
  455. .flags = IORESOURCE_IRQ,
  456. },
  457. };
  458. static struct platform_device dma0_device = {
  459. .name = "sh-dma-engine",
  460. .id = 0,
  461. .resource = sh7372_dmae0_resources,
  462. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  463. .dev = {
  464. .platform_data = &dma_platform_data,
  465. },
  466. };
  467. static struct platform_device dma1_device = {
  468. .name = "sh-dma-engine",
  469. .id = 1,
  470. .resource = sh7372_dmae1_resources,
  471. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  472. .dev = {
  473. .platform_data = &dma_platform_data,
  474. },
  475. };
  476. static struct platform_device dma2_device = {
  477. .name = "sh-dma-engine",
  478. .id = 2,
  479. .resource = sh7372_dmae2_resources,
  480. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  481. .dev = {
  482. .platform_data = &dma_platform_data,
  483. },
  484. };
  485. static struct platform_device *sh7372_early_devices[] __initdata = {
  486. &scif0_device,
  487. &scif1_device,
  488. &scif2_device,
  489. &scif3_device,
  490. &scif4_device,
  491. &scif5_device,
  492. &scif6_device,
  493. &cmt10_device,
  494. &iic0_device,
  495. &iic1_device,
  496. &dma0_device,
  497. &dma1_device,
  498. &dma2_device,
  499. };
  500. void __init sh7372_add_standard_devices(void)
  501. {
  502. platform_add_devices(sh7372_early_devices,
  503. ARRAY_SIZE(sh7372_early_devices));
  504. }
  505. void __init sh7372_add_early_devices(void)
  506. {
  507. early_platform_add_devices(sh7372_early_devices,
  508. ARRAY_SIZE(sh7372_early_devices));
  509. }