[alsa-devel] [PATCH 0/3] i.MX8M support for FSL SAI

Hi all,
those are the changes that are absolutely needed to support the i.MX8M SAI block. The most noticable difference is the moved register layout, due to the hardware guys adding two version registers at the start of the register map and considerable bigger FIFO sizes.
Downstream has a lot more changes to support new features, but those 3 patches at least allows me to play back audio on i.MX8M based systems.
Regards, Lucas
Lucas Stach (3): ASoC: fsl_sai: add of_match data ASoC: fsl_sai: derive TX FIFO watermark from FIFO depth ASoC: fsl_sai: add i.MX8M support
.../devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 45 +++++++++++++++---- sound/soc/fsl/fsl_sai.h | 8 +++- 3 files changed, 44 insertions(+), 11 deletions(-)

New revisions of the SAI IP block have even more differences that need be taken into account by the driver. To avoid sprinking compatible checks all over the driver move the current differences into of_match_data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de --- sound/soc/fsl/fsl_sai.c | 22 ++++++++++++++-------- sound/soc/fsl/fsl_sai.h | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 812c94fbb160..3a1ed8b857d6 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -9,6 +9,7 @@ #include <linux/dmaengine.h> #include <linux/module.h> #include <linux/of_address.h> +#include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -798,10 +799,7 @@ static int fsl_sai_probe(struct platform_device *pdev) return -ENOMEM;
sai->pdev = pdev; - - if (of_device_is_compatible(np, "fsl,imx6sx-sai") || - of_device_is_compatible(np, "fsl,imx6ul-sai")) - sai->sai_on_imx = true; + sai->soc_data = of_device_get_match_data(&pdev->dev);
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
@@ -910,7 +908,7 @@ static int fsl_sai_probe(struct platform_device *pdev) if (ret) return ret;
- if (sai->sai_on_imx) + if (sai->soc_data->use_imx_pcm) return imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE); else return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); @@ -923,10 +921,18 @@ static int fsl_sai_remove(struct platform_device *pdev) return 0; }
+static const struct fsl_sai_soc_data fsl_sai_vf610_data = { + .use_imx_pcm = false, +}; + +static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { + .use_imx_pcm = true, +}; + static const struct of_device_id fsl_sai_ids[] = { - { .compatible = "fsl,vf610-sai", }, - { .compatible = "fsl,imx6sx-sai", }, - { .compatible = "fsl,imx6ul-sai", }, + { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, + { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, + { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 24cb156bf995..83e2bfe05b1b 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -126,6 +126,10 @@ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6
+struct fsl_sai_soc_data { + bool use_imx_pcm; +}; + struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; @@ -135,7 +139,6 @@ struct fsl_sai { bool is_slave_mode; bool is_lsb_first; bool is_dsp_mode; - bool sai_on_imx; bool synchronous[2];
unsigned int mclk_id[2]; @@ -143,6 +146,7 @@ struct fsl_sai { unsigned int slots; unsigned int slot_width;
+ const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx; };

On 2019-07-17 04:56, Lucas Stach wrote:
New revisions of the SAI IP block have even more differences that need be taken into account by the driver. To avoid sprinking compatible checks all over the driver move the current differences into of_match_data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
Tested-by: Angus Ainslie angus@akkea.ca Reviewed-by: Angus Ainslie angus@akkea.ca
sound/soc/fsl/fsl_sai.c | 22 ++++++++++++++-------- sound/soc/fsl/fsl_sai.h | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 812c94fbb160..3a1ed8b857d6 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -9,6 +9,7 @@ #include <linux/dmaengine.h> #include <linux/module.h> #include <linux/of_address.h> +#include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -798,10 +799,7 @@ static int fsl_sai_probe(struct platform_device *pdev) return -ENOMEM;
sai->pdev = pdev;
- if (of_device_is_compatible(np, "fsl,imx6sx-sai") ||
of_device_is_compatible(np, "fsl,imx6ul-sai"))
sai->sai_on_imx = true;
sai->soc_data = of_device_get_match_data(&pdev->dev);
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
@@ -910,7 +908,7 @@ static int fsl_sai_probe(struct platform_device *pdev) if (ret) return ret;
- if (sai->sai_on_imx)
- if (sai->soc_data->use_imx_pcm) return imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE); else return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
@@ -923,10 +921,18 @@ static int fsl_sai_remove(struct platform_device *pdev) return 0; }
+static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
- .use_imx_pcm = false,
+};
+static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
- .use_imx_pcm = true,
+};
static const struct of_device_id fsl_sai_ids[] = {
- { .compatible = "fsl,vf610-sai", },
- { .compatible = "fsl,imx6sx-sai", },
- { .compatible = "fsl,imx6ul-sai", },
- { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data },
- { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data },
- { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, { /* sentinel */ }
}; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 24cb156bf995..83e2bfe05b1b 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -126,6 +126,10 @@ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6
+struct fsl_sai_soc_data {
- bool use_imx_pcm;
+};
struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; @@ -135,7 +139,6 @@ struct fsl_sai { bool is_slave_mode; bool is_lsb_first; bool is_dsp_mode;
bool sai_on_imx; bool synchronous[2];
unsigned int mclk_id[2];
@@ -143,6 +146,7 @@ struct fsl_sai { unsigned int slots; unsigned int slot_width;
- const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx;
};

On Wed, Jul 17, 2019 at 1:58 PM Lucas Stach l.stach@pengutronix.de wrote:
New revisions of the SAI IP block have even more differences that need be taken into account by the driver. To avoid sprinking compatible checks all over the driver move the current differences into of_match_data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is the way I handled in my patch series too. So,
Reviewed-by: Daniel Baluta daniel.baluta@nxp.com
sound/soc/fsl/fsl_sai.c | 22 ++++++++++++++-------- sound/soc/fsl/fsl_sai.h | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 812c94fbb160..3a1ed8b857d6 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -9,6 +9,7 @@ #include <linux/dmaengine.h> #include <linux/module.h> #include <linux/of_address.h> +#include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -798,10 +799,7 @@ static int fsl_sai_probe(struct platform_device *pdev) return -ENOMEM;
sai->pdev = pdev;
if (of_device_is_compatible(np, "fsl,imx6sx-sai") ||
of_device_is_compatible(np, "fsl,imx6ul-sai"))
sai->sai_on_imx = true;
sai->soc_data = of_device_get_match_data(&pdev->dev); sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
@@ -910,7 +908,7 @@ static int fsl_sai_probe(struct platform_device *pdev) if (ret) return ret;
if (sai->sai_on_imx)
if (sai->soc_data->use_imx_pcm) return imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE); else return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
@@ -923,10 +921,18 @@ static int fsl_sai_remove(struct platform_device *pdev) return 0; }
+static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
.use_imx_pcm = false,
+};
+static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
.use_imx_pcm = true,
+};
static const struct of_device_id fsl_sai_ids[] = {
{ .compatible = "fsl,vf610-sai", },
{ .compatible = "fsl,imx6sx-sai", },
{ .compatible = "fsl,imx6ul-sai", },
{ .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data },
{ .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data },
{ .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, { /* sentinel */ }
}; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 24cb156bf995..83e2bfe05b1b 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -126,6 +126,10 @@ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6
+struct fsl_sai_soc_data {
bool use_imx_pcm;
+};
struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; @@ -135,7 +139,6 @@ struct fsl_sai { bool is_slave_mode; bool is_lsb_first; bool is_dsp_mode;
bool sai_on_imx; bool synchronous[2]; unsigned int mclk_id[2];
@@ -143,6 +146,7 @@ struct fsl_sai { unsigned int slots; unsigned int slot_width;
const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx;
};
2.20.1
Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

The patch
ASoC: fsl_sai: add of_match data
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 5442954f20d9f0fbc0f29a69a2fe0f70aa11273e Mon Sep 17 00:00:00 2001
From: Lucas Stach l.stach@pengutronix.de Date: Wed, 17 Jul 2019 12:56:33 +0200 Subject: [PATCH] ASoC: fsl_sai: add of_match data
New revisions of the SAI IP block have even more differences that need be taken into account by the driver. To avoid sprinking compatible checks all over the driver move the current differences into of_match_data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Tested-by: Angus Ainslie angus@akkea.ca Reviewed-by: Angus Ainslie angus@akkea.ca Reviewed-by: Daniel Baluta daniel.baluta@nxp.com Link: https://lore.kernel.org/r/20190717105635.18514-2-l.stach@pengutronix.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/fsl/fsl_sai.c | 22 ++++++++++++++-------- sound/soc/fsl/fsl_sai.h | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index d58cc3ae90d8..ed0432e7327a 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -9,6 +9,7 @@ #include <linux/dmaengine.h> #include <linux/module.h> #include <linux/of_address.h> +#include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -788,10 +789,7 @@ static int fsl_sai_probe(struct platform_device *pdev) return -ENOMEM;
sai->pdev = pdev; - - if (of_device_is_compatible(np, "fsl,imx6sx-sai") || - of_device_is_compatible(np, "fsl,imx6ul-sai")) - sai->sai_on_imx = true; + sai->soc_data = of_device_get_match_data(&pdev->dev);
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
@@ -900,7 +898,7 @@ static int fsl_sai_probe(struct platform_device *pdev) if (ret) return ret;
- if (sai->sai_on_imx) + if (sai->soc_data->use_imx_pcm) return imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE); else return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); @@ -913,10 +911,18 @@ static int fsl_sai_remove(struct platform_device *pdev) return 0; }
+static const struct fsl_sai_soc_data fsl_sai_vf610_data = { + .use_imx_pcm = false, +}; + +static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { + .use_imx_pcm = true, +}; + static const struct of_device_id fsl_sai_ids[] = { - { .compatible = "fsl,vf610-sai", }, - { .compatible = "fsl,imx6sx-sai", }, - { .compatible = "fsl,imx6ul-sai", }, + { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, + { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, + { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 24cb156bf995..83e2bfe05b1b 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -126,6 +126,10 @@ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6
+struct fsl_sai_soc_data { + bool use_imx_pcm; +}; + struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; @@ -135,7 +139,6 @@ struct fsl_sai { bool is_slave_mode; bool is_lsb_first; bool is_dsp_mode; - bool sai_on_imx; bool synchronous[2];
unsigned int mclk_id[2]; @@ -143,6 +146,7 @@ struct fsl_sai { unsigned int slots; unsigned int slot_width;
+ const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx; };

The DMA request schould be triggered as soon as the FIFO has space for another burst. As different versions of the SAI block have different FIFO sizes, the watrmark level needs to be derived from version specific data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de --- sound/soc/fsl/fsl_sai.c | 4 +++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 3a1ed8b857d6..b3cd055a61c7 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -649,7 +649,7 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK, - FSL_SAI_MAXBURST_TX * 2); + sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX); regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);
@@ -923,10 +923,12 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, + .fifo_depth = 32, };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, + .fifo_depth = 32, };
static const struct of_device_id fsl_sai_ids[] = { diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 83e2bfe05b1b..7c1ef671da28 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm; + unsigned int fifo_depth; };
struct fsl_sai {

On 2019-07-17 04:56, Lucas Stach wrote:
The DMA request schould be triggered as soon as the FIFO has space for another burst. As different versions of the SAI block have different FIFO sizes, the watrmark level needs to be derived from version specific data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
Tested-by: Angus Ainslie angus@akkea.ca Reviewed-by: Angus Ainslie angus@akkea.ca
sound/soc/fsl/fsl_sai.c | 4 +++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 3a1ed8b857d6..b3cd055a61c7 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -649,7 +649,7 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK,
FSL_SAI_MAXBURST_TX * 2);
regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX);
@@ -923,10 +923,12 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
- .fifo_depth = 32,
};
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
- .fifo_depth = 32,
};
static const struct of_device_id fsl_sai_ids[] = { diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 83e2bfe05b1b..7c1ef671da28 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm;
- unsigned int fifo_depth;
};
struct fsl_sai {

The patch
ASoC: fsl_sai: derive TX FIFO watermark from FIFO depth
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 8decc2428f4684ae35afec7c9aed92fba9fc4696 Mon Sep 17 00:00:00 2001
From: Lucas Stach l.stach@pengutronix.de Date: Wed, 17 Jul 2019 12:56:34 +0200 Subject: [PATCH] ASoC: fsl_sai: derive TX FIFO watermark from FIFO depth
The DMA request schould be triggered as soon as the FIFO has space for another burst. As different versions of the SAI block have different FIFO sizes, the watrmark level needs to be derived from version specific data.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Tested-by: Angus Ainslie angus@akkea.ca Reviewed-by: Angus Ainslie angus@akkea.ca Link: https://lore.kernel.org/r/20190717105635.18514-3-l.stach@pengutronix.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/fsl/fsl_sai.c | 4 +++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index ed0432e7327a..1d1a447163e3 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -640,7 +640,7 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK, - FSL_SAI_MAXBURST_TX * 2); + sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX); regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);
@@ -913,10 +913,12 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, + .fifo_depth = 32, };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, + .fifo_depth = 32, };
static const struct of_device_id fsl_sai_ids[] = { diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 83e2bfe05b1b..7c1ef671da28 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm; + unsigned int fifo_depth; };
struct fsl_sai {

The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de --- .../devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 19 +++++++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 2e726b983845..037871d2f505 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -8,7 +8,7 @@ codec/DSP interfaces. Required properties:
- compatible : Compatible list, contains "fsl,vf610-sai", - "fsl,imx6sx-sai" or "fsl,imx6ul-sai" + "fsl,imx6sx-sai", "fsl,imx6ul-sai" or "fsl,imx8mq-sai"
- reg : Offset and length of the register set for the device.
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b3cd055a61c7..a10201078e40 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -808,6 +808,16 @@ static int fsl_sai_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base);
+ /* + * New versions of the SAI have 2 32bit version registers added at the + * start of the register map. To avoid dealing with this shift all over + * the driver, we move the start of the regmap to make both register + * layouts look the same to the regmap. This means we can't read the + * version registers through the regmap, but this is small price to pay. + */ + if (sai->soc_data->has_version_registers) + base += 8; + sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", base, &fsl_sai_regmap_config);
@@ -923,18 +933,27 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, + .has_version_registers = false, .fifo_depth = 32, };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, + .has_version_registers = false, .fifo_depth = 32, };
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = { + .use_imx_pcm = true, + .has_version_registers = true, + .fifo_depth = 128, +}; + static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, + { .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 7c1ef671da28..b6a9053ed400 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm; + bool has_version_registers; unsigned int fifo_depth; };

On 2019-07-17 04:56, Lucas Stach wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
checkpatch has a complaint about mixing code and device tree bindings.
Other than that
Tested-by: Angus Ainslie angus@akkea.ca Reviewed-by: Angus Ainslie angus@akkea.ca
.../devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 19 +++++++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 2e726b983845..037871d2f505 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -8,7 +8,7 @@ codec/DSP interfaces. Required properties:
- compatible : Compatible list, contains "fsl,vf610-sai",
"fsl,imx6sx-sai" or "fsl,imx6ul-sai"
"fsl,imx6sx-sai", "fsl,imx6ul-sai" or "fsl,imx8mq-sai"
- reg : Offset and length of the register set for the device.
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b3cd055a61c7..a10201078e40 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -808,6 +808,16 @@ static int fsl_sai_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base);
- /*
* New versions of the SAI have 2 32bit version registers added at
the
* start of the register map. To avoid dealing with this shift all
over
* the driver, we move the start of the regmap to make both register
* layouts look the same to the regmap. This means we can't read the
* version registers through the regmap, but this is small price to
pay.
*/
- if (sai->soc_data->has_version_registers)
base += 8;
- sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", base, &fsl_sai_regmap_config);
@@ -923,18 +933,27 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
- .has_version_registers = false, .fifo_depth = 32,
};
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
- .has_version_registers = false, .fifo_depth = 32,
};
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
- .use_imx_pcm = true,
- .has_version_registers = true,
- .fifo_depth = 128,
+};
static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
- { .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ }
}; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 7c1ef671da28..b6a9053ed400 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm;
- bool has_version_registers; unsigned int fifo_depth;
};

On Thu, Jul 18, 2019 at 1:36 PM Angus Ainslie angus@akkea.ca wrote:
On 2019-07-17 04:56, Lucas Stach wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
checkpatch has a complaint about mixing code and device tree bindings.
Hello Angus, Lucas,
What imx-sdma firmware have you used to test this with linux-next? I've finished my changes but aplay gets stuck sending the first audio frame.
Daniel.

Hi Daniel,
On 2019-07-22 03:39, Daniel Baluta wrote:
On Thu, Jul 18, 2019 at 1:36 PM Angus Ainslie angus@akkea.ca wrote:
On 2019-07-17 04:56, Lucas Stach wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
checkpatch has a complaint about mixing code and device tree bindings.
Hello Angus, Lucas,
What imx-sdma firmware have you used to test this with linux-next? I've finished my changes but aplay gets stuck sending the first audio frame.
I'm just using the ROM firmware, I have no additional firmware in the filesystem.
Angus
Daniel.

On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach l.stach@pengutronix.de wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is a little bit tricky. We need the verid register in order to differentiate IPs which can support 1:1 ratio for bclk:mclk
I am working now for upstreaming all SAI patches that we have in our internal tree.
.../devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 19 +++++++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 2e726b983845..037871d2f505 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -8,7 +8,7 @@ codec/DSP interfaces. Required properties:
- compatible : Compatible list, contains "fsl,vf610-sai",
"fsl,imx6sx-sai" or "fsl,imx6ul-sai"
"fsl,imx6sx-sai", "fsl,imx6ul-sai" or "fsl,imx8mq-sai"
- reg : Offset and length of the register set for the device.
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b3cd055a61c7..a10201078e40 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -808,6 +808,16 @@ static int fsl_sai_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base);
/*
* New versions of the SAI have 2 32bit version registers added at the
* start of the register map. To avoid dealing with this shift all over
* the driver, we move the start of the regmap to make both register
* layouts look the same to the regmap. This means we can't read the
* version registers through the regmap, but this is small price to pay.
*/
if (sai->soc_data->has_version_registers)
base += 8;
sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", base, &fsl_sai_regmap_config);
@@ -923,18 +933,27 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
.has_version_registers = false, .fifo_depth = 32,
};
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
.has_version_registers = false, .fifo_depth = 32,
};
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
.use_imx_pcm = true,
.has_version_registers = true,
.fifo_depth = 128,
+};
static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
{ .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ }
}; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 7c1ef671da28..b6a9053ed400 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm;
bool has_version_registers; unsigned int fifo_depth;
};
-- 2.20.1
Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Hi Daniel,
Am Mittwoch, den 17.07.2019, 17:16 +0300 schrieb Daniel Baluta:
On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach l.stach@pengutronix.de wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is a little bit tricky. We need the verid register in order to differentiate IPs which can support 1:1 ratio for bclk:mclk
And this patch doesn't prevent this usage. If needed we can just read the verid via a plain readl on the base mapping in the probe function and cache it in struct fsl_sai. This seems way less intrusive than carrying a register offset through all of the regmap accessors and validation functions. I simply haven't implemented it in this patch, as I had no need for it right now.
Regards, Lucas
I am working now for upstreaming all SAI patches that we have in our internal tree.
.../devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 19 +++++++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 2e726b983845..037871d2f505 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -8,7 +8,7 @@ codec/DSP interfaces. Required properties:
- compatible : Compatible list, contains "fsl,vf610-sai", - "fsl,imx6sx-sai" or "fsl,imx6ul-sai" + "fsl,imx6sx-sai", "fsl,imx6ul-sai" or "fsl,imx8mq-sai"
- reg : Offset and length of the register set for the device.
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b3cd055a61c7..a10201078e40 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -808,6 +808,16 @@ static int fsl_sai_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base);
+ /* + * New versions of the SAI have 2 32bit version registers added at the + * start of the register map. To avoid dealing with this shift all over + * the driver, we move the start of the regmap to make both register + * layouts look the same to the regmap. This means we can't read the + * version registers through the regmap, but this is small price to pay. + */ + if (sai->soc_data->has_version_registers) + base += 8;
sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", base, &fsl_sai_regmap_config);
@@ -923,18 +933,27 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, + .has_version_registers = false, .fifo_depth = 32, };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, + .has_version_registers = false, .fifo_depth = 32, };
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = { + .use_imx_pcm = true, + .has_version_registers = true, + .fifo_depth = 128, +};
static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data }, + { .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_sai_ids); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 7c1ef671da28..b6a9053ed400 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -128,6 +128,7 @@
struct fsl_sai_soc_data { bool use_imx_pcm; + bool has_version_registers; unsigned int fifo_depth; };
-- 2.20.1
Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

On Wed, Jul 17, 2019 at 5:33 PM Lucas Stach l.stach@pengutronix.de wrote:
Hi Daniel,
Am Mittwoch, den 17.07.2019, 17:16 +0300 schrieb Daniel Baluta:
On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach l.stach@pengutronix.de wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is a little bit tricky. We need the verid register in order to differentiate IPs which can support 1:1 ratio for bclk:mclk
And this patch doesn't prevent this usage. If needed we can just read the verid via a plain readl on the base mapping in the probe function and cache it in struct fsl_sai. This seems way less intrusive than carrying a register offset through all of the regmap accessors and validation functions. I simply haven't implemented it in this patch, as I had no need for it right now.
I must admit this is a very clever idea! Anyhow, I'm having some concerns because unfortunately not all registers were shifted by 8 bytes.
See: imx6sx [1] (page 3575) and imx8X [2] (page 5512) RMs.
We have something like this:
i.mx6 SX:
00: TCSR 04: TCR1 08: TCR2 0C: TCR3 .... 60: TMR 80: RCSR
i.mx 8X
00: VERID 04: PARAM 08: TCSR 0C: TCR1 ... 60: TMR 88: RCSR
[1] https://cache.nxp.com/secured/assets/documents/en/reference-manual/IMX6SXRM.... [2] https://www.nxp.com/docs/en/reference-manual/IMX8DQXPRM.pdf

On 2019-07-17 09:06, Daniel Baluta wrote:
On Wed, Jul 17, 2019 at 5:33 PM Lucas Stach l.stach@pengutronix.de wrote:
Hi Daniel,
Am Mittwoch, den 17.07.2019, 17:16 +0300 schrieb Daniel Baluta:
On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach l.stach@pengutronix.de wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is a little bit tricky. We need the verid register in order to differentiate IPs which can support 1:1 ratio for bclk:mclk
And this patch doesn't prevent this usage. If needed we can just read the verid via a plain readl on the base mapping in the probe function and cache it in struct fsl_sai. This seems way less intrusive than carrying a register offset through all of the regmap accessors and validation functions. I simply haven't implemented it in this patch, as I had no need for it right now.
I must admit this is a very clever idea! Anyhow, I'm having some concerns because unfortunately not all registers were shifted by 8 bytes.
See: imx6sx [1] (page 3575) and imx8X [2] (page 5512) RMs.
We have something like this:
i.mx6 SX:
00: TCSR 04: TCR1 08: TCR2 0C: TCR3 .... 60: TMR 80: RCSR
i.mx 8X
00: VERID 04: PARAM 08: TCSR 0C: TCR1 ... 60: TMR 88: RCSR
We could split it into an upper and a lower regmap. Only the lower would need the version register offset.
[1] https://cache.nxp.com/secured/assets/documents/en/reference-manual/IMX6SXRM.... [2] https://www.nxp.com/docs/en/reference-manual/IMX8DQXPRM.pdf

On Wed, Jul 17, 2019 at 6:15 PM Angus Ainslie angus@akkea.ca wrote:
On 2019-07-17 09:06, Daniel Baluta wrote:
On Wed, Jul 17, 2019 at 5:33 PM Lucas Stach l.stach@pengutronix.de wrote:
Hi Daniel,
Am Mittwoch, den 17.07.2019, 17:16 +0300 schrieb Daniel Baluta:
On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach l.stach@pengutronix.de wrote:
The SAI block on the i.MX8M moved the register layout, as 2 version registers were added at the start of the register map. We deal with this by moving the start of the regmap, so both register layouts look the same to accesses going through the regmap.
Signed-off-by: Lucas Stach l.stach@pengutronix.de
This is a little bit tricky. We need the verid register in order to differentiate IPs which can support 1:1 ratio for bclk:mclk
And this patch doesn't prevent this usage. If needed we can just read the verid via a plain readl on the base mapping in the probe function and cache it in struct fsl_sai. This seems way less intrusive than carrying a register offset through all of the regmap accessors and validation functions. I simply haven't implemented it in this patch, as I had no need for it right now.
I must admit this is a very clever idea! Anyhow, I'm having some concerns because unfortunately not all registers were shifted by 8 bytes.
See: imx6sx [1] (page 3575) and imx8X [2] (page 5512) RMs.
We have something like this:
i.mx6 SX:
00: TCSR 04: TCR1 08: TCR2 0C: TCR3 .... 60: TMR 80: RCSR
i.mx 8X
00: VERID 04: PARAM 08: TCSR 0C: TCR1 ... 60: TMR 88: RCSR
We could split it into an upper and a lower regmap. Only the lower would need the version register offset.
That would work but will be unnecessary complicated. Let me send the imx8M support as we implemented in our tree by Friday.
It has the disadvantage that we've wrapped all shifted register with a macro but I don't see other solution.

On 2019-07-17 12:56, Lucas Stach wrote:
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
.has_version_registers = false, .fifo_depth = 32, };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
.has_version_registers = false, .fifo_depth = 32, };
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
- .use_imx_pcm = true,
- .has_version_registers = true,
- .fifo_depth = 128,
+};
- static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
- { .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ } };
These datas are populating quite rapidly. If you're planning for adding more (and/ or appending additional fields), declaring helper macro could prove useful.
Czarek

On Thu, Jul 18, 2019 at 10:12 PM Cezary Rojewski cezary.rojewski@intel.com wrote:
On 2019-07-17 12:56, Lucas Stach wrote:
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
.has_version_registers = false, .fifo_depth = 32,
};
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
.has_version_registers = false, .fifo_depth = 32,
};
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
.use_imx_pcm = true,
.has_version_registers = true,
.fifo_depth = 128,
+};
- static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
};{ .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ }
Hi Czarek,
These datas are populating quite rapidly. If you're planning for adding more (and/ or appending additional fields), declaring helper macro could prove useful.
There would be definitely more fields inside *_data structures. Anyhow, not sure what do you mean by declaring a helper macro.
Can you provide an example and how would that be helpful?
thanks, Daniel.

On 2019-07-18 21:22, Daniel Baluta wrote:
On Thu, Jul 18, 2019 at 10:12 PM Cezary Rojewski cezary.rojewski@intel.com wrote:
On 2019-07-17 12:56, Lucas Stach wrote:
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false,
.has_version_registers = false, .fifo_depth = 32,
};
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true,
.has_version_registers = false, .fifo_depth = 32,
};
+static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
.use_imx_pcm = true,
.has_version_registers = true,
.fifo_depth = 128,
+};
- static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data }, { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data }, { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
};{ .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data }, { /* sentinel */ }
Hi Czarek,
These datas are populating quite rapidly. If you're planning for adding more (and/ or appending additional fields), declaring helper macro could prove useful.
There would be definitely more fields inside *_data structures. Anyhow, not sure what do you mean by declaring a helper macro.
Can you provide an example and how would that be helpful?
thanks, Daniel.
Hello Daniel,
My suggestion was rather straight-forward - examples of such can be found in soc-dapm.h header file. Instead of stating everything explicitly, there are e.g.: SND_SOC_DAPM_SPK or SND_SOC_DAPM_PGA declared to help me out.
Nothing fancy, just space savers if your structs populate like rabbits.
Czarek
participants (5)
-
Angus Ainslie
-
Cezary Rojewski
-
Daniel Baluta
-
Lucas Stach
-
Mark Brown