dev-audio.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 <linux/platform_data/asoc-s3c.h>
  21. #include <plat/gpio-cfg.h>
  22. #include <mach/gpio-samsung.h>
  23. static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
  24. {
  25. unsigned int base;
  26. switch (pdev->id) {
  27. case 0:
  28. base = S3C64XX_GPD(0);
  29. break;
  30. case 1:
  31. base = S3C64XX_GPE(0);
  32. break;
  33. case 2:
  34. s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
  35. s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
  36. s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
  37. s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
  38. return 0;
  39. default:
  40. printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
  41. pdev->id);
  42. return -EINVAL;
  43. }
  44. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
  45. return 0;
  46. }
  47. static struct resource s3c64xx_iis0_resource[] = {
  48. [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
  49. };
  50. static struct s3c_audio_pdata i2s0_pdata = {
  51. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  52. .dma_filter = pl08x_filter_id,
  53. .dma_playback = DMACH_I2S0_OUT,
  54. .dma_capture = DMACH_I2S0_IN,
  55. };
  56. struct platform_device s3c64xx_device_iis0 = {
  57. .name = "samsung-i2s",
  58. .id = 0,
  59. .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
  60. .resource = s3c64xx_iis0_resource,
  61. .dev = {
  62. .platform_data = &i2s0_pdata,
  63. },
  64. };
  65. EXPORT_SYMBOL(s3c64xx_device_iis0);
  66. static struct resource s3c64xx_iis1_resource[] = {
  67. [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
  68. };
  69. static struct s3c_audio_pdata i2s1_pdata = {
  70. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  71. .dma_filter = pl08x_filter_id,
  72. .dma_playback = DMACH_I2S1_OUT,
  73. .dma_capture = DMACH_I2S1_IN,
  74. };
  75. struct platform_device s3c64xx_device_iis1 = {
  76. .name = "samsung-i2s",
  77. .id = 1,
  78. .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
  79. .resource = s3c64xx_iis1_resource,
  80. .dev = {
  81. .platform_data = &i2s1_pdata,
  82. },
  83. };
  84. EXPORT_SYMBOL(s3c64xx_device_iis1);
  85. static struct resource s3c64xx_iisv4_resource[] = {
  86. [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
  87. };
  88. static struct s3c_audio_pdata i2sv4_pdata = {
  89. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  90. .dma_filter = pl08x_filter_id,
  91. .dma_playback = DMACH_HSI_I2SV40_TX,
  92. .dma_capture = DMACH_HSI_I2SV40_RX,
  93. .type = {
  94. .i2s = {
  95. .quirks = QUIRK_PRI_6CHAN,
  96. },
  97. },
  98. };
  99. struct platform_device s3c64xx_device_iisv4 = {
  100. .name = "samsung-i2s",
  101. .id = 2,
  102. .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
  103. .resource = s3c64xx_iisv4_resource,
  104. .dev = {
  105. .platform_data = &i2sv4_pdata,
  106. },
  107. };
  108. EXPORT_SYMBOL(s3c64xx_device_iisv4);
  109. /* PCM Controller platform_devices */
  110. static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
  111. {
  112. unsigned int base;
  113. switch (pdev->id) {
  114. case 0:
  115. base = S3C64XX_GPD(0);
  116. break;
  117. case 1:
  118. base = S3C64XX_GPE(0);
  119. break;
  120. default:
  121. printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
  122. pdev->id);
  123. return -EINVAL;
  124. }
  125. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  126. return 0;
  127. }
  128. static struct resource s3c64xx_pcm0_resource[] = {
  129. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
  130. };
  131. static struct s3c_audio_pdata s3c_pcm0_pdata = {
  132. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  133. .dma_filter = pl08x_filter_id,
  134. .dma_capture = DMACH_PCM0_RX,
  135. .dma_playback = DMACH_PCM0_TX,
  136. };
  137. struct platform_device s3c64xx_device_pcm0 = {
  138. .name = "samsung-pcm",
  139. .id = 0,
  140. .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
  141. .resource = s3c64xx_pcm0_resource,
  142. .dev = {
  143. .platform_data = &s3c_pcm0_pdata,
  144. },
  145. };
  146. EXPORT_SYMBOL(s3c64xx_device_pcm0);
  147. static struct resource s3c64xx_pcm1_resource[] = {
  148. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
  149. };
  150. static struct s3c_audio_pdata s3c_pcm1_pdata = {
  151. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  152. .dma_filter = pl08x_filter_id,
  153. .dma_playback = DMACH_PCM1_TX,
  154. .dma_capture = DMACH_PCM1_RX,
  155. };
  156. struct platform_device s3c64xx_device_pcm1 = {
  157. .name = "samsung-pcm",
  158. .id = 1,
  159. .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
  160. .resource = s3c64xx_pcm1_resource,
  161. .dev = {
  162. .platform_data = &s3c_pcm1_pdata,
  163. },
  164. };
  165. EXPORT_SYMBOL(s3c64xx_device_pcm1);
  166. /* AC97 Controller platform devices */
  167. static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
  168. {
  169. return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
  170. }
  171. static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
  172. {
  173. return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
  174. }
  175. static struct resource s3c64xx_ac97_resource[] = {
  176. [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
  177. [1] = DEFINE_RES_IRQ(IRQ_AC97),
  178. };
  179. static struct s3c_audio_pdata s3c_ac97_pdata = {
  180. .dma_playback = DMACH_AC97_PCMOUT,
  181. .dma_filter = pl08x_filter_id,
  182. .dma_capture = DMACH_AC97_PCMIN,
  183. .dma_capture_mic = DMACH_AC97_MICIN,
  184. };
  185. static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
  186. struct platform_device s3c64xx_device_ac97 = {
  187. .name = "samsung-ac97",
  188. .id = -1,
  189. .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
  190. .resource = s3c64xx_ac97_resource,
  191. .dev = {
  192. .platform_data = &s3c_ac97_pdata,
  193. .dma_mask = &s3c64xx_ac97_dmamask,
  194. .coherent_dma_mask = DMA_BIT_MASK(32),
  195. },
  196. };
  197. EXPORT_SYMBOL(s3c64xx_device_ac97);
  198. void __init s3c64xx_ac97_setup_gpio(int num)
  199. {
  200. if (num == S3C64XX_AC97_GPD)
  201. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
  202. else
  203. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
  204. }