Add Freescale ASRC driver
Subsystems (5)
Nicolin Chen
reviewerv4 cover Add Freescale ASRC driver
This series of patches add Freescale ASRC module driver support along with the extra request in imx-sdma structure required by SDMA Device to Device script.
The previous version has been in the maillist for nearly six months without any comment and reply. So I decide to drop the SDMA part's change since this series focus on ASRC support (Later, we can send SDMA part separately.) so that ASRC driver may get upstream first.
Changelog
v4: (All follow Varka's suggestions)
* PATCH-2: Added '\n' to dev_dbg() inside fsl_asrc_isr().
* PATCH-2: Added indentations to DT binding document.
* PATCH-2: Redefined fsl_asrc_set_watermarks() as void type.
* PATCH-2: Put fsl_asrc_isr() and fsl_asrc_ids before probe()
v3:
* PATCH-1: Added an Acked-by from Shawn Guo
* PATCH-2: Dropped THIS_MODULE as Tobias suggests
* PATCH-2: Use dma_coerce_mask_and_coherent() in fsl_asrc_dma_pcm_new()
* PATCH-2: Added substream check in fsl_asrc_dma_pcm_new()
v2:
* PATCH-1: Dropped the change to SDMA driver.
* PATCH-2: Dropped useless member in private data structures.
* PATCH-2: Refined some comments in fsl_asrc_dma.c driver.
* PATCH-2: Refined commit comments.
Nicolin Chen (2):
ARM: imx: Add the secondary request into the structure for imx-sdma
ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
.../devicetree/bindings/sound/fsl,asrc.txt | 60 ++ include/linux/platform_data/dma-imx.h | 1 + sound/soc/fsl/Kconfig | 9 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_asrc.c | 1032 ++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 461 +++++++++ sound/soc/fsl/fsl_asrc_dma.c | 386 ++++++++ 7 files changed, 1951 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/fsl,asrc.txt create mode 100644 sound/soc/fsl/fsl_asrc.c create mode 100644 sound/soc/fsl/fsl_asrc.h create mode 100644 sound/soc/fsl/fsl_asrc_dma.c
Signature · 1 line
1.8.4
Nicolin Chen
reviewerPATCH v4 1/2 ARM: imx: Add the secondary request into the structure for imx-sdma
SDMA supports device to device (per_2_per) scripts to handle DMA transfering between two peripheral devices. The per_2_per script, however, needs two dma requests from two sides while the current structure only defined one request.
So this patch just simply adds the secondary request so as to let SDMA and its user to add its implementation later.
[ Both change in the SDMA driver and its users like Freescale ASRC ASoC driver
should be taken along with this change in order to truly support per_2_per sciprts. However, we here make an expediency by adding this first so that we can add either side later since this patch won't break any function and meanwhile it can make merge window more smoothly: we don't need to apply the change inside dmaengine branch via ASoC tree any more. -- Nicolin ]
--- include/linux/platform_data/dma-imx.h | 1 + 1 file changed, 1 insertion(+)
include/linux/platform_data/dma-imx.h +1 -0
@@ -51,6 +51,7 @@ enum imx_dma_prio {struct imx_dma_data {int dma_request;/* DMA request line */ +int dma_request2;/* secondary DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; };
Signature · 1 line
1.8.4
Nicolin Chen
reviewerPATCH v4 2/2 ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
In reply to Nicolin ChenThe Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a signal associated with an input clock into a signal associated with a different output clock. The driver currently works as a Front End of DPCM with other Back Ends DAI links such as ESAI<->CS42888 and SSI<->WM8962 and SAI. It converts the original sample rate to a common rate supported by Back Ends for playback while converts the common rate of Back Ends to a desired rate for capture. It has 3 pairs to support three different substreams within totally 10 channels.
--- .../devicetree/bindings/sound/fsl,asrc.txt | 60 ++ sound/soc/fsl/Kconfig | 9 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_asrc.c | 1032 ++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 461 +++++++++ sound/soc/fsl/fsl_asrc_dma.c | 386 ++++++++ 6 files changed, 1950 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/fsl,asrc.txt create mode 100644 sound/soc/fsl/fsl_asrc.c create mode 100644 sound/soc/fsl/fsl_asrc.h create mode 100644 sound/soc/fsl/fsl_asrc_dma.c
Documentation/devicetree/bindings/sound/fsl,asrc.txt new file +60 -0
@@ -0,0 +1,60 @@ +Freescale Asynchronous Sample Rate Converter (ASRC) Controller + +The Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a +signal associated with an input clock into a signal associated with a different +output clock. The driver currently works as a Front End of DPCM with other Back +Ends Audio controller such as ESAI, SSI and SAI. It has three pairs to support +three substreams within totally 10 channels. + +Required properties: + + - compatible : Contains "fsl,imx35-asrc" or "fsl,imx53-asrc". + + - reg : Offset and length of the register set for the device. + + - interrupts : Contains the spdif interrupt. + + - dmas : Generic dma devicetree binding as described in + Documentation/devicetree/bindings/dma/dma.txt. + + - dma-names : Contains "rxa", "rxb", "rxc", "txa", "txb" and "txc". + + - clocks : Contains an entry for each entry in clock-names. + + - clock-names : Contains the following entries + "mem" Peripheral access clock to access registers. + "ipg" Peripheral clock to driver module. + "asrck_<0-f>" Clock sources for input and output clock. + + - big-endian : If this property is absent, the native endian mode + will be in use as default, or the big endian mode + will be in use for all the device registers. + + - fsl,asrc-rate : Defines a mutual sample rate used by DPCM Back Ends. + + - fsl,asrc-width : Defines a mutual sample width used by DPCM Back Ends. + +Example: + +asrc: asrc@02034000 { + compatible = "fsl,imx53-asrc"; + reg = <0x02034000 0x4000>; + interrupts = <0 50 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks 107>, <&clks 107>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 107>, <&clks 0>, <&clks 0>; + clock-names = "mem", "ipg", "asrck0", + "asrck_1", "asrck_2", "asrck_3", "asrck_4", + "asrck_5", "asrck_6", "asrck_7", "asrck_8", + "asrck_9", "asrck_a", "asrck_b", "asrck_c", + "asrck_d", "asrck_e", "asrck_f"; + dmas = <&sdma 17 23 1>, <&sdma 18 23 1>, <&sdma 19 23 1>, + <&sdma 20 23 1>, <&sdma 21 23 1>, <&sdma 22 23 1>; + dma-names = "rxa", "rxb", "rxc", + "txa", "txb", "txc"; + fsl,asrc-rate = <48000>; + fsl,asrc-width = <16>; + status = "okay"; +};
sound/soc/fsl/Kconfig +9 -0
@@ -2,6 +2,15 @@ menu "SoC Audio for Freescale CPUs" comment "Common SoC Audio options for Freescale CPUs:" +config SND_SOC_FSL_ASRC + tristate "Asynchronous Sample Rate Converter (ASRC) module support" + select REGMAP_MMIO + help + Say Y if you want to add Asynchronous Sample Rate Converter (ASRC) + support for the Freescale CPUs. + This option is only useful for out-of-tree drivers since + in-tree drivers select it automatically. + config SND_SOC_FSL_SAI tristate "Synchronous Audio Interface (SAI) module support" select REGMAP_MMIO
sound/soc/fsl/Makefile +2 -0
@@ -11,6 +11,7 @@ snd-soc-p1022-rdk-objs := p1022_rdk.o obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o # Freescale SSI/DMA/SAI/SPDIF Support +snd-soc-fsl-asrc-objs := fsl_asrc.o fsl_asrc_dma.o snd-soc-fsl-sai-objs := fsl_sai.o snd-soc-fsl-ssi-y := fsl_ssi.o snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o
@@ -18,6 +19,7 @@ snd-soc-fsl-spdif-objs := fsl_spdif.o snd-soc-fsl-esai-objs := fsl_esai.o snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o +obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o
sound/soc/fsl/fsl_asrc.c new file +1032 -0
1,032 lines not on this page · raw message
sound/soc/fsl/fsl_asrc.h new file +461 -0
461 lines not on this page · raw message
sound/soc/fsl/fsl_asrc_dma.c new file +386 -0
386 lines not on this page · raw message
Signature · 1 line
1.8.4
Re: [PATCH v4 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
On 07/25/2014 12:49 PM, Nicolin Chen wrote:
(...)
sound/soc/fsl/fsl_asrc.c line 302
Quoted 5 lines
sound/soc/fsl/fsl_asrc.c new file +5
-0+ + div[IN ] =clk_get_rate (clk) / inrate; +if (div[IN ] ==0 ) { +pair_err ("failed to support input sample rate %dHz by asrck_%x" , + inrate, clk_index[ideal ?OUT :IN ]);
Ohhhhh... missed terminating new line...
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +4
-0+return -EINVAL ; + } + + clk = asrc_priv->asrck_clk[clk_index[OUT ]];
sound/soc/fsl/fsl_asrc.c line 316
Quoted 10 lines
sound/soc/fsl/fsl_asrc.c new file +10
-0+ +/* Use fixed output rate for Ideal Ratio mode (INCLK_NONE) */ +if (ideal) + div[OUT ] =clk_get_rate (clk) /IDEAL_RATIO_RATE ; +else + div[OUT ] =clk_get_rate (clk) / outrate; + +if (div[OUT ] ==0 ) { +pair_err ("failed to support output sample rate %dHz by asrck_%x" , + outrate, clk_index[OUT ]);
same..
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +4
-0+return -EINVAL ; + } + +
(...)
Quoted 14 lines
sound/soc/fsl/fsl_asrc.c new file +14
-0+static int fsl_asrc_init (struct fsl_asrc *asrc_priv) +{ +/* Halt ASRC internal FP when input FIFO needs data for pair A, B, C */ +regmap_write (asrc_priv->regmap,REG_ASRCTR ,ASRCTR_ASRCEN ); + +/* Disable interrupt by default */ +regmap_write (asrc_priv->regmap,REG_ASRIER ,0x0 ); + +/* Apply recommended settings for parameters from Reference Manual */ +regmap_write (asrc_priv->regmap,REG_ASRPM1 ,0x7fffff ); +regmap_write (asrc_priv->regmap,REG_ASRPM2 ,0x255555 ); +regmap_write (asrc_priv->regmap,REG_ASRPM3 ,0xff7280 ); +regmap_write (asrc_priv->regmap,REG_ASRPM4 ,0xff7280 ); +regmap_write (asrc_priv->regmap,REG_ASRPM5 ,0xff7280 );
sound/soc/fsl/fsl_asrc.c line 728
Quoted 10 lines
sound/soc/fsl/fsl_asrc.c new file +10
-0+ +/* Base address for task queue FIFO. Set to 0x7C */ +regmap_update_bits (asrc_priv->regmap,REG_ASRTFR1 , +ASRTFR1_TF_BASE_MASK ,ASRTFR1_TF_BASE (0xfc )); + +/* Set the processing clock for 76KHz to 133M */ +regmap_write (asrc_priv->regmap,REG_ASR76K ,0x06D6 ); + +/* Set the processing clock for 56KHz to 133M */ +regmap_write (asrc_priv->regmap,REG_ASR56K ,0x0947 );
No where we are checking the return value here, but return zero...?
check the regmap_write return value then return or implement this to void...
Quoted 8 lines
sound/soc/fsl/fsl_asrc.c new file +8
-0+ +return 0 ; +} + +/** +* Interrupt handler for ASRC +*/ +
(...)
sound/soc/fsl/fsl_asrc.c line 798
Quoted 13 lines
sound/soc/fsl/fsl_asrc.c new file +13
-0+static const struct platform_device_id fsl_asrc_devtype[] = { + { + .name ="imx35-asrc" , + .driver_data =IMX35_ASRC , + }, { + .name ="imx53-asrc" , + .driver_data =IMX53_ASRC , + }, { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (platform, fsl_asrc_devtype); +
where are you using fsl_asrc_devtype,,,?
sound/soc/fsl/fsl_asrc.c line 802
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +4
-0+static const struct of_device_id fsl_asrc_ids[] = { + { + .compatible ="fsl,imx35-asrc" , + .data = &fsl_asrc_devtype[IMX35_ASRC ],
Ya here ... but what is the use...?
Quoted 9 lines
sound/soc/fsl/fsl_asrc.c new file +9
-0+ }, { + .compatible = "fsl,imx53-asrc", + .data = &fsl_asrc_devtype[IMX53_ASRC], + }, { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (of, fsl_asrc_ids); +
(...)
sound/soc/fsl/fsl_asrc.c line 864
Quoted 2 lines
sound/soc/fsl/fsl_asrc.c new file +2
-0+ asrc_priv->regmap =devm_regmap_init_mmio_clk (&pdev->dev, +"mem" , regs, &fsl_asrc_regmap_config);
devm_regmap_init_mmio_clk(&pdev->dev,
"mem", regs, &fsl_asrc_regmap_config);
sound/soc/fsl/fsl_asrc.c line 877
Quoted 13 lines
sound/soc/fsl/fsl_asrc.c new file +13
-0+if (IS_ERR (asrc_priv->regmap)) { +dev_err (&pdev->dev,"failed to init regmap\n" ); +return PTR_ERR (asrc_priv->regmap); + } + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (&pdev->dev,"no irq for node %s\n" , np->full_name); +return irq; + } + + ret =devm_request_irq (&pdev->dev, irq, fsl_asrc_isr,0 , + asrc_priv->name, asrc_priv);
same...
Thanks...
Signature · 7 lines
Regards, Varka Bhadram. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
Hi Varka,
Thank you for the comments!
Quoted 19 lines · Varka Bhadram
On 07/25/2014 12:49 PM, Nicolin Chen wrote:
(...)sound/soc/fsl/fsl_asrc.c line 798
Quoted 13 lines
sound/soc/fsl/fsl_asrc.c new file +13
-0+static const struct platform_device_id fsl_asrc_devtype[] = { + { + .name ="imx35-asrc" , + .driver_data =IMX35_ASRC , + }, { + .name ="imx53-asrc" , + .driver_data =IMX53_ASRC , + }, { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (platform, fsl_asrc_devtype); +where are you using
fsl_asrc_devtype,,,?
Quoted 6 lines
sound/soc/fsl/fsl_asrc.c line 802
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +4
-0+static const struct of_device_id fsl_asrc_ids[] = { + { + .compatible ="fsl,imx35-asrc" , + .data = &fsl_asrc_devtype[IMX35_ASRC ],Ya here ... but what is the use...?
I got your point. I will drop all these and move ids behind probe/remove() as you suggested at the first place and then use of_device_is_compatible() inside the probe() instead.
Quoted 6 lines
sound/soc/fsl/fsl_asrc.c line 864
Quoted 2 lines
sound/soc/fsl/fsl_asrc.c new file +2
-0+ asrc_priv->regmap =devm_regmap_init_mmio_clk (&pdev->dev, +"mem" , regs, &fsl_asrc_regmap_config);devm_regmap_init_mmio_clk(&pdev->dev,
"mem", regs, &fsl_asrc_regmap_config);
I'll refine to
devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs,
&fsl_asrc_regmap_config);
Quoted 16 lines
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +3
-0+if (IS_ERR (asrc_priv->regmap)) { +dev_err (&pdev->dev,"failed to init regmap\n" ); +return PTR_ERR (asrc_priv->regmap);sound/soc/fsl/fsl_asrc.c line 877
Quoted 10 lines
sound/soc/fsl/fsl_asrc.c new file +10
-0+ } + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (&pdev->dev,"no irq for node %s\n" , np->full_name); +return irq; + } + + ret =devm_request_irq (&pdev->dev, irq, fsl_asrc_isr,0 , + asrc_priv->name, asrc_priv);same...
Sorry I don't see any problem with this devm_request_irq()...
Thank you,
Nicolin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
In reply to Varka BhadramQuoted 15 lines · Varka Bhadram
Quoted 14 lines · Nicolin Chen
Quoted 14 lines
sound/soc/fsl/fsl_asrc.c line 877
Quoted 13 lines
sound/soc/fsl/fsl_asrc.c new file +13
-0+if (IS_ERR (asrc_priv->regmap)) { +dev_err (&pdev->dev,"failed to init regmap\n" ); +return PTR_ERR (asrc_priv->regmap); + } + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (&pdev->dev,"no irq for node %s\n" , np->full_name); +return irq; + } + + ret =devm_request_irq (&pdev->dev, irq, fsl_asrc_isr,0 , + asrc_priv->name, asrc_priv);same...
Quoted 3 lines
Quoted 1 line
Sorry I don't see any problem with this
devm_request_irq()...Ohhh... This is the problem with my email client... Sorry...
No problem. I appreciate your carefulness :)
Thank you,
Nicolin
Re: [PATCH v4 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
In reply to Nicolin ChenQuoted 56 lines · Nicolin Chen
Hi Varka,
Thank you for the comments!
Quoted 18 lines · Varka Bhadram
On 07/25/2014 12:49 PM, Nicolin Chen wrote:
(...)sound/soc/fsl/fsl_asrc.c line 798
Quoted 13 lines
sound/soc/fsl/fsl_asrc.c new file +13
-0+static const struct platform_device_id fsl_asrc_devtype[] = { + { + .name ="imx35-asrc" , + .driver_data =IMX35_ASRC , + }, { + .name ="imx53-asrc" , + .driver_data =IMX53_ASRC , + }, { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (platform, fsl_asrc_devtype); +where are you using
fsl_asrc_devtype,,,?Quoted 5 lines
sound/soc/fsl/fsl_asrc.c line 802
Quoted 4 lines
sound/soc/fsl/fsl_asrc.c new file +4
-0+static const struct of_device_id fsl_asrc_ids[] = { + { + .compatible ="fsl,imx35-asrc" , + .data = &fsl_asrc_devtype[IMX35_ASRC ],Ya here ... but what is the use...?
I got your point. I will drop all these and move ids behind probe/remove() as you suggested at the first place and then use
of_device_is_compatible()inside theprobe()instead.Quoted 5 lines
sound/soc/fsl/fsl_asrc.c line 864
Quoted 2 lines
sound/soc/fsl/fsl_asrc.c new file +2
-0+ asrc_priv->regmap =devm_regmap_init_mmio_clk (&pdev->dev, +"mem" , regs, &fsl_asrc_regmap_config);devm_regmap_init_mmio_clk(&pdev->dev,
"mem", regs, &fsl_asrc_regmap_config);I'll refine to
devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs,
&fsl_asrc_regmap_config);Quoted 6 lines
Quoted 6 lines
sound/soc/fsl/fsl_asrc.c new file +6
-0+if (IS_ERR (asrc_priv->regmap)) { +dev_err (&pdev->dev,"failed to init regmap\n" ); +return PTR_ERR (asrc_priv->regmap); + } + + irq =platform_get_irq (pdev,0 );Quoted 8 lines
sound/soc/fsl/fsl_asrc.c line 877
Quoted 7 lines
sound/soc/fsl/fsl_asrc.c new file +7
-0+if (irq <0 ) { +dev_err (&pdev->dev,"no irq for node %s\n" , np->full_name); +return irq; + } + + ret =devm_request_irq (&pdev->dev, irq, fsl_asrc_isr,0 , + asrc_priv->name, asrc_priv);same...
Quoted 1 line
Sorry I don't see any problem with this
devm_request_irq()...
Ohhh... This is the problem with my email client... Sorry...
Thanks...
Signature · 2 lines
Regards, Varka Bhadram.