All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] drm: panel: add support for TDO tl070wsh30 panel
@ 2020-09-07 11:10 ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: dri-devel, linux-amlogic, linux-kernel, Neil Armstrong

This adds support bindings and support for the TDO TL070WSH30 TFT-LCD panel
module shipped with the Amlogic S400 Development Kit.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Changes since v1 at [1]:
- added missing vendor-prefixes patch
- removed vrefresh
- fixed warning on add_panel return
- removed DRM logging

[1] https://patchwork.freedesktop.org/series/81376/#rev1

Neil Armstrong (3):
  dt-bindings: vendor-prefixes: Add Shanghai Top Display
    Optolelectronics vendor prefix
  dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  drm: panel: add TDO tl070wsh30 panel driver

 .../display/panel/tdo,tl070wsh30.yaml         |  58 ++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig                 |  11 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c  | 256 ++++++++++++++++++
 5 files changed, 328 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

-- 
2.22.0


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 0/3] drm: panel: add support for TDO tl070wsh30 panel
@ 2020-09-07 11:10 ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This adds support bindings and support for the TDO TL070WSH30 TFT-LCD panel
module shipped with the Amlogic S400 Development Kit.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Changes since v1 at [1]:
- added missing vendor-prefixes patch
- removed vrefresh
- fixed warning on add_panel return
- removed DRM logging

[1] https://patchwork.freedesktop.org/series/81376/#rev1

Neil Armstrong (3):
  dt-bindings: vendor-prefixes: Add Shanghai Top Display
    Optolelectronics vendor prefix
  dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  drm: panel: add TDO tl070wsh30 panel driver

 .../display/panel/tdo,tl070wsh30.yaml         |  58 ++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig                 |  11 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c  | 256 ++++++++++++++++++
 5 files changed, 328 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 0/3] drm: panel: add support for TDO tl070wsh30 panel
@ 2020-09-07 11:10 ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This adds support bindings and support for the TDO TL070WSH30 TFT-LCD panel
module shipped with the Amlogic S400 Development Kit.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Changes since v1 at [1]:
- added missing vendor-prefixes patch
- removed vrefresh
- fixed warning on add_panel return
- removed DRM logging

[1] https://patchwork.freedesktop.org/series/81376/#rev1

Neil Armstrong (3):
  dt-bindings: vendor-prefixes: Add Shanghai Top Display
    Optolelectronics vendor prefix
  dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  drm: panel: add TDO tl070wsh30 panel driver

 .../display/panel/tdo,tl070wsh30.yaml         |  58 ++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig                 |  11 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c  | 256 ++++++++++++++++++
 5 files changed, 328 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

-- 
2.22.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add Shanghai Top Display Optolelectronics vendor prefix
  2020-09-07 11:10 ` Neil Armstrong
  (?)
@ 2020-09-07 11:10   ` Neil Armstrong
  -1 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: dri-devel, linux-amlogic, linux-kernel, Neil Armstrong

Shanghai Top Display Optolelectronics Co., Ltd  is a display manufacturer
from Shanghai.
Web site of the company: http://www.shtdo.com/

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a1e4356cf522..4e9dfb352c68 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1078,6 +1078,8 @@ patternProperties:
     description: TPK U.S.A. LLC
   "^tplink,.*":
     description: TP-LINK Technologies Co., Ltd.
+  "^tdo,.*":
+    description: Shangai Top Display Optoelectronics Co., Ltd
   "^tpo,.*":
     description: TPO
   "^tq,.*":
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add Shanghai Top Display Optolelectronics vendor prefix
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

Shanghai Top Display Optolelectronics Co., Ltd  is a display manufacturer
from Shanghai.
Web site of the company: http://www.shtdo.com/

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a1e4356cf522..4e9dfb352c68 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1078,6 +1078,8 @@ patternProperties:
     description: TPK U.S.A. LLC
   "^tplink,.*":
     description: TP-LINK Technologies Co., Ltd.
+  "^tdo,.*":
+    description: Shangai Top Display Optoelectronics Co., Ltd
   "^tpo,.*":
     description: TPO
   "^tq,.*":
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add Shanghai Top Display Optolelectronics vendor prefix
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

Shanghai Top Display Optolelectronics Co., Ltd  is a display manufacturer
from Shanghai.
Web site of the company: http://www.shtdo.com/

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a1e4356cf522..4e9dfb352c68 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1078,6 +1078,8 @@ patternProperties:
     description: TPK U.S.A. LLC
   "^tplink,.*":
     description: TP-LINK Technologies Co., Ltd.
+  "^tdo,.*":
+    description: Shangai Top Display Optoelectronics Co., Ltd
   "^tpo,.*":
     description: TPO
   "^tq,.*":
-- 
2.22.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  2020-09-07 11:10 ` Neil Armstrong
  (?)
@ 2020-09-07 11:10   ` Neil Armstrong
  -1 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: dri-devel, linux-amlogic, linux-kernel, Neil Armstrong

This add the bindings for the 1024*600 tl070wsh30 DSI panel.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
new file mode 100644
index 000000000000..20f4fdedfcb0
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+# Copyright 2020 BayLibre, SAS
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TDO TL070WSH30 DSI panel
+
+maintainers:
+  - Neil Armstrong <narmstrong@baylibre.com>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+
+  compatible:
+    enum:
+      - tdo,tl070wsh30
+
+  reg:
+    maxItems: 1
+    description: DSI virtual channel
+
+  backlight: true
+  reset-gpios: true
+  port: true
+  power-supply: true
+
+additionalProperties: false
+
+required:
+  - compatible
+  - power-supply
+  - reset-gpios
+  - port
+  - reg
+
+examples:
+  - |
+    dsi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      panel@0 {
+        compatible = "tdo,tl070wsh30";
+        reg = <0>;
+        power-supply = <&vcc_lcd_reg>;
+        backlight = <&panel_backlight>;
+        reset-gpios = <&gpio_reset>;
+
+        port {
+          panel: endpoint {
+            remote-endpoint = <&mipi_dsi_out>;
+          };
+        };
+      };
+    };
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This add the bindings for the 1024*600 tl070wsh30 DSI panel.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
new file mode 100644
index 000000000000..20f4fdedfcb0
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+# Copyright 2020 BayLibre, SAS
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TDO TL070WSH30 DSI panel
+
+maintainers:
+  - Neil Armstrong <narmstrong@baylibre.com>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+
+  compatible:
+    enum:
+      - tdo,tl070wsh30
+
+  reg:
+    maxItems: 1
+    description: DSI virtual channel
+
+  backlight: true
+  reset-gpios: true
+  port: true
+  power-supply: true
+
+additionalProperties: false
+
+required:
+  - compatible
+  - power-supply
+  - reset-gpios
+  - port
+  - reg
+
+examples:
+  - |
+    dsi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      panel@0 {
+        compatible = "tdo,tl070wsh30";
+        reg = <0>;
+        power-supply = <&vcc_lcd_reg>;
+        backlight = <&panel_backlight>;
+        reset-gpios = <&gpio_reset>;
+
+        port {
+          panel: endpoint {
+            remote-endpoint = <&mipi_dsi_out>;
+          };
+        };
+      };
+    };
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam, devicetree
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This add the bindings for the 1024*600 tl070wsh30 DSI panel.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
new file mode 100644
index 000000000000..20f4fdedfcb0
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+# Copyright 2020 BayLibre, SAS
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TDO TL070WSH30 DSI panel
+
+maintainers:
+  - Neil Armstrong <narmstrong@baylibre.com>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+
+  compatible:
+    enum:
+      - tdo,tl070wsh30
+
+  reg:
+    maxItems: 1
+    description: DSI virtual channel
+
+  backlight: true
+  reset-gpios: true
+  port: true
+  power-supply: true
+
+additionalProperties: false
+
+required:
+  - compatible
+  - power-supply
+  - reset-gpios
+  - port
+  - reg
+
+examples:
+  - |
+    dsi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      panel@0 {
+        compatible = "tdo,tl070wsh30";
+        reg = <0>;
+        power-supply = <&vcc_lcd_reg>;
+        backlight = <&panel_backlight>;
+        reset-gpios = <&gpio_reset>;
+
+        port {
+          panel: endpoint {
+            remote-endpoint = <&mipi_dsi_out>;
+          };
+        };
+      };
+    };
-- 
2.22.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
  2020-09-07 11:10 ` Neil Armstrong
  (?)
@ 2020-09-07 11:10   ` Neil Armstrong
  -1 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: dri-devel, linux-amlogic, linux-kernel, Neil Armstrong

This adds support for the TDO TL070WSH30 TFT-LCD panel module.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/gpu/drm/panel/Kconfig                |  11 +
 drivers/gpu/drm/panel/Makefile               |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 8d97d07c5871..2d488a875b99 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
 	  Say Y here if you want to enable support for the Sony ACX565AKM
 	  800x600 3.5" panel (found on the Nokia N900).
 
+config DRM_PANEL_TDO_TL070WSH30
+	tristate "TDO TL070WSH30 DSI panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
+	  panel module. The panel has a 1024×600 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host, a built-in LED backlight and touch controller.
+
 config DRM_PANEL_TPO_TD028TTEC1
 	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
 	depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 15a4e7752951..35ee06a1b5c2 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
new file mode 100644
index 000000000000..c7a6c2c42c52
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
@@ -0,0 +1,256 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 BayLibre, SAS
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <video/mipi_display.h>
+
+#include <drm/drm_crtc.h>
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct tdo_tl070wsh30_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;
+
+	struct regulator *supply;
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+};
+
+static inline
+struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct tdo_tl070wsh30_panel, base);
+}
+
+static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (!tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
+	if (err < 0)
+		dev_err(panel->dev, "failed to set display off: %d\n", err);
+
+	usleep_range(10000, 11000);
+
+	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
+		return err;
+	}
+
+	usleep_range(10000, 11000);
+
+	tdo_tl070wsh30->prepared = false;
+
+	return 0;
+}
+
+static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
+		return err;
+	}
+
+	msleep(200);
+
+	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to set display on: %d\n", err);
+		return err;
+	}
+
+	msleep(20);
+
+	tdo_tl070wsh30->prepared = true;
+
+	return 0;
+}
+
+static const struct drm_display_mode default_mode = {
+	.clock = 47250,
+	.hdisplay = 1024,
+	.hsync_start = 1024 + 46,
+	.hsync_end = 1024 + 46 + 80,
+	.htotal = 1024 + 46 + 80 + 100,
+	.vdisplay = 600,
+	.vsync_start = 600 + 5,
+	.vsync_end = 600 + 5 + 5,
+	.vtotal = 600 + 5 + 5 + 20,
+	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
+};
+
+static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
+				       struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &default_mode);
+	if (!mode) {
+		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
+			default_mode.vdisplay);
+		return -ENOMEM;
+	}
+
+	drm_mode_set_name(mode);
+
+	drm_mode_probed_add(connector, mode);
+
+	connector->display_info.width_mm = 154;
+	connector->display_info.height_mm = 85;
+	connector->display_info.bpc = 8;
+
+	return 1;
+}
+
+static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
+	.unprepare = tdo_tl070wsh30_panel_unprepare,
+	.prepare = tdo_tl070wsh30_panel_prepare,
+	.get_modes = tdo_tl070wsh30_panel_get_modes,
+};
+
+static const struct of_device_id tdo_tl070wsh30_of_match[] = {
+	{ .compatible = "tdo,tl070wsh30", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
+
+static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	struct device *dev = &tdo_tl070wsh30->link->dev;
+	int err;
+
+	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
+	if (IS_ERR(tdo_tl070wsh30->supply))
+		return PTR_ERR(tdo_tl070wsh30->supply);
+
+	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
+						  GPIOD_OUT_LOW);
+	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
+		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
+		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
+		return err;
+	}
+
+	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
+		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
+
+	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
+	if (err)
+		return err;
+
+	err = regulator_enable(tdo_tl070wsh30->supply);
+	if (err < 0)
+		return err;
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
+
+	msleep(200);
+
+	drm_panel_add(&tdo_tl070wsh30->base);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	drm_panel_remove(&tdo_tl070wsh30->base);
+}
+
+static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
+	int err;
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
+
+	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
+				    GFP_KERNEL);
+	if (!tdo_tl070wsh30)
+		return -ENOMEM;
+
+	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
+	tdo_tl070wsh30->link = dsi;
+
+	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
+	if (err < 0)
+		return err;
+
+	return mipi_dsi_attach(dsi);
+}
+
+static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
+
+	err = drm_panel_disable(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
+
+	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+
+	drm_panel_unprepare(&tdo_tl070wsh30->base);
+	drm_panel_disable(&tdo_tl070wsh30->base);
+}
+
+static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
+	.driver = {
+		.name = "panel-tdo-tl070wsh30",
+		.of_match_table = tdo_tl070wsh30_of_match,
+	},
+	.probe = tdo_tl070wsh30_panel_probe,
+	.remove = tdo_tl070wsh30_panel_remove,
+	.shutdown = tdo_tl070wsh30_panel_shutdown,
+};
+module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
+
+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
+MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
+MODULE_LICENSE("GPL v2");
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This adds support for the TDO TL070WSH30 TFT-LCD panel module.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/gpu/drm/panel/Kconfig                |  11 +
 drivers/gpu/drm/panel/Makefile               |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 8d97d07c5871..2d488a875b99 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
 	  Say Y here if you want to enable support for the Sony ACX565AKM
 	  800x600 3.5" panel (found on the Nokia N900).
 
+config DRM_PANEL_TDO_TL070WSH30
+	tristate "TDO TL070WSH30 DSI panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
+	  panel module. The panel has a 1024×600 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host, a built-in LED backlight and touch controller.
+
 config DRM_PANEL_TPO_TD028TTEC1
 	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
 	depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 15a4e7752951..35ee06a1b5c2 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
new file mode 100644
index 000000000000..c7a6c2c42c52
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
@@ -0,0 +1,256 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 BayLibre, SAS
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <video/mipi_display.h>
+
+#include <drm/drm_crtc.h>
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct tdo_tl070wsh30_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;
+
+	struct regulator *supply;
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+};
+
+static inline
+struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct tdo_tl070wsh30_panel, base);
+}
+
+static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (!tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
+	if (err < 0)
+		dev_err(panel->dev, "failed to set display off: %d\n", err);
+
+	usleep_range(10000, 11000);
+
+	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
+		return err;
+	}
+
+	usleep_range(10000, 11000);
+
+	tdo_tl070wsh30->prepared = false;
+
+	return 0;
+}
+
+static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
+		return err;
+	}
+
+	msleep(200);
+
+	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to set display on: %d\n", err);
+		return err;
+	}
+
+	msleep(20);
+
+	tdo_tl070wsh30->prepared = true;
+
+	return 0;
+}
+
+static const struct drm_display_mode default_mode = {
+	.clock = 47250,
+	.hdisplay = 1024,
+	.hsync_start = 1024 + 46,
+	.hsync_end = 1024 + 46 + 80,
+	.htotal = 1024 + 46 + 80 + 100,
+	.vdisplay = 600,
+	.vsync_start = 600 + 5,
+	.vsync_end = 600 + 5 + 5,
+	.vtotal = 600 + 5 + 5 + 20,
+	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
+};
+
+static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
+				       struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &default_mode);
+	if (!mode) {
+		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
+			default_mode.vdisplay);
+		return -ENOMEM;
+	}
+
+	drm_mode_set_name(mode);
+
+	drm_mode_probed_add(connector, mode);
+
+	connector->display_info.width_mm = 154;
+	connector->display_info.height_mm = 85;
+	connector->display_info.bpc = 8;
+
+	return 1;
+}
+
+static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
+	.unprepare = tdo_tl070wsh30_panel_unprepare,
+	.prepare = tdo_tl070wsh30_panel_prepare,
+	.get_modes = tdo_tl070wsh30_panel_get_modes,
+};
+
+static const struct of_device_id tdo_tl070wsh30_of_match[] = {
+	{ .compatible = "tdo,tl070wsh30", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
+
+static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	struct device *dev = &tdo_tl070wsh30->link->dev;
+	int err;
+
+	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
+	if (IS_ERR(tdo_tl070wsh30->supply))
+		return PTR_ERR(tdo_tl070wsh30->supply);
+
+	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
+						  GPIOD_OUT_LOW);
+	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
+		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
+		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
+		return err;
+	}
+
+	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
+		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
+
+	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
+	if (err)
+		return err;
+
+	err = regulator_enable(tdo_tl070wsh30->supply);
+	if (err < 0)
+		return err;
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
+
+	msleep(200);
+
+	drm_panel_add(&tdo_tl070wsh30->base);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	drm_panel_remove(&tdo_tl070wsh30->base);
+}
+
+static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
+	int err;
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
+
+	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
+				    GFP_KERNEL);
+	if (!tdo_tl070wsh30)
+		return -ENOMEM;
+
+	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
+	tdo_tl070wsh30->link = dsi;
+
+	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
+	if (err < 0)
+		return err;
+
+	return mipi_dsi_attach(dsi);
+}
+
+static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
+
+	err = drm_panel_disable(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
+
+	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+
+	drm_panel_unprepare(&tdo_tl070wsh30->base);
+	drm_panel_disable(&tdo_tl070wsh30->base);
+}
+
+static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
+	.driver = {
+		.name = "panel-tdo-tl070wsh30",
+		.of_match_table = tdo_tl070wsh30_of_match,
+	},
+	.probe = tdo_tl070wsh30_panel_probe,
+	.remove = tdo_tl070wsh30_panel_remove,
+	.shutdown = tdo_tl070wsh30_panel_shutdown,
+};
+module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
+
+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
+MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
+MODULE_LICENSE("GPL v2");
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-07 11:10   ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 11:10 UTC (permalink / raw)
  To: thierry.reding, sam
  Cc: linux-amlogic, linux-kernel, dri-devel, Neil Armstrong

This adds support for the TDO TL070WSH30 TFT-LCD panel module.
The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
It provides a MIPI DSI interface to the host, a built-in LED backlight
and touch controller.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/gpu/drm/panel/Kconfig                |  11 +
 drivers/gpu/drm/panel/Makefile               |   1 +
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 8d97d07c5871..2d488a875b99 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
 	  Say Y here if you want to enable support for the Sony ACX565AKM
 	  800x600 3.5" panel (found on the Nokia N900).
 
+config DRM_PANEL_TDO_TL070WSH30
+	tristate "TDO TL070WSH30 DSI panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
+	  panel module. The panel has a 1024×600 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host, a built-in LED backlight and touch controller.
+
 config DRM_PANEL_TPO_TD028TTEC1
 	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
 	depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 15a4e7752951..35ee06a1b5c2 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
new file mode 100644
index 000000000000..c7a6c2c42c52
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
@@ -0,0 +1,256 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 BayLibre, SAS
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <video/mipi_display.h>
+
+#include <drm/drm_crtc.h>
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct tdo_tl070wsh30_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;
+
+	struct regulator *supply;
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+};
+
+static inline
+struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct tdo_tl070wsh30_panel, base);
+}
+
+static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (!tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
+	if (err < 0)
+		dev_err(panel->dev, "failed to set display off: %d\n", err);
+
+	usleep_range(10000, 11000);
+
+	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
+		return err;
+	}
+
+	usleep_range(10000, 11000);
+
+	tdo_tl070wsh30->prepared = false;
+
+	return 0;
+}
+
+static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
+	int err;
+
+	if (tdo_tl070wsh30->prepared)
+		return 0;
+
+	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
+		return err;
+	}
+
+	msleep(200);
+
+	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
+	if (err < 0) {
+		dev_err(panel->dev, "failed to set display on: %d\n", err);
+		return err;
+	}
+
+	msleep(20);
+
+	tdo_tl070wsh30->prepared = true;
+
+	return 0;
+}
+
+static const struct drm_display_mode default_mode = {
+	.clock = 47250,
+	.hdisplay = 1024,
+	.hsync_start = 1024 + 46,
+	.hsync_end = 1024 + 46 + 80,
+	.htotal = 1024 + 46 + 80 + 100,
+	.vdisplay = 600,
+	.vsync_start = 600 + 5,
+	.vsync_end = 600 + 5 + 5,
+	.vtotal = 600 + 5 + 5 + 20,
+	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
+};
+
+static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
+				       struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &default_mode);
+	if (!mode) {
+		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
+			default_mode.vdisplay);
+		return -ENOMEM;
+	}
+
+	drm_mode_set_name(mode);
+
+	drm_mode_probed_add(connector, mode);
+
+	connector->display_info.width_mm = 154;
+	connector->display_info.height_mm = 85;
+	connector->display_info.bpc = 8;
+
+	return 1;
+}
+
+static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
+	.unprepare = tdo_tl070wsh30_panel_unprepare,
+	.prepare = tdo_tl070wsh30_panel_prepare,
+	.get_modes = tdo_tl070wsh30_panel_get_modes,
+};
+
+static const struct of_device_id tdo_tl070wsh30_of_match[] = {
+	{ .compatible = "tdo,tl070wsh30", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
+
+static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	struct device *dev = &tdo_tl070wsh30->link->dev;
+	int err;
+
+	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
+	if (IS_ERR(tdo_tl070wsh30->supply))
+		return PTR_ERR(tdo_tl070wsh30->supply);
+
+	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
+						  GPIOD_OUT_LOW);
+	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
+		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
+		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
+		return err;
+	}
+
+	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
+		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
+
+	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
+	if (err)
+		return err;
+
+	err = regulator_enable(tdo_tl070wsh30->supply);
+	if (err < 0)
+		return err;
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
+
+	usleep_range(10000, 11000);
+
+	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
+
+	msleep(200);
+
+	drm_panel_add(&tdo_tl070wsh30->base);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
+{
+	drm_panel_remove(&tdo_tl070wsh30->base);
+}
+
+static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
+	int err;
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
+
+	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
+				    GFP_KERNEL);
+	if (!tdo_tl070wsh30)
+		return -ENOMEM;
+
+	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
+	tdo_tl070wsh30->link = dsi;
+
+	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
+	if (err < 0)
+		return err;
+
+	return mipi_dsi_attach(dsi);
+}
+
+static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
+
+	err = drm_panel_disable(&tdo_tl070wsh30->base);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
+
+	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
+
+	return 0;
+}
+
+static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
+{
+	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
+
+	drm_panel_unprepare(&tdo_tl070wsh30->base);
+	drm_panel_disable(&tdo_tl070wsh30->base);
+}
+
+static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
+	.driver = {
+		.name = "panel-tdo-tl070wsh30",
+		.of_match_table = tdo_tl070wsh30_of_match,
+	},
+	.probe = tdo_tl070wsh30_panel_probe,
+	.remove = tdo_tl070wsh30_panel_remove,
+	.shutdown = tdo_tl070wsh30_panel_shutdown,
+};
+module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
+
+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
+MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
+MODULE_LICENSE("GPL v2");
-- 
2.22.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  2020-09-07 11:10   ` Neil Armstrong
  (?)
@ 2020-09-07 11:45     ` Sam Ravnborg
  -1 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 11:45 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: thierry.reding, devicetree, dri-devel, linux-amlogic, linux-kernel

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> This add the bindings for the 1024*600 tl070wsh30 DSI panel.

The binding looks like a panel-simple-dsi.yaml candidate.
Only differen is enable-gpios versus reset-gpios

Could you check if we can use panel-simple-dsi-yaml.

	Sam

> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>  1 file changed, 58 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> new file mode 100644
> index 000000000000..20f4fdedfcb0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> +# Copyright 2020 BayLibre, SAS
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TDO TL070WSH30 DSI panel
> +
> +maintainers:
> +  - Neil Armstrong <narmstrong@baylibre.com>
> +
> +allOf:
> +  - $ref: panel-common.yaml#
> +
> +properties:
> +
> +  compatible:
> +    enum:
> +      - tdo,tl070wsh30
> +
> +  reg:
> +    maxItems: 1
> +    description: DSI virtual channel
> +
> +  backlight: true
> +  reset-gpios: true
> +  port: true
> +  power-supply: true
> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - power-supply
> +  - reset-gpios
> +  - port
> +  - reg
> +
> +examples:
> +  - |
> +    dsi {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +      panel@0 {
> +        compatible = "tdo,tl070wsh30";
> +        reg = <0>;
> +        power-supply = <&vcc_lcd_reg>;
> +        backlight = <&panel_backlight>;
> +        reset-gpios = <&gpio_reset>;
> +
> +        port {
> +          panel: endpoint {
> +            remote-endpoint = <&mipi_dsi_out>;
> +          };
> +        };
> +      };
> +    };
> -- 
> 2.22.0

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 11:45     ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 11:45 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> This add the bindings for the 1024*600 tl070wsh30 DSI panel.

The binding looks like a panel-simple-dsi.yaml candidate.
Only differen is enable-gpios versus reset-gpios

Could you check if we can use panel-simple-dsi-yaml.

	Sam

> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>  1 file changed, 58 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> new file mode 100644
> index 000000000000..20f4fdedfcb0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> +# Copyright 2020 BayLibre, SAS
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TDO TL070WSH30 DSI panel
> +
> +maintainers:
> +  - Neil Armstrong <narmstrong@baylibre.com>
> +
> +allOf:
> +  - $ref: panel-common.yaml#
> +
> +properties:
> +
> +  compatible:
> +    enum:
> +      - tdo,tl070wsh30
> +
> +  reg:
> +    maxItems: 1
> +    description: DSI virtual channel
> +
> +  backlight: true
> +  reset-gpios: true
> +  port: true
> +  power-supply: true
> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - power-supply
> +  - reset-gpios
> +  - port
> +  - reg
> +
> +examples:
> +  - |
> +    dsi {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +      panel@0 {
> +        compatible = "tdo,tl070wsh30";
> +        reg = <0>;
> +        power-supply = <&vcc_lcd_reg>;
> +        backlight = <&panel_backlight>;
> +        reset-gpios = <&gpio_reset>;
> +
> +        port {
> +          panel: endpoint {
> +            remote-endpoint = <&mipi_dsi_out>;
> +          };
> +        };
> +      };
> +    };
> -- 
> 2.22.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 11:45     ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 11:45 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> This add the bindings for the 1024*600 tl070wsh30 DSI panel.

The binding looks like a panel-simple-dsi.yaml candidate.
Only differen is enable-gpios versus reset-gpios

Could you check if we can use panel-simple-dsi-yaml.

	Sam

> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>  1 file changed, 58 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> new file mode 100644
> index 000000000000..20f4fdedfcb0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> +# Copyright 2020 BayLibre, SAS
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TDO TL070WSH30 DSI panel
> +
> +maintainers:
> +  - Neil Armstrong <narmstrong@baylibre.com>
> +
> +allOf:
> +  - $ref: panel-common.yaml#
> +
> +properties:
> +
> +  compatible:
> +    enum:
> +      - tdo,tl070wsh30
> +
> +  reg:
> +    maxItems: 1
> +    description: DSI virtual channel
> +
> +  backlight: true
> +  reset-gpios: true
> +  port: true
> +  power-supply: true
> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - power-supply
> +  - reset-gpios
> +  - port
> +  - reg
> +
> +examples:
> +  - |
> +    dsi {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +      panel@0 {
> +        compatible = "tdo,tl070wsh30";
> +        reg = <0>;
> +        power-supply = <&vcc_lcd_reg>;
> +        backlight = <&panel_backlight>;
> +        reset-gpios = <&gpio_reset>;
> +
> +        port {
> +          panel: endpoint {
> +            remote-endpoint = <&mipi_dsi_out>;
> +          };
> +        };
> +      };
> +    };
> -- 
> 2.22.0

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  2020-09-07 11:45     ` Sam Ravnborg
  (?)
@ 2020-09-07 13:24       ` Neil Armstrong
  -1 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 13:24 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: thierry.reding, devicetree, dri-devel, linux-amlogic, linux-kernel

Hi,

On 07/09/2020 13:45, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
>> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> 
> The binding looks like a panel-simple-dsi.yaml candidate.
> Only differen is enable-gpios versus reset-gpios

This is the only difference, the panel only has a reset signal and no
enable signal.

But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Neil

> 
> Could you check if we can use panel-simple-dsi-yaml.
> 
> 	Sam
> 
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>>  1 file changed, 58 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> new file mode 100644
>> index 000000000000..20f4fdedfcb0
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> @@ -0,0 +1,58 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
>> +# Copyright 2020 BayLibre, SAS
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: TDO TL070WSH30 DSI panel
>> +
>> +maintainers:
>> +  - Neil Armstrong <narmstrong@baylibre.com>
>> +
>> +allOf:
>> +  - $ref: panel-common.yaml#
>> +
>> +properties:
>> +
>> +  compatible:
>> +    enum:
>> +      - tdo,tl070wsh30
>> +
>> +  reg:
>> +    maxItems: 1
>> +    description: DSI virtual channel
>> +
>> +  backlight: true
>> +  reset-gpios: true
>> +  port: true
>> +  power-supply: true
>> +
>> +additionalProperties: false
>> +
>> +required:
>> +  - compatible
>> +  - power-supply
>> +  - reset-gpios
>> +  - port
>> +  - reg
>> +
>> +examples:
>> +  - |
>> +    dsi {
>> +      #address-cells = <1>;
>> +      #size-cells = <0>;
>> +      panel@0 {
>> +        compatible = "tdo,tl070wsh30";
>> +        reg = <0>;
>> +        power-supply = <&vcc_lcd_reg>;
>> +        backlight = <&panel_backlight>;
>> +        reset-gpios = <&gpio_reset>;
>> +
>> +        port {
>> +          panel: endpoint {
>> +            remote-endpoint = <&mipi_dsi_out>;
>> +          };
>> +        };
>> +      };
>> +    };
>> -- 
>> 2.22.0


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 13:24       ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 13:24 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi,

On 07/09/2020 13:45, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
>> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> 
> The binding looks like a panel-simple-dsi.yaml candidate.
> Only differen is enable-gpios versus reset-gpios

This is the only difference, the panel only has a reset signal and no
enable signal.

But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Neil

> 
> Could you check if we can use panel-simple-dsi-yaml.
> 
> 	Sam
> 
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>>  1 file changed, 58 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> new file mode 100644
>> index 000000000000..20f4fdedfcb0
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> @@ -0,0 +1,58 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
>> +# Copyright 2020 BayLibre, SAS
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: TDO TL070WSH30 DSI panel
>> +
>> +maintainers:
>> +  - Neil Armstrong <narmstrong@baylibre.com>
>> +
>> +allOf:
>> +  - $ref: panel-common.yaml#
>> +
>> +properties:
>> +
>> +  compatible:
>> +    enum:
>> +      - tdo,tl070wsh30
>> +
>> +  reg:
>> +    maxItems: 1
>> +    description: DSI virtual channel
>> +
>> +  backlight: true
>> +  reset-gpios: true
>> +  port: true
>> +  power-supply: true
>> +
>> +additionalProperties: false
>> +
>> +required:
>> +  - compatible
>> +  - power-supply
>> +  - reset-gpios
>> +  - port
>> +  - reg
>> +
>> +examples:
>> +  - |
>> +    dsi {
>> +      #address-cells = <1>;
>> +      #size-cells = <0>;
>> +      panel@0 {
>> +        compatible = "tdo,tl070wsh30";
>> +        reg = <0>;
>> +        power-supply = <&vcc_lcd_reg>;
>> +        backlight = <&panel_backlight>;
>> +        reset-gpios = <&gpio_reset>;
>> +
>> +        port {
>> +          panel: endpoint {
>> +            remote-endpoint = <&mipi_dsi_out>;
>> +          };
>> +        };
>> +      };
>> +    };
>> -- 
>> 2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 13:24       ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-07 13:24 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi,

On 07/09/2020 13:45, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
>> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> 
> The binding looks like a panel-simple-dsi.yaml candidate.
> Only differen is enable-gpios versus reset-gpios

This is the only difference, the panel only has a reset signal and no
enable signal.

But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Neil

> 
> Could you check if we can use panel-simple-dsi-yaml.
> 
> 	Sam
> 
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
>>  1 file changed, 58 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> new file mode 100644
>> index 000000000000..20f4fdedfcb0
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
>> @@ -0,0 +1,58 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
>> +# Copyright 2020 BayLibre, SAS
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: TDO TL070WSH30 DSI panel
>> +
>> +maintainers:
>> +  - Neil Armstrong <narmstrong@baylibre.com>
>> +
>> +allOf:
>> +  - $ref: panel-common.yaml#
>> +
>> +properties:
>> +
>> +  compatible:
>> +    enum:
>> +      - tdo,tl070wsh30
>> +
>> +  reg:
>> +    maxItems: 1
>> +    description: DSI virtual channel
>> +
>> +  backlight: true
>> +  reset-gpios: true
>> +  port: true
>> +  power-supply: true
>> +
>> +additionalProperties: false
>> +
>> +required:
>> +  - compatible
>> +  - power-supply
>> +  - reset-gpios
>> +  - port
>> +  - reg
>> +
>> +examples:
>> +  - |
>> +    dsi {
>> +      #address-cells = <1>;
>> +      #size-cells = <0>;
>> +      panel@0 {
>> +        compatible = "tdo,tl070wsh30";
>> +        reg = <0>;
>> +        power-supply = <&vcc_lcd_reg>;
>> +        backlight = <&panel_backlight>;
>> +        reset-gpios = <&gpio_reset>;
>> +
>> +        port {
>> +          panel: endpoint {
>> +            remote-endpoint = <&mipi_dsi_out>;
>> +          };
>> +        };
>> +      };
>> +    };
>> -- 
>> 2.22.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
  2020-09-07 13:24       ` Neil Armstrong
  (?)
@ 2020-09-07 19:24         ` Sam Ravnborg
  -1 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:24 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi Neil.

On Mon, Sep 07, 2020 at 03:24:47PM +0200, Neil Armstrong wrote:
> Hi,
> 
> On 07/09/2020 13:45, Sam Ravnborg wrote:
> > Hi Neil.
> > 
> > On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> >> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> > 
> > The binding looks like a panel-simple-dsi.yaml candidate.
> > Only differen is enable-gpios versus reset-gpios
> 
> This is the only difference, the panel only has a reset signal and no
> enable signal.
> 
> But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Yes, that would be fine as long as it is not a required property.
It was a mistake we did not add it from the beginning.

There has been patches floating to add reset-gpios to panle.simple.c
that I rejected - this was also wrong.
Really simple and dumb panels has no reset but dsi panels that
panel-simple supports too has a reset.

	Sam


> 
> Neil
> 
> > 
> > Could you check if we can use panel-simple-dsi-yaml.
> > 
> > 	Sam
> > 
> >>
> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> >> ---
> >>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
> >>  1 file changed, 58 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> new file mode 100644
> >> index 000000000000..20f4fdedfcb0
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> @@ -0,0 +1,58 @@
> >> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> >> +# Copyright 2020 BayLibre, SAS
> >> +%YAML 1.2
> >> +---
> >> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: TDO TL070WSH30 DSI panel
> >> +
> >> +maintainers:
> >> +  - Neil Armstrong <narmstrong@baylibre.com>
> >> +
> >> +allOf:
> >> +  - $ref: panel-common.yaml#
> >> +
> >> +properties:
> >> +
> >> +  compatible:
> >> +    enum:
> >> +      - tdo,tl070wsh30
> >> +
> >> +  reg:
> >> +    maxItems: 1
> >> +    description: DSI virtual channel
> >> +
> >> +  backlight: true
> >> +  reset-gpios: true
> >> +  port: true
> >> +  power-supply: true
> >> +
> >> +additionalProperties: false
> >> +
> >> +required:
> >> +  - compatible
> >> +  - power-supply
> >> +  - reset-gpios
> >> +  - port
> >> +  - reg
> >> +
> >> +examples:
> >> +  - |
> >> +    dsi {
> >> +      #address-cells = <1>;
> >> +      #size-cells = <0>;
> >> +      panel@0 {
> >> +        compatible = "tdo,tl070wsh30";
> >> +        reg = <0>;
> >> +        power-supply = <&vcc_lcd_reg>;
> >> +        backlight = <&panel_backlight>;
> >> +        reset-gpios = <&gpio_reset>;
> >> +
> >> +        port {
> >> +          panel: endpoint {
> >> +            remote-endpoint = <&mipi_dsi_out>;
> >> +          };
> >> +        };
> >> +      };
> >> +    };
> >> -- 
> >> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 19:24         ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:24 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi Neil.

On Mon, Sep 07, 2020 at 03:24:47PM +0200, Neil Armstrong wrote:
> Hi,
> 
> On 07/09/2020 13:45, Sam Ravnborg wrote:
> > Hi Neil.
> > 
> > On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> >> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> > 
> > The binding looks like a panel-simple-dsi.yaml candidate.
> > Only differen is enable-gpios versus reset-gpios
> 
> This is the only difference, the panel only has a reset signal and no
> enable signal.
> 
> But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Yes, that would be fine as long as it is not a required property.
It was a mistake we did not add it from the beginning.

There has been patches floating to add reset-gpios to panle.simple.c
that I rejected - this was also wrong.
Really simple and dumb panels has no reset but dsi panels that
panel-simple supports too has a reset.

	Sam


> 
> Neil
> 
> > 
> > Could you check if we can use panel-simple-dsi-yaml.
> > 
> > 	Sam
> > 
> >>
> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> >> ---
> >>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
> >>  1 file changed, 58 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> new file mode 100644
> >> index 000000000000..20f4fdedfcb0
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> @@ -0,0 +1,58 @@
> >> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> >> +# Copyright 2020 BayLibre, SAS
> >> +%YAML 1.2
> >> +---
> >> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: TDO TL070WSH30 DSI panel
> >> +
> >> +maintainers:
> >> +  - Neil Armstrong <narmstrong@baylibre.com>
> >> +
> >> +allOf:
> >> +  - $ref: panel-common.yaml#
> >> +
> >> +properties:
> >> +
> >> +  compatible:
> >> +    enum:
> >> +      - tdo,tl070wsh30
> >> +
> >> +  reg:
> >> +    maxItems: 1
> >> +    description: DSI virtual channel
> >> +
> >> +  backlight: true
> >> +  reset-gpios: true
> >> +  port: true
> >> +  power-supply: true
> >> +
> >> +additionalProperties: false
> >> +
> >> +required:
> >> +  - compatible
> >> +  - power-supply
> >> +  - reset-gpios
> >> +  - port
> >> +  - reg
> >> +
> >> +examples:
> >> +  - |
> >> +    dsi {
> >> +      #address-cells = <1>;
> >> +      #size-cells = <0>;
> >> +      panel@0 {
> >> +        compatible = "tdo,tl070wsh30";
> >> +        reg = <0>;
> >> +        power-supply = <&vcc_lcd_reg>;
> >> +        backlight = <&panel_backlight>;
> >> +        reset-gpios = <&gpio_reset>;
> >> +
> >> +        port {
> >> +          panel: endpoint {
> >> +            remote-endpoint = <&mipi_dsi_out>;
> >> +          };
> >> +        };
> >> +      };
> >> +    };
> >> -- 
> >> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings
@ 2020-09-07 19:24         ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:24 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: devicetree, thierry.reding, linux-kernel, dri-devel, linux-amlogic

Hi Neil.

On Mon, Sep 07, 2020 at 03:24:47PM +0200, Neil Armstrong wrote:
> Hi,
> 
> On 07/09/2020 13:45, Sam Ravnborg wrote:
> > Hi Neil.
> > 
> > On Mon, Sep 07, 2020 at 01:10:26PM +0200, Neil Armstrong wrote:
> >> This add the bindings for the 1024*600 tl070wsh30 DSI panel.
> > 
> > The binding looks like a panel-simple-dsi.yaml candidate.
> > Only differen is enable-gpios versus reset-gpios
> 
> This is the only difference, the panel only has a reset signal and no
> enable signal.
> 
> But I can add a reset-gpios to panel-simple-dsi.yaml, would it be ok ?

Yes, that would be fine as long as it is not a required property.
It was a mistake we did not add it from the beginning.

There has been patches floating to add reset-gpios to panle.simple.c
that I rejected - this was also wrong.
Really simple and dumb panels has no reset but dsi panels that
panel-simple supports too has a reset.

	Sam


> 
> Neil
> 
> > 
> > Could you check if we can use panel-simple-dsi-yaml.
> > 
> > 	Sam
> > 
> >>
> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> >> ---
> >>  .../display/panel/tdo,tl070wsh30.yaml         | 58 +++++++++++++++++++
> >>  1 file changed, 58 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> new file mode 100644
> >> index 000000000000..20f4fdedfcb0
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/display/panel/tdo,tl070wsh30.yaml
> >> @@ -0,0 +1,58 @@
> >> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> >> +# Copyright 2020 BayLibre, SAS
> >> +%YAML 1.2
> >> +---
> >> +$id: http://devicetree.org/schemas/display/panel/tdo,tl070wsh30.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: TDO TL070WSH30 DSI panel
> >> +
> >> +maintainers:
> >> +  - Neil Armstrong <narmstrong@baylibre.com>
> >> +
> >> +allOf:
> >> +  - $ref: panel-common.yaml#
> >> +
> >> +properties:
> >> +
> >> +  compatible:
> >> +    enum:
> >> +      - tdo,tl070wsh30
> >> +
> >> +  reg:
> >> +    maxItems: 1
> >> +    description: DSI virtual channel
> >> +
> >> +  backlight: true
> >> +  reset-gpios: true
> >> +  port: true
> >> +  power-supply: true
> >> +
> >> +additionalProperties: false
> >> +
> >> +required:
> >> +  - compatible
> >> +  - power-supply
> >> +  - reset-gpios
> >> +  - port
> >> +  - reg
> >> +
> >> +examples:
> >> +  - |
> >> +    dsi {
> >> +      #address-cells = <1>;
> >> +      #size-cells = <0>;
> >> +      panel@0 {
> >> +        compatible = "tdo,tl070wsh30";
> >> +        reg = <0>;
> >> +        power-supply = <&vcc_lcd_reg>;
> >> +        backlight = <&panel_backlight>;
> >> +        reset-gpios = <&gpio_reset>;
> >> +
> >> +        port {
> >> +          panel: endpoint {
> >> +            remote-endpoint = <&mipi_dsi_out>;
> >> +          };
> >> +        };
> >> +      };
> >> +    };
> >> -- 
> >> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
  2020-09-07 11:10   ` Neil Armstrong
  (?)
@ 2020-09-07 19:52     ` Sam Ravnborg
  -1 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:52 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: thierry.reding, linux-amlogic, linux-kernel, dri-devel

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
> It provides a MIPI DSI interface to the host, a built-in LED backlight
> and touch controller.

Despite a nicely written driver I noticed a few things that needs to be
addressed.

	Sam
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/panel/Kconfig                |  11 +
>  drivers/gpu/drm/panel/Makefile               |   1 +
>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>  3 files changed, 268 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 8d97d07c5871..2d488a875b99 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>  	  800x600 3.5" panel (found on the Nokia N900).
>  
> +config DRM_PANEL_TDO_TL070WSH30
> +	tristate "TDO TL070WSH30 DSI panel"
> +	depends on OF
> +	depends on DRM_MIPI_DSI
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	help
> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
> +	  panel module. The panel has a 1024×600 resolution and uses
> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
> +	  the host, a built-in LED backlight and touch controller.
> +
>  config DRM_PANEL_TPO_TD028TTEC1
>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>  	depends on OF && SPI
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 15a4e7752951..35ee06a1b5c2 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> new file mode 100644
> index 000000000000..c7a6c2c42c52
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> @@ -0,0 +1,256 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020 BayLibre, SAS
> + * Author: Neil Armstrong <narmstrong@baylibre.com>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <video/mipi_display.h>
> +
> +#include <drm/drm_crtc.h>
> +#include <drm/drm_device.h>
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +
> +struct tdo_tl070wsh30_panel {
> +	struct drm_panel base;
> +	struct mipi_dsi_device *link;
> +
> +	struct regulator *supply;
> +	struct gpio_desc *reset_gpio;
> +
> +	bool prepared;
> +};
> +
> +static inline
> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
> +{
> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
> +}

bikeshedding - but my preference is to order the functions:

prepare
enable
disable
unprepare

As this is the natural order they are used.
Feel free to ignore!

> +
> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (!tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
> +	if (err < 0)
> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
> +
> +	usleep_range(10000, 11000);
> +
> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	usleep_range(10000, 11000);
> +
> +	tdo_tl070wsh30->prepared = false;
> +
> +	return 0;
> +}
> +
> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(200);
> +
> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(20);
> +
> +	tdo_tl070wsh30->prepared = true;
> +
> +	return 0;
> +}
> +
> +static const struct drm_display_mode default_mode = {
> +	.clock = 47250,
> +	.hdisplay = 1024,
> +	.hsync_start = 1024 + 46,
> +	.hsync_end = 1024 + 46 + 80,
> +	.htotal = 1024 + 46 + 80 + 100,
> +	.vdisplay = 600,
> +	.vsync_start = 600 + 5,
> +	.vsync_end = 600 + 5 + 5,
> +	.vtotal = 600 + 5 + 5 + 20,
> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
> +};
> +
> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
> +				       struct drm_connector *connector)
> +{
> +	struct drm_display_mode *mode;
> +
> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
> +	if (!mode) {
> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
> +			default_mode.vdisplay);
Here we often print the refresh rate too.
If there is no need for the refresh rate than at least drop the extra
'x' at the end of the line.

> +		return -ENOMEM;
> +	}
> +
> +	drm_mode_set_name(mode);
> +
> +	drm_mode_probed_add(connector, mode);
> +
> +	connector->display_info.width_mm = 154;
> +	connector->display_info.height_mm = 85;
> +	connector->display_info.bpc = 8;
> +
> +	return 1;
> +}
> +
> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
> +	.prepare = tdo_tl070wsh30_panel_prepare,
> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
> +};
> +
> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
> +	{ .compatible = "tdo,tl070wsh30", },
> +	{ }
I often recommends
	{ /* sentinel },

but thats just to be consistent with what I see in other drivers.

> +};
> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
> +
> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	struct device *dev = &tdo_tl070wsh30->link->dev;
> +	int err;
> +
> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
> +	if (IS_ERR(tdo_tl070wsh30->supply))
> +		return PTR_ERR(tdo_tl070wsh30->supply);
> +
> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
> +						  GPIOD_OUT_LOW);
> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
> +		return err;
> +	}
> +
> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
> +
> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
> +	if (err)
> +		return err;



> +
> +	err = regulator_enable(tdo_tl070wsh30->supply);
> +	if (err < 0)
> +		return err;
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
> +
> +	msleep(200);
> +

It is the job of the prepare function to turn on the panel,
and likewise the unprepare to turn off the panel.
Please move the code above to the prepare function.


> +	drm_panel_add(&tdo_tl070wsh30->base);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	drm_panel_remove(&tdo_tl070wsh30->base);
> +}
This helper does not gain anything - call drm_panel_remove() direct.

> +
> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
> +	int err;
> +
> +	dsi->lanes = 4;
> +	dsi->format = MIPI_DSI_FMT_RGB888;
> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
> +
> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
> +				    GFP_KERNEL);
> +	if (!tdo_tl070wsh30)
> +		return -ENOMEM;
> +
> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
> +	tdo_tl070wsh30->link = dsi;
> +
> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
> +	if (err < 0)
> +		return err;
> +
> +	return mipi_dsi_attach(dsi);
> +}
> +
> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +	int err;
> +
> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
> +
> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
> +
In most panel drivers we just ignore the return results here.

> +	err = mipi_dsi_detach(dsi);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
> +
> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +
> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	drm_panel_disable(&tdo_tl070wsh30->base);
This is the wrong order. disable before unpreapre.


I am not sure what is right here - but I see some drivers that only have
the disable() + unprepare() in their shutdown() method and then the
remocal in their remove() function.
That makes sense with this split but I have not looked too deep into it.

> +}
> +
> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
> +	.driver = {
> +		.name = "panel-tdo-tl070wsh30",
> +		.of_match_table = tdo_tl070wsh30_of_match,
> +	},
> +	.probe = tdo_tl070wsh30_panel_probe,
> +	.remove = tdo_tl070wsh30_panel_remove,
> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
> +};
> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
> +
> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-07 19:52     ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:52 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: linux-amlogic, thierry.reding, linux-kernel, dri-devel

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
> It provides a MIPI DSI interface to the host, a built-in LED backlight
> and touch controller.

Despite a nicely written driver I noticed a few things that needs to be
addressed.

	Sam
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/panel/Kconfig                |  11 +
>  drivers/gpu/drm/panel/Makefile               |   1 +
>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>  3 files changed, 268 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 8d97d07c5871..2d488a875b99 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>  	  800x600 3.5" panel (found on the Nokia N900).
>  
> +config DRM_PANEL_TDO_TL070WSH30
> +	tristate "TDO TL070WSH30 DSI panel"
> +	depends on OF
> +	depends on DRM_MIPI_DSI
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	help
> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
> +	  panel module. The panel has a 1024×600 resolution and uses
> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
> +	  the host, a built-in LED backlight and touch controller.
> +
>  config DRM_PANEL_TPO_TD028TTEC1
>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>  	depends on OF && SPI
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 15a4e7752951..35ee06a1b5c2 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> new file mode 100644
> index 000000000000..c7a6c2c42c52
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> @@ -0,0 +1,256 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020 BayLibre, SAS
> + * Author: Neil Armstrong <narmstrong@baylibre.com>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <video/mipi_display.h>
> +
> +#include <drm/drm_crtc.h>
> +#include <drm/drm_device.h>
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +
> +struct tdo_tl070wsh30_panel {
> +	struct drm_panel base;
> +	struct mipi_dsi_device *link;
> +
> +	struct regulator *supply;
> +	struct gpio_desc *reset_gpio;
> +
> +	bool prepared;
> +};
> +
> +static inline
> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
> +{
> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
> +}

bikeshedding - but my preference is to order the functions:

prepare
enable
disable
unprepare

As this is the natural order they are used.
Feel free to ignore!

> +
> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (!tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
> +	if (err < 0)
> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
> +
> +	usleep_range(10000, 11000);
> +
> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	usleep_range(10000, 11000);
> +
> +	tdo_tl070wsh30->prepared = false;
> +
> +	return 0;
> +}
> +
> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(200);
> +
> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(20);
> +
> +	tdo_tl070wsh30->prepared = true;
> +
> +	return 0;
> +}
> +
> +static const struct drm_display_mode default_mode = {
> +	.clock = 47250,
> +	.hdisplay = 1024,
> +	.hsync_start = 1024 + 46,
> +	.hsync_end = 1024 + 46 + 80,
> +	.htotal = 1024 + 46 + 80 + 100,
> +	.vdisplay = 600,
> +	.vsync_start = 600 + 5,
> +	.vsync_end = 600 + 5 + 5,
> +	.vtotal = 600 + 5 + 5 + 20,
> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
> +};
> +
> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
> +				       struct drm_connector *connector)
> +{
> +	struct drm_display_mode *mode;
> +
> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
> +	if (!mode) {
> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
> +			default_mode.vdisplay);
Here we often print the refresh rate too.
If there is no need for the refresh rate than at least drop the extra
'x' at the end of the line.

> +		return -ENOMEM;
> +	}
> +
> +	drm_mode_set_name(mode);
> +
> +	drm_mode_probed_add(connector, mode);
> +
> +	connector->display_info.width_mm = 154;
> +	connector->display_info.height_mm = 85;
> +	connector->display_info.bpc = 8;
> +
> +	return 1;
> +}
> +
> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
> +	.prepare = tdo_tl070wsh30_panel_prepare,
> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
> +};
> +
> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
> +	{ .compatible = "tdo,tl070wsh30", },
> +	{ }
I often recommends
	{ /* sentinel },

but thats just to be consistent with what I see in other drivers.

> +};
> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
> +
> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	struct device *dev = &tdo_tl070wsh30->link->dev;
> +	int err;
> +
> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
> +	if (IS_ERR(tdo_tl070wsh30->supply))
> +		return PTR_ERR(tdo_tl070wsh30->supply);
> +
> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
> +						  GPIOD_OUT_LOW);
> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
> +		return err;
> +	}
> +
> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
> +
> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
> +	if (err)
> +		return err;



> +
> +	err = regulator_enable(tdo_tl070wsh30->supply);
> +	if (err < 0)
> +		return err;
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
> +
> +	msleep(200);
> +

It is the job of the prepare function to turn on the panel,
and likewise the unprepare to turn off the panel.
Please move the code above to the prepare function.


> +	drm_panel_add(&tdo_tl070wsh30->base);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	drm_panel_remove(&tdo_tl070wsh30->base);
> +}
This helper does not gain anything - call drm_panel_remove() direct.

> +
> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
> +	int err;
> +
> +	dsi->lanes = 4;
> +	dsi->format = MIPI_DSI_FMT_RGB888;
> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
> +
> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
> +				    GFP_KERNEL);
> +	if (!tdo_tl070wsh30)
> +		return -ENOMEM;
> +
> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
> +	tdo_tl070wsh30->link = dsi;
> +
> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
> +	if (err < 0)
> +		return err;
> +
> +	return mipi_dsi_attach(dsi);
> +}
> +
> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +	int err;
> +
> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
> +
> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
> +
In most panel drivers we just ignore the return results here.

> +	err = mipi_dsi_detach(dsi);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
> +
> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +
> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	drm_panel_disable(&tdo_tl070wsh30->base);
This is the wrong order. disable before unpreapre.


I am not sure what is right here - but I see some drivers that only have
the disable() + unprepare() in their shutdown() method and then the
remocal in their remove() function.
That makes sense with this split but I have not looked too deep into it.

> +}
> +
> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
> +	.driver = {
> +		.name = "panel-tdo-tl070wsh30",
> +		.of_match_table = tdo_tl070wsh30_of_match,
> +	},
> +	.probe = tdo_tl070wsh30_panel_probe,
> +	.remove = tdo_tl070wsh30_panel_remove,
> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
> +};
> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
> +
> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-07 19:52     ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2020-09-07 19:52 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: linux-amlogic, thierry.reding, linux-kernel, dri-devel

Hi Neil.

On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
> It provides a MIPI DSI interface to the host, a built-in LED backlight
> and touch controller.

Despite a nicely written driver I noticed a few things that needs to be
addressed.

	Sam
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/panel/Kconfig                |  11 +
>  drivers/gpu/drm/panel/Makefile               |   1 +
>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>  3 files changed, 268 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 8d97d07c5871..2d488a875b99 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>  	  800x600 3.5" panel (found on the Nokia N900).
>  
> +config DRM_PANEL_TDO_TL070WSH30
> +	tristate "TDO TL070WSH30 DSI panel"
> +	depends on OF
> +	depends on DRM_MIPI_DSI
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	help
> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
> +	  panel module. The panel has a 1024×600 resolution and uses
> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
> +	  the host, a built-in LED backlight and touch controller.
> +
>  config DRM_PANEL_TPO_TD028TTEC1
>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>  	depends on OF && SPI
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 15a4e7752951..35ee06a1b5c2 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> new file mode 100644
> index 000000000000..c7a6c2c42c52
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> @@ -0,0 +1,256 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020 BayLibre, SAS
> + * Author: Neil Armstrong <narmstrong@baylibre.com>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <video/mipi_display.h>
> +
> +#include <drm/drm_crtc.h>
> +#include <drm/drm_device.h>
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +
> +struct tdo_tl070wsh30_panel {
> +	struct drm_panel base;
> +	struct mipi_dsi_device *link;
> +
> +	struct regulator *supply;
> +	struct gpio_desc *reset_gpio;
> +
> +	bool prepared;
> +};
> +
> +static inline
> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
> +{
> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
> +}

bikeshedding - but my preference is to order the functions:

prepare
enable
disable
unprepare

As this is the natural order they are used.
Feel free to ignore!

> +
> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (!tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
> +	if (err < 0)
> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
> +
> +	usleep_range(10000, 11000);
> +
> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	usleep_range(10000, 11000);
> +
> +	tdo_tl070wsh30->prepared = false;
> +
> +	return 0;
> +}
> +
> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
> +	int err;
> +
> +	if (tdo_tl070wsh30->prepared)
> +		return 0;
> +
> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(200);
> +
> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
> +	if (err < 0) {
> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
> +		return err;
> +	}
> +
> +	msleep(20);
> +
> +	tdo_tl070wsh30->prepared = true;
> +
> +	return 0;
> +}
> +
> +static const struct drm_display_mode default_mode = {
> +	.clock = 47250,
> +	.hdisplay = 1024,
> +	.hsync_start = 1024 + 46,
> +	.hsync_end = 1024 + 46 + 80,
> +	.htotal = 1024 + 46 + 80 + 100,
> +	.vdisplay = 600,
> +	.vsync_start = 600 + 5,
> +	.vsync_end = 600 + 5 + 5,
> +	.vtotal = 600 + 5 + 5 + 20,
> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
> +};
> +
> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
> +				       struct drm_connector *connector)
> +{
> +	struct drm_display_mode *mode;
> +
> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
> +	if (!mode) {
> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
> +			default_mode.vdisplay);
Here we often print the refresh rate too.
If there is no need for the refresh rate than at least drop the extra
'x' at the end of the line.

> +		return -ENOMEM;
> +	}
> +
> +	drm_mode_set_name(mode);
> +
> +	drm_mode_probed_add(connector, mode);
> +
> +	connector->display_info.width_mm = 154;
> +	connector->display_info.height_mm = 85;
> +	connector->display_info.bpc = 8;
> +
> +	return 1;
> +}
> +
> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
> +	.prepare = tdo_tl070wsh30_panel_prepare,
> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
> +};
> +
> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
> +	{ .compatible = "tdo,tl070wsh30", },
> +	{ }
I often recommends
	{ /* sentinel },

but thats just to be consistent with what I see in other drivers.

> +};
> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
> +
> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	struct device *dev = &tdo_tl070wsh30->link->dev;
> +	int err;
> +
> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
> +	if (IS_ERR(tdo_tl070wsh30->supply))
> +		return PTR_ERR(tdo_tl070wsh30->supply);
> +
> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
> +						  GPIOD_OUT_LOW);
> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
> +		return err;
> +	}
> +
> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
> +
> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
> +	if (err)
> +		return err;



> +
> +	err = regulator_enable(tdo_tl070wsh30->supply);
> +	if (err < 0)
> +		return err;
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
> +
> +	usleep_range(10000, 11000);
> +
> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
> +
> +	msleep(200);
> +

It is the job of the prepare function to turn on the panel,
and likewise the unprepare to turn off the panel.
Please move the code above to the prepare function.


> +	drm_panel_add(&tdo_tl070wsh30->base);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
> +{
> +	drm_panel_remove(&tdo_tl070wsh30->base);
> +}
This helper does not gain anything - call drm_panel_remove() direct.

> +
> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
> +	int err;
> +
> +	dsi->lanes = 4;
> +	dsi->format = MIPI_DSI_FMT_RGB888;
> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
> +
> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
> +				    GFP_KERNEL);
> +	if (!tdo_tl070wsh30)
> +		return -ENOMEM;
> +
> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
> +	tdo_tl070wsh30->link = dsi;
> +
> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
> +	if (err < 0)
> +		return err;
> +
> +	return mipi_dsi_attach(dsi);
> +}
> +
> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +	int err;
> +
> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
> +
> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
> +
In most panel drivers we just ignore the return results here.

> +	err = mipi_dsi_detach(dsi);
> +	if (err < 0)
> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
> +
> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
> +
> +	return 0;
> +}
> +
> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
> +{
> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
> +
> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
> +	drm_panel_disable(&tdo_tl070wsh30->base);
This is the wrong order. disable before unpreapre.


I am not sure what is right here - but I see some drivers that only have
the disable() + unprepare() in their shutdown() method and then the
remocal in their remove() function.
That makes sense with this split but I have not looked too deep into it.

> +}
> +
> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
> +	.driver = {
> +		.name = "panel-tdo-tl070wsh30",
> +		.of_match_table = tdo_tl070wsh30_of_match,
> +	},
> +	.probe = tdo_tl070wsh30_panel_probe,
> +	.remove = tdo_tl070wsh30_panel_remove,
> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
> +};
> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
> +
> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.22.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
  2020-09-07 19:52     ` Sam Ravnborg
  (?)
@ 2020-09-08  7:41       ` Neil Armstrong
  -1 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-08  7:41 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: thierry.reding, linux-amlogic, linux-kernel, dri-devel

Hi,

On 07/09/2020 21:52, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
>> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
>> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
>> It provides a MIPI DSI interface to the host, a built-in LED backlight
>> and touch controller.
> 
> Despite a nicely written driver I noticed a few things that needs to be
> addressed.

Thanks for the review, indeed the remove/shutdown was wrong, and I aligned
with panel-simple, which seems more logical.

> 
> 	Sam
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/gpu/drm/panel/Kconfig                |  11 +
>>  drivers/gpu/drm/panel/Makefile               |   1 +
>>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>>  3 files changed, 268 insertions(+)
>>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 8d97d07c5871..2d488a875b99 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>>  	  800x600 3.5" panel (found on the Nokia N900).
>>  
>> +config DRM_PANEL_TDO_TL070WSH30
>> +	tristate "TDO TL070WSH30 DSI panel"
>> +	depends on OF
>> +	depends on DRM_MIPI_DSI
>> +	depends on BACKLIGHT_CLASS_DEVICE
>> +	help
>> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
>> +	  panel module. The panel has a 1024×600 resolution and uses
>> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
>> +	  the host, a built-in LED backlight and touch controller.
>> +
>>  config DRM_PANEL_TPO_TD028TTEC1
>>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>>  	depends on OF && SPI
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index 15a4e7752951..35ee06a1b5c2 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
>> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
>> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> new file mode 100644
>> index 000000000000..c7a6c2c42c52
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> @@ -0,0 +1,256 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2020 BayLibre, SAS
>> + * Author: Neil Armstrong <narmstrong@baylibre.com>
>> + */
>> +
>> +#include <linux/delay.h>
>> +#include <linux/gpio/consumer.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/regulator/consumer.h>
>> +
>> +#include <video/mipi_display.h>
>> +
>> +#include <drm/drm_crtc.h>
>> +#include <drm/drm_device.h>
>> +#include <drm/drm_mipi_dsi.h>
>> +#include <drm/drm_modes.h>
>> +#include <drm/drm_panel.h>
>> +
>> +struct tdo_tl070wsh30_panel {
>> +	struct drm_panel base;
>> +	struct mipi_dsi_device *link;
>> +
>> +	struct regulator *supply;
>> +	struct gpio_desc *reset_gpio;
>> +
>> +	bool prepared;
>> +};
>> +
>> +static inline
>> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
>> +{
>> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
>> +}
> 
> bikeshedding - but my preference is to order the functions:
> 
> prepare
> enable
> disable
> unprepare
> 
> As this is the natural order they are used.
> Feel free to ignore!

Ack, prepare before unprepare looks better !

> 
>> +
>> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (!tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
>> +	if (err < 0)
>> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	tdo_tl070wsh30->prepared = false;
>> +
>> +	return 0;
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(200);
>> +
>> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(20);
>> +
>> +	tdo_tl070wsh30->prepared = true;
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct drm_display_mode default_mode = {
>> +	.clock = 47250,
>> +	.hdisplay = 1024,
>> +	.hsync_start = 1024 + 46,
>> +	.hsync_end = 1024 + 46 + 80,
>> +	.htotal = 1024 + 46 + 80 + 100,
>> +	.vdisplay = 600,
>> +	.vsync_start = 600 + 5,
>> +	.vsync_end = 600 + 5 + 5,
>> +	.vtotal = 600 + 5 + 5 + 20,
>> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
>> +};
>> +
>> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
>> +				       struct drm_connector *connector)
>> +{
>> +	struct drm_display_mode *mode;
>> +
>> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
>> +	if (!mode) {
>> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
>> +			default_mode.vdisplay);
> Here we often print the refresh rate too.
> If there is no need for the refresh rate than at least drop the extra
> 'x' at the end of the line.

I forgot to remove it after vrefresh removal, but I'll prefer adding back
drm_mode_vrefresh() and the refresh.

> 
>> +		return -ENOMEM;
>> +	}
>> +
>> +	drm_mode_set_name(mode);
>> +
>> +	drm_mode_probed_add(connector, mode);
>> +
>> +	connector->display_info.width_mm = 154;
>> +	connector->display_info.height_mm = 85;
>> +	connector->display_info.bpc = 8;
>> +
>> +	return 1;
>> +}
>> +
>> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
>> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
>> +	.prepare = tdo_tl070wsh30_panel_prepare,
>> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
>> +};
>> +
>> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
>> +	{ .compatible = "tdo,tl070wsh30", },
>> +	{ }
> I often recommends
> 	{ /* sentinel },
> 
> but thats just to be consistent with what I see in other drivers.

Let it be consistent.

> 
>> +};
>> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
>> +
>> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	struct device *dev = &tdo_tl070wsh30->link->dev;
>> +	int err;
>> +
>> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
>> +	if (IS_ERR(tdo_tl070wsh30->supply))
>> +		return PTR_ERR(tdo_tl070wsh30->supply);
>> +
>> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
>> +						  GPIOD_OUT_LOW);
>> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
>> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
>> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
>> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
>> +
>> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
>> +	if (err)
>> +		return err;
> 
> 
> 
>> +
>> +	err = regulator_enable(tdo_tl070wsh30->supply);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
>> +
>> +	msleep(200);
>> +
> 
> It is the job of the prepare function to turn on the panel,
> and likewise the unprepare to turn off the panel.
> Please move the code above to the prepare function.

Moved

> 
> 
>> +	drm_panel_add(&tdo_tl070wsh30->base);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	drm_panel_remove(&tdo_tl070wsh30->base);
>> +}
> This helper does not gain anything - call drm_panel_remove() direct.

Removed

> 
>> +
>> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
>> +	int err;
>> +
>> +	dsi->lanes = 4;
>> +	dsi->format = MIPI_DSI_FMT_RGB888;
>> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
>> +
>> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
>> +				    GFP_KERNEL);
>> +	if (!tdo_tl070wsh30)
>> +		return -ENOMEM;
>> +
>> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
>> +	tdo_tl070wsh30->link = dsi;
>> +
>> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	return mipi_dsi_attach(dsi);
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +	int err;
>> +
>> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
>> +
>> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
>> +
> In most panel drivers we just ignore the return results here.

Ok

> 
>> +	err = mipi_dsi_detach(dsi);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
>> +
>> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +
>> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	drm_panel_disable(&tdo_tl070wsh30->base);
> This is the wrong order. disable before unpreapre.
> 
> 
> I am not sure what is right here - but I see some drivers that only have
> the disable() + unprepare() in their shutdown() method and then the
> remocal in their remove() function.
> That makes sense with this split but I have not looked too deep into it.

No prob, I aligned with panel-simple here.

> 
>> +}
>> +
>> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
>> +	.driver = {
>> +		.name = "panel-tdo-tl070wsh30",
>> +		.of_match_table = tdo_tl070wsh30_of_match,
>> +	},
>> +	.probe = tdo_tl070wsh30_panel_probe,
>> +	.remove = tdo_tl070wsh30_panel_remove,
>> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
>> +};
>> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
>> +
>> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
>> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
>> +MODULE_LICENSE("GPL v2");
>> -- 
>> 2.22.0
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Thanks,
Neil

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-08  7:41       ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-08  7:41 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-amlogic, thierry.reding, linux-kernel, dri-devel

Hi,

On 07/09/2020 21:52, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
>> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
>> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
>> It provides a MIPI DSI interface to the host, a built-in LED backlight
>> and touch controller.
> 
> Despite a nicely written driver I noticed a few things that needs to be
> addressed.

Thanks for the review, indeed the remove/shutdown was wrong, and I aligned
with panel-simple, which seems more logical.

> 
> 	Sam
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/gpu/drm/panel/Kconfig                |  11 +
>>  drivers/gpu/drm/panel/Makefile               |   1 +
>>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>>  3 files changed, 268 insertions(+)
>>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 8d97d07c5871..2d488a875b99 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>>  	  800x600 3.5" panel (found on the Nokia N900).
>>  
>> +config DRM_PANEL_TDO_TL070WSH30
>> +	tristate "TDO TL070WSH30 DSI panel"
>> +	depends on OF
>> +	depends on DRM_MIPI_DSI
>> +	depends on BACKLIGHT_CLASS_DEVICE
>> +	help
>> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
>> +	  panel module. The panel has a 1024×600 resolution and uses
>> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
>> +	  the host, a built-in LED backlight and touch controller.
>> +
>>  config DRM_PANEL_TPO_TD028TTEC1
>>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>>  	depends on OF && SPI
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index 15a4e7752951..35ee06a1b5c2 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
>> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
>> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> new file mode 100644
>> index 000000000000..c7a6c2c42c52
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> @@ -0,0 +1,256 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2020 BayLibre, SAS
>> + * Author: Neil Armstrong <narmstrong@baylibre.com>
>> + */
>> +
>> +#include <linux/delay.h>
>> +#include <linux/gpio/consumer.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/regulator/consumer.h>
>> +
>> +#include <video/mipi_display.h>
>> +
>> +#include <drm/drm_crtc.h>
>> +#include <drm/drm_device.h>
>> +#include <drm/drm_mipi_dsi.h>
>> +#include <drm/drm_modes.h>
>> +#include <drm/drm_panel.h>
>> +
>> +struct tdo_tl070wsh30_panel {
>> +	struct drm_panel base;
>> +	struct mipi_dsi_device *link;
>> +
>> +	struct regulator *supply;
>> +	struct gpio_desc *reset_gpio;
>> +
>> +	bool prepared;
>> +};
>> +
>> +static inline
>> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
>> +{
>> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
>> +}
> 
> bikeshedding - but my preference is to order the functions:
> 
> prepare
> enable
> disable
> unprepare
> 
> As this is the natural order they are used.
> Feel free to ignore!

Ack, prepare before unprepare looks better !

> 
>> +
>> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (!tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
>> +	if (err < 0)
>> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	tdo_tl070wsh30->prepared = false;
>> +
>> +	return 0;
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(200);
>> +
>> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(20);
>> +
>> +	tdo_tl070wsh30->prepared = true;
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct drm_display_mode default_mode = {
>> +	.clock = 47250,
>> +	.hdisplay = 1024,
>> +	.hsync_start = 1024 + 46,
>> +	.hsync_end = 1024 + 46 + 80,
>> +	.htotal = 1024 + 46 + 80 + 100,
>> +	.vdisplay = 600,
>> +	.vsync_start = 600 + 5,
>> +	.vsync_end = 600 + 5 + 5,
>> +	.vtotal = 600 + 5 + 5 + 20,
>> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
>> +};
>> +
>> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
>> +				       struct drm_connector *connector)
>> +{
>> +	struct drm_display_mode *mode;
>> +
>> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
>> +	if (!mode) {
>> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
>> +			default_mode.vdisplay);
> Here we often print the refresh rate too.
> If there is no need for the refresh rate than at least drop the extra
> 'x' at the end of the line.

I forgot to remove it after vrefresh removal, but I'll prefer adding back
drm_mode_vrefresh() and the refresh.

> 
>> +		return -ENOMEM;
>> +	}
>> +
>> +	drm_mode_set_name(mode);
>> +
>> +	drm_mode_probed_add(connector, mode);
>> +
>> +	connector->display_info.width_mm = 154;
>> +	connector->display_info.height_mm = 85;
>> +	connector->display_info.bpc = 8;
>> +
>> +	return 1;
>> +}
>> +
>> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
>> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
>> +	.prepare = tdo_tl070wsh30_panel_prepare,
>> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
>> +};
>> +
>> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
>> +	{ .compatible = "tdo,tl070wsh30", },
>> +	{ }
> I often recommends
> 	{ /* sentinel },
> 
> but thats just to be consistent with what I see in other drivers.

Let it be consistent.

> 
>> +};
>> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
>> +
>> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	struct device *dev = &tdo_tl070wsh30->link->dev;
>> +	int err;
>> +
>> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
>> +	if (IS_ERR(tdo_tl070wsh30->supply))
>> +		return PTR_ERR(tdo_tl070wsh30->supply);
>> +
>> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
>> +						  GPIOD_OUT_LOW);
>> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
>> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
>> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
>> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
>> +
>> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
>> +	if (err)
>> +		return err;
> 
> 
> 
>> +
>> +	err = regulator_enable(tdo_tl070wsh30->supply);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
>> +
>> +	msleep(200);
>> +
> 
> It is the job of the prepare function to turn on the panel,
> and likewise the unprepare to turn off the panel.
> Please move the code above to the prepare function.

Moved

> 
> 
>> +	drm_panel_add(&tdo_tl070wsh30->base);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	drm_panel_remove(&tdo_tl070wsh30->base);
>> +}
> This helper does not gain anything - call drm_panel_remove() direct.

Removed

> 
>> +
>> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
>> +	int err;
>> +
>> +	dsi->lanes = 4;
>> +	dsi->format = MIPI_DSI_FMT_RGB888;
>> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
>> +
>> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
>> +				    GFP_KERNEL);
>> +	if (!tdo_tl070wsh30)
>> +		return -ENOMEM;
>> +
>> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
>> +	tdo_tl070wsh30->link = dsi;
>> +
>> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	return mipi_dsi_attach(dsi);
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +	int err;
>> +
>> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
>> +
>> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
>> +
> In most panel drivers we just ignore the return results here.

Ok

> 
>> +	err = mipi_dsi_detach(dsi);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
>> +
>> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +
>> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	drm_panel_disable(&tdo_tl070wsh30->base);
> This is the wrong order. disable before unpreapre.
> 
> 
> I am not sure what is right here - but I see some drivers that only have
> the disable() + unprepare() in their shutdown() method and then the
> remocal in their remove() function.
> That makes sense with this split but I have not looked too deep into it.

No prob, I aligned with panel-simple here.

> 
>> +}
>> +
>> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
>> +	.driver = {
>> +		.name = "panel-tdo-tl070wsh30",
>> +		.of_match_table = tdo_tl070wsh30_of_match,
>> +	},
>> +	.probe = tdo_tl070wsh30_panel_probe,
>> +	.remove = tdo_tl070wsh30_panel_remove,
>> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
>> +};
>> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
>> +
>> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
>> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
>> +MODULE_LICENSE("GPL v2");
>> -- 
>> 2.22.0
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Thanks,
Neil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver
@ 2020-09-08  7:41       ` Neil Armstrong
  0 siblings, 0 replies; 27+ messages in thread
From: Neil Armstrong @ 2020-09-08  7:41 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-amlogic, thierry.reding, linux-kernel, dri-devel

Hi,

On 07/09/2020 21:52, Sam Ravnborg wrote:
> Hi Neil.
> 
> On Mon, Sep 07, 2020 at 01:10:27PM +0200, Neil Armstrong wrote:
>> This adds support for the TDO TL070WSH30 TFT-LCD panel module.
>> The panel has a 1024×600 resolution and uses 24 bit RGB per pixel.
>> It provides a MIPI DSI interface to the host, a built-in LED backlight
>> and touch controller.
> 
> Despite a nicely written driver I noticed a few things that needs to be
> addressed.

Thanks for the review, indeed the remove/shutdown was wrong, and I aligned
with panel-simple, which seems more logical.

> 
> 	Sam
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/gpu/drm/panel/Kconfig                |  11 +
>>  drivers/gpu/drm/panel/Makefile               |   1 +
>>  drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c | 256 +++++++++++++++++++
>>  3 files changed, 268 insertions(+)
>>  create mode 100644 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 8d97d07c5871..2d488a875b99 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -433,6 +433,17 @@ config DRM_PANEL_SONY_ACX565AKM
>>  	  Say Y here if you want to enable support for the Sony ACX565AKM
>>  	  800x600 3.5" panel (found on the Nokia N900).
>>  
>> +config DRM_PANEL_TDO_TL070WSH30
>> +	tristate "TDO TL070WSH30 DSI panel"
>> +	depends on OF
>> +	depends on DRM_MIPI_DSI
>> +	depends on BACKLIGHT_CLASS_DEVICE
>> +	help
>> +	  Say Y here if you want to enable support for TDO TL070WSH30 TFT-LCD
>> +	  panel module. The panel has a 1024×600 resolution and uses
>> +	  24 bit RGB per pixel. It provides a MIPI DSI interface to
>> +	  the host, a built-in LED backlight and touch controller.
>> +
>>  config DRM_PANEL_TPO_TD028TTEC1
>>  	tristate "Toppoly (TPO) TD028TTEC1 panel driver"
>>  	depends on OF && SPI
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index 15a4e7752951..35ee06a1b5c2 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -45,6 +45,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
>> +obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
>> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> new file mode 100644
>> index 000000000000..c7a6c2c42c52
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
>> @@ -0,0 +1,256 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2020 BayLibre, SAS
>> + * Author: Neil Armstrong <narmstrong@baylibre.com>
>> + */
>> +
>> +#include <linux/delay.h>
>> +#include <linux/gpio/consumer.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/regulator/consumer.h>
>> +
>> +#include <video/mipi_display.h>
>> +
>> +#include <drm/drm_crtc.h>
>> +#include <drm/drm_device.h>
>> +#include <drm/drm_mipi_dsi.h>
>> +#include <drm/drm_modes.h>
>> +#include <drm/drm_panel.h>
>> +
>> +struct tdo_tl070wsh30_panel {
>> +	struct drm_panel base;
>> +	struct mipi_dsi_device *link;
>> +
>> +	struct regulator *supply;
>> +	struct gpio_desc *reset_gpio;
>> +
>> +	bool prepared;
>> +};
>> +
>> +static inline
>> +struct tdo_tl070wsh30_panel *to_tdo_tl070wsh30_panel(struct drm_panel *panel)
>> +{
>> +	return container_of(panel, struct tdo_tl070wsh30_panel, base);
>> +}
> 
> bikeshedding - but my preference is to order the functions:
> 
> prepare
> enable
> disable
> unprepare
> 
> As this is the natural order they are used.
> Feel free to ignore!

Ack, prepare before unprepare looks better !

> 
>> +
>> +static int tdo_tl070wsh30_panel_unprepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (!tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_set_display_off(tdo_tl070wsh30->link);
>> +	if (err < 0)
>> +		dev_err(panel->dev, "failed to set display off: %d\n", err);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	err = mipi_dsi_dcs_enter_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	tdo_tl070wsh30->prepared = false;
>> +
>> +	return 0;
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_prepare(struct drm_panel *panel)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = to_tdo_tl070wsh30_panel(panel);
>> +	int err;
>> +
>> +	if (tdo_tl070wsh30->prepared)
>> +		return 0;
>> +
>> +	err = mipi_dsi_dcs_exit_sleep_mode(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(200);
>> +
>> +	err = mipi_dsi_dcs_set_display_on(tdo_tl070wsh30->link);
>> +	if (err < 0) {
>> +		dev_err(panel->dev, "failed to set display on: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	msleep(20);
>> +
>> +	tdo_tl070wsh30->prepared = true;
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct drm_display_mode default_mode = {
>> +	.clock = 47250,
>> +	.hdisplay = 1024,
>> +	.hsync_start = 1024 + 46,
>> +	.hsync_end = 1024 + 46 + 80,
>> +	.htotal = 1024 + 46 + 80 + 100,
>> +	.vdisplay = 600,
>> +	.vsync_start = 600 + 5,
>> +	.vsync_end = 600 + 5 + 5,
>> +	.vtotal = 600 + 5 + 5 + 20,
>> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
>> +};
>> +
>> +static int tdo_tl070wsh30_panel_get_modes(struct drm_panel *panel,
>> +				       struct drm_connector *connector)
>> +{
>> +	struct drm_display_mode *mode;
>> +
>> +	mode = drm_mode_duplicate(connector->dev, &default_mode);
>> +	if (!mode) {
>> +		dev_err(panel->dev, "failed to add mode %ux%ux\n", default_mode.hdisplay,
>> +			default_mode.vdisplay);
> Here we often print the refresh rate too.
> If there is no need for the refresh rate than at least drop the extra
> 'x' at the end of the line.

I forgot to remove it after vrefresh removal, but I'll prefer adding back
drm_mode_vrefresh() and the refresh.

> 
>> +		return -ENOMEM;
>> +	}
>> +
>> +	drm_mode_set_name(mode);
>> +
>> +	drm_mode_probed_add(connector, mode);
>> +
>> +	connector->display_info.width_mm = 154;
>> +	connector->display_info.height_mm = 85;
>> +	connector->display_info.bpc = 8;
>> +
>> +	return 1;
>> +}
>> +
>> +static const struct drm_panel_funcs tdo_tl070wsh30_panel_funcs = {
>> +	.unprepare = tdo_tl070wsh30_panel_unprepare,
>> +	.prepare = tdo_tl070wsh30_panel_prepare,
>> +	.get_modes = tdo_tl070wsh30_panel_get_modes,
>> +};
>> +
>> +static const struct of_device_id tdo_tl070wsh30_of_match[] = {
>> +	{ .compatible = "tdo,tl070wsh30", },
>> +	{ }
> I often recommends
> 	{ /* sentinel },
> 
> but thats just to be consistent with what I see in other drivers.

Let it be consistent.

> 
>> +};
>> +MODULE_DEVICE_TABLE(of, tdo_tl070wsh30_of_match);
>> +
>> +static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	struct device *dev = &tdo_tl070wsh30->link->dev;
>> +	int err;
>> +
>> +	tdo_tl070wsh30->supply = devm_regulator_get(dev, "power");
>> +	if (IS_ERR(tdo_tl070wsh30->supply))
>> +		return PTR_ERR(tdo_tl070wsh30->supply);
>> +
>> +	tdo_tl070wsh30->reset_gpio = devm_gpiod_get(dev, "reset",
>> +						  GPIOD_OUT_LOW);
>> +	if (IS_ERR(tdo_tl070wsh30->reset_gpio)) {
>> +		err = PTR_ERR(tdo_tl070wsh30->reset_gpio);
>> +		dev_dbg(dev, "failed to get reset gpio: %d\n", err);
>> +		return err;
>> +	}
>> +
>> +	drm_panel_init(&tdo_tl070wsh30->base, &tdo_tl070wsh30->link->dev,
>> +		       &tdo_tl070wsh30_panel_funcs, DRM_MODE_CONNECTOR_DSI);
>> +
>> +	err = drm_panel_of_backlight(&tdo_tl070wsh30->base);
>> +	if (err)
>> +		return err;
> 
> 
> 
>> +
>> +	err = regulator_enable(tdo_tl070wsh30->supply);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 1);
>> +
>> +	usleep_range(10000, 11000);
>> +
>> +	gpiod_set_value_cansleep(tdo_tl070wsh30->reset_gpio, 0);
>> +
>> +	msleep(200);
>> +
> 
> It is the job of the prepare function to turn on the panel,
> and likewise the unprepare to turn off the panel.
> Please move the code above to the prepare function.

Moved

> 
> 
>> +	drm_panel_add(&tdo_tl070wsh30->base);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_del(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>> +{
>> +	drm_panel_remove(&tdo_tl070wsh30->base);
>> +}
> This helper does not gain anything - call drm_panel_remove() direct.

Removed

> 
>> +
>> +static int tdo_tl070wsh30_panel_probe(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30;
>> +	int err;
>> +
>> +	dsi->lanes = 4;
>> +	dsi->format = MIPI_DSI_FMT_RGB888;
>> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM;
>> +
>> +	tdo_tl070wsh30 = devm_kzalloc(&dsi->dev, sizeof(*tdo_tl070wsh30),
>> +				    GFP_KERNEL);
>> +	if (!tdo_tl070wsh30)
>> +		return -ENOMEM;
>> +
>> +	mipi_dsi_set_drvdata(dsi, tdo_tl070wsh30);
>> +	tdo_tl070wsh30->link = dsi;
>> +
>> +	err = tdo_tl070wsh30_panel_add(tdo_tl070wsh30);
>> +	if (err < 0)
>> +		return err;
>> +
>> +	return mipi_dsi_attach(dsi);
>> +}
>> +
>> +static int tdo_tl070wsh30_panel_remove(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +	int err;
>> +
>> +	err = drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to unprepare panel: %d\n", err);
>> +
>> +	err = drm_panel_disable(&tdo_tl070wsh30->base);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
>> +
> In most panel drivers we just ignore the return results here.

Ok

> 
>> +	err = mipi_dsi_detach(dsi);
>> +	if (err < 0)
>> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
>> +
>> +	tdo_tl070wsh30_panel_del(tdo_tl070wsh30);
>> +
>> +	return 0;
>> +}
>> +
>> +static void tdo_tl070wsh30_panel_shutdown(struct mipi_dsi_device *dsi)
>> +{
>> +	struct tdo_tl070wsh30_panel *tdo_tl070wsh30 = mipi_dsi_get_drvdata(dsi);
>> +
>> +	drm_panel_unprepare(&tdo_tl070wsh30->base);
>> +	drm_panel_disable(&tdo_tl070wsh30->base);
> This is the wrong order. disable before unpreapre.
> 
> 
> I am not sure what is right here - but I see some drivers that only have
> the disable() + unprepare() in their shutdown() method and then the
> remocal in their remove() function.
> That makes sense with this split but I have not looked too deep into it.

No prob, I aligned with panel-simple here.

> 
>> +}
>> +
>> +static struct mipi_dsi_driver tdo_tl070wsh30_panel_driver = {
>> +	.driver = {
>> +		.name = "panel-tdo-tl070wsh30",
>> +		.of_match_table = tdo_tl070wsh30_of_match,
>> +	},
>> +	.probe = tdo_tl070wsh30_panel_probe,
>> +	.remove = tdo_tl070wsh30_panel_remove,
>> +	.shutdown = tdo_tl070wsh30_panel_shutdown,
>> +};
>> +module_mipi_dsi_driver(tdo_tl070wsh30_panel_driver);
>> +
>> +MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
>> +MODULE_DESCRIPTION("TDO TL070WSH30 panel driver");
>> +MODULE_LICENSE("GPL v2");
>> -- 
>> 2.22.0
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Thanks,
Neil

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-09-08  7:41 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 11:10 [PATCH 0/3] drm: panel: add support for TDO tl070wsh30 panel Neil Armstrong
2020-09-07 11:10 ` Neil Armstrong
2020-09-07 11:10 ` Neil Armstrong
2020-09-07 11:10 ` [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add Shanghai Top Display Optolelectronics vendor prefix Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 11:10 ` [PATCH v2 2/3] dt-bindings: display: panel: add TDO tl070wsh30 DSI panel bindings Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 11:45   ` Sam Ravnborg
2020-09-07 11:45     ` Sam Ravnborg
2020-09-07 11:45     ` Sam Ravnborg
2020-09-07 13:24     ` Neil Armstrong
2020-09-07 13:24       ` Neil Armstrong
2020-09-07 13:24       ` Neil Armstrong
2020-09-07 19:24       ` Sam Ravnborg
2020-09-07 19:24         ` Sam Ravnborg
2020-09-07 19:24         ` Sam Ravnborg
2020-09-07 11:10 ` [PATCH v2 3/3] drm: panel: add TDO tl070wsh30 panel driver Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 11:10   ` Neil Armstrong
2020-09-07 19:52   ` Sam Ravnborg
2020-09-07 19:52     ` Sam Ravnborg
2020-09-07 19:52     ` Sam Ravnborg
2020-09-08  7:41     ` Neil Armstrong
2020-09-08  7:41       ` Neil Armstrong
2020-09-08  7:41       ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.