Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: iris: implement the boot sequence of the firmware

Set the memory region on the firmware and implement the boot sequence.

Tested-by: Stefan Schmidt <stefan.schmidt@linaro.org> # x1e80100 (Dell XPS 13 9345)
Reviewed-by: Stefan Schmidt <stefan.schmidt@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Dikshita Agarwal and committed by
Hans Verkuil
abf5bac6 d19b1633

+114
+1
drivers/media/platform/qcom/iris/Makefile
··· 6 6 iris_platform_sm8550.o \ 7 7 iris_probe.o \ 8 8 iris_vidc.o \ 9 + iris_vpu_common.o \ 9 10 10 11 obj-$(CONFIG_VIDEO_QCOM_IRIS) += iris.o
+7
drivers/media/platform/qcom/iris/iris_core.c
··· 6 6 #include "iris_core.h" 7 7 #include "iris_firmware.h" 8 8 #include "iris_state.h" 9 + #include "iris_vpu_common.h" 9 10 10 11 void iris_core_deinit(struct iris_core *core) 11 12 { ··· 40 39 if (ret) 41 40 goto error_queue_deinit; 42 41 42 + ret = iris_vpu_boot_firmware(core); 43 + if (ret) 44 + goto error_unload_fw; 45 + 43 46 mutex_unlock(&core->lock); 44 47 45 48 return 0; 46 49 50 + error_unload_fw: 51 + iris_fw_unload(core); 47 52 error_queue_deinit: 48 53 iris_hfi_queues_deinit(core); 49 54 error:
+1
drivers/media/platform/qcom/iris/iris_platform_common.h
··· 44 44 const char *fwname; 45 45 u32 pas_id; 46 46 struct tz_cp_config *tz_cp_config_data; 47 + u32 core_arch; 47 48 }; 48 49 49 50 #endif
+3
drivers/media/platform/qcom/iris/iris_platform_sm8550.c
··· 7 7 #include "iris_hfi_gen2.h" 8 8 #include "iris_platform_common.h" 9 9 10 + #define VIDEO_ARCH_LX 1 11 + 10 12 static const struct icc_info sm8550_icc_table[] = { 11 13 { "cpu-cfg", 1000, 1000 }, 12 14 { "video-mem", 1000, 15000000 }, ··· 50 48 .fwname = "qcom/vpu/vpu30_p4.mbn", 51 49 .pas_id = IRIS_PAS_ID, 52 50 .tz_cp_config_data = &tz_cp_config_sm8550, 51 + .core_arch = VIDEO_ARCH_LX, 53 52 };
+89
drivers/media/platform/qcom/iris/iris_vpu_common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 + */ 5 + 6 + #include <linux/iopoll.h> 7 + 8 + #include "iris_core.h" 9 + #include "iris_vpu_common.h" 10 + 11 + #define CPU_BASE_OFFS 0x000A0000 12 + 13 + #define CPU_CS_BASE_OFFS (CPU_BASE_OFFS) 14 + 15 + #define CTRL_INIT (CPU_CS_BASE_OFFS + 0x48) 16 + #define CTRL_STATUS (CPU_CS_BASE_OFFS + 0x4C) 17 + 18 + #define CTRL_ERROR_STATUS__M 0xfe 19 + 20 + #define QTBL_INFO (CPU_CS_BASE_OFFS + 0x50) 21 + #define QTBL_ENABLE BIT(0) 22 + 23 + #define QTBL_ADDR (CPU_CS_BASE_OFFS + 0x54) 24 + #define CPU_CS_SCIACMDARG3 (CPU_CS_BASE_OFFS + 0x58) 25 + #define SFR_ADDR (CPU_CS_BASE_OFFS + 0x5C) 26 + #define UC_REGION_ADDR (CPU_CS_BASE_OFFS + 0x64) 27 + #define UC_REGION_SIZE (CPU_CS_BASE_OFFS + 0x68) 28 + 29 + #define CPU_CS_H2XSOFTINTEN (CPU_CS_BASE_OFFS + 0x148) 30 + #define HOST2XTENSA_INTR_ENABLE BIT(0) 31 + 32 + #define CPU_CS_X2RPMH (CPU_CS_BASE_OFFS + 0x168) 33 + 34 + static void iris_vpu_setup_ucregion_memory_map(struct iris_core *core) 35 + { 36 + u32 queue_size, value; 37 + 38 + /* Iris hardware requires 4K queue alignment */ 39 + queue_size = ALIGN(sizeof(struct iris_hfi_queue_table_header) + 40 + (IFACEQ_QUEUE_SIZE * IFACEQ_NUMQ), SZ_4K); 41 + 42 + value = (u32)core->iface_q_table_daddr; 43 + writel(value, core->reg_base + UC_REGION_ADDR); 44 + 45 + /* Iris hardware requires 1M queue alignment */ 46 + value = ALIGN(SFR_SIZE + queue_size, SZ_1M); 47 + writel(value, core->reg_base + UC_REGION_SIZE); 48 + 49 + value = (u32)core->iface_q_table_daddr; 50 + writel(value, core->reg_base + QTBL_ADDR); 51 + 52 + writel(QTBL_ENABLE, core->reg_base + QTBL_INFO); 53 + 54 + if (core->sfr_daddr) { 55 + value = (u32)core->sfr_daddr + core->iris_platform_data->core_arch; 56 + writel(value, core->reg_base + SFR_ADDR); 57 + } 58 + } 59 + 60 + int iris_vpu_boot_firmware(struct iris_core *core) 61 + { 62 + u32 ctrl_init = BIT(0), ctrl_status = 0, count = 0, max_tries = 1000; 63 + 64 + iris_vpu_setup_ucregion_memory_map(core); 65 + 66 + writel(ctrl_init, core->reg_base + CTRL_INIT); 67 + writel(0x1, core->reg_base + CPU_CS_SCIACMDARG3); 68 + 69 + while (!ctrl_status && count < max_tries) { 70 + ctrl_status = readl(core->reg_base + CTRL_STATUS); 71 + if ((ctrl_status & CTRL_ERROR_STATUS__M) == 0x4) { 72 + dev_err(core->dev, "invalid setting for uc_region\n"); 73 + break; 74 + } 75 + 76 + usleep_range(50, 100); 77 + count++; 78 + } 79 + 80 + if (count >= max_tries) { 81 + dev_err(core->dev, "error booting up iris firmware\n"); 82 + return -ETIME; 83 + } 84 + 85 + writel(HOST2XTENSA_INTR_ENABLE, core->reg_base + CPU_CS_H2XSOFTINTEN); 86 + writel(0x0, core->reg_base + CPU_CS_X2RPMH); 87 + 88 + return 0; 89 + }
+13
drivers/media/platform/qcom/iris/iris_vpu_common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 + */ 5 + 6 + #ifndef __IRIS_VPU_COMMON_H__ 7 + #define __IRIS_VPU_COMMON_H__ 8 + 9 + struct iris_core; 10 + 11 + int iris_vpu_boot_firmware(struct iris_core *core); 12 + 13 + #endif