|
10 | 10 | #include <zephyr/drivers/display.h>
|
11 | 11 | #include <zephyr/drivers/mipi_dsi.h>
|
12 | 12 | #include <zephyr/drivers/gpio.h>
|
| 13 | +#include <zephyr/pm/device.h> |
13 | 14 | #include <zephyr/sys/byteorder.h>
|
14 | 15 | #include <zephyr/logging/log.h>
|
15 | 16 |
|
@@ -357,6 +358,26 @@ static void st7701_get_capabilities(const struct device *dev,
|
357 | 358 | capabilities->current_orientation = data->orientation;
|
358 | 359 | }
|
359 | 360 |
|
| 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 | + |
360 | 381 | static DEVICE_API(display, st7701_api) = {
|
361 | 382 | .blanking_on = st7701_blanking_on,
|
362 | 383 | .blanking_off = st7701_blanking_off,
|
@@ -487,7 +508,8 @@ static int st7701_init(const struct device *dev)
|
487 | 508 | static struct st7701_data st7701_data_##inst = { \
|
488 | 509 | .dsi_pixel_format = DT_INST_PROP(inst, pixel_format), \
|
489 | 510 | }; \
|
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,\ |
491 | 513 | &st7701_config_##inst, POST_KERNEL, \
|
492 | 514 | CONFIG_DISPLAY_INIT_PRIORITY, &st7701_api);
|
493 | 515 |
|
|
0 commit comments