dev-audio.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 s5p64x0_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(S5P6440_GPR(4), 5, S3C_GPIO_SFN(5));
  28. s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, 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 s5p64x0_i2s_pdata = {
  37. .cfg_gpio = s5p64x0_cfg_i2s,
  38. .type = {
  39. .i2s = {
  40. .quirks = QUIRK_PRI_6CHAN,
  41. .src_clk = rclksrc,
  42. },
  43. },
  44. };
  45. static struct resource s5p64x0_iis0_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_iis0_resource),
  66. .resource = s5p64x0_iis0_resource,
  67. .dev = {
  68. .platform_data = &s5p64x0_i2s_pdata,
  69. },
  70. };
  71. struct platform_device s5p6450_device_iis0 = {
  72. .name = "samsung-i2s",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource),
  75. .resource = s5p64x0_iis0_resource,
  76. .dev = {
  77. .platform_data = &s5p64x0_i2s_pdata,
  78. },
  79. };
  80. /* PCM Controller platform_devices */
  81. static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
  82. {
  83. switch (pdev->id) {
  84. case 0:
  85. s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
  86. s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2));
  87. break;
  88. default:
  89. printk(KERN_DEBUG "Invalid PCM Controller number!");
  90. return -EINVAL;
  91. }
  92. return 0;
  93. }
  94. static struct s3c_audio_pdata s5p6440_pcm_pdata = {
  95. .cfg_gpio = s5p6440_pcm_cfg_gpio,
  96. };
  97. static struct resource s5p6440_pcm0_resource[] = {
  98. [0] = {
  99. .start = S5P64X0_PA_PCM,
  100. .end = S5P64X0_PA_PCM + 0x100 - 1,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [1] = {
  104. .start = DMACH_PCM0_TX,
  105. .end = DMACH_PCM0_TX,
  106. .flags = IORESOURCE_DMA,
  107. },
  108. [2] = {
  109. .start = DMACH_PCM0_RX,
  110. .end = DMACH_PCM0_RX,
  111. .flags = IORESOURCE_DMA,
  112. },
  113. };
  114. struct platform_device s5p6440_device_pcm = {
  115. .name = "samsung-pcm",
  116. .id = 0,
  117. .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
  118. .resource = s5p6440_pcm0_resource,
  119. .dev = {
  120. .platform_data = &s5p6440_pcm_pdata,
  121. },
  122. };