dev-audio.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. };
  53. struct platform_device s3c64xx_device_iis0 = {
  54. .name = "samsung-i2s",
  55. .id = 0,
  56. .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
  57. .resource = s3c64xx_iis0_resource,
  58. .dev = {
  59. .platform_data = &i2s0_pdata,
  60. },
  61. };
  62. EXPORT_SYMBOL(s3c64xx_device_iis0);
  63. static struct resource s3c64xx_iis1_resource[] = {
  64. [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
  65. };
  66. static struct s3c_audio_pdata i2s1_pdata = {
  67. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  68. };
  69. struct platform_device s3c64xx_device_iis1 = {
  70. .name = "samsung-i2s",
  71. .id = 1,
  72. .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
  73. .resource = s3c64xx_iis1_resource,
  74. .dev = {
  75. .platform_data = &i2s1_pdata,
  76. },
  77. };
  78. EXPORT_SYMBOL(s3c64xx_device_iis1);
  79. static struct resource s3c64xx_iisv4_resource[] = {
  80. [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
  81. };
  82. static struct s3c_audio_pdata i2sv4_pdata = {
  83. .cfg_gpio = s3c64xx_i2s_cfg_gpio,
  84. .type = {
  85. .quirks = QUIRK_PRI_6CHAN,
  86. },
  87. };
  88. struct platform_device s3c64xx_device_iisv4 = {
  89. .name = "samsung-i2s",
  90. .id = 2,
  91. .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
  92. .resource = s3c64xx_iisv4_resource,
  93. .dev = {
  94. .platform_data = &i2sv4_pdata,
  95. },
  96. };
  97. EXPORT_SYMBOL(s3c64xx_device_iisv4);
  98. /* PCM Controller platform_devices */
  99. static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
  100. {
  101. unsigned int base;
  102. switch (pdev->id) {
  103. case 0:
  104. base = S3C64XX_GPD(0);
  105. break;
  106. case 1:
  107. base = S3C64XX_GPE(0);
  108. break;
  109. default:
  110. printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
  111. pdev->id);
  112. return -EINVAL;
  113. }
  114. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  115. return 0;
  116. }
  117. static struct resource s3c64xx_pcm0_resource[] = {
  118. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
  119. };
  120. static struct s3c_audio_pdata s3c_pcm0_pdata = {
  121. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  122. };
  123. struct platform_device s3c64xx_device_pcm0 = {
  124. .name = "samsung-pcm",
  125. .id = 0,
  126. .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
  127. .resource = s3c64xx_pcm0_resource,
  128. .dev = {
  129. .platform_data = &s3c_pcm0_pdata,
  130. },
  131. };
  132. EXPORT_SYMBOL(s3c64xx_device_pcm0);
  133. static struct resource s3c64xx_pcm1_resource[] = {
  134. [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
  135. };
  136. static struct s3c_audio_pdata s3c_pcm1_pdata = {
  137. .cfg_gpio = s3c64xx_pcm_cfg_gpio,
  138. };
  139. struct platform_device s3c64xx_device_pcm1 = {
  140. .name = "samsung-pcm",
  141. .id = 1,
  142. .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
  143. .resource = s3c64xx_pcm1_resource,
  144. .dev = {
  145. .platform_data = &s3c_pcm1_pdata,
  146. },
  147. };
  148. EXPORT_SYMBOL(s3c64xx_device_pcm1);
  149. /* AC97 Controller platform devices */
  150. static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
  151. {
  152. return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
  153. }
  154. static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
  155. {
  156. return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
  157. }
  158. static struct resource s3c64xx_ac97_resource[] = {
  159. [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
  160. [1] = DEFINE_RES_IRQ(IRQ_AC97),
  161. };
  162. static struct s3c_audio_pdata s3c_ac97_pdata = {
  163. };
  164. static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
  165. struct platform_device s3c64xx_device_ac97 = {
  166. .name = "samsung-ac97",
  167. .id = -1,
  168. .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
  169. .resource = s3c64xx_ac97_resource,
  170. .dev = {
  171. .platform_data = &s3c_ac97_pdata,
  172. .dma_mask = &s3c64xx_ac97_dmamask,
  173. .coherent_dma_mask = DMA_BIT_MASK(32),
  174. },
  175. };
  176. EXPORT_SYMBOL(s3c64xx_device_ac97);
  177. void __init s3c64xx_ac97_setup_gpio(int num)
  178. {
  179. if (num == S3C64XX_AC97_GPD)
  180. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
  181. else
  182. s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
  183. }