ASoC: SOF: amd: Enable signed firmware image loading for Vangogh platform
authorVenkata Prasad Potturu <venkataprasad.potturu@amd.com>
Wed, 9 Aug 2023 12:35:22 +0000 (18:05 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 21 Aug 2023 15:05:49 +0000 (16:05 +0100)
Enable signed firmware loading for Vangogh platform using dmi quirks.

Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
Link: https://lore.kernel.org/r/20230809123534.287707-3-venkataprasad.potturu@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/amd/acp.c
sound/soc/sof/amd/acp.h
sound/soc/sof/amd/vangogh.c

index 0072a62..b2e00a1 100644 (file)
 #include "acp.h"
 #include "acp-dsp-offset.h"
 
+#define SECURED_FIRMWARE 1
+
+const struct dmi_system_id acp_sof_quirk_table[] = {
+       {
+               /* Valve Jupiter device */
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Valve"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Galileo"),
+                       DMI_MATCH(DMI_PRODUCT_FAMILY, "Sephiroth"),
+               },
+               .driver_data = (void *)SECURED_FIRMWARE,
+       },
+       {}
+};
+EXPORT_SYMBOL_GPL(acp_sof_quirk_table);
+
 static int smn_write(struct pci_dev *dev, u32 smn_addr, u32 data)
 {
        pci_write_config_dword(dev, 0x60, smn_addr);
@@ -468,8 +484,10 @@ EXPORT_SYMBOL_NS(amd_sof_acp_resume, SND_SOC_SOF_AMD_COMMON);
 int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 {
        struct pci_dev *pci = to_pci_dev(sdev->dev);
+       struct snd_sof_pdata *plat_data = sdev->pdata;
        struct acp_dev_data *adata;
        const struct sof_amd_acp_desc *chip;
+       const struct dmi_system_id *dmi_id;
        unsigned int addr;
        int ret;
 
@@ -531,6 +549,19 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
        sdev->debug_box.size = BOX_SIZE_1024;
 
        adata->signed_fw_image = false;
+       dmi_id = dmi_first_match(acp_sof_quirk_table);
+       if (dmi_id && dmi_id->driver_data) {
+               adata->fw_code_bin = kasprintf(GFP_KERNEL, "%s/sof-%s-code.bin",
+                                              plat_data->fw_filename_prefix,
+                                              chip->name);
+               adata->fw_data_bin = kasprintf(GFP_KERNEL, "%s/sof-%s-data.bin",
+                                              plat_data->fw_filename_prefix,
+                                              chip->name);
+               adata->signed_fw_image = dmi_id->driver_data;
+
+               dev_dbg(sdev->dev, "fw_code_bin:%s, fw_data_bin:%s\n", adata->fw_code_bin,
+                       adata->fw_data_bin);
+       }
        acp_memory_init(sdev);
 
        acp_dsp_stream_init(sdev);
index 8421053..19cad4f 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef __SOF_AMD_ACP_H
 #define __SOF_AMD_ACP_H
 
+#include <linux/dmi.h>
+
 #include "../sof-priv.h"
 #include "../sof-audio.h"
 
@@ -297,4 +299,5 @@ int acp_probes_register(struct snd_sof_dev *sdev);
 void acp_probes_unregister(struct snd_sof_dev *sdev);
 
 extern struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[];
+extern const struct dmi_system_id acp_sof_quirk_table[];
 #endif
index f3f6bd7..de15d21 100644 (file)
@@ -142,12 +142,18 @@ EXPORT_SYMBOL_NS(sof_vangogh_ops, SND_SOC_SOF_AMD_COMMON);
 
 int sof_vangogh_ops_init(struct snd_sof_dev *sdev)
 {
+       const struct dmi_system_id *dmi_id;
+
        /* common defaults */
        memcpy(&sof_vangogh_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
 
        sof_vangogh_ops.drv = vangogh_sof_dai;
        sof_vangogh_ops.num_drv = ARRAY_SIZE(vangogh_sof_dai);
 
+       dmi_id = dmi_first_match(acp_sof_quirk_table);
+       if (dmi_id && dmi_id->driver_data)
+               sof_vangogh_ops.load_firmware = acp_sof_load_signed_firmware;
+
        return 0;
 }