diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2015-10-26 04:38:26 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-11-16 05:09:29 -0500 |
commit | 232c00b6e55558c216cbf50358549a1967ee1419 (patch) | |
tree | 319673419b3a2aad8e89f73457db56607a7de68b /sound/soc/sh | |
parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) |
ASoC: rsnd: DMA become SSI/SRC member
Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.
Current rsnd_mod is member of rsnd_mod. But the DMA user is only
SSI/SRC. This DMA will be implemented as module. As 1st step, DMA
become SSI/SRC member by this patch.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r-- | sound/soc/sh/rcar/dma.c | 19 | ||||
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 8 | ||||
-rw-r--r-- | sound/soc/sh/rcar/src.c | 19 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssi.c | 16 |
4 files changed, 43 insertions, 19 deletions
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 5d084d040961..923120c7b250 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c | |||
@@ -606,14 +606,17 @@ void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma) | |||
606 | dma->ops->quit(io, dma); | 606 | dma->ops->quit(io, dma); |
607 | } | 607 | } |
608 | 608 | ||
609 | int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id) | 609 | struct rsnd_dma *rsnd_dma_init(struct rsnd_dai_stream *io, |
610 | struct rsnd_mod *mod, int id) | ||
610 | { | 611 | { |
611 | struct rsnd_mod *mod_from = NULL; | 612 | struct rsnd_mod *mod_from = NULL; |
612 | struct rsnd_mod *mod_to = NULL; | 613 | struct rsnd_mod *mod_to = NULL; |
613 | struct rsnd_priv *priv = rsnd_io_to_priv(io); | 614 | struct rsnd_priv *priv = rsnd_io_to_priv(io); |
614 | struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); | 615 | struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); |
616 | struct rsnd_dma *dma; | ||
615 | struct device *dev = rsnd_priv_to_dev(priv); | 617 | struct device *dev = rsnd_priv_to_dev(priv); |
616 | int is_play = rsnd_io_is_play(io); | 618 | int is_play = rsnd_io_is_play(io); |
619 | int ret; | ||
617 | 620 | ||
618 | /* | 621 | /* |
619 | * DMA failed. try to PIO mode | 622 | * DMA failed. try to PIO mode |
@@ -622,7 +625,13 @@ int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id) | |||
622 | * rsnd_rdai_continuance_probe() | 625 | * rsnd_rdai_continuance_probe() |
623 | */ | 626 | */ |
624 | if (!dmac) | 627 | if (!dmac) |
625 | return -EAGAIN; | 628 | return ERR_PTR(-EAGAIN); |
629 | |||
630 | dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); | ||
631 | if (!dma) | ||
632 | return ERR_PTR(-ENOMEM); | ||
633 | |||
634 | dma->mod = mod; | ||
626 | 635 | ||
627 | rsnd_dma_of_path(dma, io, is_play, &mod_from, &mod_to); | 636 | rsnd_dma_of_path(dma, io, is_play, &mod_from, &mod_to); |
628 | 637 | ||
@@ -644,7 +653,11 @@ int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id) | |||
644 | rsnd_mod_name(mod_from), rsnd_mod_id(mod_from), | 653 | rsnd_mod_name(mod_from), rsnd_mod_id(mod_from), |
645 | rsnd_mod_name(mod_to), rsnd_mod_id(mod_to)); | 654 | rsnd_mod_name(mod_to), rsnd_mod_id(mod_to)); |
646 | 655 | ||
647 | return dma->ops->init(io, dma, id, mod_from, mod_to); | 656 | ret = dma->ops->init(io, dma, id, mod_from, mod_to); |
657 | if (ret < 0) | ||
658 | return ERR_PTR(ret); | ||
659 | |||
660 | return dma; | ||
648 | } | 661 | } |
649 | 662 | ||
650 | int rsnd_dma_probe(struct platform_device *pdev, | 663 | int rsnd_dma_probe(struct platform_device *pdev, |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 085329878525..1c08eaa51430 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -206,6 +206,7 @@ struct rsnd_dmapp { | |||
206 | 206 | ||
207 | struct rsnd_dma { | 207 | struct rsnd_dma { |
208 | struct rsnd_dma_ops *ops; | 208 | struct rsnd_dma_ops *ops; |
209 | struct rsnd_mod *mod; | ||
209 | dma_addr_t src_addr; | 210 | dma_addr_t src_addr; |
210 | dma_addr_t dst_addr; | 211 | dma_addr_t dst_addr; |
211 | union { | 212 | union { |
@@ -215,11 +216,12 @@ struct rsnd_dma { | |||
215 | }; | 216 | }; |
216 | #define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en) | 217 | #define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en) |
217 | #define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp) | 218 | #define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp) |
218 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) | 219 | #define rsnd_dma_to_mod(_dma) ((dma)->mod) |
219 | 220 | ||
220 | void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma); | 221 | void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma); |
221 | void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma); | 222 | void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma); |
222 | int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id); | 223 | struct rsnd_dma *rsnd_dma_init(struct rsnd_dai_stream *io, |
224 | struct rsnd_mod *mod, int id); | ||
223 | void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma); | 225 | void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma); |
224 | int rsnd_dma_probe(struct platform_device *pdev, | 226 | int rsnd_dma_probe(struct platform_device *pdev, |
225 | const struct rsnd_of_data *of_data, | 227 | const struct rsnd_of_data *of_data, |
@@ -278,7 +280,6 @@ struct rsnd_mod { | |||
278 | int id; | 280 | int id; |
279 | enum rsnd_mod_type type; | 281 | enum rsnd_mod_type type; |
280 | struct rsnd_mod_ops *ops; | 282 | struct rsnd_mod_ops *ops; |
281 | struct rsnd_dma dma; | ||
282 | struct rsnd_priv *priv; | 283 | struct rsnd_priv *priv; |
283 | struct clk *clk; | 284 | struct clk *clk; |
284 | u32 status; | 285 | u32 status; |
@@ -328,7 +329,6 @@ struct rsnd_mod { | |||
328 | #define __rsnd_mod_call_hw_params 0 | 329 | #define __rsnd_mod_call_hw_params 0 |
329 | 330 | ||
330 | #define rsnd_mod_to_priv(mod) ((mod)->priv) | 331 | #define rsnd_mod_to_priv(mod) ((mod)->priv) |
331 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) | ||
332 | #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) | 332 | #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) |
333 | #define rsnd_mod_power_on(mod) clk_enable((mod)->clk) | 333 | #define rsnd_mod_power_on(mod) clk_enable((mod)->clk) |
334 | #define rsnd_mod_power_off(mod) clk_disable((mod)->clk) | 334 | #define rsnd_mod_power_off(mod) clk_disable((mod)->clk) |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 261b50217c48..3296f1e96d30 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
@@ -22,6 +22,7 @@ | |||
22 | struct rsnd_src { | 22 | struct rsnd_src { |
23 | struct rsnd_src_platform_info *info; /* rcar_snd.h */ | 23 | struct rsnd_src_platform_info *info; /* rcar_snd.h */ |
24 | struct rsnd_mod mod; | 24 | struct rsnd_mod mod; |
25 | struct rsnd_dma *dma; | ||
25 | struct rsnd_kctrl_cfg_s sen; /* sync convert enable */ | 26 | struct rsnd_kctrl_cfg_s sen; /* sync convert enable */ |
26 | struct rsnd_kctrl_cfg_s sync; /* sync convert */ | 27 | struct rsnd_kctrl_cfg_s sync; /* sync convert */ |
27 | u32 convert_rate; /* sampling rate convert */ | 28 | u32 convert_rate; /* sampling rate convert */ |
@@ -30,6 +31,7 @@ struct rsnd_src { | |||
30 | 31 | ||
31 | #define RSND_SRC_NAME_SIZE 16 | 32 | #define RSND_SRC_NAME_SIZE 16 |
32 | 33 | ||
34 | #define rsnd_src_to_dma(src) ((src)->dma) | ||
33 | #define rsnd_src_nr(priv) ((priv)->src_nr) | 35 | #define rsnd_src_nr(priv) ((priv)->src_nr) |
34 | #define rsnd_enable_sync_convert(src) ((src)->sen.val) | 36 | #define rsnd_enable_sync_convert(src) ((src)->sen.val) |
35 | #define rsnd_src_of_node(priv) \ | 37 | #define rsnd_src_of_node(priv) \ |
@@ -839,9 +841,9 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod, | |||
839 | return ret; | 841 | return ret; |
840 | } | 842 | } |
841 | 843 | ||
842 | ret = rsnd_dma_init(io, | 844 | src->dma = rsnd_dma_init(io, mod, src->info->dma_id); |
843 | rsnd_mod_to_dma(mod), | 845 | if (IS_ERR(src->dma)) |
844 | src->info->dma_id); | 846 | return PTR_ERR(src->dma); |
845 | 847 | ||
846 | return ret; | 848 | return ret; |
847 | } | 849 | } |
@@ -850,7 +852,9 @@ static int rsnd_src_remove_gen2(struct rsnd_mod *mod, | |||
850 | struct rsnd_dai_stream *io, | 852 | struct rsnd_dai_stream *io, |
851 | struct rsnd_priv *priv) | 853 | struct rsnd_priv *priv) |
852 | { | 854 | { |
853 | rsnd_dma_quit(io, rsnd_mod_to_dma(mod)); | 855 | struct rsnd_src *src = rsnd_mod_to_src(mod); |
856 | |||
857 | rsnd_dma_quit(io, rsnd_src_to_dma(src)); | ||
854 | 858 | ||
855 | return 0; | 859 | return 0; |
856 | } | 860 | } |
@@ -880,7 +884,9 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod, | |||
880 | struct rsnd_dai_stream *io, | 884 | struct rsnd_dai_stream *io, |
881 | struct rsnd_priv *priv) | 885 | struct rsnd_priv *priv) |
882 | { | 886 | { |
883 | rsnd_dma_start(io, rsnd_mod_to_dma(mod)); | 887 | struct rsnd_src *src = rsnd_mod_to_src(mod); |
888 | |||
889 | rsnd_dma_start(io, rsnd_src_to_dma(src)); | ||
884 | 890 | ||
885 | return _rsnd_src_start_gen2(mod, io); | 891 | return _rsnd_src_start_gen2(mod, io); |
886 | } | 892 | } |
@@ -889,11 +895,12 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod, | |||
889 | struct rsnd_dai_stream *io, | 895 | struct rsnd_dai_stream *io, |
890 | struct rsnd_priv *priv) | 896 | struct rsnd_priv *priv) |
891 | { | 897 | { |
898 | struct rsnd_src *src = rsnd_mod_to_src(mod); | ||
892 | int ret; | 899 | int ret; |
893 | 900 | ||
894 | ret = _rsnd_src_stop_gen2(mod); | 901 | ret = _rsnd_src_stop_gen2(mod); |
895 | 902 | ||
896 | rsnd_dma_stop(io, rsnd_mod_to_dma(mod)); | 903 | rsnd_dma_stop(io, rsnd_src_to_dma(src)); |
897 | 904 | ||
898 | return ret; | 905 | return ret; |
899 | } | 906 | } |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 1427ec21bd7e..eec17bcc89fa 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -63,6 +63,7 @@ struct rsnd_ssi { | |||
63 | struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ | 63 | struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ |
64 | struct rsnd_ssi *parent; | 64 | struct rsnd_ssi *parent; |
65 | struct rsnd_mod mod; | 65 | struct rsnd_mod mod; |
66 | struct rsnd_dma *dma; | ||
66 | 67 | ||
67 | u32 cr_own; | 68 | u32 cr_own; |
68 | u32 cr_clk; | 69 | u32 cr_clk; |
@@ -77,6 +78,7 @@ struct rsnd_ssi { | |||
77 | ((pos) = ((struct rsnd_ssi *)(priv)->ssi + i)); \ | 78 | ((pos) = ((struct rsnd_ssi *)(priv)->ssi + i)); \ |
78 | i++) | 79 | i++) |
79 | 80 | ||
81 | #define rsnd_ssi_to_dma(mod) ((ssi)->dma) | ||
80 | #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) | 82 | #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) |
81 | #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) | 83 | #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) |
82 | #define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0) | 84 | #define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0) |
@@ -537,9 +539,9 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, | |||
537 | if (ret) | 539 | if (ret) |
538 | return ret; | 540 | return ret; |
539 | 541 | ||
540 | ret = rsnd_dma_init( | 542 | ssi->dma = rsnd_dma_init(io, mod, dma_id); |
541 | io, rsnd_mod_to_dma(mod), | 543 | if (IS_ERR(ssi->dma)) |
542 | dma_id); | 544 | return PTR_ERR(ssi->dma); |
543 | 545 | ||
544 | return ret; | 546 | return ret; |
545 | } | 547 | } |
@@ -552,7 +554,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, | |||
552 | struct device *dev = rsnd_priv_to_dev(priv); | 554 | struct device *dev = rsnd_priv_to_dev(priv); |
553 | int irq = ssi->info->irq; | 555 | int irq = ssi->info->irq; |
554 | 556 | ||
555 | rsnd_dma_quit(io, rsnd_mod_to_dma(mod)); | 557 | rsnd_dma_quit(io, rsnd_ssi_to_dma(ssi)); |
556 | 558 | ||
557 | /* PIO will request IRQ again */ | 559 | /* PIO will request IRQ again */ |
558 | devm_free_irq(dev, irq, mod); | 560 | devm_free_irq(dev, irq, mod); |
@@ -585,7 +587,8 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, | |||
585 | struct rsnd_dai_stream *io, | 587 | struct rsnd_dai_stream *io, |
586 | struct rsnd_priv *priv) | 588 | struct rsnd_priv *priv) |
587 | { | 589 | { |
588 | struct rsnd_dma *dma = rsnd_mod_to_dma(mod); | 590 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
591 | struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi); | ||
589 | 592 | ||
590 | rsnd_dma_start(io, dma); | 593 | rsnd_dma_start(io, dma); |
591 | 594 | ||
@@ -598,7 +601,8 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, | |||
598 | struct rsnd_dai_stream *io, | 601 | struct rsnd_dai_stream *io, |
599 | struct rsnd_priv *priv) | 602 | struct rsnd_priv *priv) |
600 | { | 603 | { |
601 | struct rsnd_dma *dma = rsnd_mod_to_dma(mod); | 604 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
605 | struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi); | ||
602 | 606 | ||
603 | rsnd_ssi_stop(mod, io, priv); | 607 | rsnd_ssi_stop(mod, io, priv); |
604 | 608 | ||