Re: [PATCH v3 1/4] dt-bindings: vendor-prefixes: Add prefix for ClockworkPi

2022-10-31 Thread Max Fierke
On Sat, Oct 29, 2022, at 1:17 PM, Samuel Holland wrote:
> Hi Max,
>
> The vendor uses "clockwork" as the prefix in their downstream
> devicetrees[1][2][3], so I would suggest using the same here. I think
> there is a distinction between "Clockwork" the company and "ClockworkPi"
> the product. This is what I did for the board devicetree I sent[4].
>
> Regards,
> Samuel
>

Hi Samuel,

Ah yes, I struggled a bit with the distinction because the company itself
seems to be a bit inconsistent here.

I will follow your lead and post a v4 follow-up with that vendor prefix
changed.

Glad to see someone else working on support for this hardware!

Thanks,
Max


[PATCH v3 4/4] drm/panel: clockworkpi-cwd686: Implement .get_orientation callback

2022-09-17 Thread Max Fierke
Returns the panel's configured orientation

Signed-off-by: Max Fierke 
---
Changes in v3:
 - no changes

Changes in v2:
 - this was added as .get_orientation is now available in drm-misc-next since v1

 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c 
b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
index 87d20d784596..2c433a458c8b 100644
--- a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
+++ b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
@@ -340,7 +340,10 @@ static int cwd686_get_modes(struct drm_panel *panel, 
struct drm_connector *conne
drm_mode_set_name(mode);
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 
-   /* Set up connector's "panel orientation" property */
+   /*
+* TODO: Remove once all drm drivers call
+* drm_connector_set_orientation_from_panel()
+*/
drm_connector_set_panel_orientation(connector, ctx->orientation);
 
drm_mode_probed_add(connector, mode);
@@ -348,10 +351,18 @@ static int cwd686_get_modes(struct drm_panel *panel, 
struct drm_connector *conne
return 1; /* Number of modes */
 }
 
+static enum drm_panel_orientation cwd686_get_orientation(struct drm_panel 
*panel)
+{
+   struct cwd686 *ctx = panel_to_cwd686(panel);
+
+   return ctx->orientation;
+}
+
 static const struct drm_panel_funcs cwd686_drm_funcs = {
.unprepare = cwd686_unprepare,
.prepare = cwd686_prepare,
.get_modes = cwd686_get_modes,
+   .get_orientation = cwd686_get_orientation,
 };
 
 static int cwd686_probe(struct mipi_dsi_device *dsi)
-- 
2.37.2


[PATCH v3 3/4] drm: panel: Add driver for ClockworkPi cwd686 panel

2022-09-17 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver.

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi,
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

Original driver here for reference: 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch
Display IC datasheet provided here: 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf

Signed-off-by: Max Fierke 
---
Changes in v3:
 - no changes

Changes in v2: (Sam Ravnborg's suggestions)
 - remove some unused properties from definition (e.g. enable_gpio, supply)
 - add missing regulators
 - reorder includes
 - remove redundant ctx->backlight in favor of backlight through 
drm_panel_of_backlight
 - remove now-unneeded ctx->enabled and enable/disable hooks
 - replace ICNL9707_DCS macro with mipi_dsi_dcs_write_seq
 - use dev_err_probe instead of checking EPROBE_DEFER
 - fixed return type of cwd686_remove to be void following changes to 
mipi_dsi_driver

 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 445 ++
 3 files changed, 458 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index a582ddd583c2..e6b3d4f091f9 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -68,6 +68,18 @@ config DRM_PANEL_BOE_TV101WUM_NL6
  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
  45NA WUXGA PANEL DSI Video Mode panel
 
+config DRM_PANEL_CLOCKWORKPI_CWD686
+   tristate "ClockworkPi CWD686 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 the ClockworkPi CWD686
+ ICNL9707-based panel, e.g. as used within the ClockworkPi DevTerm.
+ The panel has a 480x1280 resolution and uses 24 bit RGB per pixel.
+
+ To compile this driver as a module, choose M here.
+
 config DRM_PANEL_DSI_CM
tristate "Generic DSI command mode panels"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 34e717382dbb..6c3ed2acaa6b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += 
panel-asus-z00t-tm5p5-n35596.
 obj-$(CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0) += panel-boe-bf060y8m-aj0.o
 obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_CLOCKWORKPI_CWD686) += panel-clockworkpi-cwd686.o
 obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
diff --git a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c 
b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
new file mode 100644
index ..87d20d784596
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
@@ -0,0 +1,445 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Clockwork Tech LLC
+ * Copyright (c) 2021-2022 Max Fierke 
+ *
+ * Based on Pinfan Zhu's work on panel-cwd686.c for ClockworkPi's 5.10 BSP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+struct cwd686 {
+   struct device *dev;
+   struct drm_panel panel;
+   struct regulator *vci;
+   struct regulator *iovcc;
+   struct gpio_desc *reset_gpio;
+   enum drm_panel_orientation orientation;
+   bool prepared;
+};
+
+static const struct drm_display_mode default_mode = {
+   .clock = 54465,
+   .hdisplay = 480,
+   .hsync_start = 480 + 150,
+   .hsync_end = 480 + 150 + 24,
+   .htotal = 480 + 150 + 24 + 40,
+   .vdisplay = 1280,
+   .vsync_start = 1280 + 12,
+   .vsync_end = 1280 + 12 + 6,
+   .vtotal = 1280 + 12 + 6 + 10,
+};
+
+static inline struct cwd686 *panel_to_cwd686(struct drm_panel *panel)
+{
+   return container_of(panel, struct cwd686, panel);
+}
+
+#define ICNL9707_CMD_CGOUTL 0xB3
+#define ICNL9707_CMD_CGOUTR 0xB4
+#define ICNL9707_P_CGOUT_VGL 0x00
+#define ICNL9707_P_CGOUT_VGH 0x01
+#define ICNL9707_P_CGOUT_HZ 0x02
+#define ICNL9707_P_CGOUT_GND 0x03
+#define ICNL9707_P_CGOUT_GSP1 0x04
+#define ICNL9707_P_CGOUT_GSP2 0x05
+#define ICNL9707_P_CGOUT_GSP3 0x06
+#define ICNL9707_P_CGOUT_GSP4 0x07
+#de

[PATCH v3 2/4] dt-bindings: display: Add ClockworkPi CWD686 panel

2022-09-17 Thread Max Fierke
The CWD686 is a 6.86" IPS LCD panel used as the primary
display in the ClockworkPi DevTerm portable (all cores)

Signed-off-by: Max Fierke 
Reviewed-by: Krzysztof Kozlowski 
---
Changes in v3 (Krzysztof Kozlowski's Suggestions)
 - add missing lines for spacing

Changes in v2 (Krzysztof Kozlowski and Rob Herring's Suggestions)
 - remove redundant backlight example
 - add missing regulators

 .../display/panel/clockworkpi,cwd686.yaml | 65 +++
 1 file changed, 65 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml

diff --git 
a/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml 
b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
new file mode 100644
index ..936e353f25e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/clockworkpi,cwd686.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ClockworkPi CWD686 6.86" IPS LCD panel
+
+maintainers:
+  - Max Fierke 
+
+description: |
+  The ClockworkPi CWD686 is a 6.86" ICNL9707-based IPS LCD panel used within 
the
+  ClockworkPi DevTerm series of portable devices. The panel has a 480x1280
+  resolution and uses 24 bit RGB per pixel.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: clockworkpi,cwd686
+
+  reg:
+description: DSI virtual channel used by that screen
+maxItems: 1
+
+  iovcc-supply:
+description: regulator that supplies the iovcc voltage
+
+  vci-supply:
+description: regulator that supplies the vci voltage
+
+  reset-gpios: true
+  rotation: true
+  backlight: true
+
+required:
+  - compatible
+  - reg
+  - backlight
+  - reset-gpios
+  - iovcc-supply
+  - vci-supply
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+dsi {
+#address-cells = <1>;
+#size-cells = <0>;
+
+panel@0 {
+compatible = "clockworkpi,cwd686";
+reg = <0>;
+backlight = <>;
+reset-gpios = < 28 GPIO_ACTIVE_HIGH>;
+rotation = <90>;
+iovcc-supply = <_1v8>;
+vci-supply = <_sys>;
+};
+};
-- 
2.37.2


[PATCH v3 0/4] Introduce ClockworkPi CWD686 DRM panel driver

2022-09-17 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver[1].

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi[1],
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

[1] 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf
[2] 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch

Thanks to Krzysztof Kozlowski, Rob Herring, and Sam Ravnborg for their
prior reviews and apologies for the long delay between patch set versions.

Changes in v3:
 - dt-bindings: add missing lines for spacing

Changes in v2:
 - dt-bindings: remove redundant backlight example
 - add missing regulators
 - remove some unused properties from definition (e.g. enable_gpio, supply)
 - reorder includes
 - remove redundant ctx->backlight in favor of backlight through 
drm_panel_of_backlight
 - remove now-unneeded ctx->enabled and enable/disable hooks
 - replace ICNL9707_DCS macro with mipi_dsi_dcs_write_seq
 - use dev_err_probe instead of checking EPROBE_DEFER
 - fixed return type of cwd686_remove to be void following changes to 
mipi_dsi_driver
 - add .get_orientation callback

Max Fierke (4):
  dt-bindings: vendor-prefixes: Add prefix for ClockworkPi
  dt-bindings: display: Add ClockworkPi CWD686 panel
  drm: panel: Add driver for ClockworkPi cwd686 panel
  drm/panel: clockworkpi-cwd686: Implement .get_orientation callback

 .../display/panel/clockworkpi,cwd686.yaml |  65 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 456 ++
 5 files changed, 536 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

-- 
2.37.2


[PATCH v3 1/4] dt-bindings: vendor-prefixes: Add prefix for ClockworkPi

2022-09-17 Thread Max Fierke
Add a prefix for Clockwork Tech LLC, known as ClockworkPi. They
produce a number of hobbyist devices, including the ClockworkPi
DevTerm and GameShell.

Signed-off-by: Max Fierke 
Acked-by: Krzysztof Kozlowski 
---
 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 2f0151e9f6be..64f4b899c40c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -258,6 +258,8 @@ patternProperties:
 description: Cirrus Logic, Inc.
   "^cisco,.*":
 description: Cisco Systems, Inc.
+  "^clockworkpi,.*":
+description: Clockwork Tech LLC
   "^cloudengines,.*":
 description: Cloud Engines, Inc.
   "^cnm,.*":
-- 
2.37.2



[PATCH v2 0/4] Introduce ClockworkPi CWD686 DRM panel driver

2022-09-05 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver[1].

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi[1],
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

[1] 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf
[2] 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch

Thanks to Krzysztof Kozlowski, Rob Herring, and Sam Ravnborg for their
prior reviews and apologies for the long delay between patch set versions.

Changes in v2:
 - dt-bindings: remove redundant backlight example
 - add missing regulators
 - remove some unused properties from definition (e.g. enable_gpio, supply)
 - reorder includes
 - remove redundant ctx->backlight in favor of backlight through 
drm_panel_of_backlight
 - remove now-unneeded ctx->enabled and enable/disable hooks
 - replace ICNL9707_DCS macro with mipi_dsi_dcs_write_seq
 - use dev_err_probe instead of checking EPROBE_DEFER
 - fixed return type of cwd686_remove to be void following changes to 
mipi_dsi_driver
 - add .get_orientation callback

Max Fierke (4):
  dt-bindings: vendor-prefixes: Add prefix for ClockworkPi
  dt-bindings: display: Add ClockworkPi CWD686 panel
  drm: panel: Add driver for ClockworkPi cwd686 panel
  drm/panel: clockworkpi-cwd686: Implement .get_orientation callback

 .../display/panel/clockworkpi,cwd686.yaml |  63 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 456 ++
 5 files changed, 534 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

-- 
2.37.1


[PATCH v2 3/4] drm: panel: Add driver for ClockworkPi cwd686 panel

2022-09-05 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver.

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi,
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

Original driver here for reference: 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch
Display IC datasheet provided here: 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf

Signed-off-by: Max Fierke 
---
Changes in v2: (Sam Ravnborg's suggestions)
 - remove some unused properties from definition (e.g. enable_gpio, supply)
 - add missing regulators
 - reorder includes
 - remove redundant ctx->backlight in favor of backlight through 
drm_panel_of_backlight
 - remove now-unneeded ctx->enabled and enable/disable hooks
 - replace ICNL9707_DCS macro with mipi_dsi_dcs_write_seq
 - use dev_err_probe instead of checking EPROBE_DEFER
 - fixed return type of cwd686_remove to be void following changes to 
mipi_dsi_driver

 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 445 ++
 3 files changed, 458 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 584a69f99af6..a93c697867f9 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -68,6 +68,18 @@ config DRM_PANEL_BOE_TV101WUM_NL6
  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
  45NA WUXGA PANEL DSI Video Mode panel
 
+config DRM_PANEL_CLOCKWORKPI_CWD686
+   tristate "ClockworkPi CWD686 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 the ClockworkPi CWD686
+ ICNL9707-based panel, e.g. as used within the ClockworkPi DevTerm.
+ The panel has a 480x1280 resolution and uses 24 bit RGB per pixel.
+
+ To compile this driver as a module, choose M here.
+
 config DRM_PANEL_DSI_CM
tristate "Generic DSI command mode panels"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 34e717382dbb..6c3ed2acaa6b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += 
panel-asus-z00t-tm5p5-n35596.
 obj-$(CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0) += panel-boe-bf060y8m-aj0.o
 obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_CLOCKWORKPI_CWD686) += panel-clockworkpi-cwd686.o
 obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
diff --git a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c 
b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
new file mode 100644
index ..87d20d784596
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
@@ -0,0 +1,445 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Clockwork Tech LLC
+ * Copyright (c) 2021-2022 Max Fierke 
+ *
+ * Based on Pinfan Zhu's work on panel-cwd686.c for ClockworkPi's 5.10 BSP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+struct cwd686 {
+   struct device *dev;
+   struct drm_panel panel;
+   struct regulator *vci;
+   struct regulator *iovcc;
+   struct gpio_desc *reset_gpio;
+   enum drm_panel_orientation orientation;
+   bool prepared;
+};
+
+static const struct drm_display_mode default_mode = {
+   .clock = 54465,
+   .hdisplay = 480,
+   .hsync_start = 480 + 150,
+   .hsync_end = 480 + 150 + 24,
+   .htotal = 480 + 150 + 24 + 40,
+   .vdisplay = 1280,
+   .vsync_start = 1280 + 12,
+   .vsync_end = 1280 + 12 + 6,
+   .vtotal = 1280 + 12 + 6 + 10,
+};
+
+static inline struct cwd686 *panel_to_cwd686(struct drm_panel *panel)
+{
+   return container_of(panel, struct cwd686, panel);
+}
+
+#define ICNL9707_CMD_CGOUTL 0xB3
+#define ICNL9707_CMD_CGOUTR 0xB4
+#define ICNL9707_P_CGOUT_VGL 0x00
+#define ICNL9707_P_CGOUT_VGH 0x01
+#define ICNL9707_P_CGOUT_HZ 0x02
+#define ICNL9707_P_CGOUT_GND 0x03
+#define ICNL9707_P_CGOUT_GSP1 0x04
+#define ICNL9707_P_CGOUT_GSP2 0x05
+#define ICNL9707_P_CGOUT_GSP3 0x06
+#define ICNL9707_P_CGOUT_GSP4 0x07
+#define ICNL9707_P_CGOUT_GSP5 0x08

[PATCH v2 2/4] dt-bindings: display: Add ClockworkPi CWD686 panel

2022-09-05 Thread Max Fierke
The CWD686 is a 6.86" IPS LCD panel used as the primary
display in the ClockworkPi DevTerm portable (all cores)

Signed-off-by: Max Fierke 
Reviewed-by: Krzysztof Kozlowski 
---
Changes in v2 (Krzysztof Kozlowski and Rob Herring's Suggestions)
 - remove redundant backlight example
 - add missing regulators

 .../display/panel/clockworkpi,cwd686.yaml | 63 +++
 1 file changed, 63 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml

diff --git 
a/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml 
b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
new file mode 100644
index ..eaf55d629266
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/clockworkpi,cwd686.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ClockworkPi CWD686 6.86" IPS LCD panel
+
+maintainers:
+  - Max Fierke 
+
+description: |
+  The ClockworkPi CWD686 is a 6.86" ICNL9707-based IPS LCD panel used within 
the
+  ClockworkPi DevTerm series of portable devices. The panel has a 480x1280
+  resolution and uses 24 bit RGB per pixel.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: clockworkpi,cwd686
+
+  reg:
+description: DSI virtual channel used by that screen
+maxItems: 1
+  iovcc-supply:
+description: regulator that supplies the iovcc voltage
+  vci-supply:
+description: regulator that supplies the vci voltage
+
+  reset-gpios: true
+  rotation: true
+  backlight: true
+
+required:
+  - compatible
+  - reg
+  - backlight
+  - reset-gpios
+  - iovcc-supply
+  - vci-supply
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+dsi {
+#address-cells = <1>;
+#size-cells = <0>;
+
+panel@0 {
+compatible = "clockworkpi,cwd686";
+reg = <0>;
+backlight = <>;
+reset-gpios = < 28 GPIO_ACTIVE_HIGH>;
+rotation = <90>;
+iovcc-supply = <_1v8>;
+vci-supply = <_sys>;
+};
+};
-- 
2.37.1


[PATCH v2 1/4] dt-bindings: vendor-prefixes: Add prefix for ClockworkPi

2022-09-05 Thread Max Fierke
Add a prefix for Clockwork Tech LLC, known as ClockworkPi. They
produce a number of hobbyist devices, including the ClockworkPi
DevTerm and GameShell.

Signed-off-by: Max Fierke 
Acked-by: Krzysztof Kozlowski 
---
 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 7a326168d1d2..b9cf4f02c362 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -254,6 +254,8 @@ patternProperties:
 description: Cirrus Logic, Inc.
   "^cisco,.*":
 description: Cisco Systems, Inc.
+  "^clockworkpi,.*":
+description: Clockwork Tech LLC
   "^cloudengines,.*":
 description: Cloud Engines, Inc.
   "^cnm,.*":
-- 
2.37.1



[PATCH v2 4/4] drm/panel: clockworkpi-cwd686: Implement .get_orientation callback

2022-09-05 Thread Max Fierke
Returns the panel's configured orientation

Signed-off-by: Max Fierke 
---
Changes in v2:
 - this was added as .get_orientation is now available in drm-misc-next since v1

 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c 
b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
index 87d20d784596..2c433a458c8b 100644
--- a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
+++ b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
@@ -340,7 +340,10 @@ static int cwd686_get_modes(struct drm_panel *panel, 
struct drm_connector *conne
drm_mode_set_name(mode);
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 
-   /* Set up connector's "panel orientation" property */
+   /*
+* TODO: Remove once all drm drivers call
+* drm_connector_set_orientation_from_panel()
+*/
drm_connector_set_panel_orientation(connector, ctx->orientation);
 
drm_mode_probed_add(connector, mode);
@@ -348,10 +351,18 @@ static int cwd686_get_modes(struct drm_panel *panel, 
struct drm_connector *conne
return 1; /* Number of modes */
 }
 
+static enum drm_panel_orientation cwd686_get_orientation(struct drm_panel 
*panel)
+{
+   struct cwd686 *ctx = panel_to_cwd686(panel);
+
+   return ctx->orientation;
+}
+
 static const struct drm_panel_funcs cwd686_drm_funcs = {
.unprepare = cwd686_unprepare,
.prepare = cwd686_prepare,
.get_modes = cwd686_get_modes,
+   .get_orientation = cwd686_get_orientation,
 };
 
 static int cwd686_probe(struct mipi_dsi_device *dsi)
-- 
2.37.1


Re: [PATCH 2/3] dt-bindings: display: Add bindings for ClockworkPi CWD686

2022-06-02 Thread Max Fierke
On Wed, Jun 1, 2022, at 1:47 PM, Rob Herring wrote:
>
> You probably can simply add this to panel-simple-dsi.yaml. It mainly 
> depends on how many power supplies this panel has.
>

Unfortunately, it does have two, a 1.8v and a 3.3v, so panel-simple-dsi.yml 
won't work here. On the devices on which the panel is present, they're both 
always on so they were left out here, but this is a good reminder that they 
probably should be added anyway.

Thanks,
Max


[PATCH 0/3] Introduce ClockworkPi CWD686 DRM panel driver

2022-06-01 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver[1].

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi[1],
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

[1] 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf
[2] 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch

Signed-off-by: Max Fierke 

Max Fierke (3):
  dt-bindings: vendor-prefixes: Add prefix for ClockworkPi
  dt-bindings: display: Add bindings for ClockworkPi CWD686
  drm: panel: Add driver for ClockworkPi cwd686 panel

 .../display/panel/clockworkpi,cwd686.yaml |  60 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 458 ++
 5 files changed, 533 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

-- 
2.36.1


[PATCH 1/3] dt-bindings: vendor-prefixes: Add prefix for ClockworkPi

2022-06-01 Thread Max Fierke
Add a prefix for Clockwork Tech LLC, known as ClockworkPi. They
produce a number of hobbyist devices, including the ClockworkPi
DevTerm and GameShell.

Signed-off-by: Max Fierke 
---
 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 79b72e370ade..9546d8320224 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -251,6 +251,8 @@ patternProperties:
 description: Cirrus Logic, Inc.
   "^cisco,.*":
 description: Cisco Systems, Inc.
+  "^clockworkpi,.*":
+description: Clockwork Tech LLC
   "^cloudengines,.*":
 description: Cloud Engines, Inc.
   "^cnm,.*":
-- 
2.36.1



[PATCH 2/3] dt-bindings: display: Add bindings for ClockworkPi CWD686

2022-06-01 Thread Max Fierke
The CWD686 is a 6.86" IPS LCD panel used as the primary
display in the ClockworkPi DevTerm portable (all cores)

Signed-off-by: Max Fierke 
---
 .../display/panel/clockworkpi,cwd686.yaml | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml

diff --git 
a/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml 
b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
new file mode 100644
index ..935a33b9305f
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/clockworkpi,cwd686.yaml
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/clockworkpi,cwd686.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ClockworkPi CWD686 6.86" IPS LCD panel
+
+maintainers:
+  - Max Fierke 
+
+description: |
+  The ClockworkPi CWD686 is a 6.86" ICNL9707-based IPS LCD panel used within 
the
+  ClockworkPi DevTerm series of portable devices. The panel has a 480x1280
+  resolution and uses 24 bit RGB per pixel.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: clockworkpi,cwd686
+
+  reg:
+description: DSI virtual channel used by that screen
+maxItems: 1
+
+  reset-gpios: true
+  rotation: true
+  backlight: true
+
+required:
+  - compatible
+  - reg
+  - backlight
+  - reset-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+backlight: backlight {
+compatible = "gpio-backlight";
+gpios = < 30 GPIO_ACTIVE_HIGH>;
+};
+
+dsi {
+#address-cells = <1>;
+#size-cells = <0>;
+
+panel@0 {
+compatible = "clockworkpi,cwd686";
+reg = <0>;
+backlight = <>;
+reset-gpios = < 28 GPIO_ACTIVE_HIGH>;
+rotation = <90>;
+};
+};
-- 
2.36.1



[PATCH 3/3] drm: panel: Add driver for ClockworkPi cwd686 panel

2022-06-01 Thread Max Fierke
The ClockworkPi DevTerm (all models) uses a 6.86" IPS display
of unknown provenance, which uses the Chipone ICNL9707 IC driver.

The display panel I have has two model numbers: TXW686001 and WTL068601G,
but cannot find any manufacturer associated with either, so opting for the
ClockworkPi model number.

This driver is based on the GPL-licensed driver released by ClockworkPi,
authored by Pinfan Zhu, with some additional cleanup, rotation support,
and display sleep re-enabling done by me.

Original driver here for reference: 
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-004-panel.patch
Display IC datasheet provided here: 
https://github.com/clockworkpi/DevTerm/blob/main/Schematics/ICNL9707_Datasheet.pdf

Signed-off-by: Max Fierke 
---
 drivers/gpu/drm/panel/Kconfig |  12 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-clockworkpi-cwd686.c  | 458 ++
 3 files changed, 471 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 4f1f004b3c54..f9cf2c8124b7 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -68,6 +68,18 @@ config DRM_PANEL_BOE_TV101WUM_NL6
  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
  45NA WUXGA PANEL DSI Video Mode panel
 
+config DRM_PANEL_CLOCKWORKPI_CWD686
+   tristate "ClockworkPi CWD686 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 the ClockworkPi CWD686
+ ICNL9707-based panel, e.g. as used within the ClockworkPi DevTerm.
+ The panel has a 480x1280 resolution and uses 24 bit RGB per pixel.
+
+ To compile this driver as a module, choose M here.
+
 config DRM_PANEL_DSI_CM
tristate "Generic DSI command mode panels"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 42a7ab54234b..24584bd7d4f8 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += 
panel-asus-z00t-tm5p5-n35596.
 obj-$(CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0) += panel-boe-bf060y8m-aj0.o
 obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_CLOCKWORKPI_CWD686) += panel-clockworkpi-cwd686.o
 obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
diff --git a/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c 
b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
new file mode 100644
index ..4ef24388d37c
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-clockworkpi-cwd686.c
@@ -0,0 +1,458 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Clockwork Tech LLC
+ * Copyright (c) 2021-2022 Max Fierke 
+ *
+ * Based on Pinfan Zhu's work on panel-cwd686.c for ClockworkPi's 5.10 BSP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct cwd686 {
+   struct device *dev;
+   struct drm_panel panel;
+   struct regulator *supply;
+   struct gpio_desc *enable_gpio;
+   struct gpio_desc *reset_gpio;
+   struct backlight_device *backlight;
+   enum drm_panel_orientation orientation;
+   bool prepared;
+   bool enabled;
+};
+
+static const struct drm_display_mode default_mode = {
+   .clock = 54465,
+   .hdisplay = 480,
+   .hsync_start = 480 + 150,
+   .hsync_end = 480 + 150 + 24,
+   .htotal = 480 + 150 + 24 + 40,
+   .vdisplay = 1280,
+   .vsync_start = 1280 + 12,
+   .vsync_end = 1280 + 12 + 6,
+   .vtotal = 1280 + 12 + 6 + 10,
+};
+
+static inline struct cwd686 *panel_to_cwd686(struct drm_panel *panel)
+{
+   return container_of(panel, struct cwd686, panel);
+}
+
+#define ICNL9707_DCS(seq...)  \
+({  \
+   static const u8 d[] = { seq };  \
+   mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));\
+})
+
+#define ICNL9707_CMD_CGOUTL 0xB3
+#define ICNL9707_CMD_CGOUTR 0xB4
+#define ICNL9707_P_CGOUT_VGL 0x00
+#define ICNL9707_P_CGOUT_VGH 0x01
+#define ICNL9707_P_CGOUT_HZ 0x02
+#define ICNL9707_P_CGOUT_GND 0x03
+#define ICNL9707_P_CGOUT_GSP1 0x04
+#define ICNL9707_P_CGOUT_GSP2 0x05
+#define ICNL9707_P_CGOUT_GSP3 0x06
+#define ICNL9707_P_CGOUT_GSP4 0x07
+#define ICNL9707_P_CGOUT_GSP5 0x08
+#define ICNL9707_P_CGOUT_GSP6 0x09
+#define ICNL9707_P_CGOUT_GSP7 0x0A
+#define ICNL9707_P_CGOUT_GSP8 0x0B
+#define ICNL9707_P_CGOUT_GCK1 0x0C
+#define ICNL9707_P