OSDN Git Service

ASoC: SOF: Introduce snd_sof_mailbox_read / snd_sof_mailbox_write callbacks
authorDaniel Baluta <daniel.baluta@nxp.com>
Mon, 4 Oct 2021 15:21:44 +0000 (18:21 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 7 Oct 2021 15:57:53 +0000 (16:57 +0100)
We need to introduce snd_sof_mailbox_{read/write} in order to provide
a generic way for mailbox access. These routines are optional, each
platform can implement their own specific routines.

So far, all platforms use mmapped I/O thus they can use custom made
routines sof_mailbox_read / sof_mailbox_write that use MMIO.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Bud Liviu-Alexandru <budliviu@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20211004152147.1268978-2-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/imx/imx8.c
sound/soc/sof/imx/imx8m.c
sound/soc/sof/intel/apl.c
sound/soc/sof/intel/bdw.c
sound/soc/sof/intel/byt.c
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/icl.c
sound/soc/sof/intel/pci-tng.c
sound/soc/sof/intel/tgl.c
sound/soc/sof/ops.h
sound/soc/sof/sof-priv.h

index 080dafb..195297b 100644 (file)
@@ -421,6 +421,10 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* ipc */
        .send_msg       = imx8_send_msg,
        .fw_ready       = sof_fw_ready,
@@ -468,6 +472,10 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* ipc */
        .send_msg       = imx8_send_msg,
        .fw_ready       = sof_fw_ready,
index 7094790..a19f89b 100644 (file)
@@ -284,6 +284,10 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* ipc */
        .send_msg       = imx8m_send_msg,
        .fw_ready       = sof_fw_ready,
index e6a1f65..917f78c 100644 (file)
@@ -42,6 +42,10 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_thread     = hda_dsp_ipc_irq_thread,
 
index d092754..9c06b92 100644 (file)
@@ -616,6 +616,10 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* ipc */
        .send_msg       = bdw_send_msg,
        .fw_ready       = sof_fw_ready,
index 8f60c72..8c500a8 100644 (file)
@@ -226,6 +226,10 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_handler    = atom_irq_handler,
        .irq_thread     = atom_irq_thread,
@@ -304,6 +308,10 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_handler    = atom_irq_handler,
        .irq_thread     = atom_irq_thread,
index 430a268..3957e2b 100644 (file)
@@ -247,6 +247,10 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_thread     = cnl_ipc_irq_thread,
 
index 38a40c0..0b2cc33 100644 (file)
@@ -41,6 +41,10 @@ const struct snd_sof_dsp_ops sof_icl_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_thread     = cnl_ipc_irq_thread,
 
index 3d6d013..8042ac7 100644 (file)
@@ -142,6 +142,10 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_handler    = atom_irq_handler,
        .irq_thread     = atom_irq_thread,
index 664a11a..48da8e7 100644 (file)
@@ -37,6 +37,10 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {
        .block_read     = sof_block_read,
        .block_write    = sof_block_write,
 
+       /* Mailbox IO */
+       .mailbox_read   = sof_mailbox_read,
+       .mailbox_write  = sof_mailbox_write,
+
        /* doorbell */
        .irq_thread     = cnl_ipc_irq_thread,
 
index a93aa5b..1a5cc8a 100644 (file)
@@ -322,6 +322,21 @@ static inline int snd_sof_dsp_block_write(struct snd_sof_dev *sdev,
        return sof_ops(sdev)->block_write(sdev, blk_type, offset, src, bytes);
 }
 
+/* mailbox IO */
+static inline void snd_sof_dsp_mailbox_read(struct snd_sof_dev *sdev,
+                                           u32 offset, void *dest, size_t bytes)
+{
+       if (sof_ops(sdev)->mailbox_read)
+               sof_ops(sdev)->mailbox_read(sdev, offset, dest, bytes);
+}
+
+static inline void snd_sof_dsp_mailbox_write(struct snd_sof_dev *sdev,
+                                            u32 offset, void *src, size_t bytes)
+{
+       if (sof_ops(sdev)->mailbox_write)
+               sof_ops(sdev)->mailbox_write(sdev, offset, src, bytes);
+}
+
 /* ipc */
 static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
                                       struct snd_sof_ipc_msg *msg)
index 4e5bab8..f6a8478 100644 (file)
@@ -151,6 +151,14 @@ struct snd_sof_dsp_ops {
                           enum snd_sof_fw_blk_type type, u32 offset,
                           void *src, size_t size); /* mandatory */
 
+       /* Mailbox IO */
+       void (*mailbox_read)(struct snd_sof_dev *sof_dev,
+                            u32 offset, void *dest,
+                            size_t size); /* optional */
+       void (*mailbox_write)(struct snd_sof_dev *sof_dev,
+                             u32 offset, void *src,
+                             size_t size); /* optional */
+
        /* doorbell */
        irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
        irqreturn_t (*irq_thread)(int irq, void *context); /* optional */