@@ -28,7 +28,9 @@ LOG_MODULE_REGISTER(video_imx335, CONFIG_VIDEO_LOG_LEVEL);
28
28
29
29
struct imx335_config {
30
30
struct i2c_dt_spec i2c ;
31
+ #if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
31
32
struct gpio_dt_spec reset_gpio ;
33
+ #endif
32
34
uint32_t input_clk ;
33
35
};
34
36
@@ -445,26 +447,27 @@ static int imx335_init(const struct device *dev)
445
447
return - ENODEV ;
446
448
}
447
449
448
- if (!gpio_is_ready_dt (& cfg -> reset_gpio )) {
449
- LOG_ERR ("%s: device %s is not ready" , dev -> name , cfg -> reset_gpio .port -> name );
450
- return - ENODEV ;
451
- }
450
+ #if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
451
+ if (cfg -> reset_gpio .port != NULL ) {
452
+ if (!gpio_is_ready_dt (& cfg -> reset_gpio )) {
453
+ LOG_ERR ("%s: device %s is not ready" , dev -> name ,
454
+ cfg -> reset_gpio .port -> name );
455
+ return - ENODEV ;
456
+ }
452
457
453
- /* Power up sequence */
454
- if (cfg -> reset_gpio .port ) {
458
+ /* Power up sequence */
455
459
ret = gpio_pin_configure_dt (& cfg -> reset_gpio , GPIO_OUTPUT_ACTIVE );
456
460
if (ret ) {
457
461
return ret ;
458
462
}
459
- }
460
463
461
- k_sleep (K_NSEC (500 )); /* Tlow */
464
+ k_sleep (K_NSEC (500 )); /* Tlow */
462
465
463
- if (cfg -> reset_gpio .port ) {
464
466
gpio_pin_set_dt (& cfg -> reset_gpio , 0 );
465
- }
466
467
467
- k_sleep (K_USEC (600 )); /* T4 */
468
+ k_sleep (K_USEC (600 )); /* T4 */
469
+ }
470
+ #endif
468
471
469
472
/* Initialize register values */
470
473
ret = video_write_cci_multiregs (& cfg -> i2c , imx335_init_params ,
@@ -499,6 +502,12 @@ static int imx335_init(const struct device *dev)
499
502
return imx335_init_controls (dev );
500
503
}
501
504
505
+ #if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
506
+ #define IMX335_GET_RESET_GPIO (n ) .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}),
507
+ #else
508
+ #define IMX335_GET_RESET_GPIO (n )
509
+ #endif
510
+
502
511
#define IMX335_INIT (n ) \
503
512
static struct imx335_data imx335_data_##n = { \
504
513
.fmt = { \
@@ -509,7 +518,7 @@ static int imx335_init(const struct device *dev)
509
518
}; \
510
519
static const struct imx335_config imx335_cfg_##n = { \
511
520
.i2c = I2C_DT_SPEC_INST_GET(n), \
512
- .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}), \
521
+ IMX335_GET_RESET_GPIO(n) \
513
522
.input_clk = DT_INST_PROP_BY_PHANDLE(n, clocks, clock_frequency), \
514
523
}; \
515
524
\
0 commit comments