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

media: iris: enable support for SC7280 platform

As a part of migrating code from the old Venus driver to the new Iris
one, add support for the SC7280 platform. It is very similar to SM8250,
but it (currently) uses no reset controls (there is an optional
GCC-generated reset, it will be added later) and no AON registers
region. Extend the VPU ops to support optional clocks and skip the AON
shutdown for this platform.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Dmitry Baryshkov and committed by
Hans Verkuil
542e3540 3b72f5e2

+119 -10
+4
drivers/media/platform/qcom/iris/iris_platform_common.h
··· 42 42 }; 43 43 44 44 extern const struct iris_platform_data qcs8300_data; 45 + extern const struct iris_platform_data sc7280_data; 45 46 extern const struct iris_platform_data sm8250_data; 46 47 extern const struct iris_platform_data sm8550_data; 47 48 extern const struct iris_platform_data sm8650_data; ··· 51 50 enum platform_clk_type { 52 51 IRIS_AXI_CLK, /* AXI0 in case of platforms with multiple AXI clocks */ 53 52 IRIS_CTRL_CLK, 53 + IRIS_AHB_CLK, 54 54 IRIS_HW_CLK, 55 + IRIS_HW_AHB_CLK, 55 56 IRIS_AXI1_CLK, 56 57 IRIS_CTRL_FREERUN_CLK, 57 58 IRIS_HW_FREERUN_CLK, ··· 227 224 u32 hw_response_timeout; 228 225 struct ubwc_config_data *ubwc_config; 229 226 u32 num_vpp_pipe; 227 + bool no_aon; 230 228 u32 max_session_count; 231 229 /* max number of macroblocks per frame supported */ 232 230 u32 max_core_mbpf;
+53
drivers/media/platform/qcom/iris/iris_platform_gen1.c
··· 12 12 #include "iris_vpu_buffer.h" 13 13 #include "iris_vpu_common.h" 14 14 15 + #include "iris_platform_sc7280.h" 16 + 15 17 #define BITRATE_MIN 32000 16 18 #define BITRATE_MAX 160000000 17 19 #define BITRATE_PEAK_DEFAULT (BITRATE_DEFAULT * 2) ··· 348 346 .max_session_count = 16, 349 347 .max_core_mbpf = NUM_MBS_8K, 350 348 .max_core_mbps = ((7680 * 4320) / 256) * 60, 349 + .dec_input_config_params_default = 350 + sm8250_vdec_input_config_param_default, 351 + .dec_input_config_params_default_size = 352 + ARRAY_SIZE(sm8250_vdec_input_config_param_default), 353 + .enc_input_config_params = sm8250_venc_input_config_param, 354 + .enc_input_config_params_size = 355 + ARRAY_SIZE(sm8250_venc_input_config_param), 356 + 357 + .dec_ip_int_buf_tbl = sm8250_dec_ip_int_buf_tbl, 358 + .dec_ip_int_buf_tbl_size = ARRAY_SIZE(sm8250_dec_ip_int_buf_tbl), 359 + .dec_op_int_buf_tbl = sm8250_dec_op_int_buf_tbl, 360 + .dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8250_dec_op_int_buf_tbl), 361 + 362 + .enc_ip_int_buf_tbl = sm8250_enc_ip_int_buf_tbl, 363 + .enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8250_enc_ip_int_buf_tbl), 364 + }; 365 + 366 + const struct iris_platform_data sc7280_data = { 367 + .get_instance = iris_hfi_gen1_get_instance, 368 + .init_hfi_command_ops = &iris_hfi_gen1_command_ops_init, 369 + .init_hfi_response_ops = iris_hfi_gen1_response_ops_init, 370 + .get_vpu_buffer_size = iris_vpu_buf_size, 371 + .vpu_ops = &iris_vpu2_ops, 372 + .set_preset_registers = iris_set_sm8250_preset_registers, 373 + .icc_tbl = sm8250_icc_table, 374 + .icc_tbl_size = ARRAY_SIZE(sm8250_icc_table), 375 + .bw_tbl_dec = sc7280_bw_table_dec, 376 + .bw_tbl_dec_size = ARRAY_SIZE(sc7280_bw_table_dec), 377 + .pmdomain_tbl = sm8250_pmdomain_table, 378 + .pmdomain_tbl_size = ARRAY_SIZE(sm8250_pmdomain_table), 379 + .opp_pd_tbl = sc7280_opp_pd_table, 380 + .opp_pd_tbl_size = ARRAY_SIZE(sc7280_opp_pd_table), 381 + .clk_tbl = sc7280_clk_table, 382 + .clk_tbl_size = ARRAY_SIZE(sc7280_clk_table), 383 + /* Upper bound of DMA address range */ 384 + .dma_mask = 0xe0000000 - 1, 385 + .fwname = "qcom/vpu/vpu20_p1.mbn", 386 + .pas_id = IRIS_PAS_ID, 387 + .inst_caps = &platform_inst_cap_sm8250, 388 + .inst_fw_caps_dec = inst_fw_cap_sm8250_dec, 389 + .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_sm8250_dec), 390 + .inst_fw_caps_enc = inst_fw_cap_sm8250_enc, 391 + .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8250_enc), 392 + .tz_cp_config_data = &tz_cp_config_sm8250, 393 + .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE, 394 + .num_vpp_pipe = 1, 395 + .no_aon = true, 396 + .max_session_count = 16, 397 + .max_core_mbpf = 4096 * 2176 / 256 * 2 + 1920 * 1088 / 256, 398 + /* max spec for SC7280 is 4096x2176@60fps */ 399 + .max_core_mbps = 4096 * 2176 / 256 * 60, 351 400 .dec_input_config_params_default = 352 401 sm8250_vdec_input_config_param_default, 353 402 .dec_input_config_params_default_size =
+26
drivers/media/platform/qcom/iris/iris_platform_sc7280.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4 + */ 5 + 6 + #ifndef __IRIS_PLATFORM_SC7280_H__ 7 + #define __IRIS_PLATFORM_SC7280_H__ 8 + 9 + static const struct bw_info sc7280_bw_table_dec[] = { 10 + { ((3840 * 2160) / 256) * 60, 1896000, }, 11 + { ((3840 * 2160) / 256) * 30, 968000, }, 12 + { ((1920 * 1080) / 256) * 60, 618000, }, 13 + { ((1920 * 1080) / 256) * 30, 318000, }, 14 + }; 15 + 16 + static const char * const sc7280_opp_pd_table[] = { "cx" }; 17 + 18 + static const struct platform_clk_data sc7280_clk_table[] = { 19 + {IRIS_CTRL_CLK, "core" }, 20 + {IRIS_AXI_CLK, "iface" }, 21 + {IRIS_AHB_CLK, "bus" }, 22 + {IRIS_HW_CLK, "vcodec_core" }, 23 + {IRIS_HW_AHB_CLK, "vcodec_bus" }, 24 + }; 25 + 26 + #endif
+4
drivers/media/platform/qcom/iris/iris_probe.c
··· 358 358 }, 359 359 #if (!IS_ENABLED(CONFIG_VIDEO_QCOM_VENUS)) 360 360 { 361 + .compatible = "qcom,sc7280-venus", 362 + .data = &sc7280_data, 363 + }, 364 + { 361 365 .compatible = "qcom,sm8250-venus", 362 366 .data = &sm8250_data, 363 367 },
+1 -1
drivers/media/platform/qcom/iris/iris_resources.c
··· 112 112 113 113 clock = iris_get_clk_by_type(core, clk_type); 114 114 if (!clock) 115 - return -EINVAL; 115 + return -ENOENT; 116 116 117 117 return clk_prepare_enable(clock); 118 118 }
+6
drivers/media/platform/qcom/iris/iris_vpu2.c
··· 3 3 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 4 */ 5 5 6 + #include <linux/bits.h> 7 + #include <linux/iopoll.h> 8 + #include <linux/reset.h> 9 + 6 10 #include "iris_instance.h" 7 11 #include "iris_vpu_common.h" 12 + 13 + #include "iris_vpu_register_defines.h" 8 14 9 15 static u64 iris_vpu2_calc_freq(struct iris_inst *inst, size_t data_size) 10 16 {
+25 -9
drivers/media/platform/qcom/iris/iris_vpu_common.c
··· 222 222 223 223 writel(MSK_SIGNAL_FROM_TENSILICA | MSK_CORE_POWER_ON, core->reg_base + CPU_CS_X2RPMH); 224 224 225 - writel(REQ_POWER_DOWN_PREP, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL); 225 + if (!core->iris_platform_data->no_aon) { 226 + writel(REQ_POWER_DOWN_PREP, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL); 226 227 227 - ret = readl_poll_timeout(core->reg_base + AON_WRAPPER_MVP_NOC_LPI_STATUS, 228 - val, val & BIT(0), 200, 2000); 229 - if (ret) 230 - goto disable_power; 228 + ret = readl_poll_timeout(core->reg_base + AON_WRAPPER_MVP_NOC_LPI_STATUS, 229 + val, val & BIT(0), 200, 2000); 230 + if (ret) 231 + goto disable_power; 232 + } 231 233 232 234 writel(REQ_POWER_DOWN_PREP, core->reg_base + WRAPPER_IRIS_CPU_NOC_LPI_CONTROL); 233 235 ··· 252 250 writel(0x0, core->reg_base + WRAPPER_TZ_CTL_AXI_CLOCK_CONFIG); 253 251 254 252 disable_power: 253 + iris_disable_unprepare_clock(core, IRIS_AHB_CLK); 255 254 iris_disable_unprepare_clock(core, IRIS_CTRL_CLK); 256 255 iris_disable_unprepare_clock(core, IRIS_AXI_CLK); 257 256 iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]); ··· 264 261 { 265 262 dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], false); 266 263 iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]); 264 + iris_disable_unprepare_clock(core, IRIS_HW_AHB_CLK); 267 265 iris_disable_unprepare_clock(core, IRIS_HW_CLK); 268 266 } 269 267 ··· 298 294 299 295 ret = iris_prepare_enable_clock(core, IRIS_CTRL_CLK); 300 296 if (ret) 301 - goto err_disable_clock; 297 + goto err_disable_axi_clock; 298 + 299 + ret = iris_prepare_enable_clock(core, IRIS_AHB_CLK); 300 + if (ret && ret != -ENOENT) 301 + goto err_disable_ctrl_clock; 302 302 303 303 return 0; 304 304 305 - err_disable_clock: 305 + err_disable_ctrl_clock: 306 + iris_disable_unprepare_clock(core, IRIS_CTRL_CLK); 307 + err_disable_axi_clock: 306 308 iris_disable_unprepare_clock(core, IRIS_AXI_CLK); 307 309 err_disable_power: 308 310 iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_CTRL_POWER_DOMAIN]); ··· 328 318 if (ret) 329 319 goto err_disable_power; 330 320 321 + ret = iris_prepare_enable_clock(core, IRIS_HW_AHB_CLK); 322 + if (ret && ret != -ENOENT) 323 + goto err_disable_hw_clock; 324 + 331 325 ret = dev_pm_genpd_set_hwmode(core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN], true); 332 326 if (ret) 333 - goto err_disable_clock; 327 + goto err_disable_hw_ahb_clock; 334 328 335 329 return 0; 336 330 337 - err_disable_clock: 331 + err_disable_hw_ahb_clock: 332 + iris_disable_unprepare_clock(core, IRIS_HW_AHB_CLK); 333 + err_disable_hw_clock: 338 334 iris_disable_unprepare_clock(core, IRIS_HW_CLK); 339 335 err_disable_power: 340 336 iris_disable_power_domains(core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN]);