dev-audio.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 -1:
  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 struct s3c_audio_pdata s3c_i2s_pdata = {
  37. .cfg_gpio = s5p6442_cfg_i2s,
  38. };
  39. static struct resource s5p6442_iis0_resource[] = {
  40. [0] = {
  41. .start = S5P6442_PA_I2S0,
  42. .end = S5P6442_PA_I2S0 + 0x100 - 1,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. [1] = {
  46. .start = DMACH_I2S0_TX,
  47. .end = DMACH_I2S0_TX,
  48. .flags = IORESOURCE_DMA,
  49. },
  50. [2] = {
  51. .start = DMACH_I2S0_RX,
  52. .end = DMACH_I2S0_RX,
  53. .flags = IORESOURCE_DMA,
  54. },
  55. };
  56. struct platform_device s5p6442_device_iis0 = {
  57. .name = "s3c64xx-iis-v4",
  58. .id = -1,
  59. .num_resources = ARRAY_SIZE(s5p6442_iis0_resource),
  60. .resource = s5p6442_iis0_resource,
  61. .dev = {
  62. .platform_data = &s3c_i2s_pdata,
  63. },
  64. };
  65. static struct resource s5p6442_iis1_resource[] = {
  66. [0] = {
  67. .start = S5P6442_PA_I2S1,
  68. .end = S5P6442_PA_I2S1 + 0x100 - 1,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .start = DMACH_I2S1_TX,
  73. .end = DMACH_I2S1_TX,
  74. .flags = IORESOURCE_DMA,
  75. },
  76. [2] = {
  77. .start = DMACH_I2S1_RX,
  78. .end = DMACH_I2S1_RX,
  79. .flags = IORESOURCE_DMA,
  80. },
  81. };
  82. struct platform_device s5p6442_device_iis1 = {
  83. .name = "s3c64xx-iis",
  84. .id = 1,
  85. .num_resources = ARRAY_SIZE(s5p6442_iis1_resource),
  86. .resource = s5p6442_iis1_resource,
  87. .dev = {
  88. .platform_data = &s3c_i2s_pdata,
  89. },
  90. };
  91. /* PCM Controller platform_devices */
  92. static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
  93. {
  94. unsigned int base;
  95. switch (pdev->id) {
  96. case 0:
  97. base = S5P6442_GPC0(0);
  98. break;
  99. case 1:
  100. base = S5P6442_GPC1(0);
  101. break;
  102. default:
  103. printk(KERN_DEBUG "Invalid PCM Controller number!");
  104. return -EINVAL;
  105. }
  106. s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
  107. return 0;
  108. }
  109. static struct s3c_audio_pdata s3c_pcm_pdata = {
  110. .cfg_gpio = s5p6442_pcm_cfg_gpio,
  111. };
  112. static struct resource s5p6442_pcm0_resource[] = {
  113. [0] = {
  114. .start = S5P6442_PA_PCM0,
  115. .end = S5P6442_PA_PCM0 + 0x100 - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = DMACH_PCM0_TX,
  120. .end = DMACH_PCM0_TX,
  121. .flags = IORESOURCE_DMA,
  122. },
  123. [2] = {
  124. .start = DMACH_PCM0_RX,
  125. .end = DMACH_PCM0_RX,
  126. .flags = IORESOURCE_DMA,
  127. },
  128. };
  129. struct platform_device s5p6442_device_pcm0 = {
  130. .name = "samsung-pcm",
  131. .id = 0,
  132. .num_resources = ARRAY_SIZE(s5p6442_pcm0_resource),
  133. .resource = s5p6442_pcm0_resource,
  134. .dev = {
  135. .platform_data = &s3c_pcm_pdata,
  136. },
  137. };
  138. static struct resource s5p6442_pcm1_resource[] = {
  139. [0] = {
  140. .start = S5P6442_PA_PCM1,
  141. .end = S5P6442_PA_PCM1 + 0x100 - 1,
  142. .flags = IORESOURCE_MEM,
  143. },
  144. [1] = {
  145. .start = DMACH_PCM1_TX,
  146. .end = DMACH_PCM1_TX,
  147. .flags = IORESOURCE_DMA,
  148. },
  149. [2] = {
  150. .start = DMACH_PCM1_RX,
  151. .end = DMACH_PCM1_RX,
  152. .flags = IORESOURCE_DMA,
  153. },
  154. };
  155. struct platform_device s5p6442_device_pcm1 = {
  156. .name = "samsung-pcm",
  157. .id = 1,
  158. .num_resources = ARRAY_SIZE(s5p6442_pcm1_resource),
  159. .resource = s5p6442_pcm1_resource,
  160. .dev = {
  161. .platform_data = &s3c_pcm_pdata,
  162. },
  163. };