board-mop500-audio.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * License terms: GNU General Public License (GPL), version 2
  5. */
  6. #include <linux/platform_device.h>
  7. #include <linux/init.h>
  8. #include <linux/gpio.h>
  9. #include <plat/gpio-nomadik.h>
  10. #include <plat/pincfg.h>
  11. #include <plat/ste_dma40.h>
  12. #include <mach/devices.h>
  13. #include <mach/hardware.h>
  14. #include <mach/irqs.h>
  15. #include <mach/msp.h>
  16. #include "ste-dma40-db8500.h"
  17. #include "board-mop500.h"
  18. #include "devices-db8500.h"
  19. #include "pins-db8500.h"
  20. static struct stedma40_chan_cfg msp0_dma_rx = {
  21. .high_priority = true,
  22. .dir = STEDMA40_PERIPH_TO_MEM,
  23. .src_dev_type = DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX,
  24. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  25. .src_info.psize = STEDMA40_PSIZE_LOG_4,
  26. .dst_info.psize = STEDMA40_PSIZE_LOG_4,
  27. /* data_width is set during configuration */
  28. };
  29. static struct stedma40_chan_cfg msp0_dma_tx = {
  30. .high_priority = true,
  31. .dir = STEDMA40_MEM_TO_PERIPH,
  32. .src_dev_type = STEDMA40_DEV_DST_MEMORY,
  33. .dst_dev_type = DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX,
  34. .src_info.psize = STEDMA40_PSIZE_LOG_4,
  35. .dst_info.psize = STEDMA40_PSIZE_LOG_4,
  36. /* data_width is set during configuration */
  37. };
  38. struct msp_i2s_platform_data msp0_platform_data = {
  39. .id = MSP_I2S_0,
  40. .msp_i2s_dma_rx = &msp0_dma_rx,
  41. .msp_i2s_dma_tx = &msp0_dma_tx,
  42. };
  43. static struct stedma40_chan_cfg msp1_dma_rx = {
  44. .high_priority = true,
  45. .dir = STEDMA40_PERIPH_TO_MEM,
  46. .src_dev_type = DB8500_DMA_DEV30_MSP3_RX,
  47. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  48. .src_info.psize = STEDMA40_PSIZE_LOG_4,
  49. .dst_info.psize = STEDMA40_PSIZE_LOG_4,
  50. /* data_width is set during configuration */
  51. };
  52. static struct stedma40_chan_cfg msp1_dma_tx = {
  53. .high_priority = true,
  54. .dir = STEDMA40_MEM_TO_PERIPH,
  55. .src_dev_type = STEDMA40_DEV_DST_MEMORY,
  56. .dst_dev_type = DB8500_DMA_DEV30_MSP1_TX,
  57. .src_info.psize = STEDMA40_PSIZE_LOG_4,
  58. .dst_info.psize = STEDMA40_PSIZE_LOG_4,
  59. /* data_width is set during configuration */
  60. };
  61. struct msp_i2s_platform_data msp1_platform_data = {
  62. .id = MSP_I2S_1,
  63. .msp_i2s_dma_rx = NULL,
  64. .msp_i2s_dma_tx = &msp1_dma_tx,
  65. };
  66. static struct stedma40_chan_cfg msp2_dma_rx = {
  67. .high_priority = true,
  68. .dir = STEDMA40_PERIPH_TO_MEM,
  69. .src_dev_type = DB8500_DMA_DEV14_MSP2_RX,
  70. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  71. /* MSP2 DMA doesn't work with PSIZE == 4 on DB8500v2 */
  72. .src_info.psize = STEDMA40_PSIZE_LOG_1,
  73. .dst_info.psize = STEDMA40_PSIZE_LOG_1,
  74. /* data_width is set during configuration */
  75. };
  76. static struct stedma40_chan_cfg msp2_dma_tx = {
  77. .high_priority = true,
  78. .dir = STEDMA40_MEM_TO_PERIPH,
  79. .src_dev_type = STEDMA40_DEV_DST_MEMORY,
  80. .dst_dev_type = DB8500_DMA_DEV14_MSP2_TX,
  81. .src_info.psize = STEDMA40_PSIZE_LOG_4,
  82. .dst_info.psize = STEDMA40_PSIZE_LOG_4,
  83. .use_fixed_channel = true,
  84. .phy_channel = 1,
  85. /* data_width is set during configuration */
  86. };
  87. static struct platform_device *db8500_add_msp_i2s(struct device *parent,
  88. int id,
  89. resource_size_t base, int irq,
  90. struct msp_i2s_platform_data *pdata)
  91. {
  92. struct platform_device *pdev;
  93. struct resource res[] = {
  94. DEFINE_RES_MEM(base, SZ_4K),
  95. DEFINE_RES_IRQ(irq),
  96. };
  97. pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n",
  98. id, irq);
  99. pdev = platform_device_register_resndata(parent, "ux500-msp-i2s", id,
  100. res, ARRAY_SIZE(res),
  101. pdata, sizeof(*pdata));
  102. if (!pdev) {
  103. pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n",
  104. id);
  105. return NULL;
  106. }
  107. return pdev;
  108. }
  109. /* Platform device for ASoC MOP500 machine */
  110. static struct platform_device snd_soc_mop500 = {
  111. .name = "snd-soc-mop500",
  112. .id = 0,
  113. .dev = {
  114. .platform_data = NULL,
  115. },
  116. };
  117. /* Platform device for Ux500-PCM */
  118. static struct platform_device ux500_pcm = {
  119. .name = "ux500-pcm",
  120. .id = 0,
  121. .dev = {
  122. .platform_data = NULL,
  123. },
  124. };
  125. struct msp_i2s_platform_data msp2_platform_data = {
  126. .id = MSP_I2S_2,
  127. .msp_i2s_dma_rx = &msp2_dma_rx,
  128. .msp_i2s_dma_tx = &msp2_dma_tx,
  129. };
  130. struct msp_i2s_platform_data msp3_platform_data = {
  131. .id = MSP_I2S_3,
  132. .msp_i2s_dma_rx = &msp1_dma_rx,
  133. .msp_i2s_dma_tx = NULL,
  134. };
  135. void mop500_audio_init(struct device *parent)
  136. {
  137. pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
  138. platform_device_register(&snd_soc_mop500);
  139. pr_info("Initialize MSP I2S-devices.\n");
  140. db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
  141. &msp0_platform_data);
  142. db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
  143. &msp1_platform_data);
  144. db8500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2,
  145. &msp2_platform_data);
  146. db8500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1,
  147. &msp3_platform_data);
  148. }
  149. /* Due for removal once the MSP driver has been fully DT:ed. */
  150. void mop500_of_audio_init(struct device *parent)
  151. {
  152. pr_info("%s: Register platform-device 'ux500-pcm'\n", __func__);
  153. platform_device_register(&ux500_pcm);
  154. }