diff --git a/drivers/cam_icp/icp_hw/a5_hw/a5_core.c b/drivers/cam_icp/icp_hw/a5_hw/a5_core.c index df6bc73170..33b39dabde 100644 --- a/drivers/cam_icp/icp_hw/a5_hw/a5_core.c +++ b/drivers/cam_icp/icp_hw/a5_hw/a5_core.c @@ -12,6 +12,7 @@ #include #include #include + #include "cam_io_util.h" #include "cam_a5_hw_intf.h" #include "cam_hw.h" @@ -28,6 +29,7 @@ #include "cam_debug_util.h" #include "cam_icp_utils.h" #include "cam_common_util.h" +#include "cam_compat.h" #define PC_POLL_DELAY_US 100 #define PC_POLL_TIMEOUT_US 10000 @@ -678,7 +680,7 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type, if (a5_soc->ubwc_config_ext) { /* Invoke kernel API to determine DDR type */ - ddr_type = of_fdt_get_ddrtype(); + ddr_type = cam_get_ddr_type(); if ((ddr_type == DDR_TYPE_LPDDR5) || (ddr_type == DDR_TYPE_LPDDR5X)) index = 1; diff --git a/drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c b/drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c index d5218d8c42..24b9476652 100644 --- a/drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c +++ b/drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c @@ -20,6 +20,7 @@ #include "lx7_reg.h" #include "lx7_soc.h" #include "cam_common_util.h" +#include "cam_compat.h" #define TZ_STATE_SUSPEND 0 #define TZ_STATE_RESUME 1 @@ -45,7 +46,7 @@ static int cam_lx7_ubwc_configure(struct cam_hw_soc_info *soc_info) soc_priv = soc_info->soc_private; - ddr_type = of_fdt_get_ddrtype(); + ddr_type = cam_get_ddr_type(); if (ddr_type == DDR_TYPE_LPDDR5 || ddr_type == DDR_TYPE_LPDDR5X) i = 1; diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c index de1112c648..8435858350 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c @@ -25,6 +25,7 @@ #include "cam_trace.h" #include "cam_smmu_api.h" #include "cam_common_util.h" +#include "cam_compat.h" static const char drv_name[] = "vfe_bus"; @@ -1881,7 +1882,7 @@ static int cam_vfe_bus_ver3_init_comp_grp(uint32_t index, rsrc_data->comp_grp_type != CAM_VFE_BUS_VER3_COMP_GRP_1) rsrc_data->ubwc_static_ctrl = 0; else { - ddr_type = of_fdt_get_ddrtype(); + ddr_type = cam_get_ddr_type(); if ((ddr_type == DDR_TYPE_LPDDR5) || (ddr_type == DDR_TYPE_LPDDR5X)) rsrc_data->ubwc_static_ctrl = diff --git a/drivers/cam_utils/cam_compat.c b/drivers/cam_utils/cam_compat.c index 4bd54b7652..b619882c3c 100644 --- a/drivers/cam_utils/cam_compat.c +++ b/drivers/cam_utils/cam_compat.c @@ -248,7 +248,7 @@ end: return rc; } -#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) #include void cam_check_iommu_faults(struct iommu_domain *domain, struct cam_smmu_pf_info *pf_info) @@ -281,4 +281,19 @@ void cam_check_iommu_faults(struct iommu_domain *domain, pf_info->pid = fault_ids.pid; pf_info->mid = fault_ids.mid; } +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) +int cam_get_ddr_type(void) +{ + /* We assume all chipsets running kernel version 5.15+ + * to be using only DDR5 based memory. + */ + return DDR_TYPE_LPDDR5; +} +#else +int cam_get_ddr_type(void) +{ + return of_fdt_get_ddrtype(); +} #endif \ No newline at end of file diff --git a/drivers/cam_utils/cam_compat.h b/drivers/cam_utils/cam_compat.h index 89e2ee905e..dbe974084a 100644 --- a/drivers/cam_utils/cam_compat.h +++ b/drivers/cam_utils/cam_compat.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. */ #ifndef _CAM_COMPAT_H_ @@ -9,36 +9,23 @@ #include #include #include +#include +#include #include "cam_csiphy_dev.h" #include "cam_cpastop_hw.h" #include "cam_smmu_api.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0) - -#define VFL_TYPE_VIDEO VFL_TYPE_GRABBER - -#endif - -#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE - -#include -#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) #include -#include - -#else - #include -#include -#include - +#define VFL_TYPE_VIDEO VFL_TYPE_GRABBER #endif -#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) +#include #include - #endif struct cam_fw_alloc_info { @@ -58,5 +45,6 @@ int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, void cam_free_clear(const void *); void cam_check_iommu_faults(struct iommu_domain *domain, struct cam_smmu_pf_info *pf_info); +int cam_get_ddr_type(void); #endif /* _CAM_COMPAT_H_ */