dev-audio.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /* linux/arch/arm/mach-s5p64x0/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 const char *rclksrc[] = {
  19. [0] = "iis",
  20. [1] = "sclk_audio2",
  21. };
  22. static int s5p6440_cfg_i2s(struct platform_device *pdev)
  23. {
  24. switch (pdev->id) {
  25. case 0:
  26. s3c_gpio_cfgpin_range(S5P6440_GPC(4), 2, S3C_GPIO_SFN(5));
  27. s3c_gpio_cfgpin(S5P6440_GPC(7), S3C_GPIO_SFN(5));
  28. s3c_gpio_cfgpin_range(S5P6440_GPH(6), 4, S3C_GPIO_SFN(5));
  29. break;
  30. default:
  31. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  32. return -EINVAL;
  33. }
  34. return 0;
  35. }
  36. static struct s3c_audio_pdata s5p6440_i2s_pdata = {
  37. .cfg_gpio = s5p6440_cfg_i2s,
  38. .type = {
  39. .i2s = {
  40. .quirks = QUIRK_PRI_6CHAN,
  41. .src_clk = rclksrc,
  42. },
  43. },
  44. };
  45. static struct resource s5p64x0_i2s0_resource[] = {
  46. [0] = {
  47. .start = S5P64X0_PA_I2S,
  48. .end = S5P64X0_PA_I2S + 0x100 - 1,
  49. .flags = IORESOURCE_MEM,
  50. },
  51. [1] = {
  52. .start = DMACH_I2S0_TX,
  53. .end = DMACH_I2S0_TX,
  54. .flags = IORESOURCE_DMA,
  55. },
  56. [2] = {
  57. .start = DMACH_I2S0_RX,
  58. .end = DMACH_I2S0_RX,
  59. .flags = IORESOURCE_DMA,
  60. },
  61. };
  62. struct platform_device s5p6440_device_iis = {
  63. .name = "samsung-i2s",
  64. .id = 0,
  65. .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
  66. .resource = s5p64x0_i2s0_resource,
  67. .dev = {
  68. .platform_data = &s5p6440_i2s_pdata,
  69. },
  70. };
  71. static int s5p6450_cfg_i2s(struct platform_device *pdev)
  72. {
  73. switch (pdev->id) {
  74. case 0:
  75. s3c_gpio_cfgpin_range(S5P6450_GPR(4), 5, S3C_GPIO_SFN(5));
  76. s3c_gpio_cfgpin_range(S5P6450_GPR(13), 2, S3C_GPIO_SFN(5));
  77. break;
  78. case 1:
  79. s3c_gpio_cfgpin(S5P6440_GPB(4), S3C_GPIO_SFN(5));
  80. s3c_gpio_cfgpin_range(S5P6450_GPC(0), 4, S3C_GPIO_SFN(5));
  81. break;
  82. case 2:
  83. s3c_gpio_cfgpin_range(S5P6450_GPK(0), 5, S3C_GPIO_SFN(5));
  84. break;
  85. default:
  86. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  87. return -EINVAL;
  88. }
  89. return 0;
  90. }
  91. static struct s3c_audio_pdata s5p6450_i2s0_pdata = {
  92. .cfg_gpio = s5p6450_cfg_i2s,
  93. .type = {
  94. .i2s = {
  95. .quirks = QUIRK_PRI_6CHAN,
  96. .src_clk = rclksrc,
  97. },
  98. },
  99. };
  100. struct platform_device s5p6450_device_iis0 = {
  101. .name = "samsung-i2s",
  102. .id = 0,
  103. .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
  104. .resource = s5p64x0_i2s0_resource,
  105. .dev = {
  106. .platform_data = &s5p6450_i2s0_pdata,
  107. },
  108. };
  109. static struct s3c_audio_pdata s5p6450_i2s_pdata = {
  110. .cfg_gpio = s5p6450_cfg_i2s,
  111. .type = {
  112. .i2s = {
  113. .src_clk = rclksrc,
  114. },
  115. },
  116. };
  117. static struct resource s5p6450_i2s1_resource[] = {
  118. [0] = {
  119. .start = S5P6450_PA_I2S1,
  120. .end = S5P6450_PA_I2S1 + 0x100 - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = DMACH_I2S1_TX,
  125. .end = DMACH_I2S1_TX,
  126. .flags = IORESOURCE_DMA,
  127. },
  128. [2] = {
  129. .start = DMACH_I2S1_RX,
  130. .end = DMACH_I2S1_RX,
  131. .flags = IORESOURCE_DMA,
  132. },
  133. };
  134. struct platform_device s5p6450_device_iis1 = {
  135. .name = "samsung-i2s",
  136. .id = 1,
  137. .num_resources = ARRAY_SIZE(s5p6450_i2s1_resource),
  138. .resource = s5p6450_i2s1_resource,
  139. .dev = {
  140. .platform_data = &s5p6450_i2s_pdata,
  141. },
  142. };
  143. static struct resource s5p6450_i2s2_resource[] = {
  144. [0] = {
  145. .start = S5P6450_PA_I2S2,
  146. .end = S5P6450_PA_I2S2 + 0x100 - 1,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. [1] = {
  150. .start = DMACH_I2S2_TX,
  151. .end = DMACH_I2S2_TX,
  152. .flags = IORESOURCE_DMA,
  153. },
  154. [2] = {
  155. .start = DMACH_I2S2_RX,
  156. .end = DMACH_I2S2_RX,
  157. .flags = IORESOURCE_DMA,
  158. },
  159. };
  160. struct platform_device s5p6450_device_iis2 = {
  161. .name = "samsung-i2s",
  162. .id = 2,
  163. .num_resources = ARRAY_SIZE(s5p6450_i2s2_resource),
  164. .resource = s5p6450_i2s2_resource,
  165. .dev = {
  166. .platform_data = &s5p6450_i2s_pdata,
  167. },
  168. };
  169. /* PCM Controller platform_devices */
  170. static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
  171. {
  172. switch (pdev->id) {
  173. case 0:
  174. s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
  175. s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2));
  176. break;
  177. default:
  178. printk(KERN_DEBUG "Invalid PCM Controller number!");
  179. return -EINVAL;
  180. }
  181. return 0;
  182. }
  183. static struct s3c_audio_pdata s5p6440_pcm_pdata = {
  184. .cfg_gpio = s5p6440_pcm_cfg_gpio,
  185. };
  186. static struct resource s5p6440_pcm0_resource[] = {
  187. [0] = {
  188. .start = S5P64X0_PA_PCM,
  189. .end = S5P64X0_PA_PCM + 0x100 - 1,
  190. .flags = IORESOURCE_MEM,
  191. },
  192. [1] = {
  193. .start = DMACH_PCM0_TX,
  194. .end = DMACH_PCM0_TX,
  195. .flags = IORESOURCE_DMA,
  196. },
  197. [2] = {
  198. .start = DMACH_PCM0_RX,
  199. .end = DMACH_PCM0_RX,
  200. .flags = IORESOURCE_DMA,
  201. },
  202. };
  203. struct platform_device s5p6440_device_pcm = {
  204. .name = "samsung-pcm",
  205. .id = 0,
  206. .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
  207. .resource = s5p6440_pcm0_resource,
  208. .dev = {
  209. .platform_data = &s5p6440_pcm_pdata,
  210. },
  211. };