From a9c66768db400a82575a82ecddec71f1d3fd4aba Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 14 Apr 2017 12:06:39 -0700 Subject: gpu: nvgpu: Add abstraction for firmware loading Add nvgpu_firmware data structure, and return it instead of Linux struct firmare from nvgpu_request_firmware. Also add abstraction for releasing firmware: nvgpu_release_firmware. JIRA NVGPU-16 Change-Id: I6dae8262957c0d4506f710289e3a43a6c1729fc7 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1463538 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/acr/nvgpu_acr.h | 10 ++-- drivers/gpu/nvgpu/include/nvgpu/firmware.h | 66 +++++++++++++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/nvgpu_common.h | 7 --- 3 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 drivers/gpu/nvgpu/include/nvgpu/firmware.h (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/acr/nvgpu_acr.h b/drivers/gpu/nvgpu/include/nvgpu/acr/nvgpu_acr.h index 6991a0ba..3844362d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/acr/nvgpu_acr.h +++ b/drivers/gpu/nvgpu/include/nvgpu/acr/nvgpu_acr.h @@ -21,6 +21,8 @@ #include "acr_objlsfm.h" #include "acr_objflcn.h" +struct nvgpu_firmware; + #define MAX_SUPPORTED_LSFM 3 /*PMU, FECS, GPCCS*/ #define ACR_COMPLETION_TIMEOUT_MS 10000 /*in msec */ @@ -74,20 +76,20 @@ struct acr_desc { struct bin_hdr *hsbin_hdr; struct acr_fw_header *fw_hdr; u32 pmu_args; - const struct firmware *acr_fw; + struct nvgpu_firmware *acr_fw; union{ struct flcn_acr_desc *acr_dmem_desc; struct flcn_acr_desc_v1 *acr_dmem_desc_v1; }; struct nvgpu_mem acr_ucode; - const struct firmware *hsbl_fw; + struct nvgpu_firmware *hsbl_fw; struct nvgpu_mem hsbl_ucode; union { struct flcn_bl_dmem_desc bl_dmem_desc; struct flcn_bl_dmem_desc_v1 bl_dmem_desc_v1; }; - const struct firmware *pmu_fw; - const struct firmware *pmu_desc; + struct nvgpu_firmware *pmu_fw; + struct nvgpu_firmware *pmu_desc; u32 capabilities; }; diff --git a/drivers/gpu/nvgpu/include/nvgpu/firmware.h b/drivers/gpu/nvgpu/include/nvgpu/firmware.h new file mode 100644 index 00000000..cf206dc2 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/firmware.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _NVGPU_FIRMWARE_H_ +#define _NVGPU_FIRMWARE_H_ + +struct gk20a; + +#define NVGPU_REQUEST_FIRMWARE_NO_WARN (1UL << 0) +#define NVGPU_REQUEST_FIRMWARE_NO_SOC (1UL << 1) + +struct nvgpu_firmware { + u8 *data; + size_t size; +}; + +/** + * nvgpu_request_firmware - load a firmware blob from filesystem. + * + * @g The GPU driver struct for device to load firmware for + * @fw_name The base name of the firmware file. + * @flags Flags for loading; + * + * NVGPU_REQUEST_FIRMWARE_NO_WARN: Do not display warning on + * failed load. + * + * NVGPU_REQUEST_FIRMWARE_NO_SOC: Do not attempt loading from + * path . + * + * nvgpu_request_firmware() will load firmware from: + * + * // + * + * If that fails and NO_SOC is not enabled, it'll try next from: + * + * // + * + * It'll allocate a nvgpu_firmware structure and initializes it and returns + * it to caller. + */ +struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g, + const char *fw_name, + int flags); + +/** + * nvgpu_release_firmware - free firmware and associated nvgpu_firmware blob + * + * @g The GPU driver struct for device to free firmware for + * @fw The firmware to free. fw blob will also be freed. + */ +void nvgpu_release_firmware(struct gk20a *g, struct nvgpu_firmware *fw); + +#endif diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_common.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_common.h index 85b4a3df..2a9e4f99 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_common.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_common.h @@ -25,11 +25,4 @@ int nvgpu_probe(struct gk20a *g, const char *interface_name, struct class *class); -#define NVGPU_REQUEST_FIRMWARE_NO_WARN BIT(0) -#define NVGPU_REQUEST_FIRMWARE_NO_SOC BIT(1) - -const struct firmware *nvgpu_request_firmware(struct gk20a *g, - const char *fw_name, - int flags); - #endif -- cgit v1.2.2