ASoC: rsnd: tidyup for DMA support for DT
Subsystems (5)
cover ASoC: rsnd: tidyup for DMA support for DT
Hi Mark
These patches are tidyup code and fixup for DMA support of DT #1 - #4 are cleanup code patches
#5 - #6 are fixup for DMA for DT
Kuninori Morimoto (6):
ASoC: rsnd: DT node clean up by using the of_node_put()
ASoC: rsnd: save platform_device instead of device
ASoC: rsnd: remove rsnd_src_non_ops
ASoC: rsnd: module name is unified
ASoC: rsnd: care DMA slave channel name for DT
ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr
.../devicetree/bindings/sound/renesas,rsnd.txt | 1 + sound/soc/sh/rcar/core.c | 87 ++++++++++++++++-- sound/soc/sh/rcar/dvc.c | 20 ++++- sound/soc/sh/rcar/gen.c | 95 ++++++++++++++++++++ sound/soc/sh/rcar/rsnd.h | 10 ++- sound/soc/sh/rcar/src.c | 50 +++++++---- sound/soc/sh/rcar/ssi.c | 28 ++++-- 7 files changed, 260 insertions(+), 31 deletions(-)
Kuninori Morimoto
maintainerPATCH 1/6 ASoC: rsnd: DT node clean up by using the of_node_put()
Driver needs to call of_node_put() after of_get_chile_by_name()
--- sound/soc/sh/rcar/src.c | 7 +++++-- sound/soc/sh/rcar/ssi.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
sound/soc/sh/rcar/src.c +5 -2
@@ -598,18 +598,21 @@ static void rsnd_of_parse_src(struct platform_device *pdev, nr =of_get_child_count (src_node);if (!nr) -return ; + goto rsnd_of_parse_src_end; src_info =devm_kzalloc (dev,sizeof (struct rsnd_src_platform_info ) * nr,GFP_KERNEL );if (!src_info) {dev_err (dev,"src info allocation error\n" ); -return ; + goto rsnd_of_parse_src_end; } info->src_info = src_info; info->src_info_nr = nr; + +rsnd_of_parse_src_end: +of_node_put (src_node); } int rsnd_src_probe(struct platform_device *pdev,
sound/soc/sh/rcar/ssi.c +5 -2
@@ -554,14 +554,14 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev, nr =of_get_child_count (node);if (!nr) -return ; + goto rsnd_of_parse_ssi_end; ssi_info =devm_kzalloc (dev,sizeof (struct rsnd_ssi_platform_info ) * nr,GFP_KERNEL );if (!ssi_info) {dev_err (dev,"ssi info allocation error\n" ); -return ; + goto rsnd_of_parse_ssi_end; } info->ssi_info = ssi_info;
@@ -584,6 +584,9 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,*/ ssi_info->pio_irq =irq_of_parse_and_map (np,0 ); } + +rsnd_of_parse_ssi_end: +of_node_put (node); } int rsnd_ssi_probe(struct platform_device *pdev,
Signature · 1 line
1.7.9.5
Kuninori Morimoto
maintainerPATCH 2/6 ASoC: rsnd: save platform_device instead of device
In reply to Kuninori MorimotoDT DMA support needs struct platform_device pointer, and it can get struct device pointer from platform_device. Save platform_device instead of device.
--- sound/soc/sh/rcar/core.c | 2 +- sound/soc/sh/rcar/rsnd.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
sound/soc/sh/rcar/core.c +1 -1
@@ -957,7 +957,7 @@ static int rsnd_probe(struct platform_device *pdev)return -ENODEV ; } - priv->dev = dev; + priv->pdev = pdev; priv->info = info;spin_lock_init (&priv->lock);
sound/soc/sh/rcar/rsnd.h +3 -2
@@ -317,7 +317,7 @@ struct rsnd_of_data {struct rsnd_priv { -struct device *dev; +struct platform_device *pdev;struct rcar_snd_info *info;spinlock_t lock;
@@ -357,7 +357,8 @@ struct rsnd_priv {int rdai_nr; }; -#define rsnd_priv_to_dev (priv) ((priv)->dev) +#define rsnd_priv_to_pdev (priv) ((priv)->pdev) +#define rsnd_priv_to_dev (priv) (&(rsnd_priv_to_pdev(priv)->dev))#define rsnd_priv_to_info (priv) ((priv)->info)#define rsnd_lock (priv, flags) spin_lock_irqsave(&priv->lock, flags)#define rsnd_unlock (priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
Signature · 1 line
1.7.9.5
Kuninori Morimoto
maintainerPATCH 3/6 ASoC: rsnd: remove rsnd_src_non_ops
In reply to Kuninori MorimotoRenesas sound driver is supporting Gen1/Gen2.
SRC probe can return error if it was unknown
generation.
Now, rsnd_src_non_ops is not needed.
--- sound/soc/sh/rcar/src.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/soc/sh/rcar/src.c +10 -10
@@ -268,10 +268,6 @@ static int rsnd_src_stop(struct rsnd_mod *mod,return 0 ; } -static struct rsnd_mod_ops rsnd_src_non_ops = { - .name ="src (non)" , -}; -/* * Gen1 functions */
@@ -627,6 +623,16 @@ int rsnd_src_probe(struct platform_device *pdev,char name[RSND_SRC_NAME_SIZE ];int i, nr; + ops =NULL ; +if (rsnd_is_gen1 (priv)) + ops = &rsnd_src_gen1_ops; +if (rsnd_is_gen2 (priv)) + ops = &rsnd_src_gen2_ops; +if (!ops) { +dev_err (dev,"unknown Generation\n" ); +return -EIO ; + } +rsnd_of_parse_src (pdev, of_data, priv);/*
@@ -655,12 +661,6 @@ int rsnd_src_probe(struct platform_device *pdev, src->info = &info->src_info[i]; src->clk = clk; - ops = &rsnd_src_non_ops; -if (rsnd_is_gen1 (priv)) - ops = &rsnd_src_gen1_ops; -if (rsnd_is_gen2 (priv)) - ops = &rsnd_src_gen2_ops; -rsnd_mod_init (priv, &src->mod, ops,RSND_MOD_SRC , i);dev_dbg (dev,"SRC%d probed\n" , i);
Signature · 1 line
1.7.9.5
Kuninori Morimoto
maintainerPATCH 4/6 ASoC: rsnd: module name is unified
In reply to Kuninori MorimotoRenesas sound driver uses many modules (= SSI/SRC/DVC), and each module had own name.
But, each module name can be used as several purpose, like clock name, DMA name etc...
This patch uses common name for each module.
--- sound/soc/sh/rcar/dvc.c | 20 ++++++++++++++++++-- sound/soc/sh/rcar/src.c | 23 ++++++++++++++++++++--- sound/soc/sh/rcar/ssi.c | 15 +++++++++++---- 3 files changed, 49 insertions(+), 9 deletions(-)
sound/soc/sh/rcar/dvc.c +18 -2
@@ -13,6 +13,9 @@#define RSND_DVC_NAME_SIZE 16#define RSND_DVC_VOLUME_MAX 100#define RSND_DVC_VOLUME_NUM 2 + +#define DVC_NAME "dvc" +struct rsnd_dvc {struct rsnd_dvc_platform_info *info;/* rcar_snd.h */ struct rsnd_mod mod;
@@ -43,6 +46,17 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)rsnd_mod_write (mod,DVC_VOL1R , vol[1 ]); } +static int rsnd_dvc_probe_gen2 (struct rsnd_mod *mod, +struct rsnd_dai *rdai) +{ +struct rsnd_priv *priv =rsnd_mod_to_priv (mod); +struct device *dev =rsnd_priv_to_dev (priv); + +dev_dbg (dev,"%s (Gen2) is probed\n" ,rsnd_mod_name (mod)); + +return 0 ; +} +static int rsnd_dvc_init (struct rsnd_mod *dvc_mod,struct rsnd_dai *rdai) {
@@ -208,7 +222,8 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, }static struct rsnd_mod_ops rsnd_dvc_ops = { - .name ="dvc (gen2)" , + .name =DVC_NAME , + .probe = rsnd_dvc_probe_gen2, .init = rsnd_dvc_init, .quit = rsnd_dvc_quit, .start = rsnd_dvc_start,
@@ -255,7 +270,8 @@ int rsnd_dvc_probe(struct platform_device *pdev, priv->dvc = dvc;for_each_rsnd_dvc (dvc, priv, i) { -snprintf (name,RSND_DVC_NAME_SIZE ,"dvc.%d" , i); +snprintf (name,RSND_DVC_NAME_SIZE ,"%s.%d" , +DVC_NAME , i); clk =devm_clk_get (dev, name);if (IS_ERR (clk))
sound/soc/sh/rcar/src.c +20 -3
@@ -10,6 +10,8 @@*/ #include "rsnd.h" +#define SRC_NAME "src" +struct rsnd_src {struct rsnd_src_platform_info *info;/* rcar_snd.h */ struct rsnd_mod mod;
@@ -389,6 +391,17 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod,return 0 ; } +static int rsnd_src_probe_gen1 (struct rsnd_mod *mod, +struct rsnd_dai *rdai) +{ +struct rsnd_priv *priv =rsnd_mod_to_priv (mod); +struct device *dev =rsnd_priv_to_dev (priv); + +dev_dbg (dev,"%s (Gen1) is probed\n" ,rsnd_mod_name (mod)); + +return 0 ; +} +static int rsnd_src_init_gen1 (struct rsnd_mod *mod,struct rsnd_dai *rdai) {
@@ -434,7 +447,8 @@ static int rsnd_src_stop_gen1(struct rsnd_mod *mod, }static struct rsnd_mod_ops rsnd_src_gen1_ops = { - .name ="sru (gen1)" , + .name =SRC_NAME , + .probe = rsnd_src_probe_gen1, .init = rsnd_src_init_gen1, .quit = rsnd_src_quit, .start = rsnd_src_start_gen1,
@@ -498,6 +512,8 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod,if (ret <0 )dev_err (dev,"SRC DMA failed\n" ); +dev_dbg (dev,"%s (Gen2) is probed\n" ,rsnd_mod_name (mod)); +return ret; }
@@ -558,7 +574,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod, }static struct rsnd_mod_ops rsnd_src_gen2_ops = { - .name ="src (gen2)" , + .name =SRC_NAME , .probe = rsnd_src_probe_gen2, .remove = rsnd_src_remove_gen2, .init = rsnd_src_init_gen2,
@@ -652,7 +668,8 @@ int rsnd_src_probe(struct platform_device *pdev, priv->src = src;for_each_rsnd_src (src, priv, i) { -snprintf (name,RSND_SRC_NAME_SIZE ,"src.%d" , i); +snprintf (name,RSND_SRC_NAME_SIZE ,"%s.%d" , +SRC_NAME , i); clk =devm_clk_get (dev, name);if (IS_ERR (clk))
sound/soc/sh/rcar/ssi.c +11 -4
@@ -57,6 +57,8 @@*/ #define CONT (1 << 8)/* WS Continue Function */ +#define SSI_NAME "ssi" +struct rsnd_ssi {struct clk *clk;struct rsnd_ssi_platform_info *info;/* rcar_snd.h */
@@ -373,6 +375,8 @@ static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,if (ret)dev_err (dev,"SSI request interrupt failed\n" ); +dev_dbg (dev,"%s (PIO) is probed\n" ,rsnd_mod_name (mod)); +return ret; }
@@ -405,7 +409,7 @@ static int rsnd_ssi_pio_stop(struct rsnd_mod *mod, }static struct rsnd_mod_ops rsnd_ssi_pio_ops = { - .name ="ssi (pio)" , + .name =SSI_NAME , .probe = rsnd_ssi_pio_probe, .init = rsnd_ssi_init, .quit = rsnd_ssi_quit,
@@ -430,6 +434,8 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,if (ret <0 )dev_err (dev,"SSI DMA failed\n" ); +dev_dbg (dev,"%s (DMA) is probed\n" ,rsnd_mod_name (mod)); +return ret; }
@@ -480,7 +486,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, }static struct rsnd_mod_ops rsnd_ssi_dma_ops = { - .name ="ssi (dma)" , + .name =SSI_NAME , .probe = rsnd_ssi_dma_probe, .remove = rsnd_ssi_dma_remove, .init = rsnd_ssi_init,
@@ -493,7 +499,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = {* Non SSI */ static struct rsnd_mod_ops rsnd_ssi_non_ops = { - .name ="ssi (non)" , + .name =SSI_NAME , };/*
@@ -620,7 +626,8 @@ int rsnd_ssi_probe(struct platform_device *pdev,for_each_rsnd_ssi (ssi, priv, i) { pinfo = &info->ssi_info[i]; -snprintf (name,RSND_SSI_NAME_SIZE ,"ssi.%d" , i); +snprintf (name,RSND_SSI_NAME_SIZE ,"%s.%d" , +SSI_NAME , i); clk =devm_clk_get (dev, name);if (IS_ERR (clk))
Signature · 1 line
1.7.9.5
Kuninori Morimoto
maintainerPATCH 5/6 ASoC: rsnd: care DMA slave channel name for DT
In reply to Kuninori MorimotoRenesas sound driver is supporting to use DMAEngine. But, DMA slave channel name "tx", "rx" is not enough in DT case.
Becuase, it has many ports and path combination.
This patch adds rsnd_dma_of_name() to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",
SSI0 to SRC0 is "ssi0_src0", SRC0 to SSI0 is "src0_ssi0", SRC0 to DVC0 is "src0_dvc0"...
Renesas sound want to use PIO transfer mode for some reasons. It will be PIO tranfer mode if device node doesn't have DMA settings.
--- .../devicetree/bindings/sound/renesas,rsnd.txt | 1 + sound/soc/sh/rcar/core.c | 80 +++++++++++++++++++- sound/soc/sh/rcar/ssi.c | 6 ++ 3 files changed, 86 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/renesas,rsnd.txt +1 -0
@@ -20,6 +20,7 @@ Required properties: SSI subnode properties: - interrupts : Should contain SSI interrupt for PIO transfer - shared-pin : if shared clock pin +- pio-transfer : use PIO transfer mode SRC subnode properties: no properties at this point
sound/soc/sh/rcar/core.c +79 -1
99 lines not on this page · raw message
sound/soc/sh/rcar/ssi.c +6 -0
@@ -589,6 +589,12 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,* irq */ ssi_info->pio_irq =irq_of_parse_and_map (np,0 ); + +/* +* DMA +*/ + ssi_info->dma_id =of_get_property (np,"pio-transfer" ,NULL ) ? +0 :1 ; } rsnd_of_parse_ssi_end:
Signature · 1 line
1.7.9.5
Re: [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT
Quoted 5 lines · Kuninori Morimoto
Renesas sound driver is supporting to use DMAEngine. But, DMA slave channel name "tx", "rx" is not enough in DT case.
Becuase, it has many ports and path combination.
Quoted 7 lines
This patch adds
rsnd_dma_of_name()to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",SSI0 to SRC0 is "ssi0_src0", SRC0 to SSI0 is "src0_ssi0", SRC0 to DVC0 is "src0_dvc0"...
I commented on another patch where the ssiX nodes are not being used, this would be so much nicer if we removed the ssiX from the name and used the of-pointer for the ssiX node to lookup the DMA...
This is going to produce a hugh list of DMA entries that are going to be difficult to manage.
Quoted 29 lines
Renesas sound want to use PIO transfer mode for some reasons. It will be PIO tranfer mode if device node doesn't have DMA settings.
Signed-off-by Kuninori Morimoto <[email protected]>--- .../devicetree/bindings/sound/renesas,rsnd.txt | 1 + sound/soc/sh/rcar/core.c | 80 +++++++++++++++++++- sound/soc/sh/rcar/ssi.c | 6 ++ 3 files changed, 86 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/sound/renesas,rsnd.txt +1
-0@@ -20,6 +20,7 @@ Required properties: SSI subnode properties: - interrupts : Should contain SSI interrupt for PIO transfer - shared-pin : if shared clock pin +- pio-transfer : use PIO transfer mode SRC subnode properties: no properties at this poinsound/soc/sh/rcar/ssi.c +0
-0
sound/soc/sh/rcar/ssi.c static void rsnd_of_parse_ssi(struct platform_device *pdev, · line 597
Quoted 9 lines
sound/soc/sh/rcar/ssi.c +6
-0@@ -589,6 +589,12 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,* irq */ ssi_info->pio_irq =irq_of_parse_and_map (np,0 ); + +/* +* DMA +*/ + ssi_info->dma_id =of_get_property (np,"pio-transfer" ,NULL ) ? +0 :1 ;
How about checking for the dma node, and if no present?
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius
Kuninori Morimoto
maintainerRe: [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT
Hi Ben
Quoted 13 lines
Quoted 5 lines
Renesas sound driver is supporting to use DMAEngine. But, DMA slave channel name "tx", "rx" is not enough in DT case.
Becuase, it has many ports and path combination.Quoted 7 lines
This patch adds
rsnd_dma_of_name()to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",SSI0 to SRC0 is "ssi0_src0", SRC0 to SSI0 is "src0_ssi0", SRC0 to DVC0 is "src0_dvc0"...
Quoted 6 lines
I commented on another patch where the ssiX nodes are not being used, this would be so much nicer if we removed the ssiX from the name and used the of-pointer for the ssiX node to lookup the DMA...
This is going to produce a hugh list of DMA entries that are going to be difficult to manage.
Thank you for your comment.
I understand your opinion.
But, I don't want to use such style for DMA IMO.
You know R-Car sound is very complex IP collection. And user want to use it as several patterns. If SSI nodes has its specific DMA setting, this means SRC/DVC needs to have same style too.
The DMA entry for SSI/SRC/DVC depends on data path. This means, user *must* understand which IP can use which DMA. (You know, R-Car sound uses Audio DMAC/Audio DMAC peri peri,
and the pattern/use case is very complex)
And, user must care his DAI too.
If user failed his settings (= DAI and DMA entry for SSI/SRC/DVC), someone (maybe me) needs to explain how R-Car sound is complex. Then ask his DAI settings, research DMA settings, and answer. This will happen for all user/integrater.
But, I don't want it :P
* all settings must be correct *
* but, it is difficult for user/beginner *
playback = <&ssi0 &src1 &dvc0>;
&ssi0 { dmas = <xxx>, dma-names = xxx };
&src1 { dmas = <xxx>, dma-names = xxx };
&dvc0 { dmas = <xxx>, dma-names = xxx };Indeed above case needs many DMA entries on SoC DTSI file, but, DMA entry for SSI/SRC/DVC will be decided automatically. This case, user cares DAI only, it is very easy IMO.
* user care only his DAI setting *
playback = <&ssi0 &src1 &dvc0>;
* it is very easy to exchange DAI setting *
playback = <&ssi0 &src3>;
Kuninori Morimoto
maintainerPATCH 6/6 ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr
In reply to Kuninori MorimotoThe DMAC src/dst addr needs to be set from driver when DT case. (It was set from SoC/DMAEngine code when non-DT case) This patch adds rsnd_gen_dma_addr() to set DMAC src/dst addr.
--- sound/soc/sh/rcar/core.c | 5 +-- sound/soc/sh/rcar/gen.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/rcar/rsnd.h | 5 +++ 3 files changed, 101 insertions(+), 4 deletions(-)
sound/soc/sh/rcar/core.c +1 -4
@@ -358,10 +358,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,return -EIO ; } - cfg.slave_id = id; - cfg.dst_addr =0 ;/* use default addr when playback */ - cfg.src_addr =0 ;/* use default addr when capture */ - cfg.direction = is_play ?DMA_MEM_TO_DEV :DMA_DEV_TO_MEM ; +rsnd_gen_dma_addr (priv, dma, &cfg, is_play, id); ret =dmaengine_slave_config (dma->chan, &cfg);if (ret <0 )
sound/soc/sh/rcar/gen.c +95 -0
101 lines not on this page · raw message
sound/soc/sh/rcar/rsnd.h +5 -0
@@ -281,6 +281,11 @@ int rsnd_gen_probe(struct platform_device *pdev,void __iomem *rsnd_gen_reg_get (struct rsnd_priv *priv,struct rsnd_mod *mod,enum rsnd_reg reg); +void rsnd_gen_dma_addr (struct rsnd_priv *priv, +struct rsnd_dma *dma, +struct dma_slave_config *cfg, +int is_play,int slave_id); +#define rsnd_is_gen1 (s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1)#define rsnd_is_gen2 (s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2)
Signature · 1 line
1.7.9.5
Quoted 6 lines · Kuninori Morimoto
Hi Mark
These patches are tidyup code and fixup for DMA support of DT #1 - #4 are cleanup code patches
#5 - #6 are fixup for DMA for DT
Applied all, thanks.