Skip to contentSkip to conversation

Add st7735s drm driver and Winstar panel

PATCH In review Stefan x Nilsson 3 participants 7 messages Sep 6, 2023 – Sep 7, 2023

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

cover Add st7735s drm driver and Winstar panel

Add a new driver for the Sitronix st7735s display controller together with a 0.96" 80x160 color TFT display by Winstar.

The driver is very similar to the st7735r driver, but uses a different pipe_enable sequence and also allows for an optional regulator to be specified using devicetree.

---
Stefan x Nilsson (2):
dt-bindings: display: Add st7735s driver
drm: tiny: Add st7735s driver

 .../bindings/display/sitronix,st7735s.yaml         |  81 +++++++
 MAINTAINERS                                        |   7 +
 drivers/gpu/drm/tiny/Kconfig                       |  14 ++
 drivers/gpu/drm/tiny/Makefile                      |   1 +
 drivers/gpu/drm/tiny/st7735s.c                     | 264 +++++++++++++++++++++
 5 files changed, 367 insertions(+)

---
base-commit: b715dcd3db4a9a57b3fbe7820db37cae930f0867
change-id: 20230825-st7735s-fb9e20e81027

Best regards,

Signature · 1 line
Stefan x Nilsson <[email protected]>
#1 lore raw

PATCH 1/2 dt-bindings: display: Add st7735s driver

Add bindings for a driver for Sitronix st7735s display controller, as well as for a Winstar wf0096atyaa3dnn0 0.96" 80x160 TFT panel.

---
 .../bindings/display/sitronix,st7735s.yaml         | 81 ++++++++++++++++++++++
 MAINTAINERS                                        |  6 ++
 2 files changed, 87 insertions(+)
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +81 -0
new file mode 100644
index 000000000000..36234ec22fe2
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/sitronix,st7735s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sitronix ST7735S Display Panels
+
+maintainers:
+  - Stefan x Nilsson <[email protected]>
+
+description:
+  This binding is for display panels using a Sitronix ST7735S
+  controller in SPI mode.
+
+allOf:
+  - $ref: panel/panel-common.yaml#
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - description:
+          Winstar WF0096ATYAA3DNN0 0.96" 80x160 Color TFT
+        items:
+          - enum:
+              - winstar,wf0096atyaa3dnn0
+          - const: sitronix,st7735s
+
+  dc-gpios:
+    maxItems: 1
+    description: Display data/command selection (D/CX)
+
+  backlight: true
+  reg: true
+  spi-max-frequency: true
+  reset-gpios: true
+  rotation: true
+
+required:
+  - compatible
+  - reg
+  - dc-gpios
+
+additionalProperties: true
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    backlight: backlight {
+            compatible = "gpio-backlight";
+            gpios = <&gpio 44 GPIO_ACTIVE_HIGH>;
+    };
+
+    regdisplay: regulatordisplay {
+            compatible = "regulator-fixed";
+            regulator-name = "display";
+            regulator-min-microvolt = <3300000>;
+            regulator-max-microvolt = <3300000>;
+            regulator-enable-ramp-delay = <100000>;
+            enable-active-high;
+    };
+
+    spi {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            display@0 {
+                    compatible = "winstar,wf0096atyaa3dnn0","sitronix,st7735s";
+                    reg = <0>;
+                    spi-max-frequency = <12000000>;
+                    dc-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
+                    reset-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
+                    backlight = <&backlight>;
+                    power-supply = <&regdsiplay>;
+                    rotation = <270>;
+            };
+    };
+
+...
MAINTAINERS +6 -0
index 6308efa121e1..c00b2b9086f2 100644
@@ -6728,6 +6728,12 @@ T:	git git://anongit.freedesktop.org/drm/drm-misc
 F:	Documentation/devicetree/bindings/display/sitronix,st7735r.yaml
 F:	drivers/gpu/drm/tiny/st7735r.c
 
+DRM DRIVER FOR SITRONIX ST7735S PANELS
+M:	Stefan x Nilsson <[email protected]>
+S:	Maintained
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+F:	Documentation/devicetree/bindings/display/sitronix,st7735s.yaml
+
 DRM DRIVER FOR SOLOMON SSD130X OLED DISPLAYS
 M:	Javier Martinez Canillas <[email protected]>
 S:	Maintained
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/2] dt-bindings: display: Add st7735s driver

Quoted 2 lines · Stefan x Nilsson

Add bindings for a driver for Sitronix st7735s display controller, as well as for a Winstar wf0096atyaa3dnn0 0.96" 80x160 TFT panel.

Commit msg and subject: if by "driver" you mean Linux driver, then drop these references and focus on the hardware.

Quoted 17 lines
---
 .../bindings/display/sitronix,st7735s.yaml         | 81 ++++++++++++++++++++++
 MAINTAINERS                                        |  6 ++
 2 files changed, 87 insertions(+)
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +4 -0
new file mode 100644
index 000000000000..36234ec22fe2
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/sitronix,st7735s.yaml#

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 14

Quoted 10 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +10 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sitronix ST7735S Display Panels
+
+maintainers:
+  - Stefan x Nilsson <[email protected]>
+
+description:
+  This binding is for display panels using a Sitronix ST7735S
+  controller in SPI mode.

Drop: "This binding is for". Describe the hardware instead.

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 22

Quoted 8 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +8 -0
+
+allOf:
+  - $ref: panel/panel-common.yaml#
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    oneOf:

You do not have multiple choices here, so why oneOf? Do you expect it to grow very soon?

Quoted 13 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +13 -0
+      - description:
+          Winstar WF0096ATYAA3DNN0 0.96" 80x160 Color TFT
+        items:
+          - enum:
+              - winstar,wf0096atyaa3dnn0
+          - const: sitronix,st7735s
+
+  dc-gpios:
+    maxItems: 1
+    description: Display data/command selection (D/CX)
+
+  backlight: true
+  reg: true

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 45

Quoted 10 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +10 -0
+  spi-max-frequency: true
+  reset-gpios: true
+  rotation: true
+
+required:
+  - compatible
+  - reg
+  - dc-gpios
+
+additionalProperties: true

This cannot be true. From where did you get such code as example?

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 54

Quoted 9 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +9 -0
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    backlight: backlight {
+            compatible = "gpio-backlight";
+            gpios = <&gpio 44 GPIO_ACTIVE_HIGH>;
+    };

Drop node, not related.

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 62

Quoted 8 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +8 -0
+
+    regdisplay: regulatordisplay {
+            compatible = "regulator-fixed";
+            regulator-name = "display";
+            regulator-min-microvolt = <3300000>;
+            regulator-max-microvolt = <3300000>;
+            regulator-enable-ramp-delay = <100000>;
+            enable-active-high;

Drop node, not related. Again: from where did you get such example?

Documentation/devicetree/bindings/display/sitronix,st7735s.yaml line 70

Quoted 8 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +8 -0
+    };
+
+    spi {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            display@0 {
+                    compatible = "winstar,wf0096atyaa3dnn0","sitronix,st7735s";

You need to fix formatting. Missing space after ,. Wrong indentation.

Use 4 spaces for example indentation.

Quoted 16 lines
Documentation/devicetree/bindings/display/sitronix,st7735s.yaml new file +11 -0
+                    reg = <0>;
+                    spi-max-frequency = <12000000>;
+                    dc-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
+                    reset-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
+                    backlight = <&backlight>;
+                    power-supply = <&regdsiplay>;
+                    rotation = <270>;
+            };
+    };
+
+...
MAINTAINERS +0 -0
index 6308efa121e1..c00b2b9086f2 100644

MAINTAINERS T: git git://anongit.freedesktop.org/drm/drm-misc · line 6734

Quoted 7 lines
MAINTAINERS +4 -0
@@ -6728,6 +6728,12 @@ T:	git git://anongit.freedesktop.org/drm/drm-misc
 F:	Documentation/devicetree/bindings/display/sitronix,st7735r.yaml
 F:	drivers/gpu/drm/tiny/st7735r.c
 
+DRM DRIVER FOR SITRONIX ST7735S PANELS
+M:	Stefan x Nilsson <[email protected]>
+S:	Maintained
+T:	git git://anongit.freedesktop.org/drm/drm-misc

Do you have the push rights to this repo? If not, then don't add it.

Best regards,
Krzysztof

#3 lore raw

PATCH 2/2 drm: tiny: Add st7735s driver

In reply to Stefan x Nilsson

Add a driver for Sitronix st7735s display controller, as well as a Winstar wf0096atyaa3dnn0 0.96" 80x160 TFT panel.

The driver code is very similar to st7735r, but with adaptations for the pipe_enable function. There is also optional support to specify a power regulator for the display.

---
 MAINTAINERS                    |   1 +
 drivers/gpu/drm/tiny/Kconfig   |  14 +++
 drivers/gpu/drm/tiny/Makefile  |   1 +
 drivers/gpu/drm/tiny/st7735s.c | 264 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 280 insertions(+)
MAINTAINERS +1 -0
index c00b2b9086f2..f24295d691e5 100644
@@ -6733,6 +6733,7 @@ M:	Stefan x Nilsson <[email protected]>
 S:	Maintained
 T:	git git://anongit.freedesktop.org/drm/drm-misc
 F:	Documentation/devicetree/bindings/display/sitronix,st7735s.yaml
+F:	drivers/gpu/drm/tiny/st7735s.c
 
 DRM DRIVER FOR SOLOMON SSD130X OLED DISPLAYS
 M:	Javier Martinez Canillas <[email protected]>
drivers/gpu/drm/tiny/Kconfig +14 -0
index f6889f649bc1..2917f5412ddd 100644
@@ -212,3 +212,17 @@ config TINYDRM_ST7735R
 	  * Okaya RH128128T 1.44" 128x128 TFT
 
 	  If M is selected the module will be called st7735r.
+
+config TINYDRM_ST7735S
+	tristate "DRM support for Sitronix ST7735S display panels"
+	depends on DRM && SPI
+	select DRM_KMS_HELPER
+	select DRM_GEM_DMA_HELPER
+	select DRM_MIPI_DBI
+	select BACKLIGHT_CLASS_DEVICE
+	help
+	  DRM driver for Sitronix ST7735S with one of the following
+	  LCDs:
+	  * Winstar WF0096ATYAA3DNN0 0.96" 80x160 Color TFT
+
+	  If M is selected the module will be called st7735s.
drivers/gpu/drm/tiny/Makefile +1 -0
index 76dde89a044b..2e805c5b6f16 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_TINYDRM_MI0283QT)		+= mi0283qt.o
 obj-$(CONFIG_TINYDRM_REPAPER)		+= repaper.o
 obj-$(CONFIG_TINYDRM_ST7586)		+= st7586.o
 obj-$(CONFIG_TINYDRM_ST7735R)		+= st7735r.o
+obj-$(CONFIG_TINYDRM_ST7735S)		+= st7735s.o
drivers/gpu/drm/tiny/st7735s.c new file +264 -0

264 lines not on this page · raw message

Signature · 1 line
2.30.2
#4 lore raw

Re: [PATCH 2/2] drm: tiny: Add st7735s driver

Quoted 96 lines · Stefan x Nilsson

Add a driver for Sitronix st7735s display controller, as well as a Winstar wf0096atyaa3dnn0 0.96" 80x160 TFT panel.

The driver code is very similar to st7735r, but with adaptations for the pipe_enable function. There is also optional support to specify a power regulator for the display.

---
 MAINTAINERS                    |   1 +
 drivers/gpu/drm/tiny/Kconfig   |  14 +++
 drivers/gpu/drm/tiny/Makefile  |   1 +
 drivers/gpu/drm/tiny/st7735s.c | 264 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 280 insertions(+)
MAINTAINERS +1 -0
index c00b2b9086f2..f24295d691e5 100644
@@ -6733,6 +6733,7 @@ M:	Stefan x Nilsson <[email protected]>
 S:	Maintained
 T:	git git://anongit.freedesktop.org/drm/drm-misc
 F:	Documentation/devicetree/bindings/display/sitronix,st7735s.yaml
+F:	drivers/gpu/drm/tiny/st7735s.c
 
 DRM DRIVER FOR SOLOMON SSD130X OLED DISPLAYS
 M:	Javier Martinez Canillas <[email protected]>
drivers/gpu/drm/tiny/Kconfig +14 -0
index f6889f649bc1..2917f5412ddd 100644
@@ -212,3 +212,17 @@ config TINYDRM_ST7735R
 	  * Okaya RH128128T 1.44" 128x128 TFT
 
 	  If M is selected the module will be called st7735r.
+
+config TINYDRM_ST7735S
+	tristate "DRM support for Sitronix ST7735S display panels"
+	depends on DRM && SPI
+	select DRM_KMS_HELPER
+	select DRM_GEM_DMA_HELPER
+	select DRM_MIPI_DBI
+	select BACKLIGHT_CLASS_DEVICE
+	help
+	  DRM driver for Sitronix ST7735S with one of the following
+	  LCDs:
+	  * Winstar WF0096ATYAA3DNN0 0.96" 80x160 Color TFT
+
+	  If M is selected the module will be called st7735s.
drivers/gpu/drm/tiny/Makefile +1 -0
index 76dde89a044b..2e805c5b6f16 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_TINYDRM_MI0283QT)		+= mi0283qt.o
 obj-$(CONFIG_TINYDRM_REPAPER)		+= repaper.o
 obj-$(CONFIG_TINYDRM_ST7586)		+= st7586.o
 obj-$(CONFIG_TINYDRM_ST7735R)		+= st7735r.o
+obj-$(CONFIG_TINYDRM_ST7735S)		+= st7735s.o
drivers/gpu/drm/tiny/st7735s.c new file +32 -0
new file mode 100644
index 000000000000..42290f4128db
@@ -0,0 +1,264 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * DRM driver for display panels connected to a Sitronix ST7735S
+ * display controller in SPI mode.
+ *
+ * Copyright (C) 2023 Axis Communications AB
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/dma-buf.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/property.h>
+#include <linux/spi/spi.h>
+#include <video/mipi_display.h>
+
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fbdev_generic.h>
+#include <drm/drm_gem_atomic_helper.h>
+#include <drm/drm_gem_dma_helper.h>
+#include <drm/drm_managed.h>
+#include <drm/drm_mipi_dbi.h>
+
+#define ST7735S_FRMCTR1		0xb1
+#define ST7735S_FRMCTR2		0xb2
+#define ST7735S_FRMCTR3		0xb3
+#define ST7735S_INVCTR		0xb4
+#define ST7735S_PWCTR1		0xc0
+#define ST7735S_PWCTR2		0xc1
+#define ST7735S_PWCTR3		0xc2

drivers/gpu/drm/tiny/st7735s.c line 42

Quoted 10 lines
drivers/gpu/drm/tiny/st7735s.c new file +10 -0
+#define ST7735S_PWCTR4		0xc3
+#define ST7735S_PWCTR5		0xc4
+#define ST7735S_VMCTR1		0xc5
+#define ST7735S_GAMCTRP1	0xe0
+#define ST7735S_GAMCTRN1	0xe1
+
+#define ST7735S_MY	BIT(7)
+#define ST7735S_MX	BIT(6)
+#define ST7735S_MV	BIT(5)
+#define ST7735S_RGB	BIT(3)

So you just duplicated st7735r. No need for new driver. Integrate your work. Probably also no need for new bindings file (although this I did not check)...

Best regards,
Krzysztof

#5 lore raw
In reply to Stefan x Nilsson
Quoted 7 lines · Stefan x Nilsson

Add a new driver for the Sitronix st7735s display controller together with a 0.96" 80x160 color TFT display by Winstar.

The driver is very similar to the st7735r driver, but uses a different pipe_enable sequence and also allows for an optional regulator to be specified using devicetree.

Can this panel be used with the generic "panel-mipi-dbi-spi" driver?

more info: https://github.com/notro/panel-mipi-dbi/wiki

#6 lore raw
Quoted 4 lines · David Lechner
Quoted 3 lines · Stefan x Nilsson

Add a new driver for the Sitronix st7735s display controller together with a 0.96" 80x160 color TFT display by Winstar.

Quoted 9 lines
Quoted 4 lines

The driver is very similar to the st7735r driver, but uses a different pipe_enable sequence and also allows for an optional regulator to be specified using devicetree.

Can this panel be used with the generic "panel-mipi-dbi-spi" driver?

more info: https://github.com/notro/panel-mipi-dbi/wiki

That looks like an excellent suggestion David!

Looks like a very convenient driver. It was not available on my 5.4 vendor kernel for my hardware so I missed it completely. Will try to backport that driver to my 5.4 kernel instead.

So lets drop these patches. Thanks for your input.

Best Regards
Stefan x Nilsson