[alsa-devel] [PATCH v2 00/11] ASoC: fsl-ssi: ac97-slave support
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Markus Pargmann (11): ASoC: phycore-ac97: Add DT support ASoC: imx-pcm-dma: Add support for DMA init by ASoC: imx-pcm-fiq: Introduce pcm-fiq-params ASoC: fsl-ssi: Add SACNT definitions ASoC: fsl-ssi: Add support for imx-pcm-fiq ASoC: fsl-ssi: Setup generic imx dma params ARM: imx: Export ac97 reset functions ASoC: fsl-ssi: imx ac97 support ASoC: fsl: Kconfig: Use fsl-ssi for phycore-ac97 ASoC: fsl: Move fsl-ssi binding doc to sound/ ASoC: fsl: Update fsl-ssi binding doc
Documentation/devicetree/bindings/powerpc/fsl/ssi.txt | 73 - Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 b/Documentation/devicetree/bindings/sound/fsl,ssi.txt | 73 + b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt | 12 b/arch/arm/mach-imx/mach-pca100.c | 7 b/arch/arm/mach-imx/mach-pcm043.c | 7 b/sound/soc/fsl/Kconfig | 2 b/sound/soc/fsl/fsl_ssi.c | 70 + b/sound/soc/fsl/fsl_ssi.h | 8 b/sound/soc/fsl/imx-pcm-dma.c | 31 b/sound/soc/fsl/imx-pcm-fiq.c | 14 b/sound/soc/fsl/imx-pcm.h | 6 b/sound/soc/fsl/imx-ssi.c | 7 b/sound/soc/fsl/imx-ssi.h | 1 b/sound/soc/fsl/phycore-ac97.c | 185 ++++ sound/soc/fsl/fsl_ssi.c | 379 +++++++--- sound/soc/fsl/imx-pcm.h | 9 17 files changed, 664 insertions(+), 233 deletions(-)
Add devicetree support for this audio soc fabric driver.
Signed-off-by: Markus Pargmann mpa@pengutronix.de ---
Notes: Changes in v2: - Simplify the driver, by combining audmux port configurations. The audmux driver actually knows on which platform he is running and will return the appropriate error code if we use functions for another platform. So we don't need to have the knowledge about it in phycore-ac97 and can try both functions. This removes the need of different compatibilities and renames it to imx27-ac97. - Use a phandle for the cpu_dai link. - Add devicetree binding documentation. - Rename binding to phytec,phycore-ac97 and fsl,ssi to phytec,ssi
.../bindings/sound/phytec,phycore-ac97.txt | 12 ++ sound/soc/fsl/phycore-ac97.c | 185 ++++++++++++++++++--- 2 files changed, 174 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt
diff --git a/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt new file mode 100644 index 0000000..e04221d --- /dev/null +++ b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt @@ -0,0 +1,12 @@ +Phytec phycore AC97 + +Required properties: +- compatible: "phytec,phycore-ac97" +- phytec,ssi: A phandle to the ssi device that is connected to ac97. + +Example: + +sound { + compatible = "phytec,phycore-ac97"; + phytec,ssi = <&ssi1>; +}; diff --git a/sound/soc/fsl/phycore-ac97.c b/sound/soc/fsl/phycore-ac97.c index d146cec..123af2b 100644 --- a/sound/soc/fsl/phycore-ac97.c +++ b/sound/soc/fsl/phycore-ac97.c @@ -21,7 +21,10 @@
#include "imx-audmux.h"
+#define DRV_NAME "phycore-audio-fabric" + static struct snd_soc_card imx_phycore; +static struct device_node *phycore_dai_cpu_node;
static struct snd_soc_ops imx_phycore_hifi_ops = { }; @@ -32,8 +35,12 @@ static struct snd_soc_dai_link imx_phycore_dai_ac97[] = { .stream_name = "HiFi", .codec_dai_name = "wm9712-hifi", .codec_name = "wm9712-codec", +#ifdef CONFIG_MACH_IMX27_DT + .platform_name = "imx-fiq-pcm-audio", +#else .cpu_dai_name = "imx-ssi.0", .platform_name = "imx-fiq-pcm-audio.0", +#endif .ops = &imx_phycore_hifi_ops, }, }; @@ -45,41 +52,83 @@ static struct snd_soc_card imx_phycore = { .num_links = ARRAY_SIZE(imx_phycore_dai_ac97), };
-static struct platform_device *imx_phycore_snd_ac97_device; +static int phycore_ac97_pca100_audmux(void) +{ + int ret; + + ret = imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V1_PCR_TFCSEL(3) | + IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ + IMX_AUDMUX_V1_PCR_RXDSEL(3)); + if (ret) + return ret; + + ret = imx_audmux_v1_configure_port(3, + IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V1_PCR_TFCSEL(0) | + IMX_AUDMUX_V1_PCR_TFSDIR | + IMX_AUDMUX_V1_PCR_RXDSEL(0)); + return ret; +} + +static int phycore_ac97_pcm043_audmux(void) +{ + int ret; + + ret = imx_audmux_v2_configure_port(3, + IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V2_PTCR_TFSEL(0) | + IMX_AUDMUX_V2_PTCR_TFSDIR, + IMX_AUDMUX_V2_PDCR_RXDSEL(0)); + if (ret) + return ret; + + ret = imx_audmux_v2_configure_port(0, + IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V2_PTCR_TCSEL(3) | + IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ + IMX_AUDMUX_V2_PDCR_RXDSEL(3)); + return ret; +} + +static __maybe_unused int phycore_ac97_init_audmux(void) +{ + int ret; + + /* + * This driver doesn't need to know which actual hardware is used. + * The audmux driver has knowledge about it's type, and returns + * an error if executed on the wrong type of hardware. + */ + ret = phycore_ac97_pca100_audmux(); + if (!ret) + return 0; + + ret = phycore_ac97_pcm043_audmux(); + + return ret; +} + static struct platform_device *imx_phycore_snd_device;
+#ifndef CONFIG_MACH_IMX27_DT + +static struct platform_device *imx_phycore_snd_ac97_device; + static int __init imx_phycore_init(void) { int ret;
if (machine_is_pca100()) { - imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - IMX_AUDMUX_V1_PCR_TFCSEL(3) | - IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ - IMX_AUDMUX_V1_PCR_RXDSEL(3)); - imx_audmux_v1_configure_port(3, - IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - IMX_AUDMUX_V1_PCR_TFCSEL(0) | - IMX_AUDMUX_V1_PCR_TFSDIR | - IMX_AUDMUX_V1_PCR_RXDSEL(0)); + phycore_ac97_pca100_audmux(); } else if (machine_is_pcm043()) { - imx_audmux_v2_configure_port(3, - IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - IMX_AUDMUX_V2_PTCR_TFSEL(0) | - IMX_AUDMUX_V2_PTCR_TFSDIR, - IMX_AUDMUX_V2_PDCR_RXDSEL(0)); - imx_audmux_v2_configure_port(0, - IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - IMX_AUDMUX_V2_PTCR_TCSEL(3) | - IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ - IMX_AUDMUX_V2_PDCR_RXDSEL(3)); + phycore_ac97_pcm043_audmux(); } else { /* return happy. We might run on a totally different machine */ return 0; }
- /* * First add codec driver, otherwise soc-audio may be deferred and fails * to load. @@ -125,6 +174,96 @@ static void __exit imx_phycore_exit(void) late_initcall(imx_phycore_init); module_exit(imx_phycore_exit);
+#else /* !CONFIG_MACH_IMX27_DT */ + +static const struct of_device_id imx_phycore_ac97_of_dev_id[] = { + { + .compatible = "phytec,phycore-ac97", + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(of, imx_phycore_ac97_of_dev_id); + +static int phycore_ac97_setup_devices(struct platform_device *pdev) +{ + int ret; + + imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1); + if (!imx_phycore_snd_device) + return -ENOMEM; + + ret = platform_device_add(imx_phycore_snd_device); + if (ret) { + dev_err(&pdev->dev, "ASoC: Platform device allocation failed\n"); + goto fail1; + } + + ret = snd_soc_register_card(&imx_phycore); + if (ret) { + dev_err(&pdev->dev, "ASoC: soc card registration failed\n"); + goto fail2; + } + return 0; + +fail2: + platform_device_del(imx_phycore_snd_device); +fail1: + platform_device_put(imx_phycore_snd_device); + return ret; +} + +static int imx_phycore_ac97_probe(struct platform_device *pdev) +{ + int ret; + struct device_node *ssi_np; + + imx_phycore.dev = &pdev->dev; + + ret = phycore_ac97_init_audmux(); + if (ret) { + dev_err(&pdev->dev, "Failed to initialize audmux\n"); + return ret; + } + + ssi_np = of_parse_phandle(pdev->dev.of_node, "phytec,ssi", 0); + if (!ssi_np) { + dev_err(&pdev->dev, "No valid ssi phandle found\n"); + return -EINVAL; + } + + imx_phycore_dai_ac97[0].cpu_of_node = ssi_np; + phycore_dai_cpu_node = ssi_np; + + + ret = phycore_ac97_setup_devices(pdev); + if (ret) + of_node_put(phycore_dai_cpu_node); + + return ret; +} + +static int imx_phycore_ac97_remove(struct platform_device *pdev) +{ + of_node_put(phycore_dai_cpu_node); + platform_device_unregister(imx_phycore_snd_device); + return 0; +} + +static struct platform_driver imx_phycore_ac97_driver = { + .probe = imx_phycore_ac97_probe, + .remove = imx_phycore_ac97_remove, + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + .of_match_table = imx_phycore_ac97_of_dev_id, + }, +}; + +module_platform_driver(imx_phycore_ac97_driver); + +#endif /* CONFIG_MACH_IMX27_DT */ + MODULE_AUTHOR("Sascha Hauer s.hauer@pengutronix.de"); -MODULE_DESCRIPTION("PhyCORE ALSA SoC driver"); +MODULE_DESCRIPTION(DRV_NAME ": PhyCORE ALSA SoC fabric driver"); MODULE_LICENSE("GPL");
Markus Pargmann wrote:
Notes: Changes in v2: - Simplify the driver, by combining audmux port configurations. The audmux driver actually knows on which platform he is running and will return the appropriate error code if we use functions for another platform. So we don't need to have the knowledge about it in phycore-ac97 and can try both functions. This removes the need of different compatibilities and renames it to imx27-ac97. - Use a phandle for the cpu_dai link. - Add devicetree binding documentation. - Rename binding to phytec,phycore-ac97 and fsl,ssi to phytec,ssi
I think some of this information belongs in the changelog.
+#ifdef CONFIG_MACH_IMX27_DT
.platform_name = "imx-fiq-pcm-audio",
+#else .cpu_dai_name = "imx-ssi.0", .platform_name = "imx-fiq-pcm-audio.0", +#endif
What's the difference between "imx-fiq-pcm-audio" and "imx-fiq-pcm-audio.0"?
On Sun, Apr 07, 2013 at 09:52:17PM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
Notes: Changes in v2: - Simplify the driver, by combining audmux port configurations. The audmux driver actually knows on which platform he is running and will return the appropriate error code if we use functions for another platform. So we don't need to have the knowledge about it in phycore-ac97 and can try both functions. This removes the need of different compatibilities and renames it to imx27-ac97. - Use a phandle for the cpu_dai link. - Add devicetree binding documentation. - Rename binding to phytec,phycore-ac97 and fsl,ssi to phytec,ssi
I think some of this information belongs in the changelog.
Okay
+#ifdef CONFIG_MACH_IMX27_DT
.platform_name = "imx-fiq-pcm-audio",
+#else .cpu_dai_name = "imx-ssi.0", .platform_name = "imx-fiq-pcm-audio.0", +#endif
What's the difference between "imx-fiq-pcm-audio" and "imx-fiq-pcm-audio.0"?
The previous version of phycore-ac97 was using devices created by the board init code. They passed a proper pdev id which was used in all drivers they created. Since fsl-ssi is using DT, that id is -1 and is ignored for the device name. So we have to remove the .0 for DT here. This driver is not used multiple times in one system, so it shouldn't be a problem.
Regards,
Markus
-- Timur Tabi
Add support for DMA initialization using devicetree node.
This patch adds two fields to imx_pcm_dma_params to pass device node information from other imx drivers to this one. If the dma_node is set, this driver tries to initialize a PCM DMA substream based on the dma_node and name.
Signed-off-by: Markus Pargmann mpa@pengutronix.de ---
Notes: Changes in v2: - Use snd_dmaengine_generic_pcm_open instead of of_snd_dmaengine_pcm_open. - Pass the device in imx_pcm_dma_params.
sound/soc/fsl/imx-pcm-dma.c | 31 ++++++++++++++++++++----------- sound/soc/fsl/imx-pcm.h | 6 ++++++ 2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 500f8ce..2d15ca5 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -101,26 +101,35 @@ static int snd_imx_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct imx_pcm_dma_params *dma_params; - struct imx_dma_data *dma_data; + struct imx_dma_data *dma_data = NULL; int ret;
snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
- dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); - if (!dma_data) - return -ENOMEM; + if (dma_params->dma_client_dev) { + ret = snd_dmaengine_generic_pcm_open(substream, + dma_params->dma_client_dev, + dma_params->dma_req_name); + if (ret) + return ret; + } else { + dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); + if (!dma_data) + return -ENOMEM;
- dma_data->peripheral_type = dma_params->shared_peripheral ? + dma_data->peripheral_type = dma_params->shared_peripheral ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI; - dma_data->priority = DMA_PRIO_HIGH; - dma_data->dma_request = dma_params->dma; + dma_data->priority = DMA_PRIO_HIGH; + dma_data->dma_request = dma_params->dma;
- ret = snd_dmaengine_pcm_open(substream, filter, dma_data); - if (ret) { - kfree(dma_data); - return ret; + ret = snd_dmaengine_pcm_open(substream, filter, dma_data); + + if (ret) { + kfree(dma_data); + return ret; + } }
snd_dmaengine_pcm_set_data(substream, dma_data); diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 5ae13a1..ff0cfdf 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -23,6 +23,12 @@ struct imx_pcm_dma_params { unsigned long dma_addr; int burstsize; bool shared_peripheral; /* The peripheral is on SPBA bus */ + + /* If set, the DMA channel is requested using the generic handler while + * ignoring fields 'dma' and 'shared_peripheral'. They have to be set + * in devicetree according to the DMA Controller devicetree bindings. */ + struct device *dma_client_dev; + const char *dma_req_name; /* DMA Request name from devicetree */ };
int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,
Cleaner parameter passing for imx-pcm-fiq. Create a seperated fiq-params struct to pass all arguments.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/imx-pcm-fiq.c | 14 +++++++------- sound/soc/fsl/imx-pcm.h | 9 +++++++++ sound/soc/fsl/imx-ssi.c | 7 ++++++- sound/soc/fsl/imx-ssi.h | 1 + 4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 920f945..995ed35 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -283,7 +283,7 @@ static struct snd_soc_platform_driver imx_soc_platform_fiq = {
int imx_pcm_fiq_init(struct platform_device *pdev) { - struct imx_ssi *ssi = platform_get_drvdata(pdev); + struct imx_pcm_fiq_params *params = platform_get_drvdata(pdev); int ret;
ret = claim_fiq(&fh); @@ -292,15 +292,15 @@ int imx_pcm_fiq_init(struct platform_device *pdev) return ret; }
- mxc_set_irq_fiq(ssi->irq, 1); - ssi_irq = ssi->irq; + mxc_set_irq_fiq(params->irq, 1); + ssi_irq = params->irq;
- imx_pcm_fiq = ssi->irq; + imx_pcm_fiq = params->irq;
- imx_ssi_fiq_base = (unsigned long)ssi->base; + imx_ssi_fiq_base = (unsigned long)params->base;
- ssi->dma_params_tx.burstsize = 4; - ssi->dma_params_rx.burstsize = 6; + params->dma_params_tx->burstsize = 4; + params->dma_params_rx->burstsize = 6;
ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); if (ret) diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index ff0cfdf..f568a0e 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -31,6 +31,15 @@ struct imx_pcm_dma_params { const char *dma_req_name; /* DMA Request name from devicetree */ };
+struct imx_pcm_fiq_params { + int irq; + void __iomem *base; + + /* Pointer to original ssi driver to setup tx rx sizes */ + struct imx_pcm_dma_params *dma_params_tx; + struct imx_pcm_dma_params *dma_params_rx; +}; + int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma); int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 96e24a3..93f7562 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -608,7 +608,12 @@ static int imx_ssi_probe(struct platform_device *pdev) goto failed_pdev_fiq_alloc; }
- platform_set_drvdata(ssi->soc_platform_pdev_fiq, ssi); + ssi->fiq_params.irq = ssi->irq; + ssi->fiq_params.base = ssi->base; + ssi->fiq_params.dma_params_rx = &ssi->dma_params_rx; + ssi->fiq_params.dma_params_tx = &ssi->dma_params_tx; + + platform_set_drvdata(ssi->soc_platform_pdev_fiq, &ssi->fiq_params); ret = platform_device_add(ssi->soc_platform_pdev_fiq); if (ret) { dev_err(&pdev->dev, "failed to add platform device\n"); diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index dc114bd..90a45ef 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h @@ -206,6 +206,7 @@ struct imx_ssi {
struct imx_pcm_dma_params dma_params_rx; struct imx_pcm_dma_params dma_params_tx; + struct imx_pcm_fiq_params fiq_params;
int enabled;
Add definitions for AC97 control register.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/fsl_ssi.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index 2173000..e6b9a69 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h @@ -196,5 +196,13 @@ struct ccsr_ssi { #define CCSR_SSI_SOR_WAIT(x) (((x) & 3) << CCSR_SSI_SOR_WAIT_SHIFT) #define CCSR_SSI_SOR_SYNRST 0x00000001
+#define CCSR_SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5) +#define CCSR_SSI_SACNT_WR 0x00000010 +#define CCSR_SSI_SACNT_RD 0x00000008 +#define CCSR_SSI_SACNT_RDWR_MASK 0x00000018 +#define CCSR_SSI_SACNT_TIF 0x00000004 +#define CCSR_SSI_SACNT_FV 0x00000002 +#define CCSR_SSI_SACNT_AC97EN 0x00000001 + #endif
Markus Pargmann wrote:
Add definitions for AC97 control register.
Signed-off-by: Markus Pargmannmpa@pengutronix.de
Acked-by: Timur Tabi timur@tabi.org
Add support for non-dma pcm for imx platforms with imx-pcm-fiq support. Instead of imx-pcm-audio, in this case imx-pcm-fiq-audio device is added and the SIER flags are set differently.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/fsl_ssi.c | 70 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 7decbd9..afb5a23 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -120,10 +120,12 @@ struct fsl_ssi_private {
bool new_binding; bool ssi_on_imx; + bool dma; struct clk *clk; struct platform_device *imx_pcm_pdev; struct imx_pcm_dma_params dma_params_tx; struct imx_pcm_dma_params dma_params_rx; + struct imx_pcm_fiq_params fiq_params;
struct { unsigned int rfrc; @@ -353,7 +355,8 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, */
/* Enable the interrupts and DMA requests */ - write_ssi(SIER_FLAGS, &ssi->sier); + if (ssi_private->dma) + write_ssi(SIER_FLAGS, &ssi->sier);
/* * Set the watermark for transmit FIFI 0 and receive FIFO 0. We @@ -520,6 +523,18 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; }
+ if (!ssi_private->dma) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor); + write_ssi(CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN, + &ssi->sier); + } else { + write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor); + write_ssi(CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN, + &ssi->sier); + } + } + return 0; }
@@ -680,6 +695,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) sizeof(fsl_ssi_dai_template)); ssi_private->cpu_dai_drv.name = ssi_private->name;
+ ssi_private->dma = !of_property_read_bool(np, "fsl,imx-fiq"); + /* Get the addresses and IRQ */ ret = of_address_to_resource(np, 0, &res); if (ret) { @@ -701,12 +718,15 @@ static int fsl_ssi_probe(struct platform_device *pdev) goto error_iomap; }
- /* The 'name' should not have any slashes in it. */ - ret = request_irq(ssi_private->irq, fsl_ssi_isr, 0, ssi_private->name, - ssi_private); - if (ret < 0) { - dev_err(&pdev->dev, "could not claim irq %u\n", ssi_private->irq); - goto error_irqmap; + if (ssi_private->dma) { + /* The 'name' should not have any slashes in it. */ + ret = request_irq(ssi_private->irq, fsl_ssi_isr, 0, + ssi_private->name, ssi_private); + if (ret < 0) { + dev_err(&pdev->dev, "could not claim irq %u\n", + ssi_private->irq); + goto error_irqmap; + } }
/* Are the RX and the TX clocks locked? */ @@ -789,12 +809,38 @@ static int fsl_ssi_probe(struct platform_device *pdev) }
if (ssi_private->ssi_on_imx) { - ssi_private->imx_pcm_pdev = - platform_device_register_simple("imx-pcm-audio", + if (!ssi_private->dma) { + ssi_private->imx_pcm_pdev = platform_device_alloc( + "imx-fiq-pcm-audio", + pdev->id); + if (!ssi_private->imx_pcm_pdev) { + ret = -ENOMEM; + goto error_dev; + } + + ssi_private->fiq_params.irq = ssi_private->irq; + ssi_private->fiq_params.base = ssi_private->ssi; + ssi_private->fiq_params.dma_params_rx = + &ssi_private->dma_params_rx; + ssi_private->fiq_params.dma_params_tx = + &ssi_private->dma_params_tx; + + platform_set_drvdata(ssi_private->imx_pcm_pdev, + &ssi_private->fiq_params); + ret = platform_device_add(ssi_private->imx_pcm_pdev); + if (ret) { + dev_err(&pdev->dev, "Failed to add imx-fiq-pcm-audio device\n"); + platform_device_put(ssi_private->imx_pcm_pdev); + goto error_dev; + } + } else { + ssi_private->imx_pcm_pdev = + platform_device_register_simple("imx-pcm-audio", -1, NULL, 0); - if (IS_ERR(ssi_private->imx_pcm_pdev)) { - ret = PTR_ERR(ssi_private->imx_pcm_pdev); - goto error_dev; + if (IS_ERR(ssi_private->imx_pcm_pdev)) { + ret = PTR_ERR(ssi_private->imx_pcm_pdev); + goto error_dev; + } } }
Markus Pargmann wrote:
Add support for non-dma pcm for imx platforms with imx-pcm-fiq support. Instead of imx-pcm-audio, in this case imx-pcm-fiq-audio device is added and the SIER flags are set differently.
So just to be clear, this is interrupt-driven SSI audio? So you're generating an interrupt every time the transmit FIFO goes below the threshold?
I wonder if it makes sense to enable both FIFOs, so that you take half as many interrupts per second.
Signed-off-by: Markus Pargmann mpa@pengutronix.de
sound/soc/fsl/fsl_ssi.c | 70 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 7decbd9..afb5a23 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -120,10 +120,12 @@ struct fsl_ssi_private {
bool new_binding; bool ssi_on_imx;
- bool dma;
Can you rename this to "use_dma" or something like that?
struct clk *clk; struct platform_device *imx_pcm_pdev; struct imx_pcm_dma_params dma_params_tx; struct imx_pcm_dma_params dma_params_rx;
struct imx_pcm_fiq_params fiq_params;
struct { unsigned int rfrc;
@@ -353,7 +355,8 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, */
/* Enable the interrupts and DMA requests */
write_ssi(SIER_FLAGS, &ssi->sier);
if (ssi_private->dma)
write_ssi(SIER_FLAGS, &ssi->sier);
/*
- Set the watermark for transmit FIFI 0 and receive FIFO 0. We
@@ -520,6 +523,18 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; }
- if (!ssi_private->dma) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor);
write_ssi(CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN,
&ssi->sier);
} else {
write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor);
write_ssi(CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN,
&ssi->sier);
}
- }
- return 0; }
@@ -680,6 +695,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) sizeof(fsl_ssi_dai_template)); ssi_private->cpu_dai_drv.name = ssi_private->name;
- ssi_private->dma = !of_property_read_bool(np, "fsl,imx-fiq");
Instead of looking for the FIQ property, maybe you should just look for the absence of a DMA property/node, and then default to interrupts if there is no DMA. That would make it more generic, and even work on non-IMX systems.
On Sun, Apr 07, 2013 at 07:18:50PM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
Add support for non-dma pcm for imx platforms with imx-pcm-fiq support. Instead of imx-pcm-audio, in this case imx-pcm-fiq-audio device is added and the SIER flags are set differently.
So just to be clear, this is interrupt-driven SSI audio? So you're generating an interrupt every time the transmit FIFO goes below the threshold?
Yes
I wonder if it makes sense to enable both FIFOs, so that you take half as many interrupts per second.
It looks like imx-pcm-fiq and ssi-fiq.s do not support transmitting through two FIFOs at the moment.
Signed-off-by: Markus Pargmann mpa@pengutronix.de
sound/soc/fsl/fsl_ssi.c | 70 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 7decbd9..afb5a23 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -120,10 +120,12 @@ struct fsl_ssi_private {
bool new_binding; bool ssi_on_imx;
- bool dma;
Can you rename this to "use_dma" or something like that?
Done.
struct clk *clk; struct platform_device *imx_pcm_pdev; struct imx_pcm_dma_params dma_params_tx; struct imx_pcm_dma_params dma_params_rx;
struct imx_pcm_fiq_params fiq_params;
struct { unsigned int rfrc;
@@ -353,7 +355,8 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, */
/* Enable the interrupts and DMA requests */
write_ssi(SIER_FLAGS, &ssi->sier);
if (ssi_private->dma)
write_ssi(SIER_FLAGS, &ssi->sier);
/*
- Set the watermark for transmit FIFI 0 and receive FIFO 0. We
@@ -520,6 +523,18 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; }
- if (!ssi_private->dma) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor);
write_ssi(CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN,
&ssi->sier);
} else {
write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor);
write_ssi(CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN,
&ssi->sier);
}
- }
- return 0;
}
@@ -680,6 +695,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) sizeof(fsl_ssi_dai_template)); ssi_private->cpu_dai_drv.name = ssi_private->name;
- ssi_private->dma = !of_property_read_bool(np, "fsl,imx-fiq");
Instead of looking for the FIQ property, maybe you should just look for the absence of a DMA property/node, and then default to interrupts if there is no DMA. That would make it more generic, and even work on non-IMX systems.
I do not think it is possible. For example imx27 ssi does support DMA but for specific boards we have to use fiq instead (phycore-ac97). So I would prefer to define the DMA in the chip dtsi file and choose fiq, if necessary, in the board dts.
Regards,
Markus
Markus Pargmann wrote:
I do not think it is possible. For example imx27 ssi does support DMA but for specific boards we have to use fiq instead (phycore-ac97). So I would prefer to define the DMA in the chip dtsi file and choose fiq, if necessary, in the board dts.
I'm not completely familiar with the way i.MX SSI bindings work, but isn't there some property that says, "this SSI needs to use this DMA channel"? So if that property is missing, then it means that there's no link between the SSI and a DMA channel, and so you need to use FIQ.
For example, for PowerPC bindings, we have this:
ssi@16000 { compatible = "fsl,mpc8610-ssi"; cell-index = <0>; reg = <0x16000 0x100>; interrupt-parent = <&mpic>; interrupts = <62 2>; fsl,mode = "i2s-slave"; codec-handle = <&cs4270>; --> fsl,playback-dma = <&dma00>; --> fsl,capture-dma = <&dma01>;
So on PowerPC, if these two properties are missing, then we would use interrupt mode.
On Sun, Apr 14, 2013 at 08:37:21AM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
I do not think it is possible. For example imx27 ssi does support DMA but for specific boards we have to use fiq instead (phycore-ac97). So I would prefer to define the DMA in the chip dtsi file and choose fiq, if necessary, in the board dts.
I'm not completely familiar with the way i.MX SSI bindings work, but isn't there some property that says, "this SSI needs to use this DMA channel"? So if that property is missing, then it means that there's no link between the SSI and a DMA channel, and so you need to use FIQ.
For example, for PowerPC bindings, we have this:
ssi@16000 { compatible = "fsl,mpc8610-ssi"; cell-index = <0>; reg = <0x16000 0x100>; interrupt-parent = <&mpic>; interrupts = <62 2>; fsl,mode = "i2s-slave"; codec-handle = <&cs4270>;
--> fsl,playback-dma = <&dma00>; --> fsl,capture-dma = <&dma01>;
So on PowerPC, if these two properties are missing, then we would use interrupt mode.
In general, imx27 does support SSI with DMA, for example MACH_IMX27_VISSTRIM_M10 does use SSI with DMA. But there are special boards like Eukrea TLV320 and phycore-ac97 that have to use FIQ instead. All of them have a imx27 chip. The imx27 SSI node (not posted yet) using the generic DMA bindings:
ssi1: ssi@10010000 { compatible = "fsl,imx21-ssi"; reg = <0x10010000 0x1000>; interrupts = <14>; dmas = <&dma 13 &dma 12 &dma 15 &dma 14>; dma-names = "tx", "rx", "tx1", "rx1"; clocks = <&clks 26>; clock-names = "ipg"; fsl,mode = "i2s-slave"; status = "disabled"; };
So instead of defining the dma channels in imx27.dtsi, we could define them only in board dts files. But that would duplicate the DMA property for every board using DMA. The alternative is the "fsl,imx-fiq" property as introduced in this patch.
Regards,
Markus
-- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Markus Pargmann wrote:
In general, imx27 does support SSI with DMA, for example MACH_IMX27_VISSTRIM_M10 does use SSI with DMA. But there are special boards like Eukrea TLV320 and phycore-ac97 that have to use FIQ instead. All of them have a imx27 chip.
Why is the decision to use FIQ board-specific? All of the hardware is inside the SoC itself. How could a board make using DMA impossible?
On Sun, Apr 14, 2013 at 09:53:57AM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
In general, imx27 does support SSI with DMA, for example MACH_IMX27_VISSTRIM_M10 does use SSI with DMA. But there are special boards like Eukrea TLV320 and phycore-ac97 that have to use FIQ instead. All of them have a imx27 chip.
Why is the decision to use FIQ board-specific? All of the hardware is inside the SoC itself. How could a board make using DMA impossible?
I only ported the imx-ssi ac97 driver code and tested twice using DMA without success. But there is a good description of the problem in imx-ssi:
" The WM9712 with which this driver was developed with always sends GPIO status data in slot 12 which we receive in our (PCM-) data stream. The only chance we have is to manually skip this data in the FIQ handler."
Regards,
Markus
Markus Pargmann wrote:
I only ported the imx-ssi ac97 driver code and tested twice using DMA without success. But there is a good description of the problem in imx-ssi:
" The WM9712 with which this driver was developed with always sends GPIO status data in slot 12 which we receive in our (PCM-) data stream. The only chance we have is to manually skip this data in the FIQ handler."
Ah, so this is a work-around for a bug, where the codec is incompatible with the SoC? Mark, are you familiar with this issue? Is there a way to reconfigure the codec so that it works better with the SoC? It seems ridiculous to add all this code just because an incompatible codec was chosen for some board.
Either way, the board DTS needs to clearly state *why* we're enabling FIQ mode when DMA mode should work. And the patch that adds FIQ support needs to say that it's for boards with broken DMA support.
On Sun, Apr 14, 2013 at 10:25:49AM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
I only ported the imx-ssi ac97 driver code and tested twice using DMA without success. But there is a good description of the problem in imx-ssi:
" The WM9712 with which this driver was developed with always sends GPIO status data in slot 12 which we receive in our (PCM-) data stream. The only chance we have is to manually skip this data in the FIQ handler."
Ah, so this is a work-around for a bug, where the codec is incompatible with the SoC? Mark, are you familiar with this issue? Is there a way to reconfigure the codec so that it works better with the SoC? It seems ridiculous to add all this code just because an incompatible codec was chosen for some board.
Either way, the board DTS needs to clearly state *why* we're enabling FIQ mode when DMA mode should work. And the patch that adds FIQ support needs to say that it's for boards with broken DMA support.
Okay, I will add those comments to the commit message, binding documentation and add parts of the imx-ssi problem description to fsl-ssi.
Regards,
Markus
On Sun, Apr 14, 2013 at 10:25:49AM -0500, Timur Tabi wrote:
Ah, so this is a work-around for a bug, where the codec is incompatible with the SoC? Mark, are you familiar with this issue? Is there a way to reconfigure the codec so that it works better with the SoC? It seems ridiculous to add all this code just because an incompatible codec was chosen for some board.
It's a limitation in the SoC - it sort of tries to bodge AC'97 in but doesn't do a great job of it and can't handle the idea that there's multiple streams of data on the bus. This isn't something that can be configured in the CODEC.
Use device pointer as parameter for imx-pcm-dma. This allows usage of the generic DMA DT bindings.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/fsl_ssi.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index afb5a23..bb9a1e0 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -742,7 +742,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) ssi_private->fifo_depth = 8;
if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) { - u32 dma_events[2]; ssi_private->ssi_on_imx = true;
ssi_private->clk = clk_get(&pdev->dev, NULL); @@ -765,18 +764,11 @@ static int fsl_ssi_probe(struct platform_device *pdev) ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0); ssi_private->dma_params_rx.dma_addr = ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0); - /* - * TODO: This is a temporary solution and should be changed - * to use generic DMA binding later when the helplers get in. - */ - ret = of_property_read_u32_array(pdev->dev.of_node, - "fsl,ssi-dma-events", dma_events, 2); - if (ret) { - dev_err(&pdev->dev, "could not get dma events\n"); - goto error_clk; - } - ssi_private->dma_params_tx.dma = dma_events[0]; - ssi_private->dma_params_rx.dma = dma_events[1]; + + ssi_private->dma_params_rx.dma_client_dev = &pdev->dev; + ssi_private->dma_params_rx.dma_req_name = "rx"; + ssi_private->dma_params_tx.dma_client_dev = &pdev->dev; + ssi_private->dma_params_tx.dma_req_name = "tx";
ssi_private->dma_params_tx.shared_peripheral = of_device_is_compatible(of_get_parent(np), @@ -887,7 +879,6 @@ error_dev: dev_set_drvdata(&pdev->dev, NULL); device_remove_file(&pdev->dev, dev_attr);
-error_clk: if (ssi_private->ssi_on_imx) { clk_disable_unprepare(ssi_private->clk); clk_put(ssi_private->clk);
Markus Pargmann wrote:
ret = of_property_read_u32_array(pdev->dev.of_node,
"fsl,ssi-dma-events", dma_events, 2);
Does this mean that the "fsl,ssi-dma-events" property is no longer used?
On Sun, Apr 07, 2013 at 09:50:19PM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
ret = of_property_read_u32_array(pdev->dev.of_node,
"fsl,ssi-dma-events", dma_events, 2);
Does this mean that the "fsl,ssi-dma-events" property is no longer used?
Yes, I just realized that it would break all platforms that do not have a DMA driver with generic bindings yet. So I will instead still check for this property in case 'dmas' is not set.
Regards,
Markus
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- arch/arm/mach-imx/mach-pca100.c | 7 +++++-- arch/arm/mach-imx/mach-pcm043.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c index b8b15bb..68badf8 100644 --- a/arch/arm/mach-imx/mach-pca100.c +++ b/arch/arm/mach-imx/mach-pca100.c @@ -22,6 +22,7 @@ #include <linux/i2c.h> #include <linux/i2c/at24.h> #include <linux/dma-mapping.h> +#include <linux/export.h> #include <linux/spi/spi.h> #include <linux/spi/eeprom.h> #include <linux/irq.h> @@ -208,7 +209,7 @@ static const struct spi_imx_master pca100_spi0_data __initconst = { .num_chipselect = ARRAY_SIZE(pca100_spi_cs), };
-static void pca100_ac97_warm_reset(struct snd_ac97 *ac97) +void pca100_ac97_warm_reset(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); gpio_set_value(GPIO_PORTC + 20, 1); @@ -217,8 +218,9 @@ static void pca100_ac97_warm_reset(struct snd_ac97 *ac97) mxc_gpio_mode(PC20_PF_SSI1_FS); msleep(2); } +EXPORT_SYMBOL(pca100_ac97_warm_reset);
-static void pca100_ac97_cold_reset(struct snd_ac97 *ac97) +void pca100_ac97_cold_reset(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); /* FS */ gpio_set_value(GPIO_PORTC + 20, 0); @@ -232,6 +234,7 @@ static void pca100_ac97_cold_reset(struct snd_ac97 *ac97) mxc_gpio_mode(PC22_PF_SSI1_TXD); msleep(2); } +EXPORT_SYMBOL(pca100_ac97_cold_reset);
static const struct imx_ssi_platform_data pca100_ssi_pdata __initconst = { .ac97_reset = pca100_ac97_cold_reset, diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c index 8ed533f..4f318ca 100644 --- a/arch/arm/mach-imx/mach-pcm043.c +++ b/arch/arm/mach-imx/mach-pcm043.c @@ -27,6 +27,7 @@ #include <linux/i2c/at24.h> #include <linux/usb/otg.h> #include <linux/usb/ulpi.h> +#include <linux/export.h>
#include <asm/mach-types.h> #include <asm/mach/arch.h> @@ -217,7 +218,7 @@ static iomux_v3_cfg_t pcm043_pads[] = { #define SD1_GPIO_WP IMX_GPIO_NR(2, 23) #define SD1_GPIO_CD IMX_GPIO_NR(2, 24)
-static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) +void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) { iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31; iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS; @@ -239,8 +240,9 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) gpio_free(AC97_GPIO_TXFS); mxc_iomux_v3_setup_pad(txfs); } +EXPORT_SYMBOL(pcm043_ac97_warm_reset);
-static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) +void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) { iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31; iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS; @@ -286,6 +288,7 @@ err1: printk("%s failed with %d\n", __func__, ret); mdelay(1); } +EXPORT_SYMBOL(pcm043_ac97_cold_reset);
static const struct imx_ssi_platform_data pcm043_ssi_pdata __initconst = { .ac97_reset = pcm043_ac97_cold_reset,
This patch copies some parts from imx-ssi to support AC97 on imx27-pca100 and imx27-pcm043. It is activated with a new fsl,imx-ac97 bool property. It was tested on imx27-pca100.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/fsl_ssi.c | 360 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 279 insertions(+), 81 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index bb9a1e0..06f52ce 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -120,6 +120,7 @@ struct fsl_ssi_private {
bool new_binding; bool ssi_on_imx; + bool imx_ac97; bool dma; struct clk *clk; struct platform_device *imx_pcm_pdev; @@ -127,6 +128,9 @@ struct fsl_ssi_private { struct imx_pcm_dma_params dma_params_rx; struct imx_pcm_fiq_params fiq_params;
+ void (*ac97_reset) (struct snd_ac97 *ac97); + void (*ac97_warm_reset)(struct snd_ac97 *ac97); + struct { unsigned int rfrc; unsigned int tfrc; @@ -323,67 +327,76 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
ssi_private->first_stream = substream;
- /* - * Section 16.5 of the MPC8610 reference manual says that the - * SSI needs to be disabled before updating the registers we set - * here. - */ - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); - - /* - * Program the SSI into I2S Slave Non-Network Synchronous mode. - * Also enable the transmit and receive FIFO. - * - * FIXME: Little-endian samples require a different shift dir - */ - write_ssi_mask(&ssi->scr, - CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, - CCSR_SSI_SCR_TFR_CLK_DIS | CCSR_SSI_SCR_I2S_MODE_SLAVE - | (synchronous ? CCSR_SSI_SCR_SYN : 0)); + /* If we use AC97, the registers are already setup correctly */ + if (!ssi_private->imx_ac97) { + /* + * Section 16.5 of the MPC8610 reference manual says + * that the SSI needs to be disabled before updating + * the registers we set here. + */ + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0);
- write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | - CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TEFS | - CCSR_SSI_STCR_TSCKP, &ssi->stcr); + /* + * Program the SSI into I2S Slave Non-Network + * Synchronous mode. Also enable the transmit and + * receive FIFO. + * + * FIXME: Little-endian samples require a different + * shift dir + */ + write_ssi_mask(&ssi->scr, + CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, + CCSR_SSI_SCR_TFR_CLK_DIS | + CCSR_SSI_SCR_I2S_MODE_SLAVE | + (synchronous ? CCSR_SSI_SCR_SYN : 0)); + + write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | + CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TEFS | + CCSR_SSI_STCR_TSCKP, &ssi->stcr); + + write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 | + CCSR_SSI_SRCR_RFSI | CCSR_SSI_SRCR_REFS | + CCSR_SSI_SRCR_RSCKP, &ssi->srcr); + /* + * The DC and PM bits are only used if the SSI is the + * clock master. + */
- write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 | - CCSR_SSI_SRCR_RFSI | CCSR_SSI_SRCR_REFS | - CCSR_SSI_SRCR_RSCKP, &ssi->srcr); + /* + * Set the watermark for transmit FIFI 0 and receive + * FIFO 0. We don't use FIFO 1. We program the + * transmit water to signal a DMA transfer if there are + * only two (or fewer) elements left in the FIFO. Two + * elements equals one frame (left channel, right + * channel). This value, however, depends on the depth + * of the transmit buffer. + * + * We program the receive FIFO to notify us if at least + * two elements (one frame) have been written to the + * FIFO. We could make this value larger (and maybe we + * should), but this way data will be written to memory + * as soon as it's available. + */ + write_ssi(CCSR_SSI_SFCSR_TFWM0(ssi_private->fifo_depth - 2) | + CCSR_SSI_SFCSR_RFWM0(ssi_private->fifo_depth - 2), + &ssi->sfcsr);
- /* - * The DC and PM bits are only used if the SSI is the clock - * master. - */ + /* + * We keep the SSI disabled because if we enable it, + * then the DMA controller will start. It's not + * supposed to start until the SCR.TE (or SCR.RE) bit + * is set, but it does anyway. The DMA controller will + * transfer one "BWC" of data (i.e. the amount of data + * that the MR.BWC bits are set to). The reason this + * is bad is because at this point, the PCM driver has + * not finished initializing the DMA controller. + */ + }
/* Enable the interrupts and DMA requests */ if (ssi_private->dma) write_ssi(SIER_FLAGS, &ssi->sier);
- /* - * Set the watermark for transmit FIFI 0 and receive FIFO 0. We - * don't use FIFO 1. We program the transmit water to signal a - * DMA transfer if there are only two (or fewer) elements left - * in the FIFO. Two elements equals one frame (left channel, - * right channel). This value, however, depends on the depth of - * the transmit buffer. - * - * We program the receive FIFO to notify us if at least two - * elements (one frame) have been written to the FIFO. We could - * make this value larger (and maybe we should), but this way - * data will be written to memory as soon as it's available. - */ - write_ssi(CCSR_SSI_SFCSR_TFWM0(ssi_private->fifo_depth - 2) | - CCSR_SSI_SFCSR_RFWM0(ssi_private->fifo_depth - 2), - &ssi->sfcsr); - - /* - * We keep the SSI disabled because if we enable it, then the - * DMA controller will start. It's not supposed to start until - * the SCR.TE (or SCR.RE) bit is set, but it does anyway. The - * DMA controller will transfer one "BWC" of data (i.e. the - * amount of data that the MR.BWC bits are set to). The reason - * this is bad is because at this point, the PCM driver has not - * finished initializing the DMA controller. - */ } else { if (synchronous) { struct snd_pcm_runtime *first_runtime = @@ -500,27 +513,29 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
- switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - write_ssi_mask(&ssi->scr, 0, - CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); - else - write_ssi_mask(&ssi->scr, 0, - CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); - else - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); - break; - - default: - return -EINVAL; + if (!ssi_private->imx_ac97) { + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + write_ssi_mask(&ssi->scr, 0, + CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); + else + write_ssi_mask(&ssi->scr, 0, + CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); + else + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); + break; + + default: + return -EINVAL; + } }
if (!ssi_private->dma) { @@ -556,8 +571,9 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
/* * If this is the last active substream, disable the SSI. + * If AC97 is active, we don't want to disable SSI. */ - if (!ssi_private->first_stream) { + if (!ssi_private->first_stream && !ssi_private->imx_ac97) { struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); @@ -589,6 +605,152 @@ static struct snd_soc_dai_driver fsl_ssi_dai_template = { .ops = &fsl_ssi_dai_ops, };
+static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { + .ac97_control = 1, + .playback = { + .stream_name = "AC97 Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "AC97 Capture", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .ops = &fsl_ssi_dai_ops, +}; + + +static struct fsl_ssi_private *fsl_ac97_data; + +static void fsl_ssi_ac97_setup(struct ccsr_ssi *ssi) +{ + write_ssi(0x0, &ssi->scr); + write_ssi(0x0, &ssi->stcr); + write_ssi(0x0, &ssi->srcr); + + write_ssi(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_NET, &ssi->scr); + + write_ssi(CCSR_SSI_SFCSR_RFWM0(8) | CCSR_SSI_SFCSR_TFWM0(8) | + CCSR_SSI_SFCSR_RFWM1(8) | CCSR_SSI_SFCSR_TFWM1(8), + &ssi->sfcsr); + + write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), + &ssi->stccr); + write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), + &ssi->srccr); + + write_ssi(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_NET | + CCSR_SSI_SCR_SSIEN, &ssi->scr); + write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); + + write_ssi(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_NET | + CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | + CCSR_SSI_SCR_RE, &ssi->scr); + + write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, + &ssi->sacnt); + write_ssi(0xff, &ssi->saccdis); + write_ssi(0x300, &ssi->saccen); + + write_ssi(0x0, &ssi->sier); +} + +static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short val) +{ + struct ccsr_ssi *ssi = fsl_ac97_data->ssi; + unsigned int lreg; + unsigned int lval; + + if (reg > 0x7f) + return; + + + lreg = reg << 12; + write_ssi(lreg, &ssi->sacadd); + + lval = val << 4; + write_ssi(lval , &ssi->sacdat); + + write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK, + CCSR_SSI_SACNT_WR); + udelay(100); +} + +static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, + unsigned short reg) +{ + struct ccsr_ssi *ssi = fsl_ac97_data->ssi; + + unsigned short val = -1; + unsigned int lreg; + + lreg = (reg & 0x7f) << 12 ; + write_ssi(lreg, &ssi->sacadd); + write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK, + CCSR_SSI_SACNT_RD); + + udelay(100); + + val = (read_ssi(&ssi->sacdat) >> 4) & 0xffff; + + return val; +} + +static void fsl_ssi_ac97_reset(struct snd_ac97 *ac97) +{ + struct fsl_ssi_private *ssi_private = fsl_ac97_data; + + if (ssi_private->ac97_reset) + ssi_private->ac97_reset(ac97); + /* First read sometimes fails, do a dummy read */ + fsl_ssi_ac97_read(ac97, 0); +} + +static void fsl_ssi_ac97_warm_reset(struct snd_ac97 *ac97) +{ + struct fsl_ssi_private *ssi_private = fsl_ac97_data; + + if (ssi_private->ac97_warm_reset) + ssi_private->ac97_warm_reset(ac97); + + /* First read sometimes fails, do a dummy read */ + fsl_ssi_ac97_read(ac97, 0); +} + +struct snd_ac97_bus_ops soc_ac97_ops = { + .read = fsl_ssi_ac97_read, + .write = fsl_ssi_ac97_write, + .reset = fsl_ssi_ac97_reset, + .warm_reset = fsl_ssi_ac97_warm_reset +}; +EXPORT_SYMBOL_GPL(soc_ac97_ops); + +/* + * Pointer to AC97 reset functions for specific boards + */ +#if IS_ENABLED(CONFIG_MACH_PCA100) +extern void pca100_ac97_cold_reset(struct snd_ac97 *ac97); +extern void pca100_ac97_warm_reset(struct snd_ac97 *ac97); +#else +void pca100_ac97_cold_reset(struct snd_ac97 *ac97) { } +void pca100_ac97_warm_reset(struct snd_ac97 *ac97) { } +#endif + +#if IS_ENABLED(CONFIG_MACH_PCM043) +extern void pcm043_ac97_cold_reset(struct snd_ac97 *ac97); +extern void pcm043_ac97_warm_reset(struct snd_ac97 *ac97); +#else +void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) { } +void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) { } +#endif + + /* Show the statistics of a flag only if its interrupt is enabled. The * compiler will optimze this code to a no-op if the interrupt is not * enabled. @@ -664,6 +826,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) const uint32_t *iprop; struct resource res; char name[64]; + bool ac97 = false;
/* SSIs that are not connected on the board should have a * status = "disabled" @@ -674,7 +837,13 @@ static int fsl_ssi_probe(struct platform_device *pdev)
/* We only support the SSI in "I2S Slave" mode */ sprop = of_get_property(np, "fsl,mode", NULL); - if (!sprop || strcmp(sprop, "i2s-slave")) { + if (!sprop) { + dev_err(&pdev->dev, "fsl,mode property is necessary\n"); + return -EINVAL; + } + if (!strcmp(sprop, "ac97-slave")) { + ac97 = true; + } else if (strcmp(sprop, "i2s-slave")) { dev_notice(&pdev->dev, "mode %s is unsupported\n", sprop); return -ENODEV; } @@ -690,13 +859,39 @@ static int fsl_ssi_probe(struct platform_device *pdev)
strcpy(ssi_private->name, p);
- /* Initialize this copy of the CPU DAI driver structure */ - memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template, - sizeof(fsl_ssi_dai_template)); - ssi_private->cpu_dai_drv.name = ssi_private->name; - ssi_private->dma = !of_property_read_bool(np, "fsl,imx-fiq");
+ if (ac97) { + sprop = of_get_property(of_find_node_by_path("/"), "compatible", + NULL); + p = strrchr(sprop, ','); + if (p) + sprop = p + 1; + + if (!strcmp(sprop, "imx27-pca100")) { + ssi_private->ac97_reset = pca100_ac97_cold_reset; + ssi_private->ac97_warm_reset = pca100_ac97_warm_reset; + } else if (!strcmp(sprop, "imx27-pcm043")) { + ssi_private->ac97_reset = pcm043_ac97_cold_reset; + ssi_private->ac97_warm_reset = pcm043_ac97_warm_reset; + } else { + dev_err(&pdev->dev, "Failed to enable ssi AC97 mode, unknown board.\n"); + ret = -EINVAL; + goto error_kmalloc; + } + + memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai, + sizeof(fsl_ssi_ac97_dai)); + + fsl_ac97_data = ssi_private; + ssi_private->imx_ac97 = true; + } else { + /* Initialize this copy of the CPU DAI driver structure */ + memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template, + sizeof(fsl_ssi_dai_template)); + } + ssi_private->cpu_dai_drv.name = ssi_private->name; + /* Get the addresses and IRQ */ ret = of_address_to_resource(np, 0, &res); if (ret) { @@ -729,6 +924,9 @@ static int fsl_ssi_probe(struct platform_device *pdev) } }
+ if (ssi_private->imx_ac97) + fsl_ssi_ac97_setup(ssi_private->ssi); + /* Are the RX and the TX clocks locked? */ if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) ssi_private->cpu_dai_drv.symmetric_rates = 1;
Markus Pargmann wrote:
This patch copies some parts from imx-ssi to support AC97 on imx27-pca100 and imx27-pcm043. It is activated with a new fsl,imx-ac97 bool property. It was tested on imx27-pca100.
I'm not crazy about this patch -- it seems a bit hackish. There are too many "if (imx_ac97)" clauses. Large pieces of code that don't appear to be related to AC97 are indented in an if-clause. I especially don't like the "If we use AC97, the registers are already setup correctly".
On Sun, Apr 07, 2013 at 09:49:03PM -0500, Timur Tabi wrote:
Markus Pargmann wrote:
This patch copies some parts from imx-ssi to support AC97 on imx27-pca100 and imx27-pcm043. It is activated with a new fsl,imx-ac97 bool property. It was tested on imx27-pca100.
I'm not crazy about this patch -- it seems a bit hackish. There are too many "if (imx_ac97)" clauses. Large pieces of code that don't appear to be related to AC97 are indented in an if-clause. I especially don't like the "If we use AC97, the registers are already setup correctly".
I will try to seperate it a little bit cleaner by using different dai ops for ac97 for the two big ifs and perhaps use a seperated register setup function so it can be used from ssi startup and ac97_setup.
Regards,
Markus
-- Timur Tabi
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- sound/soc/fsl/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3b98159..5ace408 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -153,7 +153,7 @@ config SND_SOC_PHYCORE_AC97 select SND_SOC_WM9712 select SND_SOC_IMX_PCM_FIQ select SND_SOC_IMX_AUDMUX - select SND_SOC_IMX_SSI + select SND_SOC_FSL_SSI help Say Y if you want to add support for SoC audio on Phytec phyCORE and phyCARD boards in AC97 mode
fsl-ssi was located in powerpc/fsl/ssi.txt. This is no powerpc specific device, so it should be moved to sound/ as it connects to differen audio codecs.
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- .../devicetree/bindings/powerpc/fsl/ssi.txt | 73 ---------------------- .../devicetree/bindings/sound/fsl,ssi.txt | 73 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/powerpc/fsl/ssi.txt create mode 100644 Documentation/devicetree/bindings/sound/fsl,ssi.txt
diff --git a/Documentation/devicetree/bindings/powerpc/fsl/ssi.txt b/Documentation/devicetree/bindings/powerpc/fsl/ssi.txt deleted file mode 100644 index 5ff76c9..0000000 --- a/Documentation/devicetree/bindings/powerpc/fsl/ssi.txt +++ /dev/null @@ -1,73 +0,0 @@ -Freescale Synchronous Serial Interface - -The SSI is a serial device that communicates with audio codecs. It can -be programmed in AC97, I2S, left-justified, or right-justified modes. - -Required properties: -- compatible: Compatible list, contains "fsl,ssi". -- cell-index: The SSI, <0> = SSI1, <1> = SSI2, and so on. -- reg: Offset and length of the register set for the device. -- interrupts: <a b> where a is the interrupt number and b is a - field that represents an encoding of the sense and - level information for the interrupt. This should be - encoded based on the information in section 2) - depending on the type of interrupt controller you - have. -- interrupt-parent: The phandle for the interrupt controller that - services interrupts for this device. -- fsl,mode: The operating mode for the SSI interface. - "i2s-slave" - I2S mode, SSI is clock slave - "i2s-master" - I2S mode, SSI is clock master - "lj-slave" - left-justified mode, SSI is clock slave - "lj-master" - l.j. mode, SSI is clock master - "rj-slave" - right-justified mode, SSI is clock slave - "rj-master" - r.j., SSI is clock master - "ac97-slave" - AC97 mode, SSI is clock slave - "ac97-master" - AC97 mode, SSI is clock master -- fsl,playback-dma: Phandle to a node for the DMA channel to use for - playback of audio. This is typically dictated by SOC - design. See the notes below. -- fsl,capture-dma: Phandle to a node for the DMA channel to use for - capture (recording) of audio. This is typically dictated - by SOC design. See the notes below. -- fsl,fifo-depth: The number of elements in the transmit and receive FIFOs. - This number is the maximum allowed value for SFCSR[TFWM0]. -- fsl,ssi-asynchronous: - If specified, the SSI is to be programmed in asynchronous - mode. In this mode, pins SRCK, STCK, SRFS, and STFS must - all be connected to valid signals. In synchronous mode, - SRCK and SRFS are ignored. Asynchronous mode allows - playback and capture to use different sample sizes and - sample rates. Some drivers may require that SRCK and STCK - be connected together, and SRFS and STFS be connected - together. This would still allow different sample sizes, - but not different sample rates. - -Optional properties: -- codec-handle: Phandle to a 'codec' node that defines an audio - codec connected to this SSI. This node is typically - a child of an I2C or other control node. - -Child 'codec' node required properties: -- compatible: Compatible list, contains the name of the codec - -Child 'codec' node optional properties: -- clock-frequency: The frequency of the input clock, which typically comes - from an on-board dedicated oscillator. - -Notes on fsl,playback-dma and fsl,capture-dma: - -On SOCs that have an SSI, specific DMA channels are hard-wired for playback -and capture. On the MPC8610, for example, SSI1 must use DMA channel 0 for -playback and DMA channel 1 for capture. SSI2 must use DMA channel 2 for -playback and DMA channel 3 for capture. The developer can choose which -DMA controller to use, but the channels themselves are hard-wired. The -purpose of these two properties is to represent this hardware design. - -The device tree nodes for the DMA channels that are referenced by -"fsl,playback-dma" and "fsl,capture-dma" must be marked as compatible with -"fsl,ssi-dma-channel". The SOC-specific compatible string (e.g. -"fsl,mpc8610-dma-channel") can remain. If these nodes are left as -"fsl,elo-dma-channel" or "fsl,eloplus-dma-channel", then the generic Elo DMA -drivers (fsldma) will attempt to use them, and it will conflict with the -sound drivers. diff --git a/Documentation/devicetree/bindings/sound/fsl,ssi.txt b/Documentation/devicetree/bindings/sound/fsl,ssi.txt new file mode 100644 index 0000000..5ff76c9 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/fsl,ssi.txt @@ -0,0 +1,73 @@ +Freescale Synchronous Serial Interface + +The SSI is a serial device that communicates with audio codecs. It can +be programmed in AC97, I2S, left-justified, or right-justified modes. + +Required properties: +- compatible: Compatible list, contains "fsl,ssi". +- cell-index: The SSI, <0> = SSI1, <1> = SSI2, and so on. +- reg: Offset and length of the register set for the device. +- interrupts: <a b> where a is the interrupt number and b is a + field that represents an encoding of the sense and + level information for the interrupt. This should be + encoded based on the information in section 2) + depending on the type of interrupt controller you + have. +- interrupt-parent: The phandle for the interrupt controller that + services interrupts for this device. +- fsl,mode: The operating mode for the SSI interface. + "i2s-slave" - I2S mode, SSI is clock slave + "i2s-master" - I2S mode, SSI is clock master + "lj-slave" - left-justified mode, SSI is clock slave + "lj-master" - l.j. mode, SSI is clock master + "rj-slave" - right-justified mode, SSI is clock slave + "rj-master" - r.j., SSI is clock master + "ac97-slave" - AC97 mode, SSI is clock slave + "ac97-master" - AC97 mode, SSI is clock master +- fsl,playback-dma: Phandle to a node for the DMA channel to use for + playback of audio. This is typically dictated by SOC + design. See the notes below. +- fsl,capture-dma: Phandle to a node for the DMA channel to use for + capture (recording) of audio. This is typically dictated + by SOC design. See the notes below. +- fsl,fifo-depth: The number of elements in the transmit and receive FIFOs. + This number is the maximum allowed value for SFCSR[TFWM0]. +- fsl,ssi-asynchronous: + If specified, the SSI is to be programmed in asynchronous + mode. In this mode, pins SRCK, STCK, SRFS, and STFS must + all be connected to valid signals. In synchronous mode, + SRCK and SRFS are ignored. Asynchronous mode allows + playback and capture to use different sample sizes and + sample rates. Some drivers may require that SRCK and STCK + be connected together, and SRFS and STFS be connected + together. This would still allow different sample sizes, + but not different sample rates. + +Optional properties: +- codec-handle: Phandle to a 'codec' node that defines an audio + codec connected to this SSI. This node is typically + a child of an I2C or other control node. + +Child 'codec' node required properties: +- compatible: Compatible list, contains the name of the codec + +Child 'codec' node optional properties: +- clock-frequency: The frequency of the input clock, which typically comes + from an on-board dedicated oscillator. + +Notes on fsl,playback-dma and fsl,capture-dma: + +On SOCs that have an SSI, specific DMA channels are hard-wired for playback +and capture. On the MPC8610, for example, SSI1 must use DMA channel 0 for +playback and DMA channel 1 for capture. SSI2 must use DMA channel 2 for +playback and DMA channel 3 for capture. The developer can choose which +DMA controller to use, but the channels themselves are hard-wired. The +purpose of these two properties is to represent this hardware design. + +The device tree nodes for the DMA channels that are referenced by +"fsl,playback-dma" and "fsl,capture-dma" must be marked as compatible with +"fsl,ssi-dma-channel". The SOC-specific compatible string (e.g. +"fsl,mpc8610-dma-channel") can remain. If these nodes are left as +"fsl,elo-dma-channel" or "fsl,eloplus-dma-channel", then the generic Elo DMA +drivers (fsldma) will attempt to use them, and it will conflict with the +sound drivers.
Markus Pargmann wrote:
fsl-ssi was located in powerpc/fsl/ssi.txt. This is no powerpc specific device, so it should be moved to sound/ as it connects to differen audio codecs.
The only problem with this is that the driver supports two bindings, the original binding and a newer one. The original binding is used only on PowerPC.
I'm not sure that's relevant, though.
Update the fsl-ssi bindings. DMA is no required property anymore and uses the generic DMA bindings. imx-fiq is a new alternative to DMA
Signed-off-by: Markus Pargmann mpa@pengutronix.de --- Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl,ssi.txt b/Documentation/devicetree/bindings/sound/fsl,ssi.txt index 5ff76c9..46282ec 100644 --- a/Documentation/devicetree/bindings/sound/fsl,ssi.txt +++ b/Documentation/devicetree/bindings/sound/fsl,ssi.txt @@ -24,12 +24,6 @@ Required properties: "rj-master" - r.j., SSI is clock master "ac97-slave" - AC97 mode, SSI is clock slave "ac97-master" - AC97 mode, SSI is clock master -- fsl,playback-dma: Phandle to a node for the DMA channel to use for - playback of audio. This is typically dictated by SOC - design. See the notes below. -- fsl,capture-dma: Phandle to a node for the DMA channel to use for - capture (recording) of audio. This is typically dictated - by SOC design. See the notes below. - fsl,fifo-depth: The number of elements in the transmit and receive FIFOs. This number is the maximum allowed value for SFCSR[TFWM0]. - fsl,ssi-asynchronous: @@ -43,10 +37,17 @@ Required properties: together. This would still allow different sample sizes, but not different sample rates.
+Note that either dmas, dma-names or fsl,imx-fiq are required. + Optional properties: - codec-handle: Phandle to a 'codec' node that defines an audio codec connected to this SSI. This node is typically a child of an I2C or other control node. +- dmas: Generic dma devicetree binding as described in + Documentation/devicetree/bindings/dma/dma.txt. +- dma-names: Two dmas have to be defined, "tx" and "rx", if fsl,imx-fiq + is not defined. +- fsl,imx-fiq: Bool property. Use imx-pcm-fiq instead of imx-pcm-dma.
Child 'codec' node required properties: - compatible: Compatible list, contains the name of the codec
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Markus Pargmann (11): ASoC: phycore-ac97: Add DT support ASoC: imx-pcm-dma: Add support for DMA init by ASoC: imx-pcm-fiq: Introduce pcm-fiq-params ASoC: fsl-ssi: Add SACNT definitions ASoC: fsl-ssi: Add support for imx-pcm-fiq ASoC: fsl-ssi: Setup generic imx dma params ARM: imx: Export ac97 reset functions ASoC: fsl-ssi: imx ac97 support ASoC: fsl: Kconfig: Use fsl-ssi for phycore-ac97 ASoC: fsl: Move fsl-ssi binding doc to sound/ ASoC: fsl: Update fsl-ssi binding doc
Documentation/devicetree/bindings/powerpc/fsl/ssi.txt | 73 - Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 b/Documentation/devicetree/bindings/sound/fsl,ssi.txt | 73 + b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt | 12 b/arch/arm/mach-imx/mach-pca100.c | 7 b/arch/arm/mach-imx/mach-pcm043.c | 7 b/sound/soc/fsl/Kconfig | 2 b/sound/soc/fsl/fsl_ssi.c | 70 + b/sound/soc/fsl/fsl_ssi.h | 8 b/sound/soc/fsl/imx-pcm-dma.c | 31 b/sound/soc/fsl/imx-pcm-fiq.c | 14 b/sound/soc/fsl/imx-pcm.h | 6 b/sound/soc/fsl/imx-ssi.c | 7 b/sound/soc/fsl/imx-ssi.h | 1 b/sound/soc/fsl/phycore-ac97.c | 185 ++++ sound/soc/fsl/fsl_ssi.c | 379 +++++++--- sound/soc/fsl/imx-pcm.h | 9 17 files changed, 664 insertions(+), 233 deletions(-)
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hi,
On Sun, Apr 07, 2013 at 09:39:31PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Okay, I will rebase it for v3 onto your committed cleanups and will have a look on your latest patches.
Regards,
Markus
Markus Pargmann (11): ASoC: phycore-ac97: Add DT support ASoC: imx-pcm-dma: Add support for DMA init by ASoC: imx-pcm-fiq: Introduce pcm-fiq-params ASoC: fsl-ssi: Add SACNT definitions ASoC: fsl-ssi: Add support for imx-pcm-fiq ASoC: fsl-ssi: Setup generic imx dma params ARM: imx: Export ac97 reset functions ASoC: fsl-ssi: imx ac97 support ASoC: fsl: Kconfig: Use fsl-ssi for phycore-ac97 ASoC: fsl: Move fsl-ssi binding doc to sound/ ASoC: fsl: Update fsl-ssi binding doc
Documentation/devicetree/bindings/powerpc/fsl/ssi.txt | 73 - Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 b/Documentation/devicetree/bindings/sound/fsl,ssi.txt | 73 + b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt | 12 b/arch/arm/mach-imx/mach-pca100.c | 7 b/arch/arm/mach-imx/mach-pcm043.c | 7 b/sound/soc/fsl/Kconfig | 2 b/sound/soc/fsl/fsl_ssi.c | 70 + b/sound/soc/fsl/fsl_ssi.h | 8 b/sound/soc/fsl/imx-pcm-dma.c | 31 b/sound/soc/fsl/imx-pcm-fiq.c | 14 b/sound/soc/fsl/imx-pcm.h | 6 b/sound/soc/fsl/imx-ssi.c | 7 b/sound/soc/fsl/imx-ssi.h | 1 b/sound/soc/fsl/phycore-ac97.c | 185 ++++ sound/soc/fsl/fsl_ssi.c | 379 +++++++--- sound/soc/fsl/imx-pcm.h | 9 17 files changed, 664 insertions(+), 233 deletions(-)
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On 04/07/2013 10:08 PM, Markus Pargmann wrote:
Hi,
On Sun, Apr 07, 2013 at 09:39:31PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Okay, I will rebase it for v3 onto your committed cleanups and will have a look on your latest patches.
It might be a good idea to rebase it ontop of the generic dmaengine driver patches right away, since it will simplify things quite a bit.
- Lars
Regards,
Markus
Markus Pargmann (11): ASoC: phycore-ac97: Add DT support ASoC: imx-pcm-dma: Add support for DMA init by ASoC: imx-pcm-fiq: Introduce pcm-fiq-params ASoC: fsl-ssi: Add SACNT definitions ASoC: fsl-ssi: Add support for imx-pcm-fiq ASoC: fsl-ssi: Setup generic imx dma params ARM: imx: Export ac97 reset functions ASoC: fsl-ssi: imx ac97 support ASoC: fsl: Kconfig: Use fsl-ssi for phycore-ac97 ASoC: fsl: Move fsl-ssi binding doc to sound/ ASoC: fsl: Update fsl-ssi binding doc
Documentation/devicetree/bindings/powerpc/fsl/ssi.txt | 73 - Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 b/Documentation/devicetree/bindings/sound/fsl,ssi.txt | 73 + b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt | 12 b/arch/arm/mach-imx/mach-pca100.c | 7 b/arch/arm/mach-imx/mach-pcm043.c | 7 b/sound/soc/fsl/Kconfig | 2 b/sound/soc/fsl/fsl_ssi.c | 70 + b/sound/soc/fsl/fsl_ssi.h | 8 b/sound/soc/fsl/imx-pcm-dma.c | 31 b/sound/soc/fsl/imx-pcm-fiq.c | 14 b/sound/soc/fsl/imx-pcm.h | 6 b/sound/soc/fsl/imx-ssi.c | 7 b/sound/soc/fsl/imx-ssi.h | 1 b/sound/soc/fsl/phycore-ac97.c | 185 ++++ sound/soc/fsl/fsl_ssi.c | 379 +++++++--- sound/soc/fsl/imx-pcm.h | 9 17 files changed, 664 insertions(+), 233 deletions(-)
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On Sun, Apr 07, 2013 at 10:35:02PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 10:08 PM, Markus Pargmann wrote:
Hi,
On Sun, Apr 07, 2013 at 09:39:31PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Okay, I will rebase it for v3 onto your committed cleanups and will have a look on your latest patches.
It might be a good idea to rebase it ontop of the generic dmaengine driver patches right away, since it will simplify things quite a bit.
I rebased the series onto your branch now. But there is a small problem with the DMA handling.
Currently you pass the device pointer into snd_dmaengine_pcm_register and use it to request the dma channels. At least for imx-pcm-audio driver, it would be useful to pass a second device just for the dma requests. Otherwise imx-pcm-audio needs devicetree bindings, but I think the dma properties belong to fsl-ssi.
Regards,
Markus
- Lars
Regards,
Markus
Markus Pargmann (11): ASoC: phycore-ac97: Add DT support ASoC: imx-pcm-dma: Add support for DMA init by ASoC: imx-pcm-fiq: Introduce pcm-fiq-params ASoC: fsl-ssi: Add SACNT definitions ASoC: fsl-ssi: Add support for imx-pcm-fiq ASoC: fsl-ssi: Setup generic imx dma params ARM: imx: Export ac97 reset functions ASoC: fsl-ssi: imx ac97 support ASoC: fsl: Kconfig: Use fsl-ssi for phycore-ac97 ASoC: fsl: Move fsl-ssi binding doc to sound/ ASoC: fsl: Update fsl-ssi binding doc
Documentation/devicetree/bindings/powerpc/fsl/ssi.txt | 73 - Documentation/devicetree/bindings/sound/fsl,ssi.txt | 13 b/Documentation/devicetree/bindings/sound/fsl,ssi.txt | 73 + b/Documentation/devicetree/bindings/sound/phytec,phycore-ac97.txt | 12 b/arch/arm/mach-imx/mach-pca100.c | 7 b/arch/arm/mach-imx/mach-pcm043.c | 7 b/sound/soc/fsl/Kconfig | 2 b/sound/soc/fsl/fsl_ssi.c | 70 + b/sound/soc/fsl/fsl_ssi.h | 8 b/sound/soc/fsl/imx-pcm-dma.c | 31 b/sound/soc/fsl/imx-pcm-fiq.c | 14 b/sound/soc/fsl/imx-pcm.h | 6 b/sound/soc/fsl/imx-ssi.c | 7 b/sound/soc/fsl/imx-ssi.h | 1 b/sound/soc/fsl/phycore-ac97.c | 185 ++++ sound/soc/fsl/fsl_ssi.c | 379 +++++++--- sound/soc/fsl/imx-pcm.h | 9 17 files changed, 664 insertions(+), 233 deletions(-)
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On 04/13/2013 03:32 PM, Markus Pargmann wrote:
On Sun, Apr 07, 2013 at 10:35:02PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 10:08 PM, Markus Pargmann wrote:
Hi,
On Sun, Apr 07, 2013 at 09:39:31PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Okay, I will rebase it for v3 onto your committed cleanups and will have a look on your latest patches.
It might be a good idea to rebase it ontop of the generic dmaengine driver patches right away, since it will simplify things quite a bit.
I rebased the series onto your branch now. But there is a small problem with the DMA handling.
Currently you pass the device pointer into snd_dmaengine_pcm_register and use it to request the dma channels. At least for imx-pcm-audio driver, it would be useful to pass a second device just for the dma requests. Otherwise imx-pcm-audio needs devicetree bindings, but I think the dma properties belong to fsl-ssi.
I though about that as well, just initialize of_node of the newly allocated imx-pcm-audio platform device to that of the parent device. That should work nicely.
- Lars
On Sat, Apr 13, 2013 at 03:40:04PM +0200, Lars-Peter Clausen wrote:
On 04/13/2013 03:32 PM, Markus Pargmann wrote:
On Sun, Apr 07, 2013 at 10:35:02PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 10:08 PM, Markus Pargmann wrote:
Hi,
On Sun, Apr 07, 2013 at 09:39:31PM +0200, Lars-Peter Clausen wrote:
On 04/07/2013 09:25 PM, Markus Pargmann wrote:
Hi,
This series adds DT support for phycore-ac97 using the fsl-ssi driver. In version 2 I discarded most of the imx-ssi work and integrated the ac97-slave support in fsl-ssi, including support for imx-pcm-fiq as alternative to dma. There are some other changes to get phycore-ac97 working. The first two patches have notes about the detailed changes since version 1. The rest of the patches is new and necessary for the ac97-slave support.
Regards,
Markus
Hi,
The DMA PCM related changes won't apply anymore due to the recent dmaengine PCM cleanups. I've also been working on a more generic dmaengine PCM driver which has DT support and can be used by imx. The work in progress patches can be found here: https://github.com/lclausen-adi/linux-2.6/commits/asoc-dmaengine-cleanups
- Lars
Okay, I will rebase it for v3 onto your committed cleanups and will have a look on your latest patches.
It might be a good idea to rebase it ontop of the generic dmaengine driver patches right away, since it will simplify things quite a bit.
I rebased the series onto your branch now. But there is a small problem with the DMA handling.
Currently you pass the device pointer into snd_dmaengine_pcm_register and use it to request the dma channels. At least for imx-pcm-audio driver, it would be useful to pass a second device just for the dma requests. Otherwise imx-pcm-audio needs devicetree bindings, but I think the dma properties belong to fsl-ssi.
I though about that as well, just initialize of_node of the newly allocated imx-pcm-audio platform device to that of the parent device. That should work nicely.
Okay, I wasn't sure if this is good practice, but then I will do it like this.
Regards,
Markus
participants (4)
-
Lars-Peter Clausen
-
Mark Brown
-
Markus Pargmann
-
Timur Tabi