setup-sh7372.c 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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/uio_driver.h>
  26. #include <linux/delay.h>
  27. #include <linux/input.h>
  28. #include <linux/io.h>
  29. #include <linux/serial_sci.h>
  30. #include <linux/sh_dma.h>
  31. #include <linux/sh_intc.h>
  32. #include <linux/sh_timer.h>
  33. #include <linux/pm_domain.h>
  34. #include <linux/dma-mapping.h>
  35. #include <mach/hardware.h>
  36. #include <mach/sh7372.h>
  37. #include <mach/common.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach/time.h>
  42. static struct map_desc sh7372_io_desc[] __initdata = {
  43. /* create a 1:1 entity map for 0xe6xxxxxx
  44. * used by CPGA, INTC and PFC.
  45. */
  46. {
  47. .virtual = 0xe6000000,
  48. .pfn = __phys_to_pfn(0xe6000000),
  49. .length = 256 << 20,
  50. .type = MT_DEVICE_NONSHARED
  51. },
  52. };
  53. void __init sh7372_map_io(void)
  54. {
  55. iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
  56. /*
  57. * DMA memory at 0xff200000 - 0xffdfffff. The default 2MB size isn't
  58. * enough to allocate the frame buffer memory.
  59. */
  60. init_consistent_dma_size(12 << 20);
  61. }
  62. /* SCIFA0 */
  63. static struct plat_sci_port scif0_platform_data = {
  64. .mapbase = 0xe6c40000,
  65. .flags = UPF_BOOT_AUTOCONF,
  66. .scscr = SCSCR_RE | SCSCR_TE,
  67. .scbrr_algo_id = SCBRR_ALGO_4,
  68. .type = PORT_SCIFA,
  69. .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
  70. evt2irq(0x0c00), evt2irq(0x0c00) },
  71. };
  72. static struct platform_device scif0_device = {
  73. .name = "sh-sci",
  74. .id = 0,
  75. .dev = {
  76. .platform_data = &scif0_platform_data,
  77. },
  78. };
  79. /* SCIFA1 */
  80. static struct plat_sci_port scif1_platform_data = {
  81. .mapbase = 0xe6c50000,
  82. .flags = UPF_BOOT_AUTOCONF,
  83. .scscr = SCSCR_RE | SCSCR_TE,
  84. .scbrr_algo_id = SCBRR_ALGO_4,
  85. .type = PORT_SCIFA,
  86. .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
  87. evt2irq(0x0c20), evt2irq(0x0c20) },
  88. };
  89. static struct platform_device scif1_device = {
  90. .name = "sh-sci",
  91. .id = 1,
  92. .dev = {
  93. .platform_data = &scif1_platform_data,
  94. },
  95. };
  96. /* SCIFA2 */
  97. static struct plat_sci_port scif2_platform_data = {
  98. .mapbase = 0xe6c60000,
  99. .flags = UPF_BOOT_AUTOCONF,
  100. .scscr = SCSCR_RE | SCSCR_TE,
  101. .scbrr_algo_id = SCBRR_ALGO_4,
  102. .type = PORT_SCIFA,
  103. .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
  104. evt2irq(0x0c40), evt2irq(0x0c40) },
  105. };
  106. static struct platform_device scif2_device = {
  107. .name = "sh-sci",
  108. .id = 2,
  109. .dev = {
  110. .platform_data = &scif2_platform_data,
  111. },
  112. };
  113. /* SCIFA3 */
  114. static struct plat_sci_port scif3_platform_data = {
  115. .mapbase = 0xe6c70000,
  116. .flags = UPF_BOOT_AUTOCONF,
  117. .scscr = SCSCR_RE | SCSCR_TE,
  118. .scbrr_algo_id = SCBRR_ALGO_4,
  119. .type = PORT_SCIFA,
  120. .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
  121. evt2irq(0x0c60), evt2irq(0x0c60) },
  122. };
  123. static struct platform_device scif3_device = {
  124. .name = "sh-sci",
  125. .id = 3,
  126. .dev = {
  127. .platform_data = &scif3_platform_data,
  128. },
  129. };
  130. /* SCIFA4 */
  131. static struct plat_sci_port scif4_platform_data = {
  132. .mapbase = 0xe6c80000,
  133. .flags = UPF_BOOT_AUTOCONF,
  134. .scscr = SCSCR_RE | SCSCR_TE,
  135. .scbrr_algo_id = SCBRR_ALGO_4,
  136. .type = PORT_SCIFA,
  137. .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
  138. evt2irq(0x0d20), evt2irq(0x0d20) },
  139. };
  140. static struct platform_device scif4_device = {
  141. .name = "sh-sci",
  142. .id = 4,
  143. .dev = {
  144. .platform_data = &scif4_platform_data,
  145. },
  146. };
  147. /* SCIFA5 */
  148. static struct plat_sci_port scif5_platform_data = {
  149. .mapbase = 0xe6cb0000,
  150. .flags = UPF_BOOT_AUTOCONF,
  151. .scscr = SCSCR_RE | SCSCR_TE,
  152. .scbrr_algo_id = SCBRR_ALGO_4,
  153. .type = PORT_SCIFA,
  154. .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
  155. evt2irq(0x0d40), evt2irq(0x0d40) },
  156. };
  157. static struct platform_device scif5_device = {
  158. .name = "sh-sci",
  159. .id = 5,
  160. .dev = {
  161. .platform_data = &scif5_platform_data,
  162. },
  163. };
  164. /* SCIFB */
  165. static struct plat_sci_port scif6_platform_data = {
  166. .mapbase = 0xe6c30000,
  167. .flags = UPF_BOOT_AUTOCONF,
  168. .scscr = SCSCR_RE | SCSCR_TE,
  169. .scbrr_algo_id = SCBRR_ALGO_4,
  170. .type = PORT_SCIFB,
  171. .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
  172. evt2irq(0x0d60), evt2irq(0x0d60) },
  173. };
  174. static struct platform_device scif6_device = {
  175. .name = "sh-sci",
  176. .id = 6,
  177. .dev = {
  178. .platform_data = &scif6_platform_data,
  179. },
  180. };
  181. /* CMT */
  182. static struct sh_timer_config cmt2_platform_data = {
  183. .name = "CMT2",
  184. .channel_offset = 0x40,
  185. .timer_bit = 5,
  186. .clockevent_rating = 125,
  187. .clocksource_rating = 125,
  188. };
  189. static struct resource cmt2_resources[] = {
  190. [0] = {
  191. .name = "CMT2",
  192. .start = 0xe6130040,
  193. .end = 0xe613004b,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. [1] = {
  197. .start = evt2irq(0x0b80), /* CMT2 */
  198. .flags = IORESOURCE_IRQ,
  199. },
  200. };
  201. static struct platform_device cmt2_device = {
  202. .name = "sh_cmt",
  203. .id = 2,
  204. .dev = {
  205. .platform_data = &cmt2_platform_data,
  206. },
  207. .resource = cmt2_resources,
  208. .num_resources = ARRAY_SIZE(cmt2_resources),
  209. };
  210. /* TMU */
  211. static struct sh_timer_config tmu00_platform_data = {
  212. .name = "TMU00",
  213. .channel_offset = 0x4,
  214. .timer_bit = 0,
  215. .clockevent_rating = 200,
  216. };
  217. static struct resource tmu00_resources[] = {
  218. [0] = {
  219. .name = "TMU00",
  220. .start = 0xfff60008,
  221. .end = 0xfff60013,
  222. .flags = IORESOURCE_MEM,
  223. },
  224. [1] = {
  225. .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
  226. .flags = IORESOURCE_IRQ,
  227. },
  228. };
  229. static struct platform_device tmu00_device = {
  230. .name = "sh_tmu",
  231. .id = 0,
  232. .dev = {
  233. .platform_data = &tmu00_platform_data,
  234. },
  235. .resource = tmu00_resources,
  236. .num_resources = ARRAY_SIZE(tmu00_resources),
  237. };
  238. static struct sh_timer_config tmu01_platform_data = {
  239. .name = "TMU01",
  240. .channel_offset = 0x10,
  241. .timer_bit = 1,
  242. .clocksource_rating = 200,
  243. };
  244. static struct resource tmu01_resources[] = {
  245. [0] = {
  246. .name = "TMU01",
  247. .start = 0xfff60014,
  248. .end = 0xfff6001f,
  249. .flags = IORESOURCE_MEM,
  250. },
  251. [1] = {
  252. .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
  253. .flags = IORESOURCE_IRQ,
  254. },
  255. };
  256. static struct platform_device tmu01_device = {
  257. .name = "sh_tmu",
  258. .id = 1,
  259. .dev = {
  260. .platform_data = &tmu01_platform_data,
  261. },
  262. .resource = tmu01_resources,
  263. .num_resources = ARRAY_SIZE(tmu01_resources),
  264. };
  265. /* I2C */
  266. static struct resource iic0_resources[] = {
  267. [0] = {
  268. .name = "IIC0",
  269. .start = 0xFFF20000,
  270. .end = 0xFFF20425 - 1,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. [1] = {
  274. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  275. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. };
  279. static struct platform_device iic0_device = {
  280. .name = "i2c-sh_mobile",
  281. .id = 0, /* "i2c0" clock */
  282. .num_resources = ARRAY_SIZE(iic0_resources),
  283. .resource = iic0_resources,
  284. };
  285. static struct resource iic1_resources[] = {
  286. [0] = {
  287. .name = "IIC1",
  288. .start = 0xE6C20000,
  289. .end = 0xE6C20425 - 1,
  290. .flags = IORESOURCE_MEM,
  291. },
  292. [1] = {
  293. .start = evt2irq(0x780), /* IIC1_ALI1 */
  294. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  295. .flags = IORESOURCE_IRQ,
  296. },
  297. };
  298. static struct platform_device iic1_device = {
  299. .name = "i2c-sh_mobile",
  300. .id = 1, /* "i2c1" clock */
  301. .num_resources = ARRAY_SIZE(iic1_resources),
  302. .resource = iic1_resources,
  303. };
  304. /* DMA */
  305. /* Transmit sizes and respective CHCR register values */
  306. enum {
  307. XMIT_SZ_8BIT = 0,
  308. XMIT_SZ_16BIT = 1,
  309. XMIT_SZ_32BIT = 2,
  310. XMIT_SZ_64BIT = 7,
  311. XMIT_SZ_128BIT = 3,
  312. XMIT_SZ_256BIT = 4,
  313. XMIT_SZ_512BIT = 5,
  314. };
  315. /* log2(size / 8) - used to calculate number of transfers */
  316. #define TS_SHIFT { \
  317. [XMIT_SZ_8BIT] = 0, \
  318. [XMIT_SZ_16BIT] = 1, \
  319. [XMIT_SZ_32BIT] = 2, \
  320. [XMIT_SZ_64BIT] = 3, \
  321. [XMIT_SZ_128BIT] = 4, \
  322. [XMIT_SZ_256BIT] = 5, \
  323. [XMIT_SZ_512BIT] = 6, \
  324. }
  325. #define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
  326. (((i) & 0xc) << (20 - 2)))
  327. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  328. {
  329. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  330. .addr = 0xe6c40020,
  331. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  332. .mid_rid = 0x21,
  333. }, {
  334. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  335. .addr = 0xe6c40024,
  336. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  337. .mid_rid = 0x22,
  338. }, {
  339. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  340. .addr = 0xe6c50020,
  341. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  342. .mid_rid = 0x25,
  343. }, {
  344. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  345. .addr = 0xe6c50024,
  346. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  347. .mid_rid = 0x26,
  348. }, {
  349. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  350. .addr = 0xe6c60020,
  351. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  352. .mid_rid = 0x29,
  353. }, {
  354. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  355. .addr = 0xe6c60024,
  356. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  357. .mid_rid = 0x2a,
  358. }, {
  359. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  360. .addr = 0xe6c70020,
  361. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  362. .mid_rid = 0x2d,
  363. }, {
  364. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  365. .addr = 0xe6c70024,
  366. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  367. .mid_rid = 0x2e,
  368. }, {
  369. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  370. .addr = 0xe6c80020,
  371. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  372. .mid_rid = 0x39,
  373. }, {
  374. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  375. .addr = 0xe6c80024,
  376. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  377. .mid_rid = 0x3a,
  378. }, {
  379. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  380. .addr = 0xe6cb0020,
  381. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  382. .mid_rid = 0x35,
  383. }, {
  384. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  385. .addr = 0xe6cb0024,
  386. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  387. .mid_rid = 0x36,
  388. }, {
  389. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  390. .addr = 0xe6c30040,
  391. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  392. .mid_rid = 0x3d,
  393. }, {
  394. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  395. .addr = 0xe6c30060,
  396. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
  397. .mid_rid = 0x3e,
  398. }, {
  399. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  400. .addr = 0xe6850030,
  401. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  402. .mid_rid = 0xc1,
  403. }, {
  404. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  405. .addr = 0xe6850030,
  406. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  407. .mid_rid = 0xc2,
  408. }, {
  409. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  410. .addr = 0xe6860030,
  411. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  412. .mid_rid = 0xc9,
  413. }, {
  414. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  415. .addr = 0xe6860030,
  416. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  417. .mid_rid = 0xca,
  418. }, {
  419. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  420. .addr = 0xe6870030,
  421. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  422. .mid_rid = 0xcd,
  423. }, {
  424. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  425. .addr = 0xe6870030,
  426. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
  427. .mid_rid = 0xce,
  428. }, {
  429. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  430. .addr = 0xe6bd0034,
  431. .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  432. .mid_rid = 0xd1,
  433. }, {
  434. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  435. .addr = 0xe6bd0034,
  436. .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
  437. .mid_rid = 0xd2,
  438. },
  439. };
  440. #define SH7372_CHCLR 0x220
  441. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  442. {
  443. .offset = 0,
  444. .dmars = 0,
  445. .dmars_bit = 0,
  446. .chclr_offset = SH7372_CHCLR + 0,
  447. }, {
  448. .offset = 0x10,
  449. .dmars = 0,
  450. .dmars_bit = 8,
  451. .chclr_offset = SH7372_CHCLR + 0x10,
  452. }, {
  453. .offset = 0x20,
  454. .dmars = 4,
  455. .dmars_bit = 0,
  456. .chclr_offset = SH7372_CHCLR + 0x20,
  457. }, {
  458. .offset = 0x30,
  459. .dmars = 4,
  460. .dmars_bit = 8,
  461. .chclr_offset = SH7372_CHCLR + 0x30,
  462. }, {
  463. .offset = 0x50,
  464. .dmars = 8,
  465. .dmars_bit = 0,
  466. .chclr_offset = SH7372_CHCLR + 0x50,
  467. }, {
  468. .offset = 0x60,
  469. .dmars = 8,
  470. .dmars_bit = 8,
  471. .chclr_offset = SH7372_CHCLR + 0x60,
  472. }
  473. };
  474. static const unsigned int ts_shift[] = TS_SHIFT;
  475. static struct sh_dmae_pdata dma_platform_data = {
  476. .slave = sh7372_dmae_slaves,
  477. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  478. .channel = sh7372_dmae_channels,
  479. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  480. .ts_low_shift = 3,
  481. .ts_low_mask = 0x18,
  482. .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
  483. .ts_high_mask = 0x00300000,
  484. .ts_shift = ts_shift,
  485. .ts_shift_num = ARRAY_SIZE(ts_shift),
  486. .dmaor_init = DMAOR_DME,
  487. .chclr_present = 1,
  488. };
  489. /* Resource order important! */
  490. static struct resource sh7372_dmae0_resources[] = {
  491. {
  492. /* Channel registers and DMAOR */
  493. .start = 0xfe008020,
  494. .end = 0xfe00828f,
  495. .flags = IORESOURCE_MEM,
  496. },
  497. {
  498. /* DMARSx */
  499. .start = 0xfe009000,
  500. .end = 0xfe00900b,
  501. .flags = IORESOURCE_MEM,
  502. },
  503. {
  504. .name = "error_irq",
  505. .start = evt2irq(0x20c0),
  506. .end = evt2irq(0x20c0),
  507. .flags = IORESOURCE_IRQ,
  508. },
  509. {
  510. /* IRQ for channels 0-5 */
  511. .start = evt2irq(0x2000),
  512. .end = evt2irq(0x20a0),
  513. .flags = IORESOURCE_IRQ,
  514. },
  515. };
  516. /* Resource order important! */
  517. static struct resource sh7372_dmae1_resources[] = {
  518. {
  519. /* Channel registers and DMAOR */
  520. .start = 0xfe018020,
  521. .end = 0xfe01828f,
  522. .flags = IORESOURCE_MEM,
  523. },
  524. {
  525. /* DMARSx */
  526. .start = 0xfe019000,
  527. .end = 0xfe01900b,
  528. .flags = IORESOURCE_MEM,
  529. },
  530. {
  531. .name = "error_irq",
  532. .start = evt2irq(0x21c0),
  533. .end = evt2irq(0x21c0),
  534. .flags = IORESOURCE_IRQ,
  535. },
  536. {
  537. /* IRQ for channels 0-5 */
  538. .start = evt2irq(0x2100),
  539. .end = evt2irq(0x21a0),
  540. .flags = IORESOURCE_IRQ,
  541. },
  542. };
  543. /* Resource order important! */
  544. static struct resource sh7372_dmae2_resources[] = {
  545. {
  546. /* Channel registers and DMAOR */
  547. .start = 0xfe028020,
  548. .end = 0xfe02828f,
  549. .flags = IORESOURCE_MEM,
  550. },
  551. {
  552. /* DMARSx */
  553. .start = 0xfe029000,
  554. .end = 0xfe02900b,
  555. .flags = IORESOURCE_MEM,
  556. },
  557. {
  558. .name = "error_irq",
  559. .start = evt2irq(0x22c0),
  560. .end = evt2irq(0x22c0),
  561. .flags = IORESOURCE_IRQ,
  562. },
  563. {
  564. /* IRQ for channels 0-5 */
  565. .start = evt2irq(0x2200),
  566. .end = evt2irq(0x22a0),
  567. .flags = IORESOURCE_IRQ,
  568. },
  569. };
  570. static struct platform_device dma0_device = {
  571. .name = "sh-dma-engine",
  572. .id = 0,
  573. .resource = sh7372_dmae0_resources,
  574. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  575. .dev = {
  576. .platform_data = &dma_platform_data,
  577. },
  578. };
  579. static struct platform_device dma1_device = {
  580. .name = "sh-dma-engine",
  581. .id = 1,
  582. .resource = sh7372_dmae1_resources,
  583. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  584. .dev = {
  585. .platform_data = &dma_platform_data,
  586. },
  587. };
  588. static struct platform_device dma2_device = {
  589. .name = "sh-dma-engine",
  590. .id = 2,
  591. .resource = sh7372_dmae2_resources,
  592. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  593. .dev = {
  594. .platform_data = &dma_platform_data,
  595. },
  596. };
  597. /*
  598. * USB-DMAC
  599. */
  600. unsigned int usbts_shift[] = {3, 4, 5};
  601. enum {
  602. XMIT_SZ_8BYTE = 0,
  603. XMIT_SZ_16BYTE = 1,
  604. XMIT_SZ_32BYTE = 2,
  605. };
  606. #define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
  607. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  608. {
  609. .offset = 0,
  610. }, {
  611. .offset = 0x20,
  612. },
  613. };
  614. /* USB DMAC0 */
  615. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  616. {
  617. .slave_id = SHDMA_SLAVE_USB0_TX,
  618. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  619. }, {
  620. .slave_id = SHDMA_SLAVE_USB0_RX,
  621. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  622. },
  623. };
  624. static struct sh_dmae_pdata usb_dma0_platform_data = {
  625. .slave = sh7372_usb_dmae0_slaves,
  626. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  627. .channel = sh7372_usb_dmae_channels,
  628. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  629. .ts_low_shift = 6,
  630. .ts_low_mask = 0xc0,
  631. .ts_high_shift = 0,
  632. .ts_high_mask = 0,
  633. .ts_shift = usbts_shift,
  634. .ts_shift_num = ARRAY_SIZE(usbts_shift),
  635. .dmaor_init = DMAOR_DME,
  636. .chcr_offset = 0x14,
  637. .chcr_ie_bit = 1 << 5,
  638. .dmaor_is_32bit = 1,
  639. .needs_tend_set = 1,
  640. .no_dmars = 1,
  641. .slave_only = 1,
  642. };
  643. static struct resource sh7372_usb_dmae0_resources[] = {
  644. {
  645. /* Channel registers and DMAOR */
  646. .start = 0xe68a0020,
  647. .end = 0xe68a0064 - 1,
  648. .flags = IORESOURCE_MEM,
  649. },
  650. {
  651. /* VCR/SWR/DMICR */
  652. .start = 0xe68a0000,
  653. .end = 0xe68a0014 - 1,
  654. .flags = IORESOURCE_MEM,
  655. },
  656. {
  657. /* IRQ for channels */
  658. .start = evt2irq(0x0a00),
  659. .end = evt2irq(0x0a00),
  660. .flags = IORESOURCE_IRQ,
  661. },
  662. };
  663. static struct platform_device usb_dma0_device = {
  664. .name = "sh-dma-engine",
  665. .id = 3,
  666. .resource = sh7372_usb_dmae0_resources,
  667. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  668. .dev = {
  669. .platform_data = &usb_dma0_platform_data,
  670. },
  671. };
  672. /* USB DMAC1 */
  673. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  674. {
  675. .slave_id = SHDMA_SLAVE_USB1_TX,
  676. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  677. }, {
  678. .slave_id = SHDMA_SLAVE_USB1_RX,
  679. .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
  680. },
  681. };
  682. static struct sh_dmae_pdata usb_dma1_platform_data = {
  683. .slave = sh7372_usb_dmae1_slaves,
  684. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  685. .channel = sh7372_usb_dmae_channels,
  686. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  687. .ts_low_shift = 6,
  688. .ts_low_mask = 0xc0,
  689. .ts_high_shift = 0,
  690. .ts_high_mask = 0,
  691. .ts_shift = usbts_shift,
  692. .ts_shift_num = ARRAY_SIZE(usbts_shift),
  693. .dmaor_init = DMAOR_DME,
  694. .chcr_offset = 0x14,
  695. .chcr_ie_bit = 1 << 5,
  696. .dmaor_is_32bit = 1,
  697. .needs_tend_set = 1,
  698. .no_dmars = 1,
  699. .slave_only = 1,
  700. };
  701. static struct resource sh7372_usb_dmae1_resources[] = {
  702. {
  703. /* Channel registers and DMAOR */
  704. .start = 0xe68c0020,
  705. .end = 0xe68c0064 - 1,
  706. .flags = IORESOURCE_MEM,
  707. },
  708. {
  709. /* VCR/SWR/DMICR */
  710. .start = 0xe68c0000,
  711. .end = 0xe68c0014 - 1,
  712. .flags = IORESOURCE_MEM,
  713. },
  714. {
  715. /* IRQ for channels */
  716. .start = evt2irq(0x1d00),
  717. .end = evt2irq(0x1d00),
  718. .flags = IORESOURCE_IRQ,
  719. },
  720. };
  721. static struct platform_device usb_dma1_device = {
  722. .name = "sh-dma-engine",
  723. .id = 4,
  724. .resource = sh7372_usb_dmae1_resources,
  725. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  726. .dev = {
  727. .platform_data = &usb_dma1_platform_data,
  728. },
  729. };
  730. /* VPU */
  731. static struct uio_info vpu_platform_data = {
  732. .name = "VPU5HG",
  733. .version = "0",
  734. .irq = intcs_evt2irq(0x980),
  735. };
  736. static struct resource vpu_resources[] = {
  737. [0] = {
  738. .name = "VPU",
  739. .start = 0xfe900000,
  740. .end = 0xfe900157,
  741. .flags = IORESOURCE_MEM,
  742. },
  743. };
  744. static struct platform_device vpu_device = {
  745. .name = "uio_pdrv_genirq",
  746. .id = 0,
  747. .dev = {
  748. .platform_data = &vpu_platform_data,
  749. },
  750. .resource = vpu_resources,
  751. .num_resources = ARRAY_SIZE(vpu_resources),
  752. };
  753. /* VEU0 */
  754. static struct uio_info veu0_platform_data = {
  755. .name = "VEU0",
  756. .version = "0",
  757. .irq = intcs_evt2irq(0x700),
  758. };
  759. static struct resource veu0_resources[] = {
  760. [0] = {
  761. .name = "VEU0",
  762. .start = 0xfe920000,
  763. .end = 0xfe9200cb,
  764. .flags = IORESOURCE_MEM,
  765. },
  766. };
  767. static struct platform_device veu0_device = {
  768. .name = "uio_pdrv_genirq",
  769. .id = 1,
  770. .dev = {
  771. .platform_data = &veu0_platform_data,
  772. },
  773. .resource = veu0_resources,
  774. .num_resources = ARRAY_SIZE(veu0_resources),
  775. };
  776. /* VEU1 */
  777. static struct uio_info veu1_platform_data = {
  778. .name = "VEU1",
  779. .version = "0",
  780. .irq = intcs_evt2irq(0x720),
  781. };
  782. static struct resource veu1_resources[] = {
  783. [0] = {
  784. .name = "VEU1",
  785. .start = 0xfe924000,
  786. .end = 0xfe9240cb,
  787. .flags = IORESOURCE_MEM,
  788. },
  789. };
  790. static struct platform_device veu1_device = {
  791. .name = "uio_pdrv_genirq",
  792. .id = 2,
  793. .dev = {
  794. .platform_data = &veu1_platform_data,
  795. },
  796. .resource = veu1_resources,
  797. .num_resources = ARRAY_SIZE(veu1_resources),
  798. };
  799. /* VEU2 */
  800. static struct uio_info veu2_platform_data = {
  801. .name = "VEU2",
  802. .version = "0",
  803. .irq = intcs_evt2irq(0x740),
  804. };
  805. static struct resource veu2_resources[] = {
  806. [0] = {
  807. .name = "VEU2",
  808. .start = 0xfe928000,
  809. .end = 0xfe928307,
  810. .flags = IORESOURCE_MEM,
  811. },
  812. };
  813. static struct platform_device veu2_device = {
  814. .name = "uio_pdrv_genirq",
  815. .id = 3,
  816. .dev = {
  817. .platform_data = &veu2_platform_data,
  818. },
  819. .resource = veu2_resources,
  820. .num_resources = ARRAY_SIZE(veu2_resources),
  821. };
  822. /* VEU3 */
  823. static struct uio_info veu3_platform_data = {
  824. .name = "VEU3",
  825. .version = "0",
  826. .irq = intcs_evt2irq(0x760),
  827. };
  828. static struct resource veu3_resources[] = {
  829. [0] = {
  830. .name = "VEU3",
  831. .start = 0xfe92c000,
  832. .end = 0xfe92c307,
  833. .flags = IORESOURCE_MEM,
  834. },
  835. };
  836. static struct platform_device veu3_device = {
  837. .name = "uio_pdrv_genirq",
  838. .id = 4,
  839. .dev = {
  840. .platform_data = &veu3_platform_data,
  841. },
  842. .resource = veu3_resources,
  843. .num_resources = ARRAY_SIZE(veu3_resources),
  844. };
  845. /* JPU */
  846. static struct uio_info jpu_platform_data = {
  847. .name = "JPU",
  848. .version = "0",
  849. .irq = intcs_evt2irq(0x560),
  850. };
  851. static struct resource jpu_resources[] = {
  852. [0] = {
  853. .name = "JPU",
  854. .start = 0xfe980000,
  855. .end = 0xfe9902d3,
  856. .flags = IORESOURCE_MEM,
  857. },
  858. };
  859. static struct platform_device jpu_device = {
  860. .name = "uio_pdrv_genirq",
  861. .id = 5,
  862. .dev = {
  863. .platform_data = &jpu_platform_data,
  864. },
  865. .resource = jpu_resources,
  866. .num_resources = ARRAY_SIZE(jpu_resources),
  867. };
  868. /* SPU2DSP0 */
  869. static struct uio_info spu0_platform_data = {
  870. .name = "SPU2DSP0",
  871. .version = "0",
  872. .irq = evt2irq(0x1800),
  873. };
  874. static struct resource spu0_resources[] = {
  875. [0] = {
  876. .name = "SPU2DSP0",
  877. .start = 0xfe200000,
  878. .end = 0xfe2fffff,
  879. .flags = IORESOURCE_MEM,
  880. },
  881. };
  882. static struct platform_device spu0_device = {
  883. .name = "uio_pdrv_genirq",
  884. .id = 6,
  885. .dev = {
  886. .platform_data = &spu0_platform_data,
  887. },
  888. .resource = spu0_resources,
  889. .num_resources = ARRAY_SIZE(spu0_resources),
  890. };
  891. /* SPU2DSP1 */
  892. static struct uio_info spu1_platform_data = {
  893. .name = "SPU2DSP1",
  894. .version = "0",
  895. .irq = evt2irq(0x1820),
  896. };
  897. static struct resource spu1_resources[] = {
  898. [0] = {
  899. .name = "SPU2DSP1",
  900. .start = 0xfe300000,
  901. .end = 0xfe3fffff,
  902. .flags = IORESOURCE_MEM,
  903. },
  904. };
  905. static struct platform_device spu1_device = {
  906. .name = "uio_pdrv_genirq",
  907. .id = 7,
  908. .dev = {
  909. .platform_data = &spu1_platform_data,
  910. },
  911. .resource = spu1_resources,
  912. .num_resources = ARRAY_SIZE(spu1_resources),
  913. };
  914. static struct platform_device *sh7372_early_devices[] __initdata = {
  915. &scif0_device,
  916. &scif1_device,
  917. &scif2_device,
  918. &scif3_device,
  919. &scif4_device,
  920. &scif5_device,
  921. &scif6_device,
  922. &cmt2_device,
  923. &tmu00_device,
  924. &tmu01_device,
  925. };
  926. static struct platform_device *sh7372_late_devices[] __initdata = {
  927. &iic0_device,
  928. &iic1_device,
  929. &dma0_device,
  930. &dma1_device,
  931. &dma2_device,
  932. &usb_dma0_device,
  933. &usb_dma1_device,
  934. &vpu_device,
  935. &veu0_device,
  936. &veu1_device,
  937. &veu2_device,
  938. &veu3_device,
  939. &jpu_device,
  940. &spu0_device,
  941. &spu1_device,
  942. };
  943. void __init sh7372_add_standard_devices(void)
  944. {
  945. sh7372_init_pm_domain(&sh7372_a4lc);
  946. sh7372_init_pm_domain(&sh7372_a4mp);
  947. sh7372_init_pm_domain(&sh7372_d4);
  948. sh7372_init_pm_domain(&sh7372_a4r);
  949. sh7372_init_pm_domain(&sh7372_a3rv);
  950. sh7372_init_pm_domain(&sh7372_a3ri);
  951. sh7372_init_pm_domain(&sh7372_a4s);
  952. sh7372_init_pm_domain(&sh7372_a3sp);
  953. sh7372_init_pm_domain(&sh7372_a3sg);
  954. sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
  955. sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc);
  956. sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg);
  957. sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp);
  958. platform_add_devices(sh7372_early_devices,
  959. ARRAY_SIZE(sh7372_early_devices));
  960. platform_add_devices(sh7372_late_devices,
  961. ARRAY_SIZE(sh7372_late_devices));
  962. sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
  963. sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
  964. sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
  965. sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
  966. sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
  967. sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
  968. sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
  969. sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
  970. sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
  971. sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
  972. sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
  973. sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
  974. sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
  975. sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
  976. sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
  977. sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
  978. sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device);
  979. sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device);
  980. sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device);
  981. sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device);
  982. sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device);
  983. sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device);
  984. }
  985. static void __init sh7372_earlytimer_init(void)
  986. {
  987. sh7372_clock_init();
  988. shmobile_earlytimer_init();
  989. }
  990. void __init sh7372_add_early_devices(void)
  991. {
  992. early_platform_add_devices(sh7372_early_devices,
  993. ARRAY_SIZE(sh7372_early_devices));
  994. /* setup early console here as well */
  995. shmobile_setup_console();
  996. /* override timer setup with soc-specific code */
  997. shmobile_timer.init = sh7372_earlytimer_init;
  998. }