dev-audio.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /* linux/arch/arm/mach-s5pc100/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 s5pc100_cfg_i2s(struct platform_device *pdev)
  19. {
  20. /* configure GPIO for i2s port */
  21. switch (pdev->id) {
  22. case 0: /* Dedicated pins */
  23. break;
  24. case 1:
  25. s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2));
  26. break;
  27. case 2:
  28. s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4));
  29. break;
  30. default:
  31. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  32. return -EINVAL;
  33. }
  34. return 0;
  35. }
  36. static const char *rclksrc_v5[] = {
  37. [0] = "iis",
  38. [1] = "i2sclkd2",
  39. };
  40. static struct s3c_audio_pdata i2sv5_pdata = {
  41. .cfg_gpio = s5pc100_cfg_i2s,
  42. .type = {
  43. .i2s = {
  44. .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
  45. | QUIRK_NEED_RSTCLR,
  46. .src_clk = rclksrc_v5,
  47. },
  48. },
  49. };
  50. static struct resource s5pc100_iis0_resource[] = {
  51. [0] = {
  52. .start = S5PC100_PA_I2S0,
  53. .end = S5PC100_PA_I2S0 + 0x100 - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = DMACH_I2S0_TX,
  58. .end = DMACH_I2S0_TX,
  59. .flags = IORESOURCE_DMA,
  60. },
  61. [2] = {
  62. .start = DMACH_I2S0_RX,
  63. .end = DMACH_I2S0_RX,
  64. .flags = IORESOURCE_DMA,
  65. },
  66. [3] = {
  67. .start = DMACH_I2S0S_TX,
  68. .end = DMACH_I2S0S_TX,
  69. .flags = IORESOURCE_DMA,
  70. },
  71. };
  72. struct platform_device s5pc100_device_iis0 = {
  73. .name = "samsung-i2s",
  74. .id = 0,
  75. .num_resources = ARRAY_SIZE(s5pc100_iis0_resource),
  76. .resource = s5pc100_iis0_resource,
  77. .dev = {
  78. .platform_data = &i2sv5_pdata,
  79. },
  80. };
  81. static const char *rclksrc_v3[] = {
  82. [0] = "iis",
  83. [1] = "sclk_audio",
  84. };
  85. static struct s3c_audio_pdata i2sv3_pdata = {
  86. .cfg_gpio = s5pc100_cfg_i2s,
  87. .type = {
  88. .i2s = {
  89. .src_clk = rclksrc_v3,
  90. },
  91. },
  92. };
  93. static struct resource s5pc100_iis1_resource[] = {
  94. [0] = {
  95. .start = S5PC100_PA_I2S1,
  96. .end = S5PC100_PA_I2S1 + 0x100 - 1,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. [1] = {
  100. .start = DMACH_I2S1_TX,
  101. .end = DMACH_I2S1_TX,
  102. .flags = IORESOURCE_DMA,
  103. },
  104. [2] = {
  105. .start = DMACH_I2S1_RX,
  106. .end = DMACH_I2S1_RX,
  107. .flags = IORESOURCE_DMA,
  108. },
  109. };
  110. struct platform_device s5pc100_device_iis1 = {
  111. .name = "samsung-i2s",
  112. .id = 1,
  113. .num_resources = ARRAY_SIZE(s5pc100_iis1_resource),
  114. .resource = s5pc100_iis1_resource,
  115. .dev = {
  116. .platform_data = &i2sv3_pdata,
  117. },
  118. };
  119. static struct resource s5pc100_iis2_resource[] = {
  120. [0] = {
  121. .start = S5PC100_PA_I2S2,
  122. .end = S5PC100_PA_I2S2 + 0x100 - 1,
  123. .flags = IORESOURCE_MEM,
  124. },
  125. [1] = {
  126. .start = DMACH_I2S2_TX,
  127. .end = DMACH_I2S2_TX,
  128. .flags = IORESOURCE_DMA,
  129. },
  130. [2] = {
  131. .start = DMACH_I2S2_RX,
  132. .end = DMACH_I2S2_RX,
  133. .flags = IORESOURCE_DMA,
  134. },
  135. };
  136. struct platform_device s5pc100_device_iis2 = {
  137. .name = "samsung-i2s",
  138. .id = 2,
  139. .num_resources = ARRAY_SIZE(s5pc100_iis2_resource),
  140. .resource = s5pc100_iis2_resource,
  141. .dev = {
  142. .platform_data = &i2sv3_pdata,
  143. },
  144. };
  145. /* PCM Controller platform_devices */
  146. static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev)
  147. {
  148. switch (pdev->id) {
  149. case 0:
  150. s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5));
  151. break;
  152. case 1:
  153. s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3));
  154. break;
  155. default:
  156. printk(KERN_DEBUG "Invalid PCM Controller number!");
  157. return -EINVAL;
  158. }
  159. return 0;
  160. }
  161. static struct s3c_audio_pdata s3c_pcm_pdata = {
  162. .cfg_gpio = s5pc100_pcm_cfg_gpio,
  163. };
  164. static struct resource s5pc100_pcm0_resource[] = {
  165. [0] = {
  166. .start = S5PC100_PA_PCM0,
  167. .end = S5PC100_PA_PCM0 + 0x100 - 1,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = DMACH_PCM0_TX,
  172. .end = DMACH_PCM0_TX,
  173. .flags = IORESOURCE_DMA,
  174. },
  175. [2] = {
  176. .start = DMACH_PCM0_RX,
  177. .end = DMACH_PCM0_RX,
  178. .flags = IORESOURCE_DMA,
  179. },
  180. };
  181. struct platform_device s5pc100_device_pcm0 = {
  182. .name = "samsung-pcm",
  183. .id = 0,
  184. .num_resources = ARRAY_SIZE(s5pc100_pcm0_resource),
  185. .resource = s5pc100_pcm0_resource,
  186. .dev = {
  187. .platform_data = &s3c_pcm_pdata,
  188. },
  189. };
  190. static struct resource s5pc100_pcm1_resource[] = {
  191. [0] = {
  192. .start = S5PC100_PA_PCM1,
  193. .end = S5PC100_PA_PCM1 + 0x100 - 1,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. [1] = {
  197. .start = DMACH_PCM1_TX,
  198. .end = DMACH_PCM1_TX,
  199. .flags = IORESOURCE_DMA,
  200. },
  201. [2] = {
  202. .start = DMACH_PCM1_RX,
  203. .end = DMACH_PCM1_RX,
  204. .flags = IORESOURCE_DMA,
  205. },
  206. };
  207. struct platform_device s5pc100_device_pcm1 = {
  208. .name = "samsung-pcm",
  209. .id = 1,
  210. .num_resources = ARRAY_SIZE(s5pc100_pcm1_resource),
  211. .resource = s5pc100_pcm1_resource,
  212. .dev = {
  213. .platform_data = &s3c_pcm_pdata,
  214. },
  215. };
  216. /* AC97 Controller platform devices */
  217. static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev)
  218. {
  219. return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4));
  220. }
  221. static struct resource s5pc100_ac97_resource[] = {
  222. [0] = {
  223. .start = S5PC100_PA_AC97,
  224. .end = S5PC100_PA_AC97 + 0x100 - 1,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. [1] = {
  228. .start = DMACH_AC97_PCMOUT,
  229. .end = DMACH_AC97_PCMOUT,
  230. .flags = IORESOURCE_DMA,
  231. },
  232. [2] = {
  233. .start = DMACH_AC97_PCMIN,
  234. .end = DMACH_AC97_PCMIN,
  235. .flags = IORESOURCE_DMA,
  236. },
  237. [3] = {
  238. .start = DMACH_AC97_MICIN,
  239. .end = DMACH_AC97_MICIN,
  240. .flags = IORESOURCE_DMA,
  241. },
  242. [4] = {
  243. .start = IRQ_AC97,
  244. .end = IRQ_AC97,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. };
  248. static struct s3c_audio_pdata s3c_ac97_pdata = {
  249. .cfg_gpio = s5pc100_ac97_cfg_gpio,
  250. };
  251. static u64 s5pc100_ac97_dmamask = DMA_BIT_MASK(32);
  252. struct platform_device s5pc100_device_ac97 = {
  253. .name = "samsung-ac97",
  254. .id = -1,
  255. .num_resources = ARRAY_SIZE(s5pc100_ac97_resource),
  256. .resource = s5pc100_ac97_resource,
  257. .dev = {
  258. .platform_data = &s3c_ac97_pdata,
  259. .dma_mask = &s5pc100_ac97_dmamask,
  260. .coherent_dma_mask = DMA_BIT_MASK(32),
  261. },
  262. };
  263. /* S/PDIF Controller platform_device */
  264. static int s5pc100_spdif_cfg_gpd(struct platform_device *pdev)
  265. {
  266. s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3));
  267. return 0;
  268. }
  269. static int s5pc100_spdif_cfg_gpg3(struct platform_device *pdev)
  270. {
  271. s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3));
  272. return 0;
  273. }
  274. static struct resource s5pc100_spdif_resource[] = {
  275. [0] = {
  276. .start = S5PC100_PA_SPDIF,
  277. .end = S5PC100_PA_SPDIF + 0x100 - 1,
  278. .flags = IORESOURCE_MEM,
  279. },
  280. [1] = {
  281. .start = DMACH_SPDIF,
  282. .end = DMACH_SPDIF,
  283. .flags = IORESOURCE_DMA,
  284. },
  285. };
  286. static struct s3c_audio_pdata s5p_spdif_pdata = {
  287. .cfg_gpio = s5pc100_spdif_cfg_gpd,
  288. };
  289. static u64 s5pc100_spdif_dmamask = DMA_BIT_MASK(32);
  290. struct platform_device s5pc100_device_spdif = {
  291. .name = "samsung-spdif",
  292. .id = -1,
  293. .num_resources = ARRAY_SIZE(s5pc100_spdif_resource),
  294. .resource = s5pc100_spdif_resource,
  295. .dev = {
  296. .platform_data = &s5p_spdif_pdata,
  297. .dma_mask = &s5pc100_spdif_dmamask,
  298. .coherent_dma_mask = DMA_BIT_MASK(32),
  299. },
  300. };
  301. void __init s5pc100_spdif_setup_gpio(int gpio)
  302. {
  303. if (gpio == S5PC100_SPDIF_GPD)
  304. s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpd;
  305. else
  306. s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpg3;
  307. }