drivers: video: change initialization order of CSI and cameras

video_mcux_csi_init, which setups the CSI pins (i.e: calls
pinctrl_apply_state) was called after mt9m114_init which tries to do i2c
communication with the camera to read the chip id. But since one of the
CSI pins is the camera master clock, doing things in this order won't
work. This PR inverts the order in which the devices are initialized.

Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
Michele Balistreri 2022-12-29 12:11:53 +01:00 committed by David Leach
parent b72b99f49a
commit f87313bf0f
4 changed files with 13 additions and 6 deletions

View file

@ -15,7 +15,7 @@ if VIDEO
config VIDEO_INIT_PRIORITY
int "Video initialization priority"
default 90
default 60
help
System initialization priority for video drivers.

View file

@ -409,6 +409,6 @@ static int mt9m114_init_0(const struct device *dev)
DEVICE_DT_INST_DEFINE(0, &mt9m114_init_0, NULL,
&mt9m114_data_0, &mt9m114_cfg_0,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY,
&mt9m114_driver_api);
#endif

View file

@ -645,5 +645,5 @@ static int ov7725_init_0(const struct device *dev)
DEVICE_DT_INST_DEFINE(0, &ov7725_init_0, NULL,
&ov7725_data_0, &ov7725_cfg_0,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY,
&ov7725_driver_api);

View file

@ -369,8 +369,10 @@ static int video_mcux_csi_init(const struct device *dev)
CSI_GetDefaultConfig(&data->csi_config);
/* check if there is any sensor device (video ctrl device) */
if (!device_is_ready(config->sensor_dev)) {
/* check if there is any sensor device (video ctrl device)
* the device is not yet initialized so we only check if it exists
*/
if (config->sensor_dev == NULL) {
return -ENODEV;
}
@ -440,9 +442,14 @@ static int video_mcux_csi_init_0(const struct device *dev)
return video_mcux_csi_init(dev);
}
/* CONFIG_KERNEL_INIT_PRIORITY_DEVICE is used to make sure the
* CSI peripheral is initialized before the camera, which is
* necessary since the clock to the camera is provided by the
* CSI peripheral.
*/
DEVICE_DT_INST_DEFINE(0, &video_mcux_csi_init_0,
NULL, &video_mcux_csi_data_0,
&video_mcux_csi_config_0,
POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&video_mcux_csi_driver_api);
#endif