Created
April 9, 2025 18:12
-
-
Save hlord2000/aec118861a5702c9e9c3269fdb458844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/display/ssd16xx.c b/drivers/display/ssd16xx.c | |
index 7dfaa121177..d6229c34b88 100644 | |
--- a/drivers/display/ssd16xx.c | |
+++ b/drivers/display/ssd16xx.c | |
@@ -16,6 +16,8 @@ LOG_MODULE_REGISTER(ssd16xx); | |
#include <zephyr/init.h> | |
#include <zephyr/drivers/gpio.h> | |
#include <zephyr/drivers/mipi_dbi.h> | |
+#include <zephyr/pm/device.h> | |
+#include <zephyr/pm/device_runtime.h> | |
#include <zephyr/sys/byteorder.h> | |
#include <zephyr/display/ssd16xx.h> | |
@@ -756,10 +758,12 @@ static int ssd16xx_set_profile(const struct device *dev, | |
* Perform a soft reset to make sure registers are reset. This | |
* will leave the RAM contents intact. | |
*/ | |
+ /* | |
err = ssd16xx_write_cmd(dev, SSD16XX_CMD_SW_RESET, NULL, 0); | |
if (err < 0) { | |
return err; | |
} | |
+ */ | |
gdo_len = push_y_param(dev, gdo, last_gate); | |
gdo[gdo_len++] = 0U; | |
@@ -863,6 +867,15 @@ static int ssd16xx_controller_init(const struct device *dev) | |
k_msleep(SSD16XX_RESET_DELAY); | |
+ /* | |
+ err = ssd16xx_write_cmd(config->mipi_dev, SSD16XX_CMD_SW_RESET, NULL, 0); | |
+ if (err < 0) { | |
+ return err; | |
+ } | |
+ | |
+ k_msleep(SSD16XX_RESET_DELAY); | |
+ */ | |
+ | |
err = ssd16xx_set_profile(dev, SSD16XX_PROFILE_FULL); | |
if (err < 0) { | |
return err; | |
@@ -937,6 +950,38 @@ static int ssd16xx_init(const struct device *dev) | |
return ssd16xx_controller_init(dev); | |
} | |
+#ifdef CONFIG_PM_DEVICE | |
+static int ssd16xx_pm_action(const struct device *dev, | |
+ enum pm_device_action action) | |
+{ | |
+ int err = 0; | |
+ const struct ssd16xx_config *config = dev->config; | |
+ | |
+ switch (action) { | |
+ case PM_DEVICE_ACTION_RESUME: | |
+ err = ssd16xx_controller_init(dev); | |
+ if (err < 0) { | |
+ return err; | |
+ } | |
+ break; | |
+ | |
+ case PM_DEVICE_ACTION_SUSPEND: | |
+ err = ssd16xx_write_uint8(dev, SSD16XX_CMD_SLEEP_MODE, 0x01); | |
+ if (err < 0) { | |
+ return err; | |
+ } | |
+ | |
+ k_msleep(SSD16XX_BUSY_DELAY); | |
+ break; | |
+ | |
+ default: | |
+ err = -ENOTSUP; | |
+ } | |
+ | |
+ return err; | |
+} | |
+#endif /* CONFIG_PM_DEVICE */ | |
+ | |
static const struct display_driver_api ssd16xx_driver_api = { | |
.blanking_on = ssd16xx_blanking_on, | |
.blanking_off = ssd16xx_blanking_off, | |
@@ -1075,14 +1120,16 @@ static struct ssd16xx_quirks quirks_solomon_ssd1681 = { | |
\ | |
static struct ssd16xx_data ssd16xx_data_ ## n; \ | |
\ | |
+ PM_DEVICE_DT_DEFINE(n, ssd16xx_pm_action); \ | |
DEVICE_DT_DEFINE(n, \ | |
- ssd16xx_init, NULL, \ | |
+ ssd16xx_init, PM_DEVICE_DT_GET(n), \ | |
&ssd16xx_data_ ## n, \ | |
&ssd16xx_cfg_ ## n, \ | |
POST_KERNEL, \ | |
CONFIG_DISPLAY_INIT_PRIORITY, \ | |
&ssd16xx_driver_api) | |
+ | |
DT_FOREACH_STATUS_OKAY_VARGS(solomon_ssd1608, SSD16XX_DEFINE, | |
&quirks_solomon_ssd1608); | |
DT_FOREACH_STATUS_OKAY_VARGS(solomon_ssd1673, SSD16XX_DEFINE, | |
diff --git a/drivers/display/ssd16xx_regs.h b/drivers/display/ssd16xx_regs.h | |
index 7202109b798..c3578d5df36 100644 | |
--- a/drivers/display/ssd16xx_regs.h | |
+++ b/drivers/display/ssd16xx_regs.h | |
@@ -78,7 +78,8 @@ | |
#define SSD16XX_GEN2_CTRL2_MODE2 0x08 | |
#define SSD16XX_GEN2_CTRL2_DISPLAY 0x04 | |
-#define SSD16XX_SLEEP_MODE_DSM 0x01 | |
+#define SSD16XX_SLEEP_MODE_DSM_1 0x01 | |
+#define SSD16XX_SLEEP_MODE_DSM_2 0x03 | |
#define SSD16XX_SLEEP_MODE_PON 0x00 | |
#define SSD16XX_RAM_READ_CTRL_BLACK 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment