dev-audio-s3c64xx.c 4.8 KB

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