@@ -225,15 +225,17 @@ static int gt911_init(const struct device *dev)
225
225
return - ENODEV ;
226
226
}
227
227
228
- if (!gpio_is_ready_dt (& config -> rst_gpio )) {
229
- LOG_ERR ("Reset GPIO controller device not ready" );
230
- return - ENODEV ;
231
- }
228
+ if (config -> rst_gpio .port != NULL ) {
229
+ if (!gpio_is_ready_dt (& config -> rst_gpio )) {
230
+ LOG_ERR ("Reset GPIO controller device not ready" );
231
+ return - ENODEV ;
232
+ }
232
233
233
- r = gpio_pin_configure_dt (& config -> rst_gpio , GPIO_OUTPUT_ACTIVE );
234
- if (r < 0 ) {
235
- LOG_ERR ("Could not configure reset GPIO pin" );
236
- return r ;
234
+ r = gpio_pin_configure_dt (& config -> rst_gpio , GPIO_OUTPUT_ACTIVE );
235
+ if (r < 0 ) {
236
+ LOG_ERR ("Could not configure reset GPIO pin" );
237
+ return r ;
238
+ }
237
239
}
238
240
239
241
if (config -> alt_addr == 0x0 ) {
@@ -252,13 +254,15 @@ static int gt911_init(const struct device *dev)
252
254
}
253
255
/* Delay at least 10 ms after power on before we configure gt911 */
254
256
k_sleep (K_MSEC (20 ));
255
- /* reset the device and confgiure the addr mode0 */
256
- gpio_pin_set_dt (& config -> rst_gpio , 1 );
257
- /* hold down at least 1us, 1ms here */
258
- k_sleep (K_MSEC (1 ));
259
- gpio_pin_set_dt (& config -> rst_gpio , 0 );
260
- /* hold down at least 5ms. This is the point the INT pin must be low. */
261
- k_sleep (K_MSEC (5 ));
257
+ if (config -> rst_gpio .port != NULL ) {
258
+ /* reset the device and confgiure the addr mode0 */
259
+ gpio_pin_set_dt (& config -> rst_gpio , 1 );
260
+ /* hold down at least 1us, 1ms here */
261
+ k_sleep (K_MSEC (1 ));
262
+ gpio_pin_set_dt (& config -> rst_gpio , 0 );
263
+ /* hold down at least 5ms. This is the point the INT pin must be low. */
264
+ k_sleep (K_MSEC (5 ));
265
+ }
262
266
/* hold down 50ms to make sure the address available */
263
267
k_sleep (K_MSEC (50 ));
264
268
@@ -359,7 +363,7 @@ static int gt911_init(const struct device *dev)
359
363
#define GT911_INIT (index ) \
360
364
static const struct gt911_config gt911_config_##index = { \
361
365
.bus = I2C_DT_SPEC_INST_GET(index), \
362
- .rst_gpio = GPIO_DT_SPEC_INST_GET (index, reset_gpios), \
366
+ .rst_gpio = GPIO_DT_SPEC_INST_GET_OR (index, reset_gpios, {0} ), \
363
367
.int_gpio = GPIO_DT_SPEC_INST_GET(index, irq_gpios), \
364
368
.alt_addr = DT_INST_PROP_OR(index, alt_addr, 0), \
365
369
}; \
0 commit comments