s3c24xx.c 22 KB

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