Skip to contentSkip to conversation

drm/panel: Add NewVision NV3051D Panels

PATCH Superseded Chris Morgan 5 participants 9 messages Oct 28, 2022 – Nov 10, 2022

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover drm/panel: Add NewVision NV3051D Panels

From: Chris Morgan <[email protected]>

Add the NewVision NV3051D panel as found on the Anbernic RG353P and RG353V. The underlying LCD panel itself is unknown (the NV3051D is the controller), so the device name is used for the panel with a fallback to the driver IC.

Changes from V3:
- Changed driver remove function from int to void to match change made to mipi_dsi_driver struct.

Changes from V2:
- Ensured dt_binding_check and dtbs_check successfully passed.
- Corrected some minor formatting issues in documentation.
- Added another mode per userspace request for 100hz. I was unable to find a supported 50hz mode that would also work, so for now only 60hz, 100hz, and 120hz are supported.

Changes from V1:
- Changed compatible string to the driver IC.
- Updated documentation to use new compatible string with board name.
- Refactored somewhat to make it easier to support other LCD panels with this kernel module.
- Added support for 60hz mode. Adjusted pixel clock to ensure proper 60hz and 120hz (previously was running at 124hz).
- Added vendor prefix for NewVision. Anbernic vendor prefix added in
https://lore.kernel.org/linux-devicetree/[email protected]

Chris Morgan (3):
dt-bindings: vendor-prefixes: add NewVision vendor prefix
dt-bindings: display: panel: Add NewVision NV3051D bindings drm/panel: Add NewVision NV3051D MIPI-DSI LCD panel

 .../display/panel/newvision,nv3051d.yaml      |  63 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig                 |   9 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 .../gpu/drm/panel/panel-newvision-nv3051d.c   | 523 ++++++++++++++++++
 5 files changed, 598 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/newvision,nv3051d.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3051d.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/3 dt-bindings: vendor-prefixes: add NewVision vendor prefix

From: Chris Morgan <[email protected]>

NewVision (also sometimes written as New Vision) is a company based in Shenzen that manufactures ICs for controlling LCD panels.

https://www.newvisiondisplay.com/

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 6e323a380294..c6aa7b3d1455 100644
@@ -883,6 +883,8 @@ patternProperties:
     description: Shenzhen Netxeon Technology CO., LTD
   "^neweast,.*":
     description: Guangdong Neweast Optoelectronics CO., LTD
+  "^newvision,.*":
+    description: New Vision Display (Shenzhen) Co., Ltd.
   "^nexbox,.*":
     description: Nexbox
   "^nextthing,.*":
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/3 dt-bindings: display: panel: Add NewVision NV3051D bindings

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add documentation for the NewVision NV3051D panel bindings. Note that for the two expected consumers of this panel binding the underlying LCD model is unknown. Name "anbernic,rg353p-panel" is used because the hardware itself is known as "anbernic,rg353p".

---
 .../display/panel/newvision,nv3051d.yaml      | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/newvision,nv3051d.yaml
Documentation/devicetree/bindings/display/panel/newvision,nv3051d.yaml new file +63 -0
new file mode 100644
index 000000000000..407de7fb5499
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/newvision,nv3051d.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NewVision NV3051D based LCD panel
+
+description: |
+  The NewVision NV3051D is a driver chip used to drive DSI panels. For now,
+  this driver only supports the 640x480 panels found in the Anbernic RG353
+  based devices.
+
+maintainers:
+  - Chris Morgan <[email protected]>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - anbernic,rg353p-panel
+          - anbernic,rg353v-panel
+      - const: newvision,nv3051d
+
+  reg: true
+  backlight: true
+  port: true
+  reset-gpios: true
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+  - backlight
+  - vdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    dsi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        panel@0 {
+            compatible = "anbernic,rg353p-panel", "newvision,nv3051d";
+            reg = <0>;
+            backlight = <&backlight>;
+            reset-gpios = <&gpio4 0 GPIO_ACTIVE_LOW>;
+            vdd-supply = <&vcc3v3_lcd>;
+
+            port {
+                mipi_in_panel: endpoint {
+                    remote-endpoint = <&mipi_out_panel>;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH V4 2/3] dt-bindings: display: panel: Add NewVision NV3051D bindings

Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add documentation for the NewVision NV3051D panel bindings. Note that for the two expected consumers of this panel binding the underlying LCD model is unknown. Name "anbernic,rg353p-panel" is used because the hardware itself is known as "anbernic,rg353p".

Didn't you got here tag?

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH V4 2/3] dt-bindings: display: panel: Add NewVision NV3051D bindings

Quoted 11 lines · Krzysztof Kozlowski
Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add documentation for the NewVision NV3051D panel bindings. Note that for the two expected consumers of this panel binding the underlying LCD model is unknown. Name "anbernic,rg353p-panel" is used because the hardware itself is known as "anbernic,rg353p".

Didn't you got here tag?

Yes, I'm so sorry. I always seem to miss one detail each time, I promise I'll get better (eventually, I hope). This one should already have the "Reviewed-by: Rob Herring <[email protected]>" but I forgot to include it. Literally the only change from v3 is the return of a function changing from int to void, since that changed in the 6.1 kernel.

Thank you.

Quoted 4 lines

Best regards,
Krzysztof

maintainer Reviewed-by
#5 lore raw

Re: [PATCH V4 2/3] dt-bindings: display: panel: Add NewVision NV3051D bindings

Quoted 11 lines · Chris Morgan
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add documentation for the NewVision NV3051D panel bindings. Note that for the two expected consumers of this panel binding the underlying LCD model is unknown. Name "anbernic,rg353p-panel" is used because the hardware itself is known as "anbernic,rg353p".

Quoted 8 lines
Quoted 1 line

Didn't you got here tag?

Yes, I'm so sorry. I always seem to miss one detail each time, I promise I'll get better (eventually, I hope). This one should already have the "Reviewed-by: Rob Herring <[email protected]>" but I forgot to include it. Literally the only change from v3 is the return of a function changing from int to void, since that changed in the 6.1 kernel.

If you forget, just add the tags by themselves and the tools will pick them up.

#6 lore raw

Re: [PATCH V4 2/3] dt-bindings: display: panel: Add NewVision NV3051D bindings

In reply to Chris Morgan

Hi Chris,

thanks for your patch! The following is just nitpicks so take it or leave it.

Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add documentation for the NewVision NV3051D panel bindings. Note that for the two expected consumers of this panel binding the underlying LCD model is unknown. Name "anbernic,rg353p-panel" is used because the hardware itself is known as "anbernic,rg353p".

(...)

Quoted 1 line

+ reset-gpios: true

I would add description: and say that this needs to be flagged GPIO_ACTIVE_LOW since the reset signal is active low.

Documentation/devicetree/bindings/display/panel/newvision,nv3051d.yaml line 38

Quoted 7 lines
Documentation/devicetree/bindings/display/panel/newvision,nv3051d.yaml new file +7 -0
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+  - backlight
+  - vdd-supply

If someone happen to just wire vdd-supply to some fixed regulator then they don't need vdd-supply so this is a bit of a tough requirement.

Yours,
Linus Walleij

#7 lore raw

PATCH v4 3/3 drm/panel: Add NewVision NV3051D MIPI-DSI LCD panel

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Support NewVision NV3051D panels as found on the Anbernic RG353P and RG353V. The underlying LCD part number for the RG353x devices is unknown, so the device name and a fallback for the driver IC is used instead.

---
 drivers/gpu/drm/panel/Kconfig                 |   9 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 .../gpu/drm/panel/panel-newvision-nv3051d.c   | 523 ++++++++++++++++++
 3 files changed, 533 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3051d.c
drivers/gpu/drm/panel/Kconfig +9 -0
index a582ddd583c2..427c22bdbfb3 100644
@@ -296,6 +296,15 @@ config DRM_PANEL_NEC_NL8048HL11
 	  panel (found on the Zoom2/3/3630 SDP boards). To compile this driver
 	  as a module, choose M here.
 
+config DRM_PANEL_NEWVISION_NV3051D
+	tristate "NewVision NV3051D DSI panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  This driver supports the NV3051D based panel found on the Anbernic
+	  RG353P and RG353V.
+
 config DRM_PANEL_NEWVISION_NV3052C
 	tristate "NewVision NV3052C RGB/SPI panel"
 	depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
index 34e717382dbb..cb03b3a82738 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
 obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
 obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
+obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3051D) += panel-newvision-nv3051d.o
 obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
drivers/gpu/drm/panel/panel-newvision-nv3051d.c new file +523 -0

523 lines not on this page · raw message

Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH V4 3/3] drm/panel: Add NewVision NV3051D MIPI-DSI LCD panel

Hi Chris,

thanks for your patch!

Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Support NewVision NV3051D panels as found on the Anbernic RG353P and RG353V. The underlying LCD part number for the RG353x devices is unknown, so the device name and a fallback for the driver IC is used instead.

(...)

drivers/gpu/drm/panel/panel-newvision-nv3051d.c line 39

Quoted 7 lines
drivers/gpu/drm/panel/panel-newvision-nv3051d.c new file +7 -0
+struct panel_nv3051d {
+       struct device *dev;
+       struct drm_panel panel;
+       struct gpio_desc *reset_gpio;
+       const struct nv3051d_panel_info *panel_info;
+       struct regulator *vdd;
+       bool prepared;

I think you want to get rid of prepared. The framework keeps track of state.

drivers/gpu/drm/panel/panel-newvision-nv3051d.c line 53

Quoted 7 lines
drivers/gpu/drm/panel/panel-newvision-nv3051d.c new file +7 -0
+#define dsi_dcs_write_seq(dsi, cmd, seq...) do {                       \
+               static const u8 b[] = { cmd, seq };                     \
+               int ret;                                                \
+               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
+               if (ret < 0)                                            \
+                       return ret;                                     \
+       } while (0)

This is a reimplementation of mipi_dsi_dcs_write_seq() so use that instead. (Found in include/drm/drm_mipi_dsi.h)

drivers/gpu/drm/panel/panel-newvision-nv3051d.c line 62

Quoted 4 lines
drivers/gpu/drm/panel/panel-newvision-nv3051d.c new file +4 -0
+       /*
+        * Init sequence was supplied by device vendor with no
+        * documentation.
+        */

Grrrr but not your fault. What *can* work is to look in related datasheets and infer some of the magic variables from there. Anyways best effort is best effort and as long as it's working that's OK.

An experiment you can do if you have time is to see if you can read out MTP ID from the panel (3 bytes, check how other drivers do it) and use that to figure out who manufactured the actual display controller. It's a bit of sleuthing.

drivers/gpu/drm/panel/panel-newvision-nv3051d.c line 393

Quoted 5 lines
drivers/gpu/drm/panel/panel-newvision-nv3051d.c new file +5 -0
+       ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(ctx->reset_gpio)) {
+               dev_err(dev, "cannot get reset gpio\n");
+               return PTR_ERR(ctx->reset_gpio);
+       }

I usually get it with GPIOD_OUT_HIGH so that reset i asserted at probe().

You do have active low flagged in your DTS do you not?

Yours,
Linus Walleij