msm: camera: sensor: Add component support for i2c driver
Sometimes, i2c driver will be probed earlier than CRM driver ready, then we can't register the subdev for this i2c driver. This change adds the component support for i2c driver. CRs-Fixed: 3073284 Change-Id: I5ee176497a667729d964758ac0909f6902877094 Signed-off-by: Depeng Shao <quic_depengs@quicinc.com>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
9d22ec64fc
commit
d8d3eaa882
@@ -104,6 +104,11 @@ static int camera_platform_compare_dev(struct device *dev, const void *data)
|
||||
{
|
||||
return platform_bus_type.match(dev, (struct device_driver *) data);
|
||||
}
|
||||
|
||||
static int camera_i2c_compare_dev(struct device *dev, const void *data)
|
||||
{
|
||||
return i2c_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)
|
||||
{
|
||||
@@ -188,6 +193,11 @@ static int camera_platform_compare_dev(struct device *dev, void *data)
|
||||
{
|
||||
return platform_bus_type.match(dev, (struct device_driver *) data);
|
||||
}
|
||||
|
||||
static int camera_i2c_compare_dev(struct device *dev, void *data)
|
||||
{
|
||||
return i2c_bus_type.match(dev, (struct device_driver *) data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
|
||||
@@ -214,6 +224,7 @@ int camera_component_match_add_drivers(struct device *master_dev,
|
||||
{
|
||||
int i, rc = 0;
|
||||
struct platform_device *pdev = NULL;
|
||||
struct i2c_client *client = NULL;
|
||||
struct device *start_dev = NULL, *match_dev = NULL;
|
||||
|
||||
if (!master_dev || !match_list) {
|
||||
@@ -222,13 +233,13 @@ int camera_component_match_add_drivers(struct device *master_dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cam_component_drivers); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(cam_component_platform_drivers); i++) {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
|
||||
struct device_driver const *drv =
|
||||
&cam_component_drivers[i]->driver;
|
||||
&cam_component_platform_drivers[i]->driver;
|
||||
const void *drv_ptr = (const void *)drv;
|
||||
#else
|
||||
struct device_driver *drv = &cam_component_drivers[i]->driver;
|
||||
struct device_driver *drv = &cam_component_platform_drivers[i]->driver;
|
||||
void *drv_ptr = (void *)drv;
|
||||
#endif
|
||||
start_dev = NULL;
|
||||
@@ -244,6 +255,28 @@ int camera_component_match_add_drivers(struct device *master_dev,
|
||||
put_device(start_dev);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cam_component_i2c_drivers); i++) {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
|
||||
struct device_driver const *drv =
|
||||
&cam_component_i2c_drivers[i]->driver;
|
||||
const void *drv_ptr = (const void *)drv;
|
||||
#else
|
||||
struct device_driver *drv = &cam_component_i2c_drivers[i]->driver;
|
||||
void *drv_ptr = (void *)drv;
|
||||
#endif
|
||||
start_dev = NULL;
|
||||
while ((match_dev = bus_find_device(&i2c_bus_type,
|
||||
start_dev, drv_ptr, &camera_i2c_compare_dev))) {
|
||||
put_device(start_dev);
|
||||
client = to_i2c_client(match_dev);
|
||||
CAM_DBG(CAM_UTIL, "Adding matched component:%s", client->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;
|
||||
}
|
||||
@@ -366,4 +399,4 @@ int cam_get_ddr_type(void)
|
||||
{
|
||||
return of_fdt_get_ddrtype();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user