dev-audio.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /* linux/arch/arm/plat-s3c/dev-audio.c
  2. *
  3. * Copyright 2009 Wolfson Microelectronics
  4. * Mark Brown <broonie@opensource.wolfsonmicro.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/string.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/gpio.h>
  15. #include <linux/export.h>
  16. #include <mach/irqs.h>
  17. #include <mach/map.h>
  18. #include <mach/dma.h>
  19. #include <plat/devs.h>
  20. #include <plat/audio.h>
  21. #include <plat/gpio-cfg.h>
  22. static const char *rclksrc[] = {
  23. [0] = "iis",
  24. [1] = "audio-bus",
  25. };
  26. static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
  27. {
  28. unsigned int base;
  29. switch (pdev->id) {
  30. case 0:
  31. base = S3C64XX_GPD(0);
  32. break;
  33. case 1:
  34. base = S3C64XX_GPE(0);
  35. break;
  36. case 2:
  37. s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
  38. s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
  39. s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
  40. s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
  41. return 0;
  42. default:
  43. printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
  44. pdev->id);
  45. return -EINVAL;
  46. }
  47. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
  48. return 0;
  49. }
  50. static struct resource s3c64xx_iis0_resource[] = {
  51. [0] = {
  52. .start = S3C64XX_PA_IIS0,
  53. .end = S3C64XX_PA_IIS0 + 0x100 - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = DMACH_I2S0_OUT,
  58. .end = DMACH_I2S0_OUT,
  59. .flags = IORESOURCE_DMA,
  60. },
  61. [2] = {
  62. .start = DMACH_I2S0_IN,
  63. .end = DMACH_I2S0_IN,
  64. .flags = IORESOURCE_DMA,
  65. },
  66. };
  67. static struct s3c_audio_pdata i2sv3_pdata = {
  68. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  69. .type = {
  70. .i2s = {
  71. .src_clk = rclksrc,
  72. },
  73. },
  74. };
  75. struct platform_device s3c64xx_device_iis0 = {
  76. .name = "samsung-i2s",
  77. .id = 0,
  78. .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
  79. .resource = s3c64xx_iis0_resource,
  80. .dev = {
  81. .platform_data = &i2sv3_pdata,
  82. },
  83. };
  84. EXPORT_SYMBOL(s3c64xx_device_iis0);
  85. static struct resource s3c64xx_iis1_resource[] = {
  86. [0] = {
  87. .start = S3C64XX_PA_IIS1,
  88. .end = S3C64XX_PA_IIS1 + 0x100 - 1,
  89. .flags = IORESOURCE_MEM,
  90. },
  91. [1] = {
  92. .start = DMACH_I2S1_OUT,
  93. .end = DMACH_I2S1_OUT,
  94. .flags = IORESOURCE_DMA,
  95. },
  96. [2] = {
  97. .start = DMACH_I2S1_IN,
  98. .end = DMACH_I2S1_IN,
  99. .flags = IORESOURCE_DMA,
  100. },
  101. };
  102. struct platform_device s3c64xx_device_iis1 = {
  103. .name = "samsung-i2s",
  104. .id = 1,
  105. .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
  106. .resource = s3c64xx_iis1_resource,
  107. .dev = {
  108. .platform_data = &i2sv3_pdata,
  109. },
  110. };
  111. EXPORT_SYMBOL(s3c64xx_device_iis1);
  112. static struct resource s3c64xx_iisv4_resource[] = {
  113. [0] = {
  114. .start = S3C64XX_PA_IISV4,
  115. .end = S3C64XX_PA_IISV4 + 0x100 - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = DMACH_HSI_I2SV40_TX,
  120. .end = DMACH_HSI_I2SV40_TX,
  121. .flags = IORESOURCE_DMA,
  122. },
  123. [2] = {
  124. .start = DMACH_HSI_I2SV40_RX,
  125. .end = DMACH_HSI_I2SV40_RX,
  126. .flags = IORESOURCE_DMA,
  127. },
  128. };
  129. static struct s3c_audio_pdata i2sv4_pdata = {
  130. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  131. .type = {
  132. .i2s = {
  133. .quirks = QUIRK_PRI_6CHAN,
  134. .src_clk = rclksrc,
  135. },
  136. },
  137. };
  138. struct platform_device s3c64xx_device_iisv4 = {
  139. .name = "samsung-i2s",
  140. .id = 2,
  141. .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
  142. .resource = s3c64xx_iisv4_resource,
  143. .dev = {
  144. .platform_data = &i2sv4_pdata,
  145. },
  146. };
  147. EXPORT_SYMBOL(s3c64xx_device_iisv4);
  148. /* PCM Controller platform_devices */
  149. static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
  150. {
  151. unsigned int base;
  152. switch (pdev->id) {
  153. case 0:
  154. base = S3C64XX_GPD(0);
  155. break;
  156. case 1:
  157. base = S3C64XX_GPE(0);
  158. break;
  159. default:
  160. printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
  161. pdev->id);
  162. return -EINVAL;
  163. }
  164. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  165. return 0;
  166. }
  167. static struct resource s3c64xx_pcm0_resource[] = {
  168. [0] = {
  169. .start = S3C64XX_PA_PCM0,
  170. .end = S3C64XX_PA_PCM0 + 0x100 - 1,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. [1] = {
  174. .start = DMACH_PCM0_TX,
  175. .end = DMACH_PCM0_TX,
  176. .flags = IORESOURCE_DMA,
  177. },
  178. [2] = {
  179. .start = DMACH_PCM0_RX,
  180. .end = DMACH_PCM0_RX,
  181. .flags = IORESOURCE_DMA,
  182. },
  183. };
  184. static struct s3c_audio_pdata s3c_pcm0_pdata = {
  185. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  186. };
  187. struct platform_device s3c64xx_device_pcm0 = {
  188. .name = "samsung-pcm",
  189. .id = 0,
  190. .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
  191. .resource = s3c64xx_pcm0_resource,
  192. .dev = {
  193. .platform_data = &s3c_pcm0_pdata,
  194. },
  195. };
  196. EXPORT_SYMBOL(s3c64xx_device_pcm0);
  197. static struct resource s3c64xx_pcm1_resource[] = {
  198. [0] = {
  199. .start = S3C64XX_PA_PCM1,
  200. .end = S3C64XX_PA_PCM1 + 0x100 - 1,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. [1] = {
  204. .start = DMACH_PCM1_TX,
  205. .end = DMACH_PCM1_TX,
  206. .flags = IORESOURCE_DMA,
  207. },
  208. [2] = {
  209. .start = DMACH_PCM1_RX,
  210. .end = DMACH_PCM1_RX,
  211. .flags = IORESOURCE_DMA,
  212. },
  213. };
  214. static struct s3c_audio_pdata s3c_pcm1_pdata = {
  215. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  216. };
  217. struct platform_device s3c64xx_device_pcm1 = {
  218. .name = "samsung-pcm",
  219. .id = 1,
  220. .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
  221. .resource = s3c64xx_pcm1_resource,
  222. .dev = {
  223. .platform_data = &s3c_pcm1_pdata,
  224. },
  225. };
  226. EXPORT_SYMBOL(s3c64xx_device_pcm1);
  227. /* AC97 Controller platform devices */
  228. static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
  229. {
  230. return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
  231. }
  232. static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
  233. {
  234. return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
  235. }
  236. static struct resource s3c64xx_ac97_resource[] = {
  237. [0] = {
  238. .start = S3C64XX_PA_AC97,
  239. .end = S3C64XX_PA_AC97 + 0x100 - 1,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. [1] = {
  243. .start = DMACH_AC97_PCMOUT,
  244. .end = DMACH_AC97_PCMOUT,
  245. .flags = IORESOURCE_DMA,
  246. },
  247. [2] = {
  248. .start = DMACH_AC97_PCMIN,
  249. .end = DMACH_AC97_PCMIN,
  250. .flags = IORESOURCE_DMA,
  251. },
  252. [3] = {
  253. .start = DMACH_AC97_MICIN,
  254. .end = DMACH_AC97_MICIN,
  255. .flags = IORESOURCE_DMA,
  256. },
  257. [4] = {
  258. .start = IRQ_AC97,
  259. .end = IRQ_AC97,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. };
  263. static struct s3c_audio_pdata s3c_ac97_pdata;
  264. static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
  265. struct platform_device s3c64xx_device_ac97 = {
  266. .name = "samsung-ac97",
  267. .id = -1,
  268. .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
  269. .resource = s3c64xx_ac97_resource,
  270. .dev = {
  271. .platform_data = &s3c_ac97_pdata,
  272. .dma_mask = &s3c64xx_ac97_dmamask,
  273. .coherent_dma_mask = DMA_BIT_MASK(32),
  274. },
  275. };
  276. EXPORT_SYMBOL(s3c64xx_device_ac97);
  277. void __init s3c64xx_ac97_setup_gpio(int num)
  278. {
  279. if (num == S3C64XX_AC97_GPD)
  280. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
  281. else
  282. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
  283. }