Skip to content

Commit 5b2e2af

Browse files
pdgendtcfriedt
authored andcommitted
drivers: display: st7701: Add PM actions
Add resume/suspend power management actions. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 7c9275c commit 5b2e2af

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/display/display_st7701.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <zephyr/drivers/display.h>
1111
#include <zephyr/drivers/mipi_dsi.h>
1212
#include <zephyr/drivers/gpio.h>
13+
#include <zephyr/pm/device.h>
1314
#include <zephyr/sys/byteorder.h>
1415
#include <zephyr/logging/log.h>
1516

@@ -357,6 +358,26 @@ static void st7701_get_capabilities(const struct device *dev,
357358
capabilities->current_orientation = data->orientation;
358359
}
359360

361+
#ifdef CONFIG_PM_DEVICE
362+
static int st7701_pm_action(const struct device *dev, enum pm_device_action action)
363+
{
364+
int ret;
365+
366+
switch (action) {
367+
case PM_DEVICE_ACTION_RESUME:
368+
ret = st7701_dcs_write(dev, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
369+
break;
370+
case PM_DEVICE_ACTION_SUSPEND:
371+
ret = st7701_dcs_write(dev, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0);
372+
break;
373+
default:
374+
return -ENOTSUP;
375+
}
376+
377+
return ret;
378+
}
379+
#endif
380+
360381
static DEVICE_API(display, st7701_api) = {
361382
.blanking_on = st7701_blanking_on,
362383
.blanking_off = st7701_blanking_off,
@@ -487,7 +508,8 @@ static int st7701_init(const struct device *dev)
487508
static struct st7701_data st7701_data_##inst = { \
488509
.dsi_pixel_format = DT_INST_PROP(inst, pixel_format), \
489510
}; \
490-
DEVICE_DT_INST_DEFINE(inst, &st7701_init, NULL, &st7701_data_##inst, \
511+
PM_DEVICE_DT_INST_DEFINE(inst, st7701_pm_action); \
512+
DEVICE_DT_INST_DEFINE(inst, &st7701_init, PM_DEVICE_DT_INST_GET(inst), &st7701_data_##inst,\
491513
&st7701_config_##inst, POST_KERNEL, \
492514
CONFIG_DISPLAY_INIT_PRIORITY, &st7701_api);
493515

0 commit comments

Comments
 (0)