dev-audio.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 int s5p6440_cfg_i2s(struct platform_device *pdev)
  19. {
  20. /* configure GPIO for i2s port */
  21. switch (pdev->id) {
  22. case -1:
  23. s3c_gpio_cfgpin_range(S5P6440_GPR(4), 5, S3C_GPIO_SFN(5));
  24. s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(5));
  25. break;
  26. default:
  27. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  28. return -EINVAL;
  29. }
  30. return 0;
  31. }
  32. static int s5p6450_cfg_i2s(struct platform_device *pdev)
  33. {
  34. /* configure GPIO for i2s port */
  35. switch (pdev->id) {
  36. case -1:
  37. s3c_gpio_cfgpin(S5P6450_GPB(4), S3C_GPIO_SFN(5));
  38. s3c_gpio_cfgpin_range(S5P6450_GPR(4), 5, S3C_GPIO_SFN(5));
  39. s3c_gpio_cfgpin_range(S5P6450_GPR(13), 2, S3C_GPIO_SFN(5));
  40. break;
  41. default:
  42. printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  43. return -EINVAL;
  44. }
  45. return 0;
  46. }
  47. static struct s3c_audio_pdata s5p6440_i2s_pdata = {
  48. .cfg_gpio = s5p6440_cfg_i2s,
  49. };
  50. static struct s3c_audio_pdata s5p6450_i2s_pdata = {
  51. .cfg_gpio = s5p6450_cfg_i2s,
  52. };
  53. static struct resource s5p64x0_iis0_resource[] = {
  54. [0] = {
  55. .start = S5P64X0_PA_I2S,
  56. .end = S5P64X0_PA_I2S + 0x100 - 1,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. [1] = {
  60. .start = DMACH_I2S0_TX,
  61. .end = DMACH_I2S0_TX,
  62. .flags = IORESOURCE_DMA,
  63. },
  64. [2] = {
  65. .start = DMACH_I2S0_RX,
  66. .end = DMACH_I2S0_RX,
  67. .flags = IORESOURCE_DMA,
  68. },
  69. };
  70. struct platform_device s5p6440_device_iis = {
  71. .name = "s3c64xx-iis-v4",
  72. .id = -1,
  73. .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource),
  74. .resource = s5p64x0_iis0_resource,
  75. .dev = {
  76. .platform_data = &s5p6440_i2s_pdata,
  77. },
  78. };
  79. struct platform_device s5p6450_device_iis0 = {
  80. .name = "s3c64xx-iis-v4",
  81. .id = -1,
  82. .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource),
  83. .resource = s5p64x0_iis0_resource,
  84. .dev = {
  85. .platform_data = &s5p6450_i2s_pdata,
  86. },
  87. };
  88. /* PCM Controller platform_devices */
  89. static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
  90. {
  91. switch (pdev->id) {
  92. case 0:
  93. s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
  94. s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2));
  95. break;
  96. default:
  97. printk(KERN_DEBUG "Invalid PCM Controller number!");
  98. return -EINVAL;
  99. }
  100. return 0;
  101. }
  102. static struct s3c_audio_pdata s5p6440_pcm_pdata = {
  103. .cfg_gpio = s5p6440_pcm_cfg_gpio,
  104. };
  105. static struct resource s5p6440_pcm0_resource[] = {
  106. [0] = {
  107. .start = S5P64X0_PA_PCM,
  108. .end = S5P64X0_PA_PCM + 0x100 - 1,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [1] = {
  112. .start = DMACH_PCM0_TX,
  113. .end = DMACH_PCM0_TX,
  114. .flags = IORESOURCE_DMA,
  115. },
  116. [2] = {
  117. .start = DMACH_PCM0_RX,
  118. .end = DMACH_PCM0_RX,
  119. .flags = IORESOURCE_DMA,
  120. },
  121. };
  122. struct platform_device s5p6440_device_pcm = {
  123. .name = "samsung-pcm",
  124. .id = 0,
  125. .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
  126. .resource = s5p6440_pcm0_resource,
  127. .dev = {
  128. .platform_data = &s5p6440_pcm_pdata,
  129. },
  130. };