]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoc: rsnd: dma: Calculate dma address with consider of BUSIF
authorJiada Wang <jiada_wang@mentor.com>
Mon, 3 Sep 2018 07:07:43 +0000 (07:07 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 3 Sep 2018 13:37:17 +0000 (14:37 +0100)
DMA address calculated by rsnd_dma_addr() only considers BUSIF0 so far.
But BUSIF1 ~ BUSIF7 also maybe used, in the future.

This patch updates DMA address calculations, to also consider
BUSIF number used by SSI.

One note is that we can't support SSI9-4/5/6/7 so far,
because its address is out of calculation rule.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[kuninori: adjust to upstreaming]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/dma.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/ssi.c

index fe63ef8600d02f259743a8339ce7059ea2b1be25..73f743ea3d08fe6d2256a84197146c51a4b4cf70 100644 (file)
@@ -487,11 +487,11 @@ static struct rsnd_mod_ops rsnd_dmapp_ops = {
 #define RDMA_SSI_I_N(addr, i)  (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
 #define RDMA_SSI_O_N(addr, i)  (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
 
-#define RDMA_SSIU_I_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
-#define RDMA_SSIU_O_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
+#define RDMA_SSIU_I_N(addr, i, j) (addr ##_reg - 0x00441000 + (0x1000 * (i)) + (((j) / 4) * 0xA000) + (((j) % 4) * 0x400))
+#define RDMA_SSIU_O_N(addr, i, j) RDMA_SSIU_I_N(addr, i, j)
 
-#define RDMA_SSIU_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
-#define RDMA_SSIU_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
+#define RDMA_SSIU_I_P(addr, i, j) (addr ##_reg - 0x00141000 + (0x1000 * (i)) + (((j) / 4) * 0xA000) + (((j) % 4) * 0x400))
+#define RDMA_SSIU_O_P(addr, i, j) RDMA_SSIU_I_P(addr, i, j)
 
 #define RDMA_SRC_I_N(addr, i)  (addr ##_reg - 0x00500000 + (0x400 * i))
 #define RDMA_SRC_O_N(addr, i)  (addr ##_reg - 0x004fc000 + (0x400 * i))
@@ -517,6 +517,7 @@ rsnd_gen2_dma_addr(struct rsnd_dai_stream *io,
                      !!rsnd_io_to_mod_mix(io) ||
                      !!rsnd_io_to_mod_ctu(io);
        int id = rsnd_mod_id(mod);
+       int busif = rsnd_ssi_get_busif(io);
        struct dma_addr {
                dma_addr_t out_addr;
                dma_addr_t in_addr;
@@ -533,25 +534,35 @@ rsnd_gen2_dma_addr(struct rsnd_dai_stream *io,
                },
                /* SSI */
                /* Capture */
-               {{{ RDMA_SSI_O_N(ssi, id),      0 },
-                 { RDMA_SSIU_O_P(ssi, id),     0 },
-                 { RDMA_SSIU_O_P(ssi, id),     0 } },
+               {{{ RDMA_SSI_O_N(ssi, id),              0 },
+                 { RDMA_SSIU_O_P(ssi, id, busif),      0 },
+                 { RDMA_SSIU_O_P(ssi, id, busif),      0 } },
                 /* Playback */
-                {{ 0,                          RDMA_SSI_I_N(ssi, id) },
-                 { 0,                          RDMA_SSIU_I_P(ssi, id) },
-                 { 0,                          RDMA_SSIU_I_P(ssi, id) } }
+                {{ 0,                  RDMA_SSI_I_N(ssi, id) },
+                 { 0,                  RDMA_SSIU_I_P(ssi, id, busif) },
+                 { 0,                  RDMA_SSIU_I_P(ssi, id, busif) } }
                },
                /* SSIU */
                /* Capture */
-               {{{ RDMA_SSIU_O_N(ssi, id),     0 },
-                 { RDMA_SSIU_O_P(ssi, id),     0 },
-                 { RDMA_SSIU_O_P(ssi, id),     0 } },
+               {{{ RDMA_SSIU_O_N(ssi, id, busif),      0 },
+                 { RDMA_SSIU_O_P(ssi, id, busif),      0 },
+                 { RDMA_SSIU_O_P(ssi, id, busif),      0 } },
                 /* Playback */
-                {{ 0,                          RDMA_SSIU_I_N(ssi, id) },
-                 { 0,                          RDMA_SSIU_I_P(ssi, id) },
-                 { 0,                          RDMA_SSIU_I_P(ssi, id) } } },
+                {{ 0,                  RDMA_SSIU_I_N(ssi, id, busif) },
+                 { 0,                  RDMA_SSIU_I_P(ssi, id, busif) },
+                 { 0,                  RDMA_SSIU_I_P(ssi, id, busif) } } },
        };
 
+       /*
+        * FIXME
+        *
+        * We can't support SSI9-4/5/6/7, because its address is
+        * out of calculation rule
+        */
+       if ((id == 9) && (busif >= 4))
+               dev_err(dev, "This driver doesn't support SSI%d-%d, so far",
+                       id, busif);
+
        /* it shouldn't happen */
        if (use_cmd && !use_src)
                dev_err(dev, "DVC is selected without SRC\n");
index 20e6a2ebebed8ad52e5747da4468a05721503bf5..cb27a679dc65eec3a4531a03a14d5839ff45030d 100644 (file)
@@ -692,6 +692,7 @@ void rsnd_ssi_remove(struct rsnd_priv *priv);
 struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
 int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod);
 int rsnd_ssi_use_busif(struct rsnd_dai_stream *io);
+int rsnd_ssi_get_busif(struct rsnd_dai_stream *io);
 u32 rsnd_ssi_multi_slaves_runtime(struct rsnd_dai_stream *io);
 
 #define RSND_SSI_HDMI_PORT0    0xf0
index 3f6dd9f07bc64b88716d06e4ec8df7498edfb49a..85da4fc82011ca2de2ff39ec55db46a0c388bfb7 100644 (file)
@@ -150,6 +150,11 @@ int rsnd_ssi_use_busif(struct rsnd_dai_stream *io)
        return use_busif;
 }
 
+int rsnd_ssi_get_busif(struct rsnd_dai_stream *io)
+{
+       return 0; /* BUSIF0 only for now */
+}
+
 static void rsnd_ssi_status_clear(struct rsnd_mod *mod)
 {
        rsnd_mod_write(mod, SSISR, 0);