diff --git a/drivers/cam_req_mgr/cam_req_mgr_dev.c b/drivers/cam_req_mgr/cam_req_mgr_dev.c index 038d3c28e4..ad85d89953 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_dev.c +++ b/drivers/cam_req_mgr/cam_req_mgr_dev.c @@ -24,7 +24,7 @@ #include "cam_mem_mgr.h" #include "cam_debug_util.h" #include "cam_common_util.h" -#include "camera_main.h" +#include "cam_compat.h" #define CAM_REQ_MGR_EVENT_MAX 30 diff --git a/drivers/cam_utils/cam_compat.c b/drivers/cam_utils/cam_compat.c index aa3c02bafb..e0b70865c8 100644 --- a/drivers/cam_utils/cam_compat.c +++ b/drivers/cam_utils/cam_compat.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. */ #include @@ -9,6 +9,7 @@ #include "cam_compat.h" #include "cam_debug_util.h" #include "cam_cpas_api.h" +#include "camera_main.h" #if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) @@ -96,6 +97,11 @@ void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa) reg_val |= errata_wa->data.reg_info.value; qcom_scm_io_writel(errata_wa->data.reg_info.offset, reg_val); } + +static int camera_platform_compare_dev(struct device *dev, const void *data) +{ + return platform_bus_type.match(dev, (struct device_driver *) data); +} #else int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) { @@ -174,4 +180,56 @@ void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa) reg_val |= errata_wa->data.reg_info.value; scm_io_write(errata_wa->data.reg_info.offset, reg_val); } + +static int camera_platform_compare_dev(struct device *dev, void *data) +{ + return platform_bus_type.match(dev, (struct device_driver *) data); +} #endif + +/* Callback to compare device from match list before adding as component */ +static inline int camera_component_compare_dev(struct device *dev, void *data) +{ + return dev == data; +} + +/* Add component matches to list for master of aggregate driver */ +int camera_component_match_add_drivers(struct device *master_dev, + struct component_match **match_list) +{ + int i, rc = 0; + struct platform_device *pdev = NULL; + + if (!master_dev || !match_list) { + CAM_ERR(CAM_UTIL, "Invalid parameters for component match add"); + rc = -EINVAL; + goto end; + } + + for (i = 0; i < ARRAY_SIZE(cam_component_drivers); i++) { +#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE + struct device_driver const *drv = + &cam_component_drivers[i]->driver; + const void *drv_ptr = (const void *)drv; +#else + struct device_driver *drv = &cam_component_drivers[i]->driver; + void *drv_ptr = (void *)drv; +#endif + struct device *start_dev = NULL, *match_dev; + + while ((match_dev = bus_find_device(&platform_bus_type, + start_dev, drv_ptr, &camera_platform_compare_dev))) { + put_device(start_dev); + pdev = to_platform_device(match_dev); + CAM_DBG(CAM_UTIL, "Adding matched component:%s", + pdev->name); + component_match_add(master_dev, match_list, + camera_component_compare_dev, match_dev); + start_dev = match_dev; + } + put_device(start_dev); + } + +end: + return rc; +} diff --git a/drivers/cam_utils/cam_compat.h b/drivers/cam_utils/cam_compat.h index 3e7bec620c..ae3cd2a3d3 100644 --- a/drivers/cam_utils/cam_compat.h +++ b/drivers/cam_utils/cam_compat.h @@ -1,12 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. */ #ifndef _CAM_COMPAT_H_ #define _CAM_COMPAT_H_ #include +#include +#include #include "cam_csiphy_dev.h" #include "cam_cpastop_hw.h" @@ -37,5 +39,7 @@ void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa); int cam_ife_notify_safe_lut_scm(bool safe_trigger); int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, bool protect, int32_t offset); +int camera_component_match_add_drivers(struct device *master_dev, + struct component_match **match_list); #endif /* _CAM_COMPAT_H_ */ diff --git a/drivers/camera_main.c b/drivers/camera_main.c index ec29cfd707..621f5c3dbe 100644 --- a/drivers/camera_main.c +++ b/drivers/camera_main.c @@ -209,112 +209,6 @@ static const struct camera_submodule submodule_table[] = { } }; -/* - * Drivers to be bound by component framework in this order with - * CRM as master - */ -static struct platform_driver *const cam_component_drivers[] = { -/* BASE */ - &cam_sync_driver, - &cam_smmu_driver, - &cam_cpas_driver, - &cam_cdm_intf_driver, - &cam_hw_cdm_driver, -#ifdef CONFIG_SPECTRA_ISP - &cam_top_tpg_driver, - &cam_ife_csid17x_driver, - &cam_ife_csid_lite_driver, - &cam_vfe_driver, - &isp_driver, -#endif -#ifdef CONFIG_SPECTRA_TFE - &cam_top_tpg_driver, - &cam_tfe_driver, - &cam_tfe_csid530_driver, -#endif -#ifdef CONFIG_SPECTRA_SENSOR - &cam_res_mgr_driver, - &cci_driver, - &csiphy_driver, - &cam_actuator_platform_driver, - &cam_sensor_platform_driver, - &cam_eeprom_platform_driver, - &cam_ois_platform_driver, -#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \ - IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) - &cam_flash_platform_driver, -#endif -#endif -#ifdef CONFIG_SPECTRA_ICP - &cam_a5_driver, - &cam_ipe_driver, - &cam_bps_driver, - &cam_icp_driver, -#endif -#ifdef CONFIG_SPECTRA_OPE - &cam_ope_driver, - &cam_ope_subdev_driver, -#endif -#ifdef CONFIG_SPECTRA_JPEG - &cam_jpeg_enc_driver, - &cam_jpeg_dma_driver, - &jpeg_driver, -#endif -#ifdef CONFIG_SPECTRA_FD - &cam_fd_hw_driver, - &cam_fd_driver, -#endif -#ifdef CONFIG_SPECTRA_LRME - &cam_lrme_hw_driver, - &cam_lrme_driver, -#endif -#ifdef CONFIG_SPECTRA_CUSTOM - &cam_custom_hw_sub_mod_driver, - &cam_custom_csid_driver, - &custom_driver, -#endif -}; - -/* Callback to compare device from match list before adding as component */ -static int camera_component_compare_dev(struct device *dev, void *data) -{ - return dev == data; -} - -/* Add component matches to list for master of aggregate driver */ -int camera_component_match_add_drivers(struct device *master_dev, - struct component_match **match_list) -{ - int i, rc = 0; - struct platform_device *pdev = NULL; - - if (!master_dev || !match_list) { - CAM_ERR(CAM_UTIL, "Invalid parameters for component match add"); - rc = -EINVAL; - goto end; - } - - for (i = 0; i < ARRAY_SIZE(cam_component_drivers); i++) { - struct device_driver *drv = &cam_component_drivers[i]->driver; - struct device *start_dev = NULL, *match_dev; - - while ((match_dev = bus_find_device(&platform_bus_type, - start_dev, drv, (void *)platform_bus_type.match))) { - put_device(start_dev); - pdev = to_platform_device(match_dev); - CAM_DBG(CAM_UTIL, "Adding matched component:%s", - pdev->name); - component_match_add(master_dev, match_list, - camera_component_compare_dev, match_dev); - start_dev = match_dev; - } - put_device(start_dev); - } - -end: - return rc; -} - static int camera_verify_submodules(void) { int rc = 0; diff --git a/drivers/camera_main.h b/drivers/camera_main.h index af832ee60f..e802d64b75 100644 --- a/drivers/camera_main.h +++ b/drivers/camera_main.h @@ -68,6 +68,70 @@ extern struct platform_driver cam_custom_csid_driver; extern struct platform_driver custom_driver; #endif -int camera_component_match_add_drivers(struct device *dev, - struct component_match **match_list); +/* + * Drivers to be bound by component framework in this order with + * CRM as master + */ +static struct platform_driver *const cam_component_drivers[] = { +/* BASE */ + &cam_sync_driver, + &cam_smmu_driver, + &cam_cpas_driver, + &cam_cdm_intf_driver, + &cam_hw_cdm_driver, +#ifdef CONFIG_SPECTRA_ISP + &cam_top_tpg_driver, + &cam_ife_csid17x_driver, + &cam_ife_csid_lite_driver, + &cam_vfe_driver, + &isp_driver, +#endif +#ifdef CONFIG_SPECTRA_TFE + &cam_top_tpg_driver, + &cam_tfe_driver, + &cam_tfe_csid530_driver, +#endif +#ifdef CONFIG_SPECTRA_SENSOR + &cam_res_mgr_driver, + &cci_driver, + &csiphy_driver, + &cam_actuator_platform_driver, + &cam_sensor_platform_driver, + &cam_eeprom_platform_driver, + &cam_ois_platform_driver, +#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \ + IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) + &cam_flash_platform_driver, +#endif +#endif +#ifdef CONFIG_SPECTRA_ICP + &cam_a5_driver, + &cam_ipe_driver, + &cam_bps_driver, + &cam_icp_driver, +#endif +#ifdef CONFIG_SPECTRA_OPE + &cam_ope_driver, + &cam_ope_subdev_driver, +#endif +#ifdef CONFIG_SPECTRA_JPEG + &cam_jpeg_enc_driver, + &cam_jpeg_dma_driver, + &jpeg_driver, +#endif +#ifdef CONFIG_SPECTRA_FD + &cam_fd_hw_driver, + &cam_fd_driver, +#endif +#ifdef CONFIG_SPECTRA_LRME + &cam_lrme_hw_driver, + &cam_lrme_driver, +#endif +#ifdef CONFIG_SPECTRA_CUSTOM + &cam_custom_hw_sub_mod_driver, + &cam_custom_csid_driver, + &custom_driver, +#endif +}; + #endif /* CAMERA_MAIN_H */