ASoC: sirf: Add sirf audio hub driver and use it.
Subsystems (3)
cover ASoC: sirf: Add sirf audio hub driver and use it.
From: Rongjun Ying <[email protected]>
This patchset adds including:
1. SiRF audio hub driver
2. The internal codec and port get regmap form audio hub driver
3. Add SiRF audio hub binding document
Rongjun Ying (2):
ASoC: sirf: Add sirf audio hub driver for sharing same register
address space
Documentation: Describe the SiRF audio hub Device Tree bindings
.../devicetree/bindings/sound/sirf-audio-hub.txt | 52 +++++++++++++++ sound/soc/codecs/sirf-audio-codec.c | 32 ++-------- sound/soc/sirf/Kconfig | 5 ++ sound/soc/sirf/Makefile | 2 + sound/soc/sirf/sirf-audio-hub.c | 66 ++++++++++++++++++++ sound/soc/sirf/sirf-audio-port.c | 26 +-------- 6 files changed, 131 insertions(+), 52 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/sirf-audio-hub.txt create mode 100644 sound/soc/sirf/sirf-audio-hub.c
Signature · 1 line
1.7.5.4
PATCH 1/2 ASoC: sirf: Add sirf audio hub driver for sharing same register address space
From: Rongjun Ying <[email protected]>
The SiRF audio modules such as I2S, internal audio codec and audio port are sharing same register address space. This driver create regmap and register all child audio device. The child audio drivers can get regmap form its' parent driver data.
--- sound/soc/codecs/sirf-audio-codec.c | 32 +++-------------- sound/soc/sirf/Kconfig | 5 +++ sound/soc/sirf/Makefile | 2 + sound/soc/sirf/sirf-audio-hub.c | 66 +++++++++++++++++++++++++++++++++++ sound/soc/sirf/sirf-audio-port.c | 26 +------------- 5 files changed, 79 insertions(+), 52 deletions(-) create mode 100644 sound/soc/sirf/sirf-audio-hub.c
sound/soc/codecs/sirf-audio-codec.c +5 -27
@@ -283,9 +283,10 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream,int cmd, struct snd_soc_dai *dai) { - int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_soc_codec *codec = dai->codec;u32 val =0 ; +if (substream->stream !=SNDRV_PCM_STREAM_PLAYBACK ) +return 0 ;/* * This is a workaround, When stop playback,
@@ -299,15 +300,13 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream,case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (playback) - val =IC_HSLEN |IC_HSREN ; + val =IC_HSLEN |IC_HSREN ;break ;default :return -EINVAL ; } -if (playback) -snd_soc_update_bits (codec,AUDIO_IC_CODEC_CTRL0 , +snd_soc_update_bits (codec,AUDIO_IC_CODEC_CTRL0 ,IC_HSLEN |IC_HSREN , val);return 0 ; }
@@ -397,23 +396,10 @@ static const struct of_device_id sirf_audio_codec_of_match[] = { };MODULE_DEVICE_TABLE (of, sirf_audio_codec_of_match); -static const struct regmap_config sirf_audio_codec_regmap_config = { - .reg_bits =32 , - .reg_stride =4 , - .val_bits =32 , - .max_register =AUDIO_IC_CODEC_CTRL3 , - .cache_type =REGCACHE_NONE , -}; -static int sirf_audio_codec_driver_probe (struct platform_device *pdev) {int ret;struct sirf_audio_codec *sirf_audio_codec; -void __iomem *base; -struct resource *mem_res; -const struct of_device_id *match; - - match =of_match_node (sirf_audio_codec_of_match, pdev->dev.of_node); sirf_audio_codec =devm_kzalloc (&pdev->dev,sizeof (struct sirf_audio_codec ),GFP_KERNEL );
@@ -422,15 +408,7 @@ static int sirf_audio_codec_driver_probe(struct platform_device *pdev)platform_set_drvdata (pdev, sirf_audio_codec); - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - base =devm_ioremap_resource (&pdev->dev, mem_res); -if (base ==NULL ) -return -ENOMEM ; - - sirf_audio_codec->regmap =devm_regmap_init_mmio (&pdev->dev, base, - &sirf_audio_codec_regmap_config); -if (IS_ERR (sirf_audio_codec->regmap)) -return PTR_ERR (sirf_audio_codec->regmap); + sirf_audio_codec->regmap =dev_get_drvdata (pdev->dev.parent); sirf_audio_codec->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (sirf_audio_codec->clk)) {
sound/soc/sirf/Kconfig +5 -0
@@ -8,6 +8,11 @@ config SND_SOC_SIRF_AUDIO depends on SND_SOC_SIRF select SND_SOC_SIRF_AUDIO_CODEC select SND_SOC_SIRF_AUDIO_PORT + select SND_SOC_SIRF_AUDIO_HUB + +config SND_SOC_SIRF_AUDIO_HUB + depends on SND_SOC_SIRF + tristate config SND_SOC_SIRF_AUDIO_PORT select REGMAP_MMIO
sound/soc/sirf/Makefile +2 -0
@@ -1,5 +1,7 @@ snd-soc-sirf-audio-objs := sirf-audio.o +snd-soc-sirf-audio-hub-objs := sirf-audio-hub.o snd-soc-sirf-audio-port-objs := sirf-audio-port.o obj-$(CONFIG_SND_SOC_SIRF_AUDIO) += snd-soc-sirf-audio.o +obj-$(CONFIG_SND_SOC_SIRF_AUDIO_HUB) += snd-soc-sirf-audio-hub.o obj-$(CONFIG_SND_SOC_SIRF_AUDIO_PORT) += snd-soc-sirf-audio-port.o
sound/soc/sirf/sirf-audio-hub.c new file +66 -0
66 lines not on this page · raw message
sound/soc/sirf/sirf-audio-port.c +1 -25
@@ -127,41 +127,17 @@ static const struct snd_soc_component_driver sirf_audio_port_component = { .name = "sirf-audio-port", }; -static const struct regmap_config sirf_audio_port_regmap_config = { - .reg_bits =32 , - .reg_stride =4 , - .val_bits =32 , - .max_register =AUDIO_PORT_IC_RXFIFO_INT_MSK , - .cache_type =REGCACHE_NONE , -}; -static int sirf_audio_port_probe (struct platform_device *pdev) {int ret;struct sirf_audio_port *port; -void __iomem *base; -struct resource *mem_res; port =devm_kzalloc (&pdev->dev,sizeof (struct sirf_audio_port ),GFP_KERNEL );if (!port)return -ENOMEM ; - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!mem_res) { -dev_err (&pdev->dev,"no mem resource?\n" ); -return -ENODEV ; - } - - base =devm_ioremap (&pdev->dev, mem_res->start, -resource_size (mem_res)); -if (base ==NULL ) -return -ENOMEM ; - - port->regmap =devm_regmap_init_mmio (&pdev->dev, base, - &sirf_audio_port_regmap_config); -if (IS_ERR (port->regmap)) -return PTR_ERR (port->regmap); + port->regmap =dev_get_drvdata (pdev->dev.parent); ret =devm_snd_soc_register_component (&pdev->dev, &sirf_audio_port_component, &sirf_audio_port_dai,1 );
Signature · 1 line
1.7.5.4
Mark Brown
maintainerRe: [PATCH 1/2] ASoC: sirf: Add sirf audio hub driver for sharing same register address space
Quoted 20 lines · RongJun Ying
@@ -283,9 +jc83,10 @@ static int sirf_audio_codec_trigger(struct
snd_pcm_substream*substream,sound/soc/codecs/sirf-audio-codec.c +3
-3int cmd, struct snd_soc_dai *dai) { - int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_soc_codec *codec = dai->codec;u32 val =0 ; +if (substream->stream !=SNDRV_PCM_STREAM_PLAYBACK ) +return 0 ;/* * This is a workaround, When stop playback, @@ -299,15 +300,13 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream,case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (playback) - val =IC_HSLEN |IC_HSREN ; + val =IC_HSLEN |IC_HSREN ;break ;
sound/soc/codecs/sirf-audio-codec.c static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, · line 312
Quoted 10 lines
sound/soc/codecs/sirf-audio-codec.c +1
-2default :return -EINVAL ; } -if (playback) -snd_soc_update_bits (codec,AUDIO_IC_CODEC_CTRL0 , +snd_soc_update_bits (codec,AUDIO_IC_CODEC_CTRL0 ,IC_HSLEN |IC_HSREN , val);return 0 ; }
All the changes in this file appear to be unrelated stylistic changes. They're fine but you should do such things as separate commits, this makes things harder to review.
sound/soc/sirf/sirf-audio-hub.c line 18
Quoted 2 lines
sound/soc/sirf/sirf-audio-hub.c new file +2
-0+/* This regmap is shared all child audio drivers */ +struct regmap *regmap;
Why is this a global variable? I'd expect it to be in the driver data for the device. This is also a global symbol so would at the very least would need better namespacing.
sound/soc/sirf/sirf-audio-hub.c line 24
Quoted 5 lines
sound/soc/sirf/sirf-audio-hub.c new file +5
-0+ +static const struct regmap_config sirf_audio_regmap_config = + .reg_bits = + .val_bits =32 , + .cache_type = REGCACHE_NONE,
None is the default.
Looking at this code I'm not clear how the function devices get instantiated?
PATCH 2/2 Documentation: Describe the SiRF audio hub Device Tree bindings
In reply to RongJun YingFrom: Rongjun Ying <[email protected]>
--- .../devicetree/bindings/sound/sirf-audio-hub.txt | 52 ++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/sirf-audio-hub.txt
Documentation/devicetree/bindings/sound/sirf-audio-hub.txt new file +52 -0
@@ -0,0 +1,52 @@ +SiRF audio hub + +The audio hub is the consist of an internal audio codec, internal +audio port and i2s controller. There are sharing same register +address space. + +Required properties: +- compatible: Must be "sirf,audio-hub" +- reg : The register address of the device +- #address-cells: Must be 1 +- #size-cells: Must be 1 + +Nodes: +Internal audio codec: +- compatible : "sirf,atlas6-audio-codec" or "sirf,prima2-audio-codec" +- clocks: A phandle reference to the SiRF internal audio codec clock + +Internal audio port: +- compatible: "sirf,audio-port" + +I2S controller: +- compatible: "sirf,prima2-i2s" +- clocks: A phandle reference to the SiRF I2S controller clock + +Example: +sirf_audio_hub: audio_hub@b0040000 { + compatible = "sirf,audio-hub"; + reg = <0xb0040000 0x10000>; + #address-cells = <1>; + #size-cells = <1>; + + audiocodec: audiocodec { + compatible = "sirf,atlas6-audio-codec"; + interrupts = <35>; + clocks = <&clks 27>; + }; + + audioport: audioport { + compatible = "sirf,audio-port"; + dmas = <&dmac1 3>, <&dmac1 8>; + dma-names = "rx", "tx"; + }; + + i2s: i2s { + compatible = "sirf,prima2-i2s"; + dmas = <&dmac1 6>, <&dmac1 12>; + dma-names = "rx", "tx"; + clocks = <&clks 27>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s_pins_a>; + }; +};
Signature · 1 line
1.7.5.4
Mark Brown
maintainerRe: [PATCH 2/2] Documentation: Describe the SiRF audio hub Device Tree bindings
Documentation/devicetree/bindings/sound/sirf-audio-hub.txt line 45
Quoted 11 lines · RongJun Ying
Documentation/devicetree/bindings/sound/sirf-audio-hub.txt new file +10
-0+ audiocodec: audiocodec { + compatible = "sirf,atlas6-audio-codec"; + interrupts = <35>; + clocks = <&clks 27>; + }; + + audioport: audioport { + compatible = "sirf,audio-port"; + i2s: i2s { + compatible = "sirf,prima2-i2s";
Given that this is all one single IP block which doesn't really exist independently at the hardware level it shouldn't have separate nodes or compatible strings for the functions at the DT level - that's all to do with how Linux structures things, not about the hardware. As ever DT should represent the hardware, not Linux's abstractions for it.