common.c 19 KB

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