ASoC: brcm: Add DSL/PON SoC audio driver
Subsystems (3)
PATCH 1/1 ASoC: brcm: Add DSL/PON SoC audio driver
This patch adds Broadcom DSL/PON SoC audio driver with Whistler I2S block. The SoC supported by this patch are BCM63158B0,BCM63178 and BCM47622/6755.
--- sound/soc/bcm/Kconfig | 9 + sound/soc/bcm/Makefile | 4 + sound/soc/bcm/bcm63xx-i2s-whistler.c | 328 ++++++++++++++++++ sound/soc/bcm/bcm63xx-i2s.h | 93 +++++ sound/soc/bcm/bcm63xx-pcm-whistler.c | 488 +++++++++++++++++++++++++++ 5 files changed, 922 insertions(+) create mode 100644 sound/soc/bcm/bcm63xx-i2s-whistler.c create mode 100644 sound/soc/bcm/bcm63xx-i2s.h create mode 100644 sound/soc/bcm/bcm63xx-pcm-whistler.c
sound/soc/bcm/Kconfig +9 -0
@@ -17,3 +17,12 @@ config SND_SOC_CYGNUS Cygnus chips (bcm958300, bcm958305, bcm911360) If you don't know what to do here, say N. + +config SND_BCM63XX_I2S_WHISTLER + tristate "SoC Audio support for the Broadcom BCM63XX I2S module" + select REGMAP_MMIO + help + Say Y if you want to add support for ASoC audio on Broadcom + DSL/PON chips (bcm63158, bcm63178) + + If you don't know what to do here, say N
sound/soc/bcm/Makefile +4 -0
@@ -9,3 +9,7 @@ snd-soc-cygnus-objs := cygnus-pcm.o cygnus-ssp.o obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-cygnus.o +# BCM63XX Platform Support +snd-soc-63xx-objs := bcm63xx-i2s-whistler.o bcm63xx-pcm-whistler.o + +obj-$(CONFIG_SND_BCM63XX_I2S_WHISTLER) += snd-soc-63xx.o
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +328 -0
328 lines not on this page · raw message
sound/soc/bcm/bcm63xx-i2s.h new file +93 -0
93 lines not on this page · raw message
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +488 -0
488 lines not on this page · raw message
--
2.25.1
PATCH 1/1 ASoC: brcm: DSL/PON SoC device tree bindings of audio driver
--- .../bindings/sound/brcm,bcm63xx-audio.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 Documentation/devicetree/bindings/sound/brcm,bcm63xx-audio.txt
Documentation/devicetree/bindings/sound/brcm,bcm63xx-audio.txt new file +29 -0
@@ -0,0 +1,29 @@ +Broadcom DSL/PON BCM63xx Audio I2S controller + +Required properties: +- compatible: Should be "brcm,bcm63xx-i2s". +- #address-cells: 32bit valued, 1 cell. +- #size-cells: 32bit valued, 0 cell. +- reg: Should contain audio registers location and length +- interrupts: Should contain the interrupt for the controller. +- clocks: Must contain an entry for each entry in clock-names. + Please refer to clock-bindings.txt. +- clock-names: Should be one of each entry matching the clocks phandles list: + - "i2sclk" (generated clock) Required. + - "i2sosc" (fixed 200MHz clock) Required. + +(1) : The generated clock is required only when any of TX and RX + works on Master Mode. +(2) : The fixed 200MHz clock is from internal chip and always on + +Example: + + i2s: bcm63xx-i2s { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,bcm63xx-i2s"; + reg = <0xFF802080 0xFF>; + interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&i2sclk>, <&osc>; + clock-names = "i2sclk","i2sosc"; + };
Signature · 1 line
2.25.1
Quoted 6 lines · Kevin Li
This patch adds Broadcom DSL/PON SoC audio driver with Whistler I2S block. The SoC supported by this patch are BCM63158B0,BCM63178 and BCM47622/6755.
Signed-off-by Kevin Li <[email protected]>---
[snip]
Quoted 17 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +17
-0+int bcm63xx_soc_platform_probe (struct platform_device *pdev, +struct bcm_i2s_priv *i2s_priv) +{ +int ret; + + i2s_priv->r_irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!i2s_priv->r_irq) { +dev_err (&pdev->dev,"Unable to get register irq resource.\n" ); +return -ENODEV ; + } + + ret =devm_request_irq (&pdev->dev, i2s_priv->r_irq->start, i2s_dma_isr, + i2s_priv->r_irq->flags,"i2s_dma" , (void *)i2s_priv); +if (ret) { +dev_err (&pdev->dev, +"i2s_init: failed to request interrupt.ret=%d\n" , ret); +return ret;
sound/soc/bcm/bcm63xx-pcm-whistler.c line 484
Quoted 10 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +10
-0+ } + +return devm_snd_soc_register_component (&pdev->dev, + &bcm63xx_soc_platform,NULL ,0 ); +} + +int bcm63xx_soc_platform_remove (struct platform_device *pdev) +{ +return 0 ; +}
How does one probe this module if the bcm63xx_soc_platform_probe() functions are not called from anywhere and/or hooked up to the module entry/exit points?
Are you not missing a platform_driver entry which matches the compatible string you defined?
Signature · 1 line
Florian
Hi Florian,
It is called from bcm63xx-i2s-whistler.c.
Maybe the name "_probe" function confused. It was 2 platform drivers, I combined them together now.
Let me know if this answers your question, and what to do to address your question.
Regards!
Kevin
-----Original Message-----
From: Florian Fainelli [mailto:[email protected]]
Sent: Friday, March 06, 2020 2:34 PM
To: Kevin Li <[email protected]>; Mark Brown <[email protected]>
Cc: [email protected]; [email protected]; Kuninori Morimoto <[email protected]>; Scott Branden <[email protected]>; Liam Girdwood <[email protected]>; Ray Jui <[email protected]>; Takashi Iwai <[email protected]>; Jaroslav Kysela <[email protected]>; [email protected]; Stephen Boyd <[email protected]>; [email protected]
Subject: Re: [PATCH] ASoC: brcm: Add DSL/PON SoC audio driver
Quoted 6 lines · Kevin Li
This patch adds Broadcom DSL/PON SoC audio driver with Whistler I2S block. The SoC supported by this patch are BCM63158B0,BCM63178 and BCM47622/6755.
Signed-off-by Kevin Li <[email protected]>---
[snip]
Quoted 14 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +14
-0+int bcm63xx_soc_platform_probe (struct platform_device *pdev, +struct bcm_i2s_priv *i2s_priv) { +int ret; + + i2s_priv->r_irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!i2s_priv->r_irq) { +dev_err (&pdev->dev,"Unable to get register irq resource.\n" ); +return -ENODEV ; + } + + ret =devm_request_irq (&pdev->dev, i2s_priv->r_irq->start, i2s_dma_isr, + i2s_priv->r_irq->flags,"i2s_dma" , (void *)i2s_priv); +if (ret) { + dev_err(&pdev->dev,
sound/soc/bcm/bcm63xx-pcm-whistler.c line 484
Quoted 10 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +10
-0+ "i2s_init: failed to request interrupt.ret=%d\n", ret); +return ret; + } + +return devm_snd_soc_register_component (&pdev->dev, + &bcm63xx_soc_platform,NULL ,0 ); } + +int bcm63xx_soc_platform_remove (struct platform_device *pdev) { +return 0 ; +}
How does one probe this module if the bcm63xx_soc_platform_probe() functions are not called from anywhere and/or hooked up to the module entry/exit points?
Are you not missing a platform_driver entry which matches the compatible string you defined?
--
Florian
Quoted 8 lines · Kevin Li
Hi Florian,
It is called from
bcm63xx-i2s-whistler.c.
Maybe the name "_probe" function confused. It was 2 platform drivers, I combined them together now.Let me know if this answers your question, and what to do to address your question.
Ok, that makes sense now, sorry for not spotting it earlier.
PS: no top posting please ;)
Quoted 60 lines
Regards!
Kevin-----Original Message-----
From: Florian Fainelli [mailto:[email protected]]
Sent: Friday, March 06, 2020 2:34 PM
To: Kevin Li <[email protected]>; Mark Brown <[email protected]>
Cc: [email protected]; [email protected]; Kuninori Morimoto <[email protected]>; Scott Branden <[email protected]>; Liam Girdwood <[email protected]>; Ray Jui <[email protected]>; Takashi Iwai <[email protected]>; Jaroslav Kysela <[email protected]>; [email protected]; Stephen Boyd <[email protected]>; [email protected]
Subject: Re: [PATCH] ASoC: brcm: Add DSL/PON SoC audio driverQuoted 6 lines · Kevin Li
This patch adds Broadcom DSL/PON SoC audio driver with Whistler I2S block. The SoC supported by this patch are BCM63158B0,BCM63178 and BCM47622/6755.
Signed-off-by Kevin Li <[email protected]>---
[snip]
Quoted 14 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +14
-0+int bcm63xx_soc_platform_probe (struct platform_device *pdev, +struct bcm_i2s_priv *i2s_priv) { +int ret; + + i2s_priv->r_irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!i2s_priv->r_irq) { +dev_err (&pdev->dev,"Unable to get register irq resource.\n" ); +return -ENODEV ; + } + + ret =devm_request_irq (&pdev->dev, i2s_priv->r_irq->start, i2s_dma_isr, + i2s_priv->r_irq->flags,"i2s_dma" , (void *)i2s_priv); +if (ret) { + dev_err(&pdev->dev,sound/soc/bcm/bcm63xx-pcm-whistler.c line 484
Quoted 10 lines
sound/soc/bcm/bcm63xx-pcm-whistler.c new file +10
-0+ "i2s_init: failed to request interrupt.ret=%d\n", ret); +return ret; + } + +return devm_snd_soc_register_component (&pdev->dev, + &bcm63xx_soc_platform,NULL ,0 ); } + +int bcm63xx_soc_platform_remove (struct platform_device *pdev) { +return 0 ; +}How does one probe this module if the
bcm63xx_soc_platform_probe()functions are not called from anywhere and/or hooked up to the module entry/exit points?Are you not missing a
platform_driverentry which matches the compatible string you defined?
--
Florian
Signature · 1 line
Florian
Mark Brown
maintainerQuoted 3 lines · Kevin Li
This patch adds Broadcom DSL/PON SoC audio driver with Whistler I2S block. The SoC supported by this patch are BCM63158B0,BCM63178 and BCM47622/6755.
Please number patches within a series when you send it - submitting-patches.rst should cover this.
sound/soc/bcm/bcm63xx-i2s-whistler.c line 4
Quoted 6 lines
+++
b/sound/soc/bcm/bcm63xx-i2s-whistler.csound/soc/bcm/bcm63xx-i2s-whistler.c new file +4
-0@@ -0,0 +1,328 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* linux/sound/bcm/bcm63xx-i2s-whistler.c +* BCM63xx whistler i2s driver
Please make the entire comment a C++ one so things look more intentional.
sound/soc/bcm/bcm63xx-i2s-whistler.c line 80
Quoted 4 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +4
-0+static int bcm63xx_i2s_set_fmt (struct snd_soc_dai *cpu_dai,unsigned int fmt) +{ +return 0 ; +}
Remove empty functions, if the framework prevents removing the function entirely that's a sign that you need to do something.
sound/soc/bcm/bcm63xx-i2s-whistler.c line 106
Quoted 4 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +4
-0+static int bcm63xx_i2s_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +unsigned int slaveMode;
Please use the kernel coding style.
Quoted 12 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +12
-0+struct bcm_i2s_priv *i2s_priv =snd_soc_dai_get_drvdata (dai); +struct regmap *regmap_i2s = i2s_priv->regmap_i2s; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +regmap_update_bits (regmap_i2s,I2S_TX_CFG , +I2S_TX_OUT_R |I2S_TX_DATA_ALIGNMENT | +I2S_TX_DATA_ENABLE |I2S_TX_CLOCK_ENABLE , +I2S_TX_OUT_R |I2S_TX_DATA_ALIGNMENT | +I2S_TX_DATA_ENABLE |I2S_TX_CLOCK_ENABLE ); +regmap_write (regmap_i2s,I2S_TX_IRQ_CTL ,0 ); +regmap_write (regmap_i2s,I2S_TX_IRQ_IFF_THLD ,0 ); +regmap_write (regmap_i2s,I2S_TX_IRQ_OFF_THLD ,1 );
sound/soc/bcm/bcm63xx-i2s-whistler.c line 128
Quoted 10 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +10
-0+ +regmap_read (regmap_i2s,I2S_RX_CFG_2 , &slaveMode); +if (slaveMode &I2S_RX_SLAVE_MODE_MASK ) +regmap_update_bits (regmap_i2s,I2S_TX_CFG_2 , +I2S_TX_SLAVE_MODE_MASK , +I2S_TX_MASTER_MODE ); +else +regmap_update_bits (regmap_i2s,I2S_TX_CFG_2 , +I2S_TX_SLAVE_MODE_MASK , +I2S_TX_SLAVE_MODE );
Setting master or slave mode should be done with a set_fmt() operation but your set_fmt() operation was empty. How would this be configured?
Hi Mark,
The SoC I2S block we currently have shares one clock and frame sync signal for both playback and capture stream, plus playback and capture can only have one master at a time. If we set playback and capture master at same time, it will have jitter on clock and FS.
Based on above, for playback and capture, whichever starts first, it will be master, another stream will be slave if it starts before the first stream shutting down. So working as master or slave for a stream is depending on another stream's status.
Same thing for shutting down a stream. A master stream shutting down will have to set another stream to master if another stream is on working status as a slave. A glitch/Jitter will happen at this moment. But we minimize it.
That is why this master/slave mode handles in startup/shutdown functions. Not sure how other company handles this kind of I2S block.
Let me know if it is still not clear.
Yes, set_fmt() is not needed. Will be addressed along with rest questions you mentioned on the next patch, with a patch version.
Thanks!
Kevin
sound/soc/bcm/bcm63xx-i2s-whistler.c
Quoted 7 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +7
-0+struct bcm_i2s_priv *i2s_priv =snd_soc_dai_get_drvdata (dai); +struct regmap *regmap_i2s = i2s_priv->regmap_i2s; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + regmap_update_bits(regmap_i2s, I2S_TX_CFG, + I2S_TX_OUT_R | I2S_TX_DATA_ALIGNMENT | + I2S_TX_DATA_ENABLE |
I2S_TX_CLOCK_ENABLE,
Review
Quoted 2 lines
(quoted diff) +2
-0+ I2S_TX_OUT_R | I2S_TX_DATA_ALIGNMENT | + I2S_TX_DATA_ENABLE |
I2S_TX_CLOCK_ENABLE);
sound/soc/bcm/bcm63xx-i2s-whistler.c line 128
Quoted 13 lines
sound/soc/bcm/bcm63xx-i2s-whistler.c new file +13
-0+regmap_write (regmap_i2s,I2S_TX_IRQ_CTL ,0 ); +regmap_write (regmap_i2s,I2S_TX_IRQ_IFF_THLD ,0 ); +regmap_write (regmap_i2s,I2S_TX_IRQ_OFF_THLD ,1 ); + +regmap_read (regmap_i2s,I2S_RX_CFG_2 , &slaveMode); +if (slaveMode &I2S_RX_SLAVE_MODE_MASK ) +regmap_update_bits (regmap_i2s,I2S_TX_CFG_2 , +I2S_TX_SLAVE_MODE_MASK , +I2S_TX_MASTER_MODE ); +else +regmap_update_bits (regmap_i2s,I2S_TX_CFG_2 , +I2S_TX_SLAVE_MODE_MASK , +I2S_TX_SLAVE_MODE );
Setting master or slave mode should be done with a set_fmt() operation but your set_fmt() operation was empty. How would this be configured?
Mark Brown
maintainerQuoted 1 line · Kevin Li
Hi Mark,
Please don't top post, reply in line with needed context. This allows readers to readily follow the flow of conversation and understand what you are talking about and also helps ensure that everything in the discussion is being addressed.
Quoted 4 lines
The SoC I2S block we currently have shares one clock and frame sync signal for both playback and capture stream, plus playback and capture can only have one master at a time. If we set playback and capture master at same time, it will have jitter on clock and FS.
I can't really parse what you're talking about here (perhaps some of that context would have helped...) but it doesn't seem to be the clocking of the I2S bus which would normally be what master and slave would be talking about. If it's something else perhaps the code needs to be clarified to make it clear that it's not talking about the bus.
I can't really parse what you're talking about here (perhaps some of that context would have helped...) but it doesn't seem to be the clocking of the I2S bus which would normally be what master and slave would be talking about.
It is the clock setting of I2S bus master or slave.
If I am playing music only, I set TX as master. All others are slave. If I am recording only. I set RX as master. All others are slave. If I am playing and recording at same time, I set first coming stream as master second coming stream as slave. If I shut down first stream before second stream, then I will set the second stream as master, otherwise there will be no clock/FS signal on the I2S bus to maintain the second stream to its end.
Hope it is clearer.
Mark Brown
maintainerOn Mon, Mar 09, 2020 at 11:14:18AM -0700, Kevin Li wrote:
Please fix your mailer, it looks like you've included some text I wrote here:
Quoted 4 lines
I can't really parse what you're talking about here (perhaps some of that context would have helped...) but it doesn't seem to be the clocking of the I2S bus which would normally be what master and slave would be talking about.
but it's completely indistinguishable from the new text that you've added.
Quoted 8 lines
It is the clock setting of I2S bus master or slave.
If I am playing music only, I set TX as master. All others are slave. If I am recording only. I set RX as master. All others are slave. If I am playing and recording at same time, I set first coming stream as master second coming stream as slave. If I shut down first stream before second stream, then I will set the second stream as master, otherwise there will be no clock/FS signal on the I2S bus to maintain the second stream to its end.
This is not how any of this is supposed to work, it's unlikely to work well with other devices. If the device supports both master and slave operation then you should let the machine driver pick if the SoC or the CODEC is master via set_fmt(), randomly varying this at runtime is not going to be helpful.
Quoted 7 lines
This is not how any of this is supposed to work, it's unlikely to work well with other devices. If the device supports both master and slave operation then you should let the machine driver pick if the SoC or the CODEC is master via
set_fmt(), randomly varying this at runtime is not going to be helpful.
Maybe the name "master/slave" is confusing, these names come from internal chip signals and do not represent the state of the i2s bus master. Our SoC supports only master mode in the i2s bus. The Rx and Tx block each have an independent bit to indicate if it is generating the clock for the i2s bus. The i2s bus clocks need to be generated from either the Rx block or the Tx block, but not both.
Mark Brown
maintainerQuoted 6 lines · Kevin Li
Quoted 5 lines
This is not how any of this is supposed to work, it's unlikely to work well with other devices. If the device supports both master and slave operation then you should let the machine driver pick if the SoC or the CODEC is master via
set_fmt(), randomly varying this at runtime is not going to be helpful.
Quoted 6 lines
Maybe the name "master/slave" is confusing, these names come from internal chip signals and do not represent the state of the i2s bus master. Our SoC supports only master mode in the i2s bus. The Rx and Tx block each have an independent bit to indicate if it is generating the clock for the i2s bus. The i2s bus clocks need to be generated from either the Rx block or the Tx block, but not both.
Right, at the very least this needs to be better documented in the code.