Re: [PATCH 3/4] drm/tiny/mi0283qt: Move driver to panel-ilitek-ili9341

2019-08-01 Thread David Lechner

On 8/1/19 8:52 AM, Noralf Trønnes wrote:

The MI0283QT panels use a ILI9341 controller so it makes sense to merge
it with the other ili9341 code.

The DRM driver name is ABI, so that is retained.

Cc: David Lechner 
Signed-off-by: Noralf Trønnes 
---


...


@@ -216,6 +339,10 @@ static int ili9341_probe(struct spi_device *spi)
return PTR_ERR(dc);
}
  
+	ili->regulator = devm_regulator_get(dev, "power");

+   if (IS_ERR(ili->regulator))
+   return PTR_ERR(ili->regulator);
+
ili->backlight = devm_of_find_backlight(dev);
if (IS_ERR(ili->backlight))
return PTR_ERR(ili->backlight);
@@ -230,7 +357,12 @@ static int ili9341_probe(struct spi_device *spi)
ili->panel.dev = dev;
ili->panel.funcs = ili->conf->funcs;
  


Should probably add a comment here that this is for backwards
compatibility of the driver name so that no one is tempted to
to add more driver structs when adding new panels.


-   return drm_mipi_dbi_panel_register(>panel, >dbidev, 
_drm_driver,
+   if (ili->conf == _data)
+   driver = _drm_driver;
+   else
+   driver = _drm_driver;
+
+   return drm_mipi_dbi_panel_register(>panel, >dbidev, driver,
   ili->conf->mode, rotation);
  }
  

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

[PATCH 3/4] drm/tiny/mi0283qt: Move driver to panel-ilitek-ili9341

2019-08-01 Thread Noralf Trønnes
The MI0283QT panels use a ILI9341 controller so it makes sense to merge
it with the other ili9341 code.

The DRM driver name is ABI, so that is retained.

Cc: David Lechner 
Signed-off-by: Noralf Trønnes 
---
 MAINTAINERS  |   9 +-
 drivers/gpu/drm/panel/Kconfig|   1 +
 drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 161 +-
 drivers/gpu/drm/tiny/Kconfig |  11 -
 drivers/gpu/drm/tiny/Makefile|   1 -
 drivers/gpu/drm/tiny/mi0283qt.c  | 294 ---
 6 files changed, 161 insertions(+), 316 deletions(-)
 delete mode 100644 drivers/gpu/drm/tiny/mi0283qt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 66b3893a100f..cd7b8bdb3780 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5110,10 +5110,12 @@ F:  
Documentation/devicetree/bindings/display/ilitek,ili9225.txt
 
 DRM DRIVER FOR ILITEK ILI9341 PANELS
 M: David Lechner 
+M: Noralf Trønnes 
 T: git git://anongit.freedesktop.org/drm/drm-misc
 S: Maintained
 F: drivers/gpu/drm/panel/panel-ilitek-ili9341.c
 F: Documentation/devicetree/bindings/display/ilitek,ili9341.txt
+F: Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
 
 DRM DRIVER FOR HX8357D PANELS
 M: Eric Anholt 
@@ -5137,13 +5139,6 @@ M:   Dave Airlie 
 S: Odd Fixes
 F: drivers/gpu/drm/mgag200/
 
-DRM DRIVER FOR MI0283QT
-M: Noralf Trønnes 
-T: git git://anongit.freedesktop.org/drm/drm-misc
-S: Maintained
-F: drivers/gpu/drm/tiny/mi0283qt.c
-F: Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
-
 DRM DRIVER FOR MSM ADRENO GPU
 M: Rob Clark 
 M: Sean Paul 
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index a24953ec2d40..fbb5a723eeb5 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -65,6 +65,7 @@ config DRM_PANEL_ILITEK_ILI9341
help
  DRM driver for the following Ilitek ILI9341 panels:
  * YX240QV29-T 2.4" 240x320 TFT (Adafruit 2.4")
+ * Multi-Inno MI0283QT
 
  If M is selected the module will be called panel-ilitek-ili9341.
 
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c 
b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
index f8df737018d3..f6082fa2a389 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
@@ -3,8 +3,6 @@
  * DRM driver for Ilitek ILI9341 panels
  *
  * Copyright 2018 David Lechner 
- *
- * Based on mi0283qt.c:
  * Copyright 2016 Noralf Trønnes
  */
 
@@ -13,7 +11,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define ILI9341_FRMCTR10xb1
@@ -57,6 +58,7 @@ struct ili9341_config {
 struct ili9341 {
struct mipi_dbi_dev dbidev; /* This must be the first entry */
struct drm_panel panel;
+   struct regulator *regulator;
struct backlight_device *backlight;
const struct ili9341_config *conf;
 };
@@ -174,12 +176,133 @@ static const struct ili9341_config yx240qv29_data = {
.mode = _mode,
 };
 
+static int mi0283qt_prepare(struct drm_panel *panel)
+{
+   struct ili9341 *ili = panel_to_ili9341(panel);
+   struct mipi_dbi_dev *dbidev = >dbidev;
+   struct mipi_dbi *dbi = >dbi;
+   u8 addr_mode;
+   int ret;
+
+   if (ili->regulator)
+   regulator_enable(ili->regulator);
+
+   ret = mipi_dbi_poweron_conditional_reset(dbidev);
+   if (ret < 0) {
+   if (ili->regulator)
+   regulator_disable(ili->regulator);
+   return ret;
+   }
+   if (ret == 1)
+   goto out_enable;
+
+   mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF);
+
+   mipi_dbi_command(dbi, ILI9341_PWCTRLB, 0x00, 0x83, 0x30);
+   mipi_dbi_command(dbi, ILI9341_PWRSEQ, 0x64, 0x03, 0x12, 0x81);
+   mipi_dbi_command(dbi, ILI9341_DTCTRLA, 0x85, 0x01, 0x79);
+   mipi_dbi_command(dbi, ILI9341_PWCTRLA, 0x39, 0x2c, 0x00, 0x34, 0x02);
+   mipi_dbi_command(dbi, ILI9341_PUMPCTRL, 0x20);
+   mipi_dbi_command(dbi, ILI9341_DTCTRLB, 0x00, 0x00);
+
+   /* Power Control */
+   mipi_dbi_command(dbi, ILI9341_PWCTRL1, 0x26);
+   mipi_dbi_command(dbi, ILI9341_PWCTRL2, 0x11);
+   /* VCOM */
+   mipi_dbi_command(dbi, ILI9341_VMCTRL1, 0x35, 0x3e);
+   mipi_dbi_command(dbi, ILI9341_VMCTRL2, 0xbe);
+
+   /* Memory Access Control */
+   mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, 
MIPI_DCS_PIXEL_FMT_16BIT);
+
+   /* Frame Rate */
+   mipi_dbi_command(dbi, ILI9341_FRMCTR1, 0x00, 0x1b);
+
+   /* Gamma */
+   mipi_dbi_command(dbi, ILI9341_EN3GAM, 0x08);
+   mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, 0x01);
+   mipi_dbi_command(dbi, ILI9341_PGAMCTRL,
+0x1f, 0x1a, 0x18, 0x0a, 0x0f, 0x06, 0x45, 0x87,
+