]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
ASoC: SOF: Intel: hda: define parse_platform_ext_manifest op
authorFred Oh <fred.oh@linux.intel.com>
Fri, 27 Nov 2020 16:40:19 +0000 (18:40 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 27 Nov 2020 17:23:04 +0000 (17:23 +0000)
Define the parse_platform_ext_manifest() op for HDA platforms to parse
the SOF_EXT_MAN_CAVS_CONFIG_CAVS_LPRO config item to determine if the FW
is configured for LPRO. The default clock configuration is assumed to be
HPRO in the absence of this item in the extended manifest.
New member clk_config_lpro is added to struct sof_intel_hda_dev to store
the FW clock config information and that this will be used later to perform
platform-specific operations in the post_fw_run op.

Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20201127164022.2498406-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/apl.c
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/ext_manifest.h [new file with mode: 0644]
sound/soc/sof/intel/hda-loader.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/tgl.c

index 4eeade2e77f7f7587a0fc0591b184d13ad568c06..fc29b91b8932bd77252e7961f492ad4efe8c3896 100644 (file)
@@ -92,6 +92,9 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
        .pre_fw_run = hda_dsp_pre_fw_run,
        .post_fw_run = hda_dsp_post_fw_run,
 
+       /* parse platform specific extended manifest */
+       .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data,
+
        /* dsp core power up/down */
        .core_power_up = hda_dsp_enable_core,
        .core_power_down = hda_dsp_core_reset_power_down,
index a5d3258104c08dd7590aeceb13ed0e754a4c92c4..158c38743731ed9fc7d964225ab5721ba1f9700f 100644 (file)
@@ -294,6 +294,9 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
        .pre_fw_run = hda_dsp_pre_fw_run,
        .post_fw_run = hda_dsp_post_fw_run,
 
+       /* parse platform specific extended manifest */
+       .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data,
+
        /* dsp core power up/down */
        .core_power_up = hda_dsp_enable_core,
        .core_power_down = hda_dsp_core_reset_power_down,
diff --git a/sound/soc/sof/intel/ext_manifest.h b/sound/soc/sof/intel/ext_manifest.h
new file mode 100644 (file)
index 0000000..a30e25b
--- /dev/null
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * Copyright(c) 2020 Intel Corporation. All rights reserved.
+ */
+
+/*
+ * Intel extended manifest is a extra place to store Intel cavs specific
+ * metadata about firmware, for example LPRO/HPRO configuration is
+ * Intel cavs specific. This part of output binary is not signed.
+ */
+
+#ifndef __INTEL_CAVS_EXT_MANIFEST_H__
+#define __INTEL_CAVS_EXT_MANIFEST_H__
+
+#include <sound/sof/ext_manifest.h>
+
+/* EXT_MAN_ELEM_PLATFORM_CONFIG_DATA elements identificators */
+enum sof_cavs_config_elem_type {
+       SOF_EXT_MAN_CAVS_CONFIG_EMPTY           = 0,
+       SOF_EXT_MAN_CAVS_CONFIG_CAVS_LPRO       = 1,
+};
+
+/* EXT_MAN_ELEM_PLATFORM_CONFIG_DATA elements */
+struct sof_ext_man_cavs_config_data {
+       struct sof_ext_man_elem_header hdr;
+
+       struct sof_config_elem elems[];
+} __packed;
+
+#endif /* __INTEL_CAVS_EXT_MANIFEST_H__ */
index 2707a16c6a4d3db863fe6d322f705f468fdde48d..73806223abd158c494fb36feceb4eb76e9f52b13 100644 (file)
@@ -19,6 +19,7 @@
 #include <sound/hdaudio_ext.h>
 #include <sound/hda_register.h>
 #include <sound/sof.h>
+#include "ext_manifest.h"
 #include "../ops.h"
 #include "hda.h"
 
@@ -470,3 +471,37 @@ int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
        /* re-enable clock gating and power gating */
        return hda_dsp_ctrl_clock_power_gating(sdev, true);
 }
+
+int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
+                                        const struct sof_ext_man_elem_header *hdr)
+{
+       const struct sof_ext_man_cavs_config_data *config_data =
+               container_of(hdr, struct sof_ext_man_cavs_config_data, hdr);
+       struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
+       int i, elem_num;
+
+       /* calculate total number of config data elements */
+       elem_num = (hdr->size - sizeof(struct sof_ext_man_elem_header))
+                  / sizeof(struct sof_config_elem);
+       if (elem_num <= 0) {
+               dev_err(sdev->dev, "cavs config data is inconsistent: %d\n", elem_num);
+               return -EINVAL;
+       }
+
+       for (i = 0; i < elem_num; i++)
+               switch (config_data->elems[i].token) {
+               case SOF_EXT_MAN_CAVS_CONFIG_EMPTY:
+                       /* skip empty token */
+                       break;
+               case SOF_EXT_MAN_CAVS_CONFIG_CAVS_LPRO:
+                       hda->clk_config_lpro = config_data->elems[i].value;
+                       dev_dbg(sdev->dev, "FW clock config: %s\n",
+                               hda->clk_config_lpro ? "LPRO" : "HPRO");
+                       break;
+               default:
+                       dev_warn(sdev->dev, "unsupported token type: %d\n",
+                                config_data->elems[i].token);
+               }
+
+       return 0;
+}
index 75954e642c5ee6731a56a9282166c37d4f07b707..d1df579e52aaae61caf18e83be0e4096027a3c82 100644 (file)
@@ -447,6 +447,9 @@ struct sof_intel_hda_dev {
 
        /* sdw context allocated by SoundWire driver */
        struct sdw_intel_ctx *sdw;
+
+       /* FW clock config, 0:HPRO, 1:LPRO */
+       bool clk_config_lpro;
 };
 
 static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
@@ -618,6 +621,10 @@ int hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev);
 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
 
+/* parse platform specific ext manifest ops */
+int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
+                                        const struct sof_ext_man_elem_header *hdr);
+
 /*
  * HDA Controller Operations.
  */
index bdcc66d0df78e818cebc2af7d0c81ca4aee191c0..2252ca38ff4bfc1d5fb1e5784fa2129284a4ecc8 100644 (file)
@@ -84,6 +84,9 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {
        .pre_fw_run = hda_dsp_pre_fw_run,
        .post_fw_run = hda_dsp_post_fw_run,
 
+       /* parse platform specific extended manifest */
+       .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data,
+
        /* dsp core power up/down */
        .core_power_up = hda_dsp_enable_core,
        .core_power_down = hda_dsp_core_reset_power_down,