common.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. // SPDX-License-Identifier: GPL-2.0+
  2. //
  3. // Copyright (c) 2004-2005 Simtec Electronics
  4. // http://www.simtec.co.uk/products/SWLINUX/
  5. // Ben Dooks <ben@simtec.co.uk>
  6. //
  7. // Common code for S3C24XX machines
  8. #include <linux/dma-mapping.h>
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/ioport.h>
  13. #include <linux/serial_core.h>
  14. #include <linux/serial_s3c.h>
  15. #include <clocksource/samsung_pwm.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/io.h>
  19. #include <linux/platform_data/dma-s3c24xx.h>
  20. #include <linux/dmaengine.h>
  21. #include <mach/hardware.h>
  22. #include <mach/regs-clock.h>
  23. #include <asm/irq.h>
  24. #include <asm/cacheflush.h>
  25. #include <asm/system_info.h>
  26. #include <asm/system_misc.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <mach/regs-gpio.h>
  30. #include <mach/dma.h>
  31. #include <plat/cpu.h>
  32. #include <plat/devs.h>
  33. #include <plat/cpu-freq.h>
  34. #include <plat/pwm-core.h>
  35. #include "common.h"
  36. /* table of supported CPUs */
  37. static const char name_s3c2410[] = "S3C2410";
  38. static const char name_s3c2412[] = "S3C2412";
  39. static const char name_s3c2416[] = "S3C2416/S3C2450";
  40. static const char name_s3c2440[] = "S3C2440";
  41. static const char name_s3c2442[] = "S3C2442";
  42. static const char name_s3c2442b[] = "S3C2442B";
  43. static const char name_s3c2443[] = "S3C2443";
  44. static const char name_s3c2410a[] = "S3C2410A";
  45. static const char name_s3c2440a[] = "S3C2440A";
  46. static struct cpu_table cpu_ids[] __initdata = {
  47. {
  48. .idcode = 0x32410000,
  49. .idmask = 0xffffffff,
  50. .map_io = s3c2410_map_io,
  51. .init_uarts = s3c2410_init_uarts,
  52. .init = s3c2410_init,
  53. .name = name_s3c2410
  54. },
  55. {
  56. .idcode = 0x32410002,
  57. .idmask = 0xffffffff,
  58. .map_io = s3c2410_map_io,
  59. .init_uarts = s3c2410_init_uarts,
  60. .init = s3c2410a_init,
  61. .name = name_s3c2410a
  62. },
  63. {
  64. .idcode = 0x32440000,
  65. .idmask = 0xffffffff,
  66. .map_io = s3c2440_map_io,
  67. .init_uarts = s3c244x_init_uarts,
  68. .init = s3c2440_init,
  69. .name = name_s3c2440
  70. },
  71. {
  72. .idcode = 0x32440001,
  73. .idmask = 0xffffffff,
  74. .map_io = s3c2440_map_io,
  75. .init_uarts = s3c244x_init_uarts,
  76. .init = s3c2440_init,
  77. .name = name_s3c2440a
  78. },
  79. {
  80. .idcode = 0x32440aaa,
  81. .idmask = 0xffffffff,
  82. .map_io = s3c2442_map_io,
  83. .init_uarts = s3c244x_init_uarts,
  84. .init = s3c2442_init,
  85. .name = name_s3c2442
  86. },
  87. {
  88. .idcode = 0x32440aab,
  89. .idmask = 0xffffffff,
  90. .map_io = s3c2442_map_io,
  91. .init_uarts = s3c244x_init_uarts,
  92. .init = s3c2442_init,
  93. .name = name_s3c2442b
  94. },
  95. {
  96. .idcode = 0x32412001,
  97. .idmask = 0xffffffff,
  98. .map_io = s3c2412_map_io,
  99. .init_uarts = s3c2412_init_uarts,
  100. .init = s3c2412_init,
  101. .name = name_s3c2412,
  102. },
  103. { /* a newer version of the s3c2412 */
  104. .idcode = 0x32412003,
  105. .idmask = 0xffffffff,
  106. .map_io = s3c2412_map_io,
  107. .init_uarts = s3c2412_init_uarts,
  108. .init = s3c2412_init,
  109. .name = name_s3c2412,
  110. },
  111. { /* a strange version of the s3c2416 */
  112. .idcode = 0x32450003,
  113. .idmask = 0xffffffff,
  114. .map_io = s3c2416_map_io,
  115. .init_uarts = s3c2416_init_uarts,
  116. .init = s3c2416_init,
  117. .name = name_s3c2416,
  118. },
  119. {
  120. .idcode = 0x32443001,
  121. .idmask = 0xffffffff,
  122. .map_io = s3c2443_map_io,
  123. .init_uarts = s3c2443_init_uarts,
  124. .init = s3c2443_init,
  125. .name = name_s3c2443,
  126. },
  127. };
  128. /* minimal IO mapping */
  129. static struct map_desc s3c_iodesc[] __initdata = {
  130. IODESC_ENT(GPIO),
  131. IODESC_ENT(IRQ),
  132. IODESC_ENT(MEMCTRL),
  133. IODESC_ENT(UART)
  134. };
  135. /* read cpu identificaiton code */
  136. static unsigned long s3c24xx_read_idcode_v5(void)
  137. {
  138. #if defined(CONFIG_CPU_S3C2416)
  139. /* s3c2416 is v5, with S3C24XX_GSTATUS1 instead of S3C2412_GSTATUS1 */
  140. u32 gs = __raw_readl(S3C24XX_GSTATUS1);
  141. /* test for s3c2416 or similar device */
  142. if ((gs >> 16) == 0x3245)
  143. return gs;
  144. #endif
  145. #if defined(CONFIG_CPU_S3C2412)
  146. return __raw_readl(S3C2412_GSTATUS1);
  147. #else
  148. return 1UL; /* don't look like an 2400 */
  149. #endif
  150. }
  151. static unsigned long s3c24xx_read_idcode_v4(void)
  152. {
  153. return __raw_readl(S3C2410_GSTATUS1);
  154. }
  155. static void s3c24xx_default_idle(void)
  156. {
  157. unsigned long tmp = 0;
  158. int i;
  159. /* idle the system by using the idle mode which will wait for an
  160. * interrupt to happen before restarting the system.
  161. */
  162. /* Warning: going into idle state upsets jtag scanning */
  163. __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
  164. S3C2410_CLKCON);
  165. /* the samsung port seems to do a loop and then unset idle.. */
  166. for (i = 0; i < 50; i++)
  167. tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
  168. /* this bit is not cleared on re-start... */
  169. __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
  170. S3C2410_CLKCON);
  171. }
  172. static struct samsung_pwm_variant s3c24xx_pwm_variant = {
  173. .bits = 16,
  174. .div_base = 1,
  175. .has_tint_cstat = false,
  176. .tclk_mask = (1 << 4),
  177. };
  178. void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
  179. {
  180. arm_pm_idle = s3c24xx_default_idle;
  181. /* initialise the io descriptors we need for initialisation */
  182. iotable_init(mach_desc, size);
  183. iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
  184. if (cpu_architecture() >= CPU_ARCH_ARMv5) {
  185. samsung_cpu_id = s3c24xx_read_idcode_v5();
  186. } else {
  187. samsung_cpu_id = s3c24xx_read_idcode_v4();
  188. }
  189. s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  190. samsung_pwm_set_platdata(&s3c24xx_pwm_variant);
  191. }
  192. void __init samsung_set_timer_source(unsigned int event, unsigned int source)
  193. {
  194. s3c24xx_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1;
  195. s3c24xx_pwm_variant.output_mask &= ~(BIT(event) | BIT(source));
  196. }
  197. void __init samsung_timer_init(void)
  198. {
  199. unsigned int timer_irqs[SAMSUNG_PWM_NUM] = {
  200. IRQ_TIMER0, IRQ_TIMER1, IRQ_TIMER2, IRQ_TIMER3, IRQ_TIMER4,
  201. };
  202. samsung_pwm_clocksource_init(S3C_VA_TIMER,
  203. timer_irqs, &s3c24xx_pwm_variant);
  204. }
  205. /* Serial port registrations */
  206. #define S3C2410_PA_UART0 (S3C24XX_PA_UART)
  207. #define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 )
  208. #define S3C2410_PA_UART2 (S3C24XX_PA_UART + 0x8000 )
  209. #define S3C2443_PA_UART3 (S3C24XX_PA_UART + 0xC000 )
  210. static struct resource s3c2410_uart0_resource[] = {
  211. [0] = DEFINE_RES_MEM(S3C2410_PA_UART0, SZ_16K),
  212. [1] = DEFINE_RES_NAMED(IRQ_S3CUART_RX0, \
  213. IRQ_S3CUART_ERR0 - IRQ_S3CUART_RX0 + 1, \
  214. NULL, IORESOURCE_IRQ)
  215. };
  216. static struct resource s3c2410_uart1_resource[] = {
  217. [0] = DEFINE_RES_MEM(S3C2410_PA_UART1, SZ_16K),
  218. [1] = DEFINE_RES_NAMED(IRQ_S3CUART_RX1, \
  219. IRQ_S3CUART_ERR1 - IRQ_S3CUART_RX1 + 1, \
  220. NULL, IORESOURCE_IRQ)
  221. };
  222. static struct resource s3c2410_uart2_resource[] = {
  223. [0] = DEFINE_RES_MEM(S3C2410_PA_UART2, SZ_16K),
  224. [1] = DEFINE_RES_NAMED(IRQ_S3CUART_RX2, \
  225. IRQ_S3CUART_ERR2 - IRQ_S3CUART_RX2 + 1, \
  226. NULL, IORESOURCE_IRQ)
  227. };
  228. static struct resource s3c2410_uart3_resource[] = {
  229. [0] = DEFINE_RES_MEM(S3C2443_PA_UART3, SZ_16K),
  230. [1] = DEFINE_RES_NAMED(IRQ_S3CUART_RX3, \
  231. IRQ_S3CUART_ERR3 - IRQ_S3CUART_RX3 + 1, \
  232. NULL, IORESOURCE_IRQ)
  233. };
  234. struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
  235. [0] = {
  236. .resources = s3c2410_uart0_resource,
  237. .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
  238. },
  239. [1] = {
  240. .resources = s3c2410_uart1_resource,
  241. .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
  242. },
  243. [2] = {
  244. .resources = s3c2410_uart2_resource,
  245. .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
  246. },
  247. [3] = {
  248. .resources = s3c2410_uart3_resource,
  249. .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
  250. },
  251. };
  252. #define s3c24xx_device_dma_mask (*((u64[]) { DMA_BIT_MASK(32) }))
  253. #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \
  254. defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442)
  255. static struct resource s3c2410_dma_resource[] = {
  256. [0] = DEFINE_RES_MEM(S3C24XX_PA_DMA, S3C24XX_SZ_DMA),
  257. [1] = DEFINE_RES_IRQ(IRQ_DMA0),
  258. [2] = DEFINE_RES_IRQ(IRQ_DMA1),
  259. [3] = DEFINE_RES_IRQ(IRQ_DMA2),
  260. [4] = DEFINE_RES_IRQ(IRQ_DMA3),
  261. };
  262. #endif
  263. #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2442)
  264. static struct s3c24xx_dma_channel s3c2410_dma_channels[DMACH_MAX] = {
  265. [DMACH_XD0] = { S3C24XX_DMA_AHB, true, S3C24XX_DMA_CHANREQ(0, 0), },
  266. [DMACH_XD1] = { S3C24XX_DMA_AHB, true, S3C24XX_DMA_CHANREQ(0, 1), },
  267. [DMACH_SDI] = { S3C24XX_DMA_APB, false, S3C24XX_DMA_CHANREQ(2, 0) |
  268. S3C24XX_DMA_CHANREQ(2, 2) |
  269. S3C24XX_DMA_CHANREQ(1, 3),
  270. },
  271. [DMACH_SPI0] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(3, 1), },
  272. [DMACH_SPI1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(2, 3), },
  273. [DMACH_UART0] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(1, 0), },
  274. [DMACH_UART1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(1, 1), },
  275. [DMACH_UART2] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(0, 3), },
  276. [DMACH_TIMER] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(3, 0) |
  277. S3C24XX_DMA_CHANREQ(3, 2) |
  278. S3C24XX_DMA_CHANREQ(3, 3),
  279. },
  280. [DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(2, 1) |
  281. S3C24XX_DMA_CHANREQ(1, 2),
  282. },
  283. [DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(0, 2), },
  284. [DMACH_USB_EP1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 0), },
  285. [DMACH_USB_EP2] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 1), },
  286. [DMACH_USB_EP3] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 2), },
  287. [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), },
  288. };
  289. static const struct dma_slave_map s3c2410_dma_slave_map[] = {
  290. { "s3c2410-sdi", "rx-tx", (void *)DMACH_SDI },
  291. { "s3c2410-spi.0", "rx", (void *)DMACH_SPI0_RX },
  292. { "s3c2410-spi.0", "tx", (void *)DMACH_SPI0_TX },
  293. { "s3c2410-spi.1", "rx", (void *)DMACH_SPI1_RX },
  294. { "s3c2410-spi.1", "tx", (void *)DMACH_SPI1_TX },
  295. /*
  296. * The DMA request source[1] (DMACH_UARTx_SRC2) are
  297. * not used in the UART driver.
  298. */
  299. { "s3c2410-uart.0", "rx", (void *)DMACH_UART0 },
  300. { "s3c2410-uart.0", "tx", (void *)DMACH_UART0 },
  301. { "s3c2410-uart.1", "rx", (void *)DMACH_UART1 },
  302. { "s3c2410-uart.1", "tx", (void *)DMACH_UART1 },
  303. { "s3c2410-uart.2", "rx", (void *)DMACH_UART2 },
  304. { "s3c2410-uart.2", "tx", (void *)DMACH_UART2 },
  305. { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
  306. { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
  307. { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
  308. { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
  309. { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
  310. { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
  311. { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
  312. { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
  313. { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
  314. { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
  315. };
  316. static struct s3c24xx_dma_platdata s3c2410_dma_platdata = {
  317. .num_phy_channels = 4,
  318. .channels = s3c2410_dma_channels,
  319. .num_channels = DMACH_MAX,
  320. .slave_map = s3c2410_dma_slave_map,
  321. .slavecnt = ARRAY_SIZE(s3c2410_dma_slave_map),
  322. };
  323. struct platform_device s3c2410_device_dma = {
  324. .name = "s3c2410-dma",
  325. .id = 0,
  326. .num_resources = ARRAY_SIZE(s3c2410_dma_resource),
  327. .resource = s3c2410_dma_resource,
  328. .dev = {
  329. .dma_mask = &s3c24xx_device_dma_mask,
  330. .coherent_dma_mask = DMA_BIT_MASK(32),
  331. .platform_data = &s3c2410_dma_platdata,
  332. },
  333. };
  334. #endif
  335. #ifdef CONFIG_CPU_S3C2412
  336. static struct s3c24xx_dma_channel s3c2412_dma_channels[DMACH_MAX] = {
  337. [DMACH_XD0] = { S3C24XX_DMA_AHB, true, 17 },
  338. [DMACH_XD1] = { S3C24XX_DMA_AHB, true, 18 },
  339. [DMACH_SDI] = { S3C24XX_DMA_APB, false, 10 },
  340. [DMACH_SPI0_RX] = { S3C24XX_DMA_APB, true, 1 },
  341. [DMACH_SPI0_TX] = { S3C24XX_DMA_APB, true, 0 },
  342. [DMACH_SPI1_RX] = { S3C24XX_DMA_APB, true, 3 },
  343. [DMACH_SPI1_TX] = { S3C24XX_DMA_APB, true, 2 },
  344. [DMACH_UART0] = { S3C24XX_DMA_APB, true, 19 },
  345. [DMACH_UART1] = { S3C24XX_DMA_APB, true, 21 },
  346. [DMACH_UART2] = { S3C24XX_DMA_APB, true, 23 },
  347. [DMACH_UART0_SRC2] = { S3C24XX_DMA_APB, true, 20 },
  348. [DMACH_UART1_SRC2] = { S3C24XX_DMA_APB, true, 22 },
  349. [DMACH_UART2_SRC2] = { S3C24XX_DMA_APB, true, 24 },
  350. [DMACH_TIMER] = { S3C24XX_DMA_APB, true, 9 },
  351. [DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, 5 },
  352. [DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, 4 },
  353. [DMACH_USB_EP1] = { S3C24XX_DMA_APB, true, 13 },
  354. [DMACH_USB_EP2] = { S3C24XX_DMA_APB, true, 14 },
  355. [DMACH_USB_EP3] = { S3C24XX_DMA_APB, true, 15 },
  356. [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 },
  357. };
  358. static const struct dma_slave_map s3c2412_dma_slave_map[] = {
  359. { "s3c2412-sdi", "rx-tx", (void *)DMACH_SDI },
  360. { "s3c2412-spi.0", "rx", (void *)DMACH_SPI0_RX },
  361. { "s3c2412-spi.0", "tx", (void *)DMACH_SPI0_TX },
  362. { "s3c2412-spi.1", "rx", (void *)DMACH_SPI1_RX },
  363. { "s3c2412-spi.1", "tx", (void *)DMACH_SPI1_TX },
  364. { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
  365. { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
  366. { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
  367. { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
  368. { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
  369. { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
  370. { "s3c2412-iis", "rx", (void *)DMACH_I2S_IN },
  371. { "s3c2412-iis", "tx", (void *)DMACH_I2S_OUT },
  372. { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
  373. { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
  374. { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
  375. { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
  376. { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
  377. { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
  378. { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
  379. { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
  380. };
  381. static struct s3c24xx_dma_platdata s3c2412_dma_platdata = {
  382. .num_phy_channels = 4,
  383. .channels = s3c2412_dma_channels,
  384. .num_channels = DMACH_MAX,
  385. .slave_map = s3c2412_dma_slave_map,
  386. .slavecnt = ARRAY_SIZE(s3c2412_dma_slave_map),
  387. };
  388. struct platform_device s3c2412_device_dma = {
  389. .name = "s3c2412-dma",
  390. .id = 0,
  391. .num_resources = ARRAY_SIZE(s3c2410_dma_resource),
  392. .resource = s3c2410_dma_resource,
  393. .dev = {
  394. .dma_mask = &s3c24xx_device_dma_mask,
  395. .coherent_dma_mask = DMA_BIT_MASK(32),
  396. .platform_data = &s3c2412_dma_platdata,
  397. },
  398. };
  399. #endif
  400. #if defined(CONFIG_CPU_S3C2440)
  401. static struct s3c24xx_dma_channel s3c2440_dma_channels[DMACH_MAX] = {
  402. [DMACH_XD0] = { S3C24XX_DMA_AHB, true, S3C24XX_DMA_CHANREQ(0, 0), },
  403. [DMACH_XD1] = { S3C24XX_DMA_AHB, true, S3C24XX_DMA_CHANREQ(0, 1), },
  404. [DMACH_SDI] = { S3C24XX_DMA_APB, false, S3C24XX_DMA_CHANREQ(2, 0) |
  405. S3C24XX_DMA_CHANREQ(6, 1) |
  406. S3C24XX_DMA_CHANREQ(2, 2) |
  407. S3C24XX_DMA_CHANREQ(1, 3),
  408. },
  409. [DMACH_SPI0] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(3, 1), },
  410. [DMACH_SPI1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(2, 3), },
  411. [DMACH_UART0] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(1, 0), },
  412. [DMACH_UART1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(1, 1), },
  413. [DMACH_UART2] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(0, 3), },
  414. [DMACH_TIMER] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(3, 0) |
  415. S3C24XX_DMA_CHANREQ(3, 2) |
  416. S3C24XX_DMA_CHANREQ(3, 3),
  417. },
  418. [DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(2, 1) |
  419. S3C24XX_DMA_CHANREQ(1, 2),
  420. },
  421. [DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(5, 0) |
  422. S3C24XX_DMA_CHANREQ(0, 2),
  423. },
  424. [DMACH_PCM_IN] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(6, 0) |
  425. S3C24XX_DMA_CHANREQ(5, 2),
  426. },
  427. [DMACH_PCM_OUT] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(5, 1) |
  428. S3C24XX_DMA_CHANREQ(6, 3),
  429. },
  430. [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(6, 2) |
  431. S3C24XX_DMA_CHANREQ(5, 3),
  432. },
  433. [DMACH_USB_EP1] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 0), },
  434. [DMACH_USB_EP2] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 1), },
  435. [DMACH_USB_EP3] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 2), },
  436. [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), },
  437. };
  438. static const struct dma_slave_map s3c2440_dma_slave_map[] = {
  439. /* TODO: DMACH_XD0 */
  440. /* TODO: DMACH_XD1 */
  441. { "s3c2440-sdi", "rx-tx", (void *)DMACH_SDI },
  442. { "s3c2410-spi.0", "rx", (void *)DMACH_SPI0 },
  443. { "s3c2410-spi.0", "tx", (void *)DMACH_SPI0 },
  444. { "s3c2410-spi.1", "rx", (void *)DMACH_SPI1 },
  445. { "s3c2410-spi.1", "tx", (void *)DMACH_SPI1 },
  446. { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
  447. { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
  448. { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
  449. { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
  450. { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
  451. { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
  452. { "s3c2440-uart.3", "rx", (void *)DMACH_UART3 },
  453. { "s3c2440-uart.3", "tx", (void *)DMACH_UART3 },
  454. /* TODO: DMACH_TIMER */
  455. { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
  456. { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
  457. { "samsung-ac97", "rx", (void *)DMACH_PCM_IN },
  458. { "samsung-ac97", "tx", (void *)DMACH_PCM_OUT },
  459. { "samsung-ac97", "rx", (void *)DMACH_MIC_IN },
  460. { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
  461. { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
  462. { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
  463. { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
  464. { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
  465. { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
  466. { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
  467. { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
  468. };
  469. static struct s3c24xx_dma_platdata s3c2440_dma_platdata = {
  470. .num_phy_channels = 4,
  471. .channels = s3c2440_dma_channels,
  472. .num_channels = DMACH_MAX,
  473. .slave_map = s3c2440_dma_slave_map,
  474. .slavecnt = ARRAY_SIZE(s3c2440_dma_slave_map),
  475. };
  476. struct platform_device s3c2440_device_dma = {
  477. .name = "s3c2410-dma",
  478. .id = 0,
  479. .num_resources = ARRAY_SIZE(s3c2410_dma_resource),
  480. .resource = s3c2410_dma_resource,
  481. .dev = {
  482. .dma_mask = &s3c24xx_device_dma_mask,
  483. .coherent_dma_mask = DMA_BIT_MASK(32),
  484. .platform_data = &s3c2440_dma_platdata,
  485. },
  486. };
  487. #endif
  488. #if defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
  489. static struct resource s3c2443_dma_resource[] = {
  490. [0] = DEFINE_RES_MEM(S3C24XX_PA_DMA, S3C24XX_SZ_DMA),
  491. [1] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA0),
  492. [2] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA1),
  493. [3] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA2),
  494. [4] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA3),
  495. [5] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA4),
  496. [6] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA5),
  497. };
  498. static struct s3c24xx_dma_channel s3c2443_dma_channels[DMACH_MAX] = {
  499. [DMACH_XD0] = { S3C24XX_DMA_AHB, true, 17 },
  500. [DMACH_XD1] = { S3C24XX_DMA_AHB, true, 18 },
  501. [DMACH_SDI] = { S3C24XX_DMA_APB, false, 10 },
  502. [DMACH_SPI0_RX] = { S3C24XX_DMA_APB, true, 1 },
  503. [DMACH_SPI0_TX] = { S3C24XX_DMA_APB, true, 0 },
  504. [DMACH_SPI1_RX] = { S3C24XX_DMA_APB, true, 3 },
  505. [DMACH_SPI1_TX] = { S3C24XX_DMA_APB, true, 2 },
  506. [DMACH_UART0] = { S3C24XX_DMA_APB, true, 19 },
  507. [DMACH_UART1] = { S3C24XX_DMA_APB, true, 21 },
  508. [DMACH_UART2] = { S3C24XX_DMA_APB, true, 23 },
  509. [DMACH_UART3] = { S3C24XX_DMA_APB, true, 25 },
  510. [DMACH_UART0_SRC2] = { S3C24XX_DMA_APB, true, 20 },
  511. [DMACH_UART1_SRC2] = { S3C24XX_DMA_APB, true, 22 },
  512. [DMACH_UART2_SRC2] = { S3C24XX_DMA_APB, true, 24 },
  513. [DMACH_UART3_SRC2] = { S3C24XX_DMA_APB, true, 26 },
  514. [DMACH_TIMER] = { S3C24XX_DMA_APB, true, 9 },
  515. [DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, 5 },
  516. [DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, 4 },
  517. [DMACH_PCM_IN] = { S3C24XX_DMA_APB, true, 28 },
  518. [DMACH_PCM_OUT] = { S3C24XX_DMA_APB, true, 27 },
  519. [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 },
  520. };
  521. static const struct dma_slave_map s3c2443_dma_slave_map[] = {
  522. { "s3c2440-sdi", "rx-tx", (void *)DMACH_SDI },
  523. { "s3c2443-spi.0", "rx", (void *)DMACH_SPI0_RX },
  524. { "s3c2443-spi.0", "tx", (void *)DMACH_SPI0_TX },
  525. { "s3c2443-spi.1", "rx", (void *)DMACH_SPI1_RX },
  526. { "s3c2443-spi.1", "tx", (void *)DMACH_SPI1_TX },
  527. { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
  528. { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
  529. { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
  530. { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
  531. { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
  532. { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
  533. { "s3c2440-uart.3", "rx", (void *)DMACH_UART3 },
  534. { "s3c2440-uart.3", "tx", (void *)DMACH_UART3 },
  535. { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
  536. { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
  537. };
  538. static struct s3c24xx_dma_platdata s3c2443_dma_platdata = {
  539. .num_phy_channels = 6,
  540. .channels = s3c2443_dma_channels,
  541. .num_channels = DMACH_MAX,
  542. .slave_map = s3c2443_dma_slave_map,
  543. .slavecnt = ARRAY_SIZE(s3c2443_dma_slave_map),
  544. };
  545. struct platform_device s3c2443_device_dma = {
  546. .name = "s3c2443-dma",
  547. .id = 0,
  548. .num_resources = ARRAY_SIZE(s3c2443_dma_resource),
  549. .resource = s3c2443_dma_resource,
  550. .dev = {
  551. .dma_mask = &s3c24xx_device_dma_mask,
  552. .coherent_dma_mask = DMA_BIT_MASK(32),
  553. .platform_data = &s3c2443_dma_platdata,
  554. },
  555. };
  556. #endif
  557. #if defined(CONFIG_COMMON_CLK) && defined(CONFIG_CPU_S3C2410)
  558. void __init s3c2410_init_clocks(int xtal)
  559. {
  560. s3c2410_common_clk_init(NULL, xtal, 0, S3C24XX_VA_CLKPWR);
  561. }
  562. #endif
  563. #ifdef CONFIG_CPU_S3C2412
  564. void __init s3c2412_init_clocks(int xtal)
  565. {
  566. s3c2412_common_clk_init(NULL, xtal, 0, S3C24XX_VA_CLKPWR);
  567. }
  568. #endif
  569. #ifdef CONFIG_CPU_S3C2416
  570. void __init s3c2416_init_clocks(int xtal)
  571. {
  572. s3c2443_common_clk_init(NULL, xtal, 0, S3C24XX_VA_CLKPWR);
  573. }
  574. #endif
  575. #if defined(CONFIG_COMMON_CLK) && defined(CONFIG_CPU_S3C2440)
  576. void __init s3c2440_init_clocks(int xtal)
  577. {
  578. s3c2410_common_clk_init(NULL, xtal, 1, S3C24XX_VA_CLKPWR);
  579. }
  580. #endif
  581. #if defined(CONFIG_COMMON_CLK) && defined(CONFIG_CPU_S3C2442)
  582. void __init s3c2442_init_clocks(int xtal)
  583. {
  584. s3c2410_common_clk_init(NULL, xtal, 2, S3C24XX_VA_CLKPWR);
  585. }
  586. #endif
  587. #ifdef CONFIG_CPU_S3C2443
  588. void __init s3c2443_init_clocks(int xtal)
  589. {
  590. s3c2443_common_clk_init(NULL, xtal, 1, S3C24XX_VA_CLKPWR);
  591. }
  592. #endif
  593. #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2440) || \
  594. defined(CONFIG_CPU_S3C2442)
  595. static struct resource s3c2410_dclk_resource[] = {
  596. [0] = DEFINE_RES_MEM(0x56000084, 0x4),
  597. };
  598. struct platform_device s3c2410_device_dclk = {
  599. .name = "s3c2410-dclk",
  600. .id = 0,
  601. .num_resources = ARRAY_SIZE(s3c2410_dclk_resource),
  602. .resource = s3c2410_dclk_resource,
  603. };
  604. #endif