dev-audio.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /* linux/arch/arm/mach-s5pv210/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] = "busclk",
  20. [1] = "i2sclk",
  21. };
  22. static int s5pv210_cfg_i2s(struct platform_device *pdev)
  23. {
  24. /* configure GPIO for i2s port */
  25. switch (pdev->id) {
  26. case 0:
  27. s3c_gpio_cfgpin_range(S5PV210_GPI(0), 7, S3C_GPIO_SFN(2));
  28. break;
  29. case 1:
  30. s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(2));
  31. break;
  32. case 2:
  33. s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(4));
  34. break;
  35. default:
  36. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  37. return -EINVAL;
  38. }
  39. return 0;
  40. }
  41. static struct s3c_audio_pdata i2sv5_pdata = {
  42. .cfg_gpio = s5pv210_cfg_i2s,
  43. .type = {
  44. .i2s = {
  45. .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
  46. | QUIRK_NEED_RSTCLR,
  47. .src_clk = rclksrc,
  48. },
  49. },
  50. };
  51. static struct resource s5pv210_iis0_resource[] = {
  52. [0] = {
  53. .start = S5PV210_PA_IIS0,
  54. .end = S5PV210_PA_IIS0 + 0x100 - 1,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. [1] = {
  58. .start = DMACH_I2S0_TX,
  59. .end = DMACH_I2S0_TX,
  60. .flags = IORESOURCE_DMA,
  61. },
  62. [2] = {
  63. .start = DMACH_I2S0_RX,
  64. .end = DMACH_I2S0_RX,
  65. .flags = IORESOURCE_DMA,
  66. },
  67. [3] = {
  68. .start = DMACH_I2S0S_TX,
  69. .end = DMACH_I2S0S_TX,
  70. .flags = IORESOURCE_DMA,
  71. },
  72. };
  73. struct platform_device s5pv210_device_iis0 = {
  74. .name = "samsung-i2s",
  75. .id = 0,
  76. .num_resources = ARRAY_SIZE(s5pv210_iis0_resource),
  77. .resource = s5pv210_iis0_resource,
  78. .dev = {
  79. .platform_data = &i2sv5_pdata,
  80. },
  81. };
  82. static const char *rclksrc_v3[] = {
  83. [0] = "iis",
  84. [1] = "audio-bus",
  85. };
  86. static struct s3c_audio_pdata i2sv3_pdata = {
  87. .cfg_gpio = s5pv210_cfg_i2s,
  88. .type = {
  89. .i2s = {
  90. .src_clk = rclksrc_v3,
  91. },
  92. },
  93. };
  94. static struct resource s5pv210_iis1_resource[] = {
  95. [0] = {
  96. .start = S5PV210_PA_IIS1,
  97. .end = S5PV210_PA_IIS1 + 0x100 - 1,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [1] = {
  101. .start = DMACH_I2S1_TX,
  102. .end = DMACH_I2S1_TX,
  103. .flags = IORESOURCE_DMA,
  104. },
  105. [2] = {
  106. .start = DMACH_I2S1_RX,
  107. .end = DMACH_I2S1_RX,
  108. .flags = IORESOURCE_DMA,
  109. },
  110. };
  111. struct platform_device s5pv210_device_iis1 = {
  112. .name = "samsung-i2s",
  113. .id = 1,
  114. .num_resources = ARRAY_SIZE(s5pv210_iis1_resource),
  115. .resource = s5pv210_iis1_resource,
  116. .dev = {
  117. .platform_data = &i2sv3_pdata,
  118. },
  119. };
  120. static struct resource s5pv210_iis2_resource[] = {
  121. [0] = {
  122. .start = S5PV210_PA_IIS2,
  123. .end = S5PV210_PA_IIS2 + 0x100 - 1,
  124. .flags = IORESOURCE_MEM,
  125. },
  126. [1] = {
  127. .start = DMACH_I2S2_TX,
  128. .end = DMACH_I2S2_TX,
  129. .flags = IORESOURCE_DMA,
  130. },
  131. [2] = {
  132. .start = DMACH_I2S2_RX,
  133. .end = DMACH_I2S2_RX,
  134. .flags = IORESOURCE_DMA,
  135. },
  136. };
  137. struct platform_device s5pv210_device_iis2 = {
  138. .name = "samsung-i2s",
  139. .id = 2,
  140. .num_resources = ARRAY_SIZE(s5pv210_iis2_resource),
  141. .resource = s5pv210_iis2_resource,
  142. .dev = {
  143. .platform_data = &i2sv3_pdata,
  144. },
  145. };
  146. /* PCM Controller platform_devices */
  147. static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev)
  148. {
  149. switch (pdev->id) {
  150. case 0:
  151. s3c_gpio_cfgpin_range(S5PV210_GPI(0), 5, S3C_GPIO_SFN(3));
  152. break;
  153. case 1:
  154. s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(3));
  155. break;
  156. case 2:
  157. s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(2));
  158. break;
  159. default:
  160. printk(KERN_DEBUG "Invalid PCM Controller number!");
  161. return -EINVAL;
  162. }
  163. return 0;
  164. }
  165. static struct s3c_audio_pdata s3c_pcm_pdata = {
  166. .cfg_gpio = s5pv210_pcm_cfg_gpio,
  167. };
  168. static struct resource s5pv210_pcm0_resource[] = {
  169. [0] = {
  170. .start = S5PV210_PA_PCM0,
  171. .end = S5PV210_PA_PCM0 + 0x100 - 1,
  172. .flags = IORESOURCE_MEM,
  173. },
  174. [1] = {
  175. .start = DMACH_PCM0_TX,
  176. .end = DMACH_PCM0_TX,
  177. .flags = IORESOURCE_DMA,
  178. },
  179. [2] = {
  180. .start = DMACH_PCM0_RX,
  181. .end = DMACH_PCM0_RX,
  182. .flags = IORESOURCE_DMA,
  183. },
  184. };
  185. struct platform_device s5pv210_device_pcm0 = {
  186. .name = "samsung-pcm",
  187. .id = 0,
  188. .num_resources = ARRAY_SIZE(s5pv210_pcm0_resource),
  189. .resource = s5pv210_pcm0_resource,
  190. .dev = {
  191. .platform_data = &s3c_pcm_pdata,
  192. },
  193. };
  194. static struct resource s5pv210_pcm1_resource[] = {
  195. [0] = {
  196. .start = S5PV210_PA_PCM1,
  197. .end = S5PV210_PA_PCM1 + 0x100 - 1,
  198. .flags = IORESOURCE_MEM,
  199. },
  200. [1] = {
  201. .start = DMACH_PCM1_TX,
  202. .end = DMACH_PCM1_TX,
  203. .flags = IORESOURCE_DMA,
  204. },
  205. [2] = {
  206. .start = DMACH_PCM1_RX,
  207. .end = DMACH_PCM1_RX,
  208. .flags = IORESOURCE_DMA,
  209. },
  210. };
  211. struct platform_device s5pv210_device_pcm1 = {
  212. .name = "samsung-pcm",
  213. .id = 1,
  214. .num_resources = ARRAY_SIZE(s5pv210_pcm1_resource),
  215. .resource = s5pv210_pcm1_resource,
  216. .dev = {
  217. .platform_data = &s3c_pcm_pdata,
  218. },
  219. };
  220. static struct resource s5pv210_pcm2_resource[] = {
  221. [0] = {
  222. .start = S5PV210_PA_PCM2,
  223. .end = S5PV210_PA_PCM2 + 0x100 - 1,
  224. .flags = IORESOURCE_MEM,
  225. },
  226. [1] = {
  227. .start = DMACH_PCM2_TX,
  228. .end = DMACH_PCM2_TX,
  229. .flags = IORESOURCE_DMA,
  230. },
  231. [2] = {
  232. .start = DMACH_PCM2_RX,
  233. .end = DMACH_PCM2_RX,
  234. .flags = IORESOURCE_DMA,
  235. },
  236. };
  237. struct platform_device s5pv210_device_pcm2 = {
  238. .name = "samsung-pcm",
  239. .id = 2,
  240. .num_resources = ARRAY_SIZE(s5pv210_pcm2_resource),
  241. .resource = s5pv210_pcm2_resource,
  242. .dev = {
  243. .platform_data = &s3c_pcm_pdata,
  244. },
  245. };
  246. /* AC97 Controller platform devices */
  247. static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev)
  248. {
  249. return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4));
  250. }
  251. static struct resource s5pv210_ac97_resource[] = {
  252. [0] = {
  253. .start = S5PV210_PA_AC97,
  254. .end = S5PV210_PA_AC97 + 0x100 - 1,
  255. .flags = IORESOURCE_MEM,
  256. },
  257. [1] = {
  258. .start = DMACH_AC97_PCMOUT,
  259. .end = DMACH_AC97_PCMOUT,
  260. .flags = IORESOURCE_DMA,
  261. },
  262. [2] = {
  263. .start = DMACH_AC97_PCMIN,
  264. .end = DMACH_AC97_PCMIN,
  265. .flags = IORESOURCE_DMA,
  266. },
  267. [3] = {
  268. .start = DMACH_AC97_MICIN,
  269. .end = DMACH_AC97_MICIN,
  270. .flags = IORESOURCE_DMA,
  271. },
  272. [4] = {
  273. .start = IRQ_AC97,
  274. .end = IRQ_AC97,
  275. .flags = IORESOURCE_IRQ,
  276. },
  277. };
  278. static struct s3c_audio_pdata s3c_ac97_pdata = {
  279. .cfg_gpio = s5pv210_ac97_cfg_gpio,
  280. };
  281. static u64 s5pv210_ac97_dmamask = DMA_BIT_MASK(32);
  282. struct platform_device s5pv210_device_ac97 = {
  283. .name = "samsung-ac97",
  284. .id = -1,
  285. .num_resources = ARRAY_SIZE(s5pv210_ac97_resource),
  286. .resource = s5pv210_ac97_resource,
  287. .dev = {
  288. .platform_data = &s3c_ac97_pdata,
  289. .dma_mask = &s5pv210_ac97_dmamask,
  290. .coherent_dma_mask = DMA_BIT_MASK(32),
  291. },
  292. };
  293. /* S/PDIF Controller platform_device */
  294. static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev)
  295. {
  296. s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3));
  297. return 0;
  298. }
  299. static struct resource s5pv210_spdif_resource[] = {
  300. [0] = {
  301. .start = S5PV210_PA_SPDIF,
  302. .end = S5PV210_PA_SPDIF + 0x100 - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .start = DMACH_SPDIF,
  307. .end = DMACH_SPDIF,
  308. .flags = IORESOURCE_DMA,
  309. },
  310. };
  311. static struct s3c_audio_pdata samsung_spdif_pdata = {
  312. .cfg_gpio = s5pv210_spdif_cfg_gpio,
  313. };
  314. static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32);
  315. struct platform_device s5pv210_device_spdif = {
  316. .name = "samsung-spdif",
  317. .id = -1,
  318. .num_resources = ARRAY_SIZE(s5pv210_spdif_resource),
  319. .resource = s5pv210_spdif_resource,
  320. .dev = {
  321. .platform_data = &samsung_spdif_pdata,
  322. .dma_mask = &s5pv210_spdif_dmamask,
  323. .coherent_dma_mask = DMA_BIT_MASK(32),
  324. },
  325. };