dev-audio.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* linux/arch/arm/mach-s5p6442/dev-audio.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co. Ltd
  4. * Jaswinder Singh <jassi.brar@samsung.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/platform_device.h>
  11. #include <linux/dma-mapping.h>
  12. #include <linux/gpio.h>
  13. #include <plat/gpio-cfg.h>
  14. #include <plat/audio.h>
  15. #include <mach/map.h>
  16. #include <mach/dma.h>
  17. #include <mach/irqs.h>
  18. static int s5p6442_cfg_i2s(struct platform_device *pdev)
  19. {
  20. unsigned int base;
  21. /* configure GPIO for i2s port */
  22. switch (pdev->id) {
  23. case 1:
  24. base = S5P6442_GPC1(0);
  25. break;
  26. case 0:
  27. base = S5P6442_GPC0(0);
  28. break;
  29. default:
  30. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  31. return -EINVAL;
  32. }
  33. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  34. return 0;
  35. }
  36. static const char *rclksrc_v35[] = {
  37. [0] = "busclk",
  38. [1] = "i2sclk",
  39. };
  40. static struct s3c_audio_pdata i2sv35_pdata = {
  41. .cfg_gpio = s5p6442_cfg_i2s,
  42. .type = {
  43. .i2s = {
  44. .quirks = QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR,
  45. .src_clk = rclksrc_v35,
  46. },
  47. },
  48. };
  49. static struct resource s5p6442_iis0_resource[] = {
  50. [0] = {
  51. .start = S5P6442_PA_I2S0,
  52. .end = S5P6442_PA_I2S0 + 0x100 - 1,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. [1] = {
  56. .start = DMACH_I2S0_TX,
  57. .end = DMACH_I2S0_TX,
  58. .flags = IORESOURCE_DMA,
  59. },
  60. [2] = {
  61. .start = DMACH_I2S0_RX,
  62. .end = DMACH_I2S0_RX,
  63. .flags = IORESOURCE_DMA,
  64. },
  65. [3] = {
  66. .start = DMACH_I2S0S_TX,
  67. .end = DMACH_I2S0S_TX,
  68. .flags = IORESOURCE_DMA,
  69. },
  70. };
  71. struct platform_device s5p6442_device_iis0 = {
  72. .name = "samsung-i2s",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(s5p6442_iis0_resource),
  75. .resource = s5p6442_iis0_resource,
  76. .dev = {
  77. .platform_data = &i2sv35_pdata,
  78. },
  79. };
  80. static const char *rclksrc_v3[] = {
  81. [0] = "iis",
  82. [1] = "sclk_audio",
  83. };
  84. static struct s3c_audio_pdata i2sv3_pdata = {
  85. .cfg_gpio = s5p6442_cfg_i2s,
  86. .type = {
  87. .i2s = {
  88. .src_clk = rclksrc_v3,
  89. },
  90. },
  91. };
  92. static struct resource s5p6442_iis1_resource[] = {
  93. [0] = {
  94. .start = S5P6442_PA_I2S1,
  95. .end = S5P6442_PA_I2S1 + 0x100 - 1,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = {
  99. .start = DMACH_I2S1_TX,
  100. .end = DMACH_I2S1_TX,
  101. .flags = IORESOURCE_DMA,
  102. },
  103. [2] = {
  104. .start = DMACH_I2S1_RX,
  105. .end = DMACH_I2S1_RX,
  106. .flags = IORESOURCE_DMA,
  107. },
  108. };
  109. struct platform_device s5p6442_device_iis1 = {
  110. .name = "samsung-i2s",
  111. .id = 1,
  112. .num_resources = ARRAY_SIZE(s5p6442_iis1_resource),
  113. .resource = s5p6442_iis1_resource,
  114. .dev = {
  115. .platform_data = &i2sv3_pdata,
  116. },
  117. };
  118. /* PCM Controller platform_devices */
  119. static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
  120. {
  121. unsigned int base;
  122. switch (pdev->id) {
  123. case 0:
  124. base = S5P6442_GPC0(0);
  125. break;
  126. case 1:
  127. base = S5P6442_GPC1(0);
  128. break;
  129. default:
  130. printk(KERN_DEBUG "Invalid PCM Controller number!");
  131. return -EINVAL;
  132. }
  133. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
  134. return 0;
  135. }
  136. static struct s3c_audio_pdata s3c_pcm_pdata = {
  137. .cfg_gpio = s5p6442_pcm_cfg_gpio,
  138. };
  139. static struct resource s5p6442_pcm0_resource[] = {
  140. [0] = {
  141. .start = S5P6442_PA_PCM0,
  142. .end = S5P6442_PA_PCM0 + 0x100 - 1,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [1] = {
  146. .start = DMACH_PCM0_TX,
  147. .end = DMACH_PCM0_TX,
  148. .flags = IORESOURCE_DMA,
  149. },
  150. [2] = {
  151. .start = DMACH_PCM0_RX,
  152. .end = DMACH_PCM0_RX,
  153. .flags = IORESOURCE_DMA,
  154. },
  155. };
  156. struct platform_device s5p6442_device_pcm0 = {
  157. .name = "samsung-pcm",
  158. .id = 0,
  159. .num_resources = ARRAY_SIZE(s5p6442_pcm0_resource),
  160. .resource = s5p6442_pcm0_resource,
  161. .dev = {
  162. .platform_data = &s3c_pcm_pdata,
  163. },
  164. };
  165. static struct resource s5p6442_pcm1_resource[] = {
  166. [0] = {
  167. .start = S5P6442_PA_PCM1,
  168. .end = S5P6442_PA_PCM1 + 0x100 - 1,
  169. .flags = IORESOURCE_MEM,
  170. },
  171. [1] = {
  172. .start = DMACH_PCM1_TX,
  173. .end = DMACH_PCM1_TX,
  174. .flags = IORESOURCE_DMA,
  175. },
  176. [2] = {
  177. .start = DMACH_PCM1_RX,
  178. .end = DMACH_PCM1_RX,
  179. .flags = IORESOURCE_DMA,
  180. },
  181. };
  182. struct platform_device s5p6442_device_pcm1 = {
  183. .name = "samsung-pcm",
  184. .id = 1,
  185. .num_resources = ARRAY_SIZE(s5p6442_pcm1_resource),
  186. .resource = s5p6442_pcm1_resource,
  187. .dev = {
  188. .platform_data = &s3c_pcm_pdata,
  189. },
  190. };