ASoC: SOF: Introduce snd_sof_dsp_get_bar_index ops
authorDaniel Baluta <daniel.baluta@nxp.com>
Mon, 22 Jul 2019 14:13:47 +0000 (09:13 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 23 Jul 2019 11:19:29 +0000 (12:19 +0100)
FW encapsulates information about section types (e.g DRAM, IRAM)
inside module block header. This information can be used in order
to correctly load the section to the appropriate place in memory.

SOF Linux driver needs to know for each platform how to map the
section type with the corresponding memory BAR. So, this patch
introduces get_bar_index, a new operation inside snd_sof_dsp_ops.

Intel platforms, usually load all the section in a contiguous memory
area (usually denoted by sdev->mmio_bar) so things are relatively
simple there. Anyhow, on i.MX8 IRAM and DRAM for example are mapped
to distinct BARs.

By default, if no get_bar function is provided the core implementation
will always return sdev->mmio_bar so that there will be no need for
a change to existing Intel code.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190722141402.7194-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ops.h
sound/soc/sof/sof-priv.h

index b1c27615b805b3ea12cd98a795a373f1a6e3bb59..8fda42748f3930e5f47e7cb82b912d539dc024fc 100644 (file)
@@ -100,6 +100,25 @@ static inline int snd_sof_dsp_post_fw_run(struct snd_sof_dev *sdev)
        return 0;
 }
 
+/* misc */
+
+/**
+ * snd_sof_dsp_get_bar_index - Maps a section type with a BAR index
+ *
+ * @sdev: sof device
+ * @type: section type as described by snd_sof_fw_blk_type
+ *
+ * Returns the corresponding BAR index (a positive integer) or -EINVAL
+ * in case there is no mapping
+ */
+static inline int snd_sof_dsp_get_bar_index(struct snd_sof_dev *sdev, u32 type)
+{
+       if (sof_ops(sdev)->get_bar_index)
+               return sof_ops(sdev)->get_bar_index(sdev, type);
+
+       return sdev->mmio_bar;
+}
+
 /* power management */
 static inline int snd_sof_dsp_resume(struct snd_sof_dev *sdev)
 {
index fa5cb7d2a660244e7adab5beb4aa001a4bbfc0f1..a6ec9115a9fb275cea4c91bb88bb4c219b25269c 100644 (file)
@@ -196,6 +196,9 @@ struct snd_sof_dsp_ops {
        int (*trace_trigger)(struct snd_sof_dev *sdev,
                             int cmd); /* optional */
 
+       /* misc */
+       int (*get_bar_index)(struct snd_sof_dev *sdev,
+                            u32 type); /* optional */
        /* DAI ops */
        struct snd_soc_dai_driver *drv;
        int num_drv;