2
0

151-ASoC-mchp-i2s-mcc-Add-multi-channel-support-for-I2S-.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From 5bef4e8125d09443b5486971d5550ed285cde4b1 Mon Sep 17 00:00:00 2001
  2. From: Codrin Ciubotariu <[email protected]>
  3. Date: Mon, 1 Mar 2021 19:09:01 +0200
  4. Subject: [PATCH 151/247] ASoC: mchp-i2s-mcc: Add multi-channel support for I2S
  5. and LEFT_J formats
  6. The latest I2S-MCC available in SAMA7G5 supports multi-channel for I2S and
  7. Left-Justified formats. For this, the new version uses 8 (4 * 2) input and
  8. output pins, with each pin being responsible for 2 channels. This sums up
  9. to a total of 8 channels for synchronous capture and playback.
  10. Signed-off-by: Codrin Ciubotariu <[email protected]>
  11. Link: https://lore.kernel.org/r/[email protected]
  12. Signed-off-by: Mark Brown <[email protected]>
  13. ---
  14. sound/soc/atmel/mchp-i2s-mcc.c | 38 ++++++++++++++++++++++++++++++++++
  15. 1 file changed, 38 insertions(+)
  16. --- a/sound/soc/atmel/mchp-i2s-mcc.c
  17. +++ b/sound/soc/atmel/mchp-i2s-mcc.c
  18. @@ -16,6 +16,7 @@
  19. #include <linux/clk.h>
  20. #include <linux/mfd/syscon.h>
  21. #include <linux/lcm.h>
  22. +#include <linux/of_device.h>
  23. #include <sound/core.h>
  24. #include <sound/pcm.h>
  25. @@ -225,6 +226,10 @@ static const struct regmap_config mchp_i
  26. .max_register = MCHP_I2SMCC_VERSION,
  27. };
  28. +struct mchp_i2s_mcc_soc_data {
  29. + unsigned int data_pin_pair_num;
  30. +};
  31. +
  32. struct mchp_i2s_mcc_dev {
  33. struct wait_queue_head wq_txrdy;
  34. struct wait_queue_head wq_rxrdy;
  35. @@ -232,6 +237,7 @@ struct mchp_i2s_mcc_dev {
  36. struct regmap *regmap;
  37. struct clk *pclk;
  38. struct clk *gclk;
  39. + const struct mchp_i2s_mcc_soc_data *soc;
  40. struct snd_dmaengine_dai_dma_data playback;
  41. struct snd_dmaengine_dai_dma_data capture;
  42. unsigned int fmt;
  43. @@ -549,6 +555,17 @@ static int mchp_i2s_mcc_hw_params(struct
  44. }
  45. if (dev->fmt & (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J)) {
  46. + /* for I2S and LEFT_J one pin is needed for every 2 channels */
  47. + if (channels > dev->soc->data_pin_pair_num * 2) {
  48. + dev_err(dev->dev,
  49. + "unsupported number of audio channels: %d\n",
  50. + channels);
  51. + return -EINVAL;
  52. + }
  53. +
  54. + /* enable for interleaved format */
  55. + mrb |= MCHP_I2SMCC_MRB_CRAMODE_REGULAR;
  56. +
  57. switch (channels) {
  58. case 1:
  59. if (is_playback)
  60. @@ -558,6 +575,12 @@ static int mchp_i2s_mcc_hw_params(struct
  61. break;
  62. case 2:
  63. break;
  64. + case 4:
  65. + mra |= MCHP_I2SMCC_MRA_WIRECFG_I2S_2_TDM_1;
  66. + break;
  67. + case 8:
  68. + mra |= MCHP_I2SMCC_MRA_WIRECFG_I2S_4_TDM_2;
  69. + break;
  70. default:
  71. dev_err(dev->dev, "unsupported number of audio channels\n");
  72. return -EINVAL;
  73. @@ -869,12 +892,22 @@ static const struct snd_soc_component_dr
  74. };
  75. #ifdef CONFIG_OF
  76. +static struct mchp_i2s_mcc_soc_data mchp_i2s_mcc_sam9x60 = {
  77. + .data_pin_pair_num = 1,
  78. +};
  79. +
  80. +static struct mchp_i2s_mcc_soc_data mchp_i2s_mcc_sama7g5 = {
  81. + .data_pin_pair_num = 4,
  82. +};
  83. +
  84. static const struct of_device_id mchp_i2s_mcc_dt_ids[] = {
  85. {
  86. .compatible = "microchip,sam9x60-i2smcc",
  87. + .data = &mchp_i2s_mcc_sam9x60,
  88. },
  89. {
  90. .compatible = "microchip,sama7g5-i2smcc",
  91. + .data = &mchp_i2s_mcc_sama7g5,
  92. },
  93. { /* sentinel */ }
  94. };
  95. @@ -932,6 +965,11 @@ static int mchp_i2s_mcc_probe(struct pla
  96. dev->gclk = NULL;
  97. }
  98. + dev->soc = of_device_get_match_data(&pdev->dev);
  99. + if (!dev->soc) {
  100. + dev_err(&pdev->dev, "failed to get soc data\n");
  101. + return -ENODEV;
  102. + }
  103. dev->dev = &pdev->dev;
  104. dev->regmap = regmap;
  105. platform_set_drvdata(pdev, dev);