Skip to content

Commit d34ed32

Browse files
AnElderlyFoxkartben
authored andcommitted
drivers: display: elcdif: remove backlight enable pin dependency
The driver no longer requires a backlight enable GPIO pin to be defined, which allows compatibility with displays that do not provide such a pin. Signed-off-by: Isaev Denis <anelderlyfox@yahoo.com>
1 parent a250e91 commit d34ed32

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

drivers/display/display_mcux_elcdif.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,26 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u
224224

225225
static int mcux_elcdif_display_blanking_off(const struct device *dev)
226226
{
227+
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpio)
227228
const struct mcux_elcdif_config *config = dev->config;
229+
if (config->backlight_gpio.port) {
230+
return gpio_pin_set_dt(&config->backlight_gpio, 1);
231+
}
232+
#endif /* DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpio) */
228233

229-
return gpio_pin_set_dt(&config->backlight_gpio, 1);
234+
return -ENOSYS;
230235
}
231236

232237
static int mcux_elcdif_display_blanking_on(const struct device *dev)
233238
{
239+
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpio)
234240
const struct mcux_elcdif_config *config = dev->config;
241+
if (config->backlight_gpio.port) {
242+
return gpio_pin_set_dt(&config->backlight_gpio, 0);
243+
}
244+
#endif /* DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpio) */
235245

236-
return gpio_pin_set_dt(&config->backlight_gpio, 0);
246+
return -ENOSYS;
237247
}
238248

239249
static int mcux_elcdif_set_pixel_format(const struct device *dev,
@@ -328,10 +338,14 @@ static int mcux_elcdif_init(const struct device *dev)
328338
return err;
329339
}
330340

331-
err = gpio_pin_configure_dt(&config->backlight_gpio, GPIO_OUTPUT_ACTIVE);
332-
if (err) {
333-
return err;
341+
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpio)
342+
if (config->backlight_gpio.port) {
343+
err = gpio_pin_configure_dt(&config->backlight_gpio, GPIO_OUTPUT_ACTIVE);
344+
if (err) {
345+
return err;
346+
}
334347
}
348+
#endif /* DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios) */
335349

336350
k_sem_init(&dev_data->sem, 0, 1);
337351
#ifdef CONFIG_MCUX_ELCDIF_PXP
@@ -398,9 +412,9 @@ static DEVICE_API(display, mcux_elcdif_api) = {
398412
DT_INST_ENUM_IDX(id, data_bus_width)), \
399413
}, \
400414
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), \
401-
.backlight_gpio = GPIO_DT_SPEC_INST_GET(id, backlight_gpios), \
415+
.backlight_gpio = GPIO_DT_SPEC_INST_GET_OR(id, backlight_gpios, {0}), \
402416
IF_ENABLED(CONFIG_MCUX_ELCDIF_PXP, \
403-
(.pxp = DEVICE_DT_GET(DT_INST_PHANDLE(id, nxp_pxp)),))}; \
417+
(.pxp = DEVICE_DT_GET(DT_INST_PHANDLE(id, nxp_pxp)),))}; \
404418
static struct mcux_elcdif_data mcux_elcdif_data_##id = { \
405419
.next_idx = 0, \
406420
.pixel_format = DT_INST_PROP(id, pixel_format), \

dts/bindings/display/nxp,imx-elcdif.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ properties:
2727

2828
backlight-gpios:
2929
type: phandle-array
30-
required: true
3130
description:
3231
LCB backlight control gpio. Driver will initialize this GPIO to active high
3332

0 commit comments

Comments
 (0)