board-mop500-audio.c 4.4 KB

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