16329253b947e3a3d990a1c9fe541faa2b839a41
[openwrt/staging/pepe2k.git] /
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
5 setup commands
6
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
9 will be in HS mode.
10 It also sends shutdown commands just before it asserts reset and
11 disables the regulator, which is rather redundant.
12
13 Add an option to configure these two choices from the panel_desc.
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 ---
17 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 32 ++++++++++++++++---
18 1 file changed, 28 insertions(+), 4 deletions(-)
19
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 {
23 } arg;
24 };
25
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),
30 +};
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;
37 unsigned int lanes;
38 + enum ili9881_desc_flags flags;
39 };
40
41 struct ili9881c {
42 @@ -1727,6 +1734,12 @@ static int ili9881c_prepare(struct drm_p
43 if (ret)
44 return ret;
45
46 + if (ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE) {
47 + msleep(120);
48 +
49 + ret = mipi_dsi_dcs_set_display_on(ctx->dsi);
50 + }
51 +
52 return 0;
53 }
54
55 @@ -1734,9 +1747,11 @@ static int ili9881c_enable(struct drm_pa
56 {
57 struct ili9881c *ctx = panel_to_ili9881c(panel);
58
59 - msleep(120);
60 + if (!(ctx->desc->flags & ILI9881_FLAGS_PANEL_ON_IN_PREPARE)) {
61 + msleep(120);
62
63 - mipi_dsi_dcs_set_display_on(ctx->dsi);
64 + mipi_dsi_dcs_set_display_on(ctx->dsi);
65 + }
66
67 return 0;
68 }
69 @@ -1745,7 +1760,8 @@ static int ili9881c_disable(struct drm_p
70 {
71 struct ili9881c *ctx = panel_to_ili9881c(panel);
72
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);
76
77 return 0;
78 }
79 @@ -1754,7 +1770,13 @@ static int ili9881c_unprepare(struct drm
80 {
81 struct ili9881c *ctx = panel_to_ili9881c(panel);
82
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);
87 +
88 + mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
89 + }
90 +
91 regulator_disable(ctx->power);
92 gpiod_set_value_cansleep(ctx->reset, 1);
93
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,
97 .lanes = 2,
98 + .flags = ILI9881_FLAGS_NO_SHUTDOWN_CMDS |
99 + ILI9881_FLAGS_PANEL_ON_IN_PREPARE,
100 };
101
102 static const struct of_device_id ili9881c_of_match[] = {