1 From 5bef4e8125d09443b5486971d5550ed285cde4b1 Mon Sep 17 00:00:00 2001
2 From: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
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
7 The latest I2S-MCC available in SAMA7G5 supports multi-channel for I2S and
8 Left-Justified formats. For this, the new version uses 8 (4 * 2) input and
9 output pins, with each pin being responsible for 2 channels. This sums up
10 to a total of 8 channels for synchronous capture and playback.
12 Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
13 Link: https://lore.kernel.org/r/20210301170905.835091-4-codrin.ciubotariu@microchip.com
14 Signed-off-by: Mark Brown <broonie@kernel.org>
16 sound/soc/atmel/mchp-i2s-mcc.c | 38 ++++++++++++++++++++++++++++++++++
17 1 file changed, 38 insertions(+)
19 --- a/sound/soc/atmel/mchp-i2s-mcc.c
20 +++ b/sound/soc/atmel/mchp-i2s-mcc.c
22 #include <linux/clk.h>
23 #include <linux/mfd/syscon.h>
24 #include <linux/lcm.h>
25 +#include <linux/of_device.h>
27 #include <sound/core.h>
28 #include <sound/pcm.h>
29 @@ -225,6 +226,10 @@ static const struct regmap_config mchp_i
30 .max_register = MCHP_I2SMCC_VERSION,
33 +struct mchp_i2s_mcc_soc_data {
34 + unsigned int data_pin_pair_num;
37 struct mchp_i2s_mcc_dev {
38 struct wait_queue_head wq_txrdy;
39 struct wait_queue_head wq_rxrdy;
40 @@ -232,6 +237,7 @@ struct mchp_i2s_mcc_dev {
41 struct regmap *regmap;
44 + const struct mchp_i2s_mcc_soc_data *soc;
45 struct snd_dmaengine_dai_dma_data playback;
46 struct snd_dmaengine_dai_dma_data capture;
48 @@ -549,6 +555,17 @@ static int mchp_i2s_mcc_hw_params(struct
51 if (dev->fmt & (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J)) {
52 + /* for I2S and LEFT_J one pin is needed for every 2 channels */
53 + if (channels > dev->soc->data_pin_pair_num * 2) {
55 + "unsupported number of audio channels: %d\n",
60 + /* enable for interleaved format */
61 + mrb |= MCHP_I2SMCC_MRB_CRAMODE_REGULAR;
66 @@ -558,6 +575,12 @@ static int mchp_i2s_mcc_hw_params(struct
71 + mra |= MCHP_I2SMCC_MRA_WIRECFG_I2S_2_TDM_1;
74 + mra |= MCHP_I2SMCC_MRA_WIRECFG_I2S_4_TDM_2;
77 dev_err(dev->dev, "unsupported number of audio channels\n");
79 @@ -869,12 +892,22 @@ static const struct snd_soc_component_dr
83 +static struct mchp_i2s_mcc_soc_data mchp_i2s_mcc_sam9x60 = {
84 + .data_pin_pair_num = 1,
87 +static struct mchp_i2s_mcc_soc_data mchp_i2s_mcc_sama7g5 = {
88 + .data_pin_pair_num = 4,
91 static const struct of_device_id mchp_i2s_mcc_dt_ids[] = {
93 .compatible = "microchip,sam9x60-i2smcc",
94 + .data = &mchp_i2s_mcc_sam9x60,
97 .compatible = "microchip,sama7g5-i2smcc",
98 + .data = &mchp_i2s_mcc_sama7g5,
102 @@ -932,6 +965,11 @@ static int mchp_i2s_mcc_probe(struct pla
106 + dev->soc = of_device_get_match_data(&pdev->dev);
108 + dev_err(&pdev->dev, "failed to get soc data\n");
111 dev->dev = &pdev->dev;
112 dev->regmap = regmap;
113 platform_set_drvdata(pdev, dev);