1 From d644270369cc6bf39012cce735dde6b86ad01424 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 18 Sep 2024 16:09:28 +0100
4 Subject: [PATCH 1273/1350] drm: panel: ili9881: Add option to reconfigure
7 The driver is typically asking for LP commands, but then tries
8 to send set_display_[on|off] from enable/disable when the host
10 It also sends shutdown commands just before it asserts reset and
11 disables the regulator, which is rather redundant.
13 Add an option to configure these two choices from the panel_desc.
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 32 ++++++++++++++++---
18 1 file changed, 28 insertions(+), 4 deletions(-)
20 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
21 +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
22 @@ -40,12 +40,19 @@ struct ili9881c_instr {
26 +enum ili9881_desc_flags {
27 + ILI9881_FLAGS_NO_SHUTDOWN_CMDS = BIT(0),
28 + ILI9881_FLAGS_PANEL_ON_IN_PREPARE = BIT(1),
29 + ILI9881_FLAGS_MAX = BIT(31),
32 struct ili9881c_desc {
33 const struct ili9881c_instr *init;
34 const size_t init_length;
35 const struct drm_display_mode *mode;
36 const unsigned long mode_flags;
38 + enum ili9881_desc_flags flags;
42 @@ -1727,6 +1734,12 @@ static int ili9881c_prepare(struct drm_p
46 + if (ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE) {
49 + ret = mipi_dsi_dcs_set_display_on(ctx->dsi);
55 @@ -1734,9 +1747,11 @@ static int ili9881c_enable(struct drm_pa
57 struct ili9881c *ctx = panel_to_ili9881c(panel);
60 + if (!(ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE)) {
63 - mipi_dsi_dcs_set_display_on(ctx->dsi);
64 + mipi_dsi_dcs_set_display_on(ctx->dsi);
69 @@ -1745,7 +1760,8 @@ static int ili9881c_disable(struct drm_p
71 struct ili9881c *ctx = panel_to_ili9881c(panel);
73 - mipi_dsi_dcs_set_display_off(ctx->dsi);
74 + if (!(ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE))
75 + mipi_dsi_dcs_set_display_off(ctx->dsi);
79 @@ -1754,7 +1770,13 @@ static int ili9881c_unprepare(struct drm
81 struct ili9881c *ctx = panel_to_ili9881c(panel);
83 - mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
84 + if (!(ctx->desc->flags & ILI9881_FLAGS_NO_SHUTDOWN_CMDS)) {
85 + if (ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE)
86 + mipi_dsi_dcs_set_display_off(ctx->dsi);
88 + mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
91 regulator_disable(ctx->power);
92 gpiod_set_value_cansleep(ctx->reset, 1);
94 @@ -2066,6 +2088,8 @@ static const struct ili9881c_desc rpi_7i
95 .mode = &rpi_7inch_default_mode,
96 .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM,
98 + .flags = ILI9881_FLAGS_NO_SHUTDOWN_CMDS |
99 + ILI9881_FLAGS_PANEL_ON_IN_PREPARE,
102 static const struct of_device_id ili9881c_of_match[] = {