Skip to contentSkip to conversation

Add support for Sitronix ST7571 LCD controller

PATCH Superseded Marcus Folkesson 2 participants 5 messages Apr 23, 2025

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Marcus Folkesson

author maintainer
#0 lore raw

v5 cover Add support for Sitronix ST7571 LCD controller

This series add support for the ST7571 LCD Controller.
It is a 4 gray scale dot matrix LCD controller that supports several interfaces such as SPI, I2C and a 8bit parallell port. The controlelr supports both monochrome and grayscale displays.

This driver only supports the I2C interface, but all common parts could easily be put into a common file to be used with other interfaces. I only have I2C to test with.

The device is a little defiant, it tends to NAK some commands, but all commands takes effect, hence the I2C_M_IGNORE_NAK flag.

---
Changes in v5:
- Use bitfield macros where appropriate
- Add comments where needed
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- (dt-binding) Add sitronix,grayscale property
- Describe why ignore_nack may be needed
- Make drm_to_st7571 an inline function
- Add support to clear screen
- Change from C2 to R2
- Add support for XRGB8888
- Use dev_err_probe() where appropriate
- Make Kconfig config depend on MMU
- Introduce device data to prepare for support for other chips
- Add support for drm_encoder_helper_funcs.atomic_en(dis)able
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- (dt-binding) Use 'Controller' rather than 'Panel' in texts
- (dt-binding) Constrain the reg property
- (dt-binding) Remove panel-timing description
- (dt-binding) Change description
- Mostly cosmetic changes in the driver code
- Don't call drm_atomic_helper_shutdown() in remove()
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Reworked pretty much the whole driver to not use obsolete code.
- Use panel and timing bindings to specify resolution and panel size
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Marcus Folkesson (3):
dt-bindings: display: Add Sitronix ST7571 LCD Controller drm/st7571-i2c: add support for Sitronix ST7571 LCD controller
MAINTAINERS: add entry for Sitronix ST7571 LCD Controller

 .../bindings/display/sitronix,st7571.yaml          |   73 ++
 MAINTAINERS                                        |    6 +
 drivers/gpu/drm/tiny/Kconfig                       |   11 +
 drivers/gpu/drm/tiny/Makefile                      |    1 +
 drivers/gpu/drm/tiny/st7571-i2c.c                  | 1007 ++++++++++++++++++++
 5 files changed, 1098 insertions(+)

---
base-commit: 1e26c5e28ca5821a824e90dd359556f5e9e7b89f
change-id: 20250401-st7571-9382b9cfc03f

Best regards,

Signature · 1 line
Marcus Folkesson <[email protected]>
author maintainer
#1 lore raw

PATCH v5 1/3 dt-bindings: display: Add Sitronix ST7571 LCD Controller

Sitronix ST7571 is a dot matrix LCD controller supporting both 4bit grayscale and monochrome LCDs.

---
 .../bindings/display/sitronix,st7571.yaml          | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)
Documentation/devicetree/bindings/display/sitronix,st7571.yaml new file +73 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4fea782fccd701f5095a08290c13722a12a58b52
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/sitronix,st7571.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sitronix ST7571 Display Controller
+
+maintainers:
+  - Marcus Folkesson <[email protected]>
+
+description:
+  Sitronix ST7571 is a driver and controller for 4-level gray
+  scale and monochrome dot matrix LCD panels.
+
+allOf:
+  - $ref: panel/panel-common.yaml#
+
+properties:
+  compatible:
+    const: sitronix,st7571
+
+  reg:
+    maxItems: 1
+
+  sitronix,grayscale:
+    type: boolean
+    description:
+      Display supports 4-level grayscale.
+
+  reset-gpios: true
+  width-mm: true
+  height-mm: true
+  panel-timing: true
+
+required:
+  - compatible
+  - reg
+  - reset-gpios
+  - width-mm
+  - height-mm
+  - panel-timing
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      display@3f {
+        compatible = "sitronix,st7571";
+        reg = <0x3f>;
+        reset-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
+        width-mm = <37>;
+        height-mm = <27>;
+
+        panel-timing {
+          hactive = <128>;
+          vactive = <96>;
+          hback-porch = <0>;
+          vback-porch = <0>;
+          clock-frequency = <0>;
+          hfront-porch = <0>;
+          hsync-len = <0>;
+          vfront-porch = <0>;
+          vsync-len = <0>;
+        };
+      };
+    };
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v5 2/3 drm/st7571-i2c: add support for Sitronix ST7571 LCD controller

In reply to Marcus Folkesson

Sitronix ST7571 is a 4bit gray scale dot matrix LCD controller. The controller has a SPI, I2C and 8bit parallel interface, this driver is for the I2C interface only.

---
 drivers/gpu/drm/tiny/Kconfig      |   11 +
 drivers/gpu/drm/tiny/Makefile     |    1 +
 drivers/gpu/drm/tiny/st7571-i2c.c | 1007 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1019 insertions(+)
drivers/gpu/drm/tiny/Kconfig +11 -0
index 94cbdb1337c07f1628a33599a7130369b9d59d98..e4a55482e3bcd3f6851df1d322a14cbe1f96adfb 100644
@@ -232,6 +232,17 @@ config TINYDRM_ST7586
 
 	  If M is selected the module will be called st7586.
 
+config DRM_ST7571_I2C
+	tristate "DRM support for Sitronix ST7571 display panels (I2C)"
+	depends on DRM && I2C && MMU
+	select DRM_GEM_SHMEM_HELPER
+	select DRM_KMS_HELPER
+	select REGMAP_I2C
+	help
+	  DRM driver for Sitronix ST7571 panels controlled over I2C.
+
+	  if M is selected the module will be called st7571-i2c.
+
 config TINYDRM_ST7735R
 	tristate "DRM support for Sitronix ST7715R/ST7735R display panels"
 	depends on DRM && SPI
drivers/gpu/drm/tiny/Makefile +1 -0
index 60816d2eb4ff93b87228ed8eadd60a0a33a1144b..eab7568c92c880cfdf7c2f0b9c4bfac4685dbe95 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_DRM_OFDRM)			+= ofdrm.o
 obj-$(CONFIG_DRM_PANEL_MIPI_DBI)	+= panel-mipi-dbi.o
 obj-$(CONFIG_DRM_SIMPLEDRM)		+= simpledrm.o
+obj-$(CONFIG_DRM_ST7571_I2C)		+= st7571-i2c.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
 obj-$(CONFIG_TINYDRM_ILI9163)		+= ili9163.o
 obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
drivers/gpu/drm/tiny/st7571-i2c.c new file +1007 -0

1,007 lines not on this page · raw message

Signature · 1 line
2.49.0
#3 lore raw

Re: [PATCH v5 2/3] drm/st7571-i2c: add support for Sitronix ST7571 LCD controller

Marcus Folkesson <[email protected]> writes:

Hello Marcus,

I tried to apply your patches to drm-misc and found some issues, so I will have to ask you to do a final re-spin. Sorry about that...

Quoted 22 lines

Sitronix ST7571 is a 4bit gray scale dot matrix LCD controller. The controller has a SPI, I2C and 8bit parallel interface, this driver is for the I2C interface only.

---
 drivers/gpu/drm/tiny/Kconfig      |   11 +
 drivers/gpu/drm/tiny/Makefile     |    1 +
 drivers/gpu/drm/tiny/st7571-i2c.c | 1007 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1019 insertions(+)
drivers/gpu/drm/tiny/Kconfig +1 -0
index 94cbdb1337c07f1628a33599a7130369b9d59d98..e4a55482e3bcd3f6851df1d322a14cbe1f96adfb 100644
@@ -232,6 +232,17 @@ config TINYDRM_ST7586
 
 	  If M is selected the module will be called st7586.
 
+config DRM_ST7571_I2C

drivers/gpu/drm/tiny/Kconfig config TINYDRM_ST7586 · line 245

Quoted 10 lines
drivers/gpu/drm/tiny/Kconfig +10 -0
+	tristate "DRM support for Sitronix ST7571 display panels (I2C)"
+	depends on DRM && I2C && MMU
+	select DRM_GEM_SHMEM_HELPER
+	select DRM_KMS_HELPER
+	select REGMAP_I2C
+	help
+	  DRM driver for Sitronix ST7571 panels controlled over I2C.
+
+	  if M is selected the module will be called st7571-i2c.
+

checkpatch here complains about:

WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines #144: FILE: drivers/gpu/drm/tiny/Kconfig:215:
+config DRM_ST7571_I2C

+       tristate "DRM support for Sitronix ST7571 display panels (I2C)"                                  
+       depends on DRM && I2C && MMU                                                                     
+       select DRM_GEM_SHMEM_HELPER                                                                      
+       select DRM_KMS_HELPER                                                                                                                                                                                      
+       select REGMAP_I2C
+       help                                                                                             

+ DRM driver for Sitronix ST7571 panels controlled over I2C.

but honestly I think is just silly and your explanation is good enough so you could ignore it if you want.

drivers/gpu/drm/tiny/Makefile obj-$(CONFIG_DRM_GM12U320) += gm12u320.o · line 10

Quoted 12 lines
drivers/gpu/drm/tiny/Kconfig +0 -0
 config TINYDRM_ST7735R
 	tristate "DRM support for Sitronix ST7715R/ST7735R display panels"
 	depends on DRM && SPI
drivers/gpu/drm/tiny/Makefile +1 -0
index 60816d2eb4ff93b87228ed8eadd60a0a33a1144b..eab7568c92c880cfdf7c2f0b9c4bfac4685dbe95 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_DRM_OFDRM)			+= ofdrm.o
 obj-$(CONFIG_DRM_PANEL_MIPI_DBI)	+= panel-mipi-dbi.o
 obj-$(CONFIG_DRM_SIMPLEDRM)		+= simpledrm.o
+obj-$(CONFIG_DRM_ST7571_I2C)		+= st7571-i2c.o

this chunk doesn't apply on top of the drm-misc/drm-next branch [1] due the simpledrm driver being moved out of the tiny directory. Please do a rebase on top of that branch when posting a v6.

[1]: https://gitlab.freedesktop.org/drm/misc/kernel/-/tree/drm-misc-next

[...]

drivers/gpu/drm/tiny/Makefile obj-$(CONFIG_DRM_GM12U320) += gm12u320.o · line 11

Quoted 1 line
drivers/gpu/drm/tiny/Makefile +1 -0
+++ b/drivers/gpu/drm/tiny/st7571-i2c.c

Please run ./scripts/checkpatch.pl --strict -f -- drivers/gpu/drm/tiny/st7571-i2c.c since checkpatch complains about some issues. Other than some style nits, it has some good points IMO. In particular:

[...]

drivers/gpu/drm/tiny/Makefile obj-$(CONFIG_DRM_GM12U320) += gm12u320.o

Quoted 5 lines
drivers/gpu/drm/tiny/Makefile +5 -0
+
+static int st7571_fb_update_rect_grayscale(struct drm_framebuffer *fb, struct drm_rect *rect)
+{
+	struct st7571_device *st7571 = drm_to_st7571(fb->dev);
+	uint32_t format = fb->format->format;

CHECK: Prefer kernel type 'u32' over 'uint32_t' #523: FILE: drivers/gpu/drm/tiny/st7571-i2c.c:348:
+ uint32_t format = fb->format->format;

[...]

drivers/gpu/drm/tiny/Makefile

Quoted 5 lines
drivers/gpu/drm/tiny/Makefile +5 -0
+
+static const uint64_t st7571_primary_plane_fmtmods[] = {
+	DRM_FORMAT_MOD_LINEAR,
+	DRM_FORMAT_MOD_INVALID
+};

CHECK: Prefer kernel type 'u64' over 'uint64_t' #611: FILE: drivers/gpu/drm/tiny/st7571-i2c.c:436:
+static const uint64_t st7571_primary_plane_fmtmods[] = {

[...]

drivers/gpu/drm/tiny/Makefile

Quoted 4 lines
drivers/gpu/drm/tiny/Makefile +4 -0
+static void st7571_reset(struct st7571_device *st7571)
+{
+	gpiod_set_value_cansleep(st7571->reset, 1);
+	udelay(20);

CHECK: usleep_range is preferred over udelay; see function description of usleep_range() and udelay(). #993: FILE: drivers/gpu/drm/tiny/st7571-i2c.c:818:
+ udelay(20);

Specially since this is not in atomic context AFAIK. The Delay and sleep mechanisms [2] doc has a good explanation about the different functions provided by the Linux kernel for this.

Feel free to keep my R-B tag if you decide that some of the checkpatch suggestions are applicable. The most important bit for me is the rebase, to allow your patch to be cleanly applied on the drm-misc-next branch.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#4 lore raw

PATCH v5 3/3 MAINTAINERS: add entry for Sitronix ST7571 LCD Controller

In reply to Marcus Folkesson

Add MAINTAINERS entry for the Sitronix ST7571 dot matrix LCD controller.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 889bd4a59551c9bc125f94944a6e1c7e3ef2de83..eeae24fda846b9f63400ebb08c3fa7f02f3f4b19 100644
@@ -7572,6 +7572,12 @@ T:	git https://gitlab.freedesktop.org/drm/misc/kernel.git
 F:	Documentation/devicetree/bindings/display/sitronix,st7586.txt
 F:	drivers/gpu/drm/tiny/st7586.c
 
+DRM DRIVER FOR SITRONIX ST7571 PANELS
+M:	Marcus Folkesson <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/display/sitronix,st7571.yaml
+F:	drivers/gpu/drm/tiny/st7571-i2c.c
+
 DRM DRIVER FOR SITRONIX ST7701 PANELS
 M:	Jagan Teki <[email protected]>
 S:	Maintained
Signature · 1 line
2.49.0