dev-audio.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright 2009 Wolfson Microelectronics
  4. // Mark Brown <broonie@opensource.wolfsonmicro.com>
  5. #include <linux/kernel.h>
  6. #include <linux/string.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/gpio.h>
  10. #include <linux/export.h>
  11. #include <mach/irqs.h>
  12. #include <mach/map.h>
  13. #include <mach/dma.h>
  14. #include <plat/devs.h>
  15. #include <linux/platform_data/asoc-s3c.h>
  16. #include <plat/gpio-cfg.h>
  17. #include <mach/gpio-samsung.h>
  18. static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
  19. {
  20. unsigned int base;
  21. switch (pdev->id) {
  22. case 0:
  23. base = S3C64XX_GPD(0);
  24. break;
  25. case 1:
  26. base = S3C64XX_GPE(0);
  27. break;
  28. case 2:
  29. s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
  30. s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
  31. s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
  32. s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
  33. return 0;
  34. default:
  35. printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
  36. pdev->id);
  37. return -EINVAL;
  38. }
  39. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
  40. return 0;
  41. }
  42. static struct resource s3c64xx_iis0_resource[] = {
  43. [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
  44. };
  45. static struct s3c_audio_pdata i2s0_pdata = {
  46. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  47. };
  48. struct platform_device s3c64xx_device_iis0 = {
  49. .name = "samsung-i2s",
  50. .id = 0,
  51. .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
  52. .resource = s3c64xx_iis0_resource,
  53. .dev = {
  54. .platform_data = &i2s0_pdata,
  55. },
  56. };
  57. EXPORT_SYMBOL(s3c64xx_device_iis0);
  58. static struct resource s3c64xx_iis1_resource[] = {
  59. [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
  60. };
  61. static struct s3c_audio_pdata i2s1_pdata = {
  62. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  63. };
  64. struct platform_device s3c64xx_device_iis1 = {
  65. .name = "samsung-i2s",
  66. .id = 1,
  67. .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
  68. .resource = s3c64xx_iis1_resource,
  69. .dev = {
  70. .platform_data = &i2s1_pdata,
  71. },
  72. };
  73. EXPORT_SYMBOL(s3c64xx_device_iis1);
  74. static struct resource s3c64xx_iisv4_resource[] = {
  75. [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
  76. };
  77. static struct s3c_audio_pdata i2sv4_pdata = {
  78. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  79. .type = {
  80. .quirks = QUIRK_PRI_6CHAN,
  81. },
  82. };
  83. struct platform_device s3c64xx_device_iisv4 = {
  84. .name = "samsung-i2s",
  85. .id = 2,
  86. .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
  87. .resource = s3c64xx_iisv4_resource,
  88. .dev = {
  89. .platform_data = &i2sv4_pdata,
  90. },
  91. };
  92. EXPORT_SYMBOL(s3c64xx_device_iisv4);
  93. /* PCM Controller platform_devices */
  94. static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
  95. {
  96. unsigned int base;
  97. switch (pdev->id) {
  98. case 0:
  99. base = S3C64XX_GPD(0);
  100. break;
  101. case 1:
  102. base = S3C64XX_GPE(0);
  103. break;
  104. default:
  105. printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
  106. pdev->id);
  107. return -EINVAL;
  108. }
  109. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  110. return 0;
  111. }
  112. static struct resource s3c64xx_pcm0_resource[] = {
  113. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
  114. };
  115. static struct s3c_audio_pdata s3c_pcm0_pdata = {
  116. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  117. };
  118. struct platform_device s3c64xx_device_pcm0 = {
  119. .name = "samsung-pcm",
  120. .id = 0,
  121. .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
  122. .resource = s3c64xx_pcm0_resource,
  123. .dev = {
  124. .platform_data = &s3c_pcm0_pdata,
  125. },
  126. };
  127. EXPORT_SYMBOL(s3c64xx_device_pcm0);
  128. static struct resource s3c64xx_pcm1_resource[] = {
  129. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
  130. };
  131. static struct s3c_audio_pdata s3c_pcm1_pdata = {
  132. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  133. };
  134. struct platform_device s3c64xx_device_pcm1 = {
  135. .name = "samsung-pcm",
  136. .id = 1,
  137. .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
  138. .resource = s3c64xx_pcm1_resource,
  139. .dev = {
  140. .platform_data = &s3c_pcm1_pdata,
  141. },
  142. };
  143. EXPORT_SYMBOL(s3c64xx_device_pcm1);
  144. /* AC97 Controller platform devices */
  145. static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
  146. {
  147. return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
  148. }
  149. static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
  150. {
  151. return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
  152. }
  153. static struct resource s3c64xx_ac97_resource[] = {
  154. [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
  155. [1] = DEFINE_RES_IRQ(IRQ_AC97),
  156. };
  157. static struct s3c_audio_pdata s3c_ac97_pdata = {
  158. };
  159. static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
  160. struct platform_device s3c64xx_device_ac97 = {
  161. .name = "samsung-ac97",
  162. .id = -1,
  163. .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
  164. .resource = s3c64xx_ac97_resource,
  165. .dev = {
  166. .platform_data = &s3c_ac97_pdata,
  167. .dma_mask = &s3c64xx_ac97_dmamask,
  168. .coherent_dma_mask = DMA_BIT_MASK(32),
  169. },
  170. };
  171. EXPORT_SYMBOL(s3c64xx_device_ac97);
  172. void __init s3c64xx_ac97_setup_gpio(int num)
  173. {
  174. if (num == S3C64XX_AC97_GPD)
  175. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
  176. else
  177. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
  178. }