Skip to contentSkip to conversation

drm/panel: sitronix-st7789v: Convert to mipi_dbi

PATCH In review Chen-Yu Tsai 2 participants 4 messages Feb 17 – Feb 18

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/panel: sitronix-st7789v: Convert to mipi_dbi

Hi folks,

This small series converts the st7789v panel to use the mipi-dbi helpers for register access.

Originally I intended to also add tinydrm support. My purpose was just to test a TFT module that is on the Avaota A1 board. Archit is interested in working on this driver, and I already used his/her previous patch to check that my TFT was sort of working, albeit probably with the wrong internal parameters. So this series will serve as a base for that work.

Patch 1 adds an option to invert the reset GPIO logic in the mipi-dbi helpers. The reset logic originally assumes "high" is out of reset, so an "enable" GPIO rather than a "reset" GPIO. However the st7789v drivers assumes the proper "reset" GPIO logic.

Patch 2 converts all SPI register accesses in the st7789v to use the mipi_dbi helpers. This actually reduces the number of function calls, as the command and data portions of each message are combined. This conversion also lets the driver support 8-bit plus D/C GPIO transfers.

This series is unfortunately only compile tested, as I do not have an st7789v panel that is wired up for RGB input. So please help test the changes.

Thanks
ChenYu

Changes since v1:
- Fix compile error from half changed reset GPIO handling

Chen-Yu Tsai (2):
drm/mipi-dbi: Provide option to invert reset GPIO logic drm/panel: sitronix-st7789v: Convert to mipi_dbi

 drivers/gpu/drm/drm_mipi_dbi.c                |   4 +-
 drivers/gpu/drm/panel/Kconfig                 |   1 +
 .../gpu/drm/panel/panel-sitronix-st7789v.c    | 306 +++++++-----------
 include/drm/drm_mipi_dbi.h                    |   9 +
 4 files changed, 121 insertions(+), 199 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/2 drm/mipi-dbi: Provide option to invert reset GPIO logic

When mipi_dbi (tinydrm) was added, the reset handling assumed that "logic high" or "active" was out of reset, while "logic low" or "inactive" was in reset. This is the opposite of how many reset bindings are written, wherein "active" means the reset is active, i.e the device is put or held in reset.

Provide an option to invert the logic so that drivers for bindings with "active is in reset" using mipi_dbi can use the common reset handling.

---
 drivers/gpu/drm/drm_mipi_dbi.c | 4 ++--
 include/drm/drm_mipi_dbi.h     | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_mipi_dbi.c +2 -2
index 00482227a9cd..7fa1f73a38a4 100644
@@ -713,9 +713,9 @@ void mipi_dbi_hw_reset(struct mipi_dbi *dbi)
 	if (!dbi->reset)
 		return;
 
-	gpiod_set_value_cansleep(dbi->reset, 0);
+	gpiod_set_value_cansleep(dbi->reset, dbi->invert_reset ? 1 : 0);
 	usleep_range(20, 1000);
-	gpiod_set_value_cansleep(dbi->reset, 1);
+	gpiod_set_value_cansleep(dbi->reset, dbi->invert_reset ? 0 : 1);
 	msleep(120);
 }
 EXPORT_SYMBOL(mipi_dbi_hw_reset);
include/drm/drm_mipi_dbi.h +9 -0
index f45f9612c0bc..6cebf74bcecc 100644
@@ -44,6 +44,15 @@ struct mipi_dbi {
 	 */
 	bool swap_bytes;
 
+	/**
+	 * @invert_reset: Invert reset logic level.
+	 *
+	 * This is needed as drm_mipi_dbi (formerly tinydrm) introduced reset
+	 * GPIO controls with "logic high" being "out of reset", while other
+	 * bindings typically have "logic high" as "in reset".
+	 */
+	bool invert_reset;
+
 	/**
 	 * @reset: Optional reset gpio
 	 */
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 2/2 drm/panel: sitronix-st7789v: Convert to mipi_dbi

In reply to Chen-Yu Tsai

The wire protocol of the ST7789V is basically MIPI DBI. Switch to the mipi_dbi helpers to reduce some code. This also ends up adding support for 8-bit D/C mode. The reset logic in the mipi_dbi helpers is also used.

While at it, also clean up st7789v_check_id() to use ST7789V_IDS_SIZE to declare the ids array size and sizeof(ids) where the size is needed.

---
Changes since v1:
- Fix compile error from half changed reset GPIO handling

---
 drivers/gpu/drm/panel/Kconfig                 |   1 +
 .../gpu/drm/panel/panel-sitronix-st7789v.c    | 306 +++++++-----------
 2 files changed, 110 insertions(+), 197 deletions(-)
drivers/gpu/drm/panel/Kconfig +1 -0
index 307152ad7759..64325874d3e2 100644
@@ -1011,6 +1011,7 @@ config DRM_PANEL_SITRONIX_ST7789V
 	tristate "Sitronix ST7789V panel"
 	depends on OF && SPI
 	depends on BACKLIGHT_CLASS_DEVICE
+	select DRM_MIPI_DBI
 	help
 	  Say Y here if you want to enable support for the Sitronix
 	  ST7789V controller for 240x320 LCD panels
drivers/gpu/drm/panel/panel-sitronix-st7789v.c +109 -197

418 lines not on this page · raw message

Signature · 1 line
2.47.3
#3 lore raw
In reply to Chen-Yu Tsai
Quoted 23 lines · Chen-Yu Tsai

Hi folks,

This small series converts the st7789v panel to use the mipi-dbi helpers for register access.

Originally I intended to also add tinydrm support. My purpose was just to test a TFT module that is on the Avaota A1 board. Archit is interested in working on this driver, and I already used his/her previous patch to check that my TFT was sort of working, albeit probably with the wrong internal parameters. So this series will serve as a base for that work.

Patch 1 adds an option to invert the reset GPIO logic in the mipi-dbi helpers. The reset logic originally assumes "high" is out of reset, so an "enable" GPIO rather than a "reset" GPIO. However the st7789v drivers assumes the proper "reset" GPIO logic.

Patch 2 converts all SPI register accesses in the st7789v to use the mipi_dbi helpers. This actually reduces the number of function calls, as the command and data portions of each message are combined. This conversion also lets the driver support 8-bit plus D/C GPIO transfers.

Quoted 8 lines

This series is unfortunately only compile tested, as I do not have an st7789v panel that is wired up for RGB input. So please help test the changes.

Thanks
ChenYu

Hi ChenYu,

Thank you for sharing the series.

I’ll focus on completing the transition to the mipi_dbi helpers, ensuring the reset
handling works correctly with the optional logic inversion, and updating st7789v_check_id() to use ST7789V_IDS_SIZE and sizeof(ids) as discussed.

Although I don’t have access to the hardware, I’ll make sure the series builds cleanly and review the changes carefully. I’ll also verify that the 8-bit SPI + D/C
GPIO configuration is handled correctly at the driver level.

--
Sincerely,
Archit Anant