msm: camera: common: Add component helper support in camera

Due to the asynchronous nature of platform probes, inter
dependency between drivers needs to be taken care during
kernel boot up. Component helper provides the facility of
adding matching drivers in a list ordered in the way we want
to bind those drivers. The CRM driver acts as component master
to make sure all slave drivers are bound before it returns
from its own bind call. Add support for serializing platform
probes through component framework.

CRs-Fixed: 2584631
Change-Id: I345da1d2b9cccf6021ac6fc899143013b7714ec4
Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
This commit is contained in:
Mukund Madhusudan Atre
2020-01-25 21:15:38 -08:00
parent 8d05aad1b0
commit 5cb000ee7f
44 changed files with 1826 additions and 615 deletions

View File

@@ -53,6 +53,7 @@
#include "cam_top_tpg_v1.h"
#include "cam_tfe_dev.h"
#include "cam_tfe_csid530.h"
#include "camera_main.h"
struct camera_submodule_component {
int (*init)(void);
@@ -205,6 +206,110 @@ 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_ife_csid17x_driver,
&cam_ife_csid_lite_driver,
&cam_vfe_driver,
&isp_driver,
#endif
#ifdef CONFIG_SPECTRA_TFE
&cam_top_tpg_v1_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)
&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;