Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 315e4b16 authored by Aditya Bavanari's avatar Aditya Bavanari Committed by Gerrit - the friendly Code Review server
Browse files

adsp-loader: Add support to load adsp fw name



When adsp variant read from fuse registers is not
supported, add support to read the fw name
and load the same.

Change-Id: Icf9aeee8b4c607a6f768f0d73ab0e55d78dc8ac9
Signed-off-by: default avatarAditya Bavanari <abavanar@codeaurora.org>
parent e7efdae3
Loading
Loading
Loading
Loading
+41 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2014, 2017-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2014, 2017-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/init.h>
@@ -333,6 +333,8 @@ static int adsp_loader_probe(struct platform_device *pdev)
	int fw_name_size;
	u32 adsp_var_idx = 0;
	int ret = 0;
	u32 adsp_fuse_not_supported = 0;
	const char *adsp_fw_name;

	ret = adsp_loader_init_sysfs(pdev);
	if (ret != 0) {
@@ -344,7 +346,44 @@ static int adsp_loader_probe(struct platform_device *pdev)
	/* get adsp variant idx */
	cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
	if (IS_ERR_OR_NULL(cell)) {
		dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__);
		dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n",
			__func__);

		/*
		 * When ADSP variant read from fuse register is not
		 * supported, check if image with different fw image
		 * name needs to be loaded
		 */
		ret = of_property_read_u32(pdev->dev.of_node,
					  "adsp-fuse-not-supported",
					  &adsp_fuse_not_supported);
		if (ret) {
			dev_dbg(&pdev->dev,
				"%s: adsp_fuse_not_supported prop not found",
				__func__, ret);
			goto wqueue;
		}

		if (adsp_fuse_not_supported) {
			/* Read ADSP firmware image name */
			ret = of_property_read_string(pdev->dev.of_node,
						"adsp-fw-name",
						 &adsp_fw_name);
			if (ret < 0) {
				dev_dbg(&pdev->dev, "%s: unable to read fw-name\n",
					__func__);
				goto wqueue;
			}

			fw_name_size = strlen(adsp_fw_name) + 1;
			priv->adsp_fw_name = devm_kzalloc(&pdev->dev,
						fw_name_size,
						GFP_KERNEL);
			if (!priv->adsp_fw_name)
				goto wqueue;
			strlcpy(priv->adsp_fw_name, adsp_fw_name,
				fw_name_size);
		}
		goto wqueue;
	}
	buf = nvmem_cell_read(cell, &len);