dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport
@ 2020-08-09 21:51 Linus Walleij
  2020-08-09 21:51 ` [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport Linus Walleij
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Linus Walleij @ 2020-08-09 21:51 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, Stephan Gerhold, Paweł Chmiel
  Cc: dri-devel

This begins to modify the Samsung S6E63M0 driver to provide
DSI support.

After these initial changes the driver can already be used
with the Samsung GT-I8190 (Golden) phone.

After this initial support we will make more changes to
support more gammas (more levels of backlight), special
biasing on different display types and handling of the
ESD IRQ.

But let's begin with this.

Linus Walleij (4):
  drm/panel: s6e63m0: Break out SPI transport
  drm/panel: s6e63m0: Add DSI transport
  drm/panel: s6e63m0: Add reading functionality
  drm/panel: s6e63m0: Add code to identify panel

 drivers/gpu/drm/panel/Kconfig                 |  23 ++-
 drivers/gpu/drm/panel/Makefile                |   2 +
 .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 145 +++++++++++++++++
 .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 101 ++++++++++++
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 146 ++++++++++--------
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h |  13 ++
 6 files changed, 363 insertions(+), 67 deletions(-)
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h

-- 
2.26.2

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

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

* [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport
  2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
@ 2020-08-09 21:51 ` Linus Walleij
  2020-08-09 21:51 ` [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2020-08-09 21:51 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, Stephan Gerhold, Paweł Chmiel
  Cc: dri-devel

This panel can be accessed using both SPI and DSI.

To make it possible to probe and use the device also from
a DSI bus, first break out the SPI support to its own file.

Since all the panel driver does is write DCS commands to
the panel, we pass a DCS write function to probe()
from each subdriver.

We make the Kconfig entry for SPI mode default so all
current users will continue to work.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/panel/Kconfig                 | 15 +++-
 drivers/gpu/drm/panel/Makefile                |  1 +
 .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 89 +++++++++++++++++++
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 80 +++--------------
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h | 10 +++
 5 files changed, 124 insertions(+), 71 deletions(-)
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 39055c1f0e2f..96e1548e475f 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -326,13 +326,22 @@ config DRM_PANEL_SAMSUNG_S6E63J0X03
 	select VIDEOMODE_HELPERS
 
 config DRM_PANEL_SAMSUNG_S6E63M0
-	tristate "Samsung S6E63M0 RGB/SPI panel"
+	tristate "Samsung S6E63M0 RGB panel"
 	depends on OF
-	depends on SPI
 	depends on BACKLIGHT_CLASS_DEVICE
 	help
 	  Say Y here if you want to enable support for Samsung S6E63M0
-	  AMOLED LCD panel.
+	  AMOLED LCD panel. This panel can be accessed using SPI or
+	  DSI.
+
+config DRM_PANEL_SAMSUNG_S6E63M0_SPI
+	tristate "Samsung S6E63M0 RGB SPI interface"
+	depends on SPI
+	depends on DRM_PANEL_SAMSUNG_S6E63M0
+	default DRM_PANEL_SAMSUNG_S6E63M0
+	help
+	  Say Y here if you want to be able to access the Samsung
+	  S6E63M0 panel using SPI.
 
 config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01
 	tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller"
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index de74f282c433..9cf71adfa794 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D16D0) += panel-samsung-s6d16d0.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
 obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
new file mode 100644
index 000000000000..4082fbd75b79
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/delay.h>
+
+#include <drm/drm_print.h>
+
+#include "panel-samsung-s6e63m0.h"
+
+#define DATA_MASK	0x100
+
+static int s6e63m0_spi_write_word(struct device *dev, u16 data)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct spi_transfer xfer = {
+		.len	= 2,
+		.tx_buf = &data,
+	};
+	struct spi_message msg;
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer, &msg);
+
+	return spi_sync(spi, &msg);
+}
+
+static int s6e63m0_spi_dcs_write(struct device *dev, const u8 *data, size_t len)
+{
+	int ret = 0;
+
+	DRM_DEV_DEBUG(dev, "SPI writing dcs seq: %*ph\n", (int)len, data);
+	ret = s6e63m0_spi_write_word(dev, *data);
+
+	while (!ret && --len) {
+		++data;
+		ret = s6e63m0_spi_write_word(dev, *data | DATA_MASK);
+	}
+
+	if (ret) {
+		DRM_DEV_ERROR(dev, "SPI error %d writing dcs seq: %*ph\n", ret,
+			      (int)len, data);
+	}
+
+	usleep_range(300, 310);
+
+	return ret;
+}
+
+static int s6e63m0_spi_probe(struct spi_device *spi)
+{
+	struct device *dev = &spi->dev;
+	int ret;
+
+	spi->bits_per_word = 9;
+	spi->mode = SPI_MODE_3;
+	ret = spi_setup(spi);
+	if (ret < 0) {
+		DRM_DEV_ERROR(dev, "spi setup failed.\n");
+		return ret;
+	}
+	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write);
+}
+
+static int s6e63m0_spi_remove(struct spi_device *spi)
+{
+	return s6e63m0_remove(&spi->dev);
+}
+
+static const struct of_device_id s6e63m0_spi_of_match[] = {
+	{ .compatible = "samsung,s6e63m0" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, s6e63m0_spi_of_match);
+
+static struct spi_driver s6e63m0_spi_driver = {
+	.probe			= s6e63m0_spi_probe,
+	.remove			= s6e63m0_spi_remove,
+	.driver			= {
+		.name		= "panel-samsung-s6e63m0",
+		.of_match_table = s6e63m0_spi_of_match,
+	},
+};
+module_spi_driver(s6e63m0_spi_driver);
+
+MODULE_AUTHOR("Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>");
+MODULE_DESCRIPTION("s6e63m0 LCD SPI Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
index a5f76eb4fa25..610676ef8a75 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
@@ -17,10 +17,11 @@
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
-#include <linux/spi/spi.h>
 
 #include <video/mipi_display.h>
 
+#include "panel-samsung-s6e63m0.h"
+
 /* Manufacturer Command Set */
 #define MCS_ELVSS_ON                0xb1
 #define MCS_MIECTL1                0xc0
@@ -34,8 +35,6 @@
 #define NUM_GAMMA_LEVELS             11
 #define GAMMA_TABLE_COUNT           23
 
-#define DATA_MASK                                       0x100
-
 #define MAX_BRIGHTNESS              (NUM_GAMMA_LEVELS - 1)
 
 /* array of gamma tables for gamma value 2.2 */
@@ -88,6 +87,7 @@ static u8 const s6e63m0_gamma_22[NUM_GAMMA_LEVELS][GAMMA_TABLE_COUNT] = {
 
 struct s6e63m0 {
 	struct device *dev;
+	int (*dcs_write)(struct device *dev, const u8 *data, size_t len);
 	struct drm_panel panel;
 	struct backlight_device *bl_dev;
 
@@ -136,43 +136,12 @@ static int s6e63m0_clear_error(struct s6e63m0 *ctx)
 	return ret;
 }
 
-static int s6e63m0_spi_write_word(struct s6e63m0 *ctx, u16 data)
-{
-	struct spi_device *spi = to_spi_device(ctx->dev);
-	struct spi_transfer xfer = {
-		.len	= 2,
-		.tx_buf = &data,
-	};
-	struct spi_message msg;
-
-	spi_message_init(&msg);
-	spi_message_add_tail(&xfer, &msg);
-
-	return spi_sync(spi, &msg);
-}
-
 static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len)
 {
-	int ret = 0;
-
 	if (ctx->error < 0 || len == 0)
 		return;
 
-	DRM_DEV_DEBUG(ctx->dev, "writing dcs seq: %*ph\n", (int)len, data);
-	ret = s6e63m0_spi_write_word(ctx, *data);
-
-	while (!ret && --len) {
-		++data;
-		ret = s6e63m0_spi_write_word(ctx, *data | DATA_MASK);
-	}
-
-	if (ret) {
-		DRM_DEV_ERROR(ctx->dev, "error %d writing dcs seq: %*ph\n", ret,
-			      (int)len, data);
-		ctx->error = ret;
-	}
-
-	usleep_range(300, 310);
+	ctx->error = ctx->dcs_write(ctx->dev, data, len);
 }
 
 #define s6e63m0_dcs_write_seq_static(ctx, seq ...) \
@@ -433,9 +402,9 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx)
 	return ret;
 }
 
-static int s6e63m0_probe(struct spi_device *spi)
+int s6e63m0_probe(struct device *dev,
+		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len))
 {
-	struct device *dev = &spi->dev;
 	struct s6e63m0 *ctx;
 	int ret;
 
@@ -443,7 +412,8 @@ static int s6e63m0_probe(struct spi_device *spi)
 	if (!ctx)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, ctx);
+	ctx->dcs_write = dcs_write;
+	dev_set_drvdata(dev, ctx);
 
 	ctx->dev = dev;
 	ctx->enabled = false;
@@ -465,14 +435,6 @@ static int s6e63m0_probe(struct spi_device *spi)
 		return PTR_ERR(ctx->reset_gpio);
 	}
 
-	spi->bits_per_word = 9;
-	spi->mode = SPI_MODE_3;
-	ret = spi_setup(spi);
-	if (ret < 0) {
-		DRM_DEV_ERROR(dev, "spi setup failed.\n");
-		return ret;
-	}
-
 	drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs,
 		       DRM_MODE_CONNECTOR_DPI);
 
@@ -482,32 +444,14 @@ static int s6e63m0_probe(struct spi_device *spi)
 
 	return drm_panel_add(&ctx->panel);
 }
+EXPORT_SYMBOL_GPL(s6e63m0_probe);
 
-static int s6e63m0_remove(struct spi_device *spi)
+int s6e63m0_remove(struct device *dev)
 {
-	struct s6e63m0 *ctx = spi_get_drvdata(spi);
+	struct s6e63m0 *ctx = dev_get_drvdata(dev);
 
 	drm_panel_remove(&ctx->panel);
 
 	return 0;
 }
-
-static const struct of_device_id s6e63m0_of_match[] = {
-	{ .compatible = "samsung,s6e63m0" },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, s6e63m0_of_match);
-
-static struct spi_driver s6e63m0_driver = {
-	.probe			= s6e63m0_probe,
-	.remove			= s6e63m0_remove,
-	.driver			= {
-		.name		= "panel-samsung-s6e63m0",
-		.of_match_table = s6e63m0_of_match,
-	},
-};
-module_spi_driver(s6e63m0_driver);
-
-MODULE_AUTHOR("Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>");
-MODULE_DESCRIPTION("s6e63m0 LCD Driver");
-MODULE_LICENSE("GPL v2");
+EXPORT_SYMBOL_GPL(s6e63m0_remove);
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
new file mode 100644
index 000000000000..44e31f39f211
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _PANEL_SAMSUNG_S6E63M0_H
+#define _PANEL_SAMSUNG_S6E63M0_H
+
+int s6e63m0_probe(struct device *dev,
+		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len));
+int s6e63m0_remove(struct device *dev);
+
+#endif /* _PANEL_SAMSUNG_S6E63M0_H */
-- 
2.26.2

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

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

* [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport
  2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
  2020-08-09 21:51 ` [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport Linus Walleij
@ 2020-08-09 21:51 ` Linus Walleij
  2020-08-14 15:34   ` Stephan Gerhold
  2020-08-09 21:51 ` [PATCH 3/4] drm/panel: s6e63m0: Add reading functionality Linus Walleij
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2020-08-09 21:51 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, Stephan Gerhold, Paweł Chmiel
  Cc: dri-devel

This makes it possible to use the s6e63m0 panel with a
DSI host, such as in the Samsung GT-I8190 (Golden) mobile
phone.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/panel/Kconfig                 |   8 ++
 drivers/gpu/drm/panel/Makefile                |   1 +
 .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 128 ++++++++++++++++++
 .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c |   2 +-
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c |   4 +-
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h |   4 +-
 6 files changed, 144 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 96e1548e475f..731e84c5a13b 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -343,6 +343,14 @@ config DRM_PANEL_SAMSUNG_S6E63M0_SPI
 	  Say Y here if you want to be able to access the Samsung
 	  S6E63M0 panel using SPI.
 
+config DRM_PANEL_SAMSUNG_S6E63M0_DSI
+	tristate "Samsung S6E63M0 RGB DSI interface"
+	depends on DRM_MIPI_DSI
+	depends on DRM_PANEL_SAMSUNG_S6E63M0
+	help
+	  Say Y here if you want to be able to access the Samsung
+	  S6E63M0 panel using DSI.
+
 config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01
 	tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 9cf71adfa794..14212cae3c29 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_DSI) += panel-samsung-s6e63m0-dsi.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
 obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
new file mode 100644
index 000000000000..f4927a6ce26d
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DSI interface to the Samsung S6E63M0 panel.
+ * (C) 2019 Linus Walleij
+ */
+
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/of_device.h>
+
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_print.h>
+
+#include "panel-samsung-s6e63m0.h"
+
+#define MCS_GLOBAL_PARAM	0xb0
+#define S6E63M0_DSI_MAX_CHUNK	15 /* CMD + 15 bytes max */
+
+static int s6e63m0_dsi_dcs_write(struct device *dev, const u8 *data, size_t len)
+{
+	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
+	const u8 *seqp = data;
+	u8 cmd;
+	u8 cmdwritten;
+	int remain;
+	int chunk;
+	int ret;
+
+	DRM_DEV_INFO(dev, "DSI writing dcs seq: %*ph\n", (int)len, data);
+
+	/* Pick out and skip past the DCS command */
+	cmd = *seqp;
+	seqp++;
+	cmdwritten = 0;
+	remain = len - 1;
+	chunk = remain;
+
+	/* Send max S6E63M0_DSI_MAX_CHUNK bytes at a time */
+	if (chunk > S6E63M0_DSI_MAX_CHUNK)
+		chunk = S6E63M0_DSI_MAX_CHUNK;
+	ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
+	if (ret < 0) {
+		DRM_DEV_ERROR(dev,
+			      "error sending DCS command seq cmd %02x\n",
+			      cmd);
+		return ret;
+	}
+	cmdwritten += chunk;
+	seqp += chunk;
+
+	while (cmdwritten < remain) {
+		chunk = remain - cmdwritten;
+		if (chunk > S6E63M0_DSI_MAX_CHUNK)
+			chunk = S6E63M0_DSI_MAX_CHUNK;
+		ret = mipi_dsi_dcs_write(dsi, MCS_GLOBAL_PARAM, &cmdwritten, 1);
+		if (ret < 0) {
+			DRM_DEV_ERROR(dev,
+				      "error sending CMD %02x global param %02x\n",
+				      cmd, cmdwritten);
+			return ret;
+		}
+		ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
+		if (ret < 0) {
+			DRM_DEV_ERROR(dev,
+				      "error sending CMD %02x chunk\n",
+				      cmd);
+			return ret;
+		}
+		cmdwritten += chunk;
+		seqp += chunk;
+	}
+	DRM_DEV_INFO(dev, "sent command %02x %02x bytes\n",
+		     cmd, cmdwritten);
+
+	usleep_range(8000, 9000);
+
+	return 0;
+}
+
+static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi)
+{
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->lanes = 2;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->hs_rate = 349440000;
+	dsi->lp_rate = 9600000;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
+		MIPI_DSI_MODE_EOT_PACKET |
+		MIPI_DSI_MODE_VIDEO_BURST;
+
+	ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_write, true);
+	if (ret)
+		return ret;
+
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0)
+		s6e63m0_remove(dev);
+
+	return ret;
+}
+
+static int s6e63m0_dsi_remove(struct mipi_dsi_device *dsi)
+{
+	mipi_dsi_detach(dsi);
+	return s6e63m0_remove(&dsi->dev);
+}
+
+static const struct of_device_id s6e63m0_dsi_of_match[] = {
+	{ .compatible = "samsung,s6e63m0" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, s6e63m0_dsi_of_match);
+
+static struct mipi_dsi_driver s6e63m0_dsi_driver = {
+	.probe			= s6e63m0_dsi_probe,
+	.remove			= s6e63m0_dsi_remove,
+	.driver			= {
+		.name		= "panel-samsung-s6e63m0",
+		.of_match_table = s6e63m0_dsi_of_match,
+	},
+};
+module_mipi_dsi_driver(s6e63m0_dsi_driver);
+
+MODULE_AUTHOR("Linus Walleij <linusw@kernel.org>");
+MODULE_DESCRIPTION("s6e63m0 LCD DSI Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
index 4082fbd75b79..0587eac52f2a 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
@@ -60,7 +60,7 @@ static int s6e63m0_spi_probe(struct spi_device *spi)
 		DRM_DEV_ERROR(dev, "spi setup failed.\n");
 		return ret;
 	}
-	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write);
+	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write, false);
 }
 
 static int s6e63m0_spi_remove(struct spi_device *spi)
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
index 610676ef8a75..c6d17e938955 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
@@ -403,7 +403,8 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx)
 }
 
 int s6e63m0_probe(struct device *dev,
-		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len))
+		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len),
+		  bool dsi_mode)
 {
 	struct s6e63m0 *ctx;
 	int ret;
@@ -436,6 +437,7 @@ int s6e63m0_probe(struct device *dev,
 	}
 
 	drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs,
+		       dsi_mode ? DRM_MODE_CONNECTOR_DSI :
 		       DRM_MODE_CONNECTOR_DPI);
 
 	ret = s6e63m0_backlight_register(ctx);
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
index 44e31f39f211..229e23b0c97a 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
@@ -4,7 +4,9 @@
 #define _PANEL_SAMSUNG_S6E63M0_H
 
 int s6e63m0_probe(struct device *dev,
-		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len));
+		  int (*dcs_write)(struct device *dev, const u8 *data,
+				   size_t len),
+		  bool dsi_mode);
 int s6e63m0_remove(struct device *dev);
 
 #endif /* _PANEL_SAMSUNG_S6E63M0_H */
-- 
2.26.2

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

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

* [PATCH 3/4] drm/panel: s6e63m0: Add reading functionality
  2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
  2020-08-09 21:51 ` [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport Linus Walleij
  2020-08-09 21:51 ` [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
@ 2020-08-09 21:51 ` Linus Walleij
  2020-08-09 21:51 ` [PATCH 4/4] drm/panel: s6e63m0: Add code to identify panel Linus Walleij
  2020-08-18 17:10 ` [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Sam Ravnborg
  4 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2020-08-09 21:51 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, Stephan Gerhold, Paweł Chmiel
  Cc: dri-devel

This adds code to send read commands to read a single
byte from the display, in order to perform MTP ID
look-up of the mounted panel on the s6e63m0 controller.
This is needed for proper biasing on the DSI variants.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 19 ++++++++++++++++++-
 .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 14 +++++++++++++-
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 11 +++++++++++
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h |  1 +
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
index f4927a6ce26d..2ec9e7900791 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
@@ -16,6 +16,22 @@
 #define MCS_GLOBAL_PARAM	0xb0
 #define S6E63M0_DSI_MAX_CHUNK	15 /* CMD + 15 bytes max */
 
+static int s6e63m0_dsi_dcs_read(struct device *dev, const u8 cmd, u8 *data)
+{
+	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
+	int ret;
+
+	ret = mipi_dsi_dcs_read(dsi, cmd, data, 1);
+	if (ret < 0) {
+		DRM_DEV_ERROR(dev, "could not read DCS CMD %02x\n", cmd);
+		return ret;
+	}
+
+	DRM_DEV_INFO(dev, "DSI read CMD %02x = %02x\n", cmd, *data);
+
+	return 0;
+}
+
 static int s6e63m0_dsi_dcs_write(struct device *dev, const u8 *data, size_t len)
 {
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
@@ -90,7 +106,8 @@ static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi)
 		MIPI_DSI_MODE_EOT_PACKET |
 		MIPI_DSI_MODE_VIDEO_BURST;
 
-	ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_write, true);
+	ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_read, s6e63m0_dsi_dcs_write,
+			    true);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
index 0587eac52f2a..3b1a2a3a44ea 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
@@ -11,6 +11,17 @@
 
 #define DATA_MASK	0x100
 
+static int s6e63m0_spi_dcs_read(struct device *dev, const u8 cmd, u8 *data)
+{
+	/*
+	 * FIXME: implement reading DCS commands over SPI so we can
+	 * properly identify which physical panel is connected.
+	 */
+	*data = 0;
+
+	return 0;
+}
+
 static int s6e63m0_spi_write_word(struct device *dev, u16 data)
 {
 	struct spi_device *spi = to_spi_device(dev);
@@ -60,7 +71,8 @@ static int s6e63m0_spi_probe(struct spi_device *spi)
 		DRM_DEV_ERROR(dev, "spi setup failed.\n");
 		return ret;
 	}
-	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write, false);
+	return s6e63m0_probe(dev, s6e63m0_spi_dcs_read, s6e63m0_spi_dcs_write,
+			     false);
 }
 
 static int s6e63m0_spi_remove(struct spi_device *spi)
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
index c6d17e938955..b25021bdd724 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
@@ -87,6 +87,7 @@ static u8 const s6e63m0_gamma_22[NUM_GAMMA_LEVELS][GAMMA_TABLE_COUNT] = {
 
 struct s6e63m0 {
 	struct device *dev;
+	int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val);
 	int (*dcs_write)(struct device *dev, const u8 *data, size_t len);
 	struct drm_panel panel;
 	struct backlight_device *bl_dev;
@@ -136,6 +137,14 @@ static int s6e63m0_clear_error(struct s6e63m0 *ctx)
 	return ret;
 }
 
+static void s6e63m0_dcs_read(struct s6e63m0 *ctx, const u8 cmd, u8 *data)
+{
+	if (ctx->error < 0)
+		return;
+
+	ctx->error = ctx->dcs_read(ctx->dev, cmd, data);
+}
+
 static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len)
 {
 	if (ctx->error < 0 || len == 0)
@@ -403,6 +412,7 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx)
 }
 
 int s6e63m0_probe(struct device *dev,
+		  int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val),
 		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len),
 		  bool dsi_mode)
 {
@@ -413,6 +423,7 @@ int s6e63m0_probe(struct device *dev,
 	if (!ctx)
 		return -ENOMEM;
 
+	ctx->dcs_read = dcs_read;
 	ctx->dcs_write = dcs_write;
 	dev_set_drvdata(dev, ctx);
 
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
index 229e23b0c97a..c669fec91763 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
@@ -4,6 +4,7 @@
 #define _PANEL_SAMSUNG_S6E63M0_H
 
 int s6e63m0_probe(struct device *dev,
+		  int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val),
 		  int (*dcs_write)(struct device *dev, const u8 *data,
 				   size_t len),
 		  bool dsi_mode);
-- 
2.26.2

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

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

* [PATCH 4/4] drm/panel: s6e63m0: Add code to identify panel
  2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
                   ` (2 preceding siblings ...)
  2020-08-09 21:51 ` [PATCH 3/4] drm/panel: s6e63m0: Add reading functionality Linus Walleij
@ 2020-08-09 21:51 ` Linus Walleij
  2020-08-18 17:10 ` [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Sam Ravnborg
  4 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2020-08-09 21:51 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, Stephan Gerhold, Paweł Chmiel
  Cc: dri-devel

We add code to identify a few different panels mounted
on the s6e63m0 controller. This is necessary to achieve
the proper biasing with DSI versions of the panel.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
index b25021bdd724..0b22e382b80f 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
@@ -26,12 +26,21 @@
 #define MCS_ELVSS_ON                0xb1
 #define MCS_MIECTL1                0xc0
 #define MCS_BCMODE                              0xc1
+#define MCS_READ_ID1		0xda
+#define MCS_READ_ID2		0xdb
+#define MCS_READ_ID3		0xdc
+#define MCS_LEVEL_2_KEY		0xf0
+#define MCS_MTP_KEY		0xf1
 #define MCS_DISCTL   0xf2
 #define MCS_SRCCTL           0xf6
 #define MCS_IFCTL                       0xf7
 #define MCS_PANELCTL         0xF8
 #define MCS_PGAMMACTL                   0xfa
 
+#define S6E63M0_LCD_ID_VALUE_M2		0xA4
+#define S6E63M0_LCD_ID_VALUE_SM2	0xB4
+#define S6E63M0_LCD_ID_VALUE_SM2_1	0xB6
+
 #define NUM_GAMMA_LEVELS             11
 #define GAMMA_TABLE_COUNT           23
 
@@ -91,6 +100,7 @@ struct s6e63m0 {
 	int (*dcs_write)(struct device *dev, const u8 *data, size_t len);
 	struct drm_panel panel;
 	struct backlight_device *bl_dev;
+	u8 lcd_type;
 
 	struct regulator_bulk_data supplies[2];
 	struct gpio_desc *reset_gpio;
@@ -159,6 +169,48 @@ static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len)
 		s6e63m0_dcs_write(ctx, d, ARRAY_SIZE(d)); \
 	})
 
+
+static int s6e63m0_check_lcd_type(struct s6e63m0 *ctx)
+{
+	u8 id1, id2, id3;
+	int ret;
+
+	s6e63m0_dcs_read(ctx, MCS_READ_ID1, &id1);
+	s6e63m0_dcs_read(ctx, MCS_READ_ID2, &id2);
+	s6e63m0_dcs_read(ctx, MCS_READ_ID3, &id3);
+
+	ret = s6e63m0_clear_error(ctx);
+	if (ret) {
+		DRM_DEV_ERROR(ctx->dev, "error checking LCD type (%d)\n",
+			      ret);
+		ctx->lcd_type = 0x00;
+		return ret;
+	}
+
+	DRM_DEV_INFO(ctx->dev, "MTP ID: %02x %02x %02x\n", id1, id2, id3);
+
+	/* We attempt to detect what panel is mounted on the controller */
+	switch (id2) {
+	case S6E63M0_LCD_ID_VALUE_M2:
+		DRM_DEV_INFO(ctx->dev,
+			     "detected LCD panel AMS397GE MIPI M2\n");
+		break;
+	case S6E63M0_LCD_ID_VALUE_SM2:
+	case S6E63M0_LCD_ID_VALUE_SM2_1:
+		DRM_DEV_INFO(ctx->dev,
+			     "detected LCD panel AMS397GE MIPI SM2\n");
+		break;
+	default:
+		DRM_DEV_INFO(ctx->dev,
+			     "unknown LCD panel type %02x\n", id2);
+		break;
+	}
+
+	ctx->lcd_type = id2;
+
+	return 0;
+}
+
 static void s6e63m0_init(struct s6e63m0 *ctx)
 {
 	s6e63m0_dcs_write_seq_static(ctx, MCS_PANELCTL,
@@ -312,6 +364,15 @@ static int s6e63m0_prepare(struct drm_panel *panel)
 	if (ret < 0)
 		return ret;
 
+	/* Magic to unlock level 2 control of the display */
+	s6e63m0_dcs_write_seq_static(ctx, MCS_LEVEL_2_KEY, 0x5a, 0x5a);
+	/* Magic to unlock MTP reading */
+	s6e63m0_dcs_write_seq_static(ctx, MCS_MTP_KEY, 0x5a, 0x5a);
+
+	ret = s6e63m0_check_lcd_type(ctx);
+	if (ret < 0)
+		return ret;
+
 	s6e63m0_init(ctx);
 
 	ret = s6e63m0_clear_error(ctx);
-- 
2.26.2

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

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

* Re: [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport
  2020-08-09 21:51 ` [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
@ 2020-08-14 15:34   ` Stephan Gerhold
  0 siblings, 0 replies; 9+ messages in thread
From: Stephan Gerhold @ 2020-08-14 15:34 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Thierry Reding, Sam Ravnborg, dri-devel, Paweł Chmiel

On Sun, Aug 09, 2020 at 11:51:02PM +0200, Linus Walleij wrote:
> This makes it possible to use the s6e63m0 panel with a
> DSI host, such as in the Samsung GT-I8190 (Golden) mobile
> phone.
> 
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpu/drm/panel/Kconfig                 |   8 ++
>  drivers/gpu/drm/panel/Makefile                |   1 +
>  .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 128 ++++++++++++++++++
>  .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c |   2 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0.c |   4 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0.h |   4 +-
>  6 files changed, 144 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 96e1548e475f..731e84c5a13b 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -343,6 +343,14 @@ config DRM_PANEL_SAMSUNG_S6E63M0_SPI
>  	  Say Y here if you want to be able to access the Samsung
>  	  S6E63M0 panel using SPI.
>  
> +config DRM_PANEL_SAMSUNG_S6E63M0_DSI
> +	tristate "Samsung S6E63M0 RGB DSI interface"
> +	depends on DRM_MIPI_DSI
> +	depends on DRM_PANEL_SAMSUNG_S6E63M0
> +	help
> +	  Say Y here if you want to be able to access the Samsung
> +	  S6E63M0 panel using DSI.
> +
>  config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01
>  	tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller"
>  	depends on OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 9cf71adfa794..14212cae3c29 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -35,6 +35,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_DSI) += panel-samsung-s6e63m0-dsi.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
>  obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
> new file mode 100644
> index 000000000000..f4927a6ce26d
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
> @@ -0,0 +1,128 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * DSI interface to the Samsung S6E63M0 panel.
> + * (C) 2019 Linus Walleij
> + */
> +
> +#include <linux/module.h>
> +#include <linux/delay.h>
> +#include <linux/of_device.h>
> +
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_print.h>
> +
> +#include "panel-samsung-s6e63m0.h"
> +
> +#define MCS_GLOBAL_PARAM	0xb0
> +#define S6E63M0_DSI_MAX_CHUNK	15 /* CMD + 15 bytes max */
> +
> +static int s6e63m0_dsi_dcs_write(struct device *dev, const u8 *data, size_t len)
> +{
> +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
> +	const u8 *seqp = data;
> +	u8 cmd;
> +	u8 cmdwritten;
> +	int remain;
> +	int chunk;
> +	int ret;
> +
> +	DRM_DEV_INFO(dev, "DSI writing dcs seq: %*ph\n", (int)len, data);
> +

We should probably remove these or demote them to debug.
It's quite verbose.

> +	/* Pick out and skip past the DCS command */
> +	cmd = *seqp;
> +	seqp++;
> +	cmdwritten = 0;
> +	remain = len - 1;
> +	chunk = remain;
> +
> +	/* Send max S6E63M0_DSI_MAX_CHUNK bytes at a time */
> +	if (chunk > S6E63M0_DSI_MAX_CHUNK)
> +		chunk = S6E63M0_DSI_MAX_CHUNK;
> +	ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
> +	if (ret < 0) {
> +		DRM_DEV_ERROR(dev,
> +			      "error sending DCS command seq cmd %02x\n",
> +			      cmd);
> +		return ret;
> +	}
> +	cmdwritten += chunk;
> +	seqp += chunk;
> +
> +	while (cmdwritten < remain) {
> +		chunk = remain - cmdwritten;
> +		if (chunk > S6E63M0_DSI_MAX_CHUNK)
> +			chunk = S6E63M0_DSI_MAX_CHUNK;
> +		ret = mipi_dsi_dcs_write(dsi, MCS_GLOBAL_PARAM, &cmdwritten, 1);
> +		if (ret < 0) {
> +			DRM_DEV_ERROR(dev,
> +				      "error sending CMD %02x global param %02x\n",
> +				      cmd, cmdwritten);
> +			return ret;
> +		}
> +		ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
> +		if (ret < 0) {
> +			DRM_DEV_ERROR(dev,
> +				      "error sending CMD %02x chunk\n",
> +				      cmd);
> +			return ret;
> +		}
> +		cmdwritten += chunk;
> +		seqp += chunk;
> +	}
> +	DRM_DEV_INFO(dev, "sent command %02x %02x bytes\n",
> +		     cmd, cmdwritten);

Here as well.

However, otherwise it seems to work fine on my samsung-golden,
so for the entire series:

Tested-by: Stephan Gerhold <stephan@gerhold.net>

I think it would be great to get a Tested-by from someone using the SPI
transport as well. It seems to be used in s5pv210-aries.dtsi.

Thanks!
Stephan

> +
> +	usleep_range(8000, 9000);
> +
> +	return 0;
> +}
> +
> +static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi)
> +{
> +	struct device *dev = &dsi->dev;
> +	int ret;
> +
> +	dsi->lanes = 2;
> +	dsi->format = MIPI_DSI_FMT_RGB888;
> +	dsi->hs_rate = 349440000;
> +	dsi->lp_rate = 9600000;
> +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> +		MIPI_DSI_MODE_EOT_PACKET |
> +		MIPI_DSI_MODE_VIDEO_BURST;
> +
> +	ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_write, true);
> +	if (ret)
> +		return ret;
> +
> +	ret = mipi_dsi_attach(dsi);
> +	if (ret < 0)
> +		s6e63m0_remove(dev);
> +
> +	return ret;
> +}
> +
> +static int s6e63m0_dsi_remove(struct mipi_dsi_device *dsi)
> +{
> +	mipi_dsi_detach(dsi);
> +	return s6e63m0_remove(&dsi->dev);
> +}
> +
> +static const struct of_device_id s6e63m0_dsi_of_match[] = {
> +	{ .compatible = "samsung,s6e63m0" },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, s6e63m0_dsi_of_match);
> +
> +static struct mipi_dsi_driver s6e63m0_dsi_driver = {
> +	.probe			= s6e63m0_dsi_probe,
> +	.remove			= s6e63m0_dsi_remove,
> +	.driver			= {
> +		.name		= "panel-samsung-s6e63m0",
> +		.of_match_table = s6e63m0_dsi_of_match,
> +	},
> +};
> +module_mipi_dsi_driver(s6e63m0_dsi_driver);
> +
> +MODULE_AUTHOR("Linus Walleij <linusw@kernel.org>");
> +MODULE_DESCRIPTION("s6e63m0 LCD DSI Driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
> index 4082fbd75b79..0587eac52f2a 100644
> --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
> @@ -60,7 +60,7 @@ static int s6e63m0_spi_probe(struct spi_device *spi)
>  		DRM_DEV_ERROR(dev, "spi setup failed.\n");
>  		return ret;
>  	}
> -	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write);
> +	return s6e63m0_probe(dev, s6e63m0_spi_dcs_write, false);
>  }
>  
>  static int s6e63m0_spi_remove(struct spi_device *spi)
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
> index 610676ef8a75..c6d17e938955 100644
> --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
> @@ -403,7 +403,8 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx)
>  }
>  
>  int s6e63m0_probe(struct device *dev,
> -		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len))
> +		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len),
> +		  bool dsi_mode)
>  {
>  	struct s6e63m0 *ctx;
>  	int ret;
> @@ -436,6 +437,7 @@ int s6e63m0_probe(struct device *dev,
>  	}
>  
>  	drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs,
> +		       dsi_mode ? DRM_MODE_CONNECTOR_DSI :
>  		       DRM_MODE_CONNECTOR_DPI);
>  
>  	ret = s6e63m0_backlight_register(ctx);
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
> index 44e31f39f211..229e23b0c97a 100644
> --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
> @@ -4,7 +4,9 @@
>  #define _PANEL_SAMSUNG_S6E63M0_H
>  
>  int s6e63m0_probe(struct device *dev,
> -		  int (*dcs_write)(struct device *dev, const u8 *data, size_t len));
> +		  int (*dcs_write)(struct device *dev, const u8 *data,
> +				   size_t len),
> +		  bool dsi_mode);
>  int s6e63m0_remove(struct device *dev);
>  
>  #endif /* _PANEL_SAMSUNG_S6E63M0_H */
> -- 
> 2.26.2
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport
  2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
                   ` (3 preceding siblings ...)
  2020-08-09 21:51 ` [PATCH 4/4] drm/panel: s6e63m0: Add code to identify panel Linus Walleij
@ 2020-08-18 17:10 ` Sam Ravnborg
  2020-08-27  9:04   ` Linus Walleij
  4 siblings, 1 reply; 9+ messages in thread
From: Sam Ravnborg @ 2020-08-18 17:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Thierry Reding, dri-devel, Stephan Gerhold, Paweł Chmiel

Hi Linus.

On Sun, Aug 09, 2020 at 11:51:00PM +0200, Linus Walleij wrote:
> This begins to modify the Samsung S6E63M0 driver to provide
> DSI support.
> 
> After these initial changes the driver can already be used
> with the Samsung GT-I8190 (Golden) phone.
> 
> After this initial support we will make more changes to
> support more gammas (more levels of backlight), special
> biasing on different display types and handling of the
> ESD IRQ.
> 
> But let's begin with this.

How does this patchset relate to the patchset posted by Paul?
https://lore.kernel.org/dri-devel/20200727164613.19744-1-paul@crapouillou.net/

Seems that two different approcahes are used for the same type of
problem.

Is it possible to find a common solution?

	Sam

> 
> Linus Walleij (4):
>   drm/panel: s6e63m0: Break out SPI transport
>   drm/panel: s6e63m0: Add DSI transport
>   drm/panel: s6e63m0: Add reading functionality
>   drm/panel: s6e63m0: Add code to identify panel
> 
>  drivers/gpu/drm/panel/Kconfig                 |  23 ++-
>  drivers/gpu/drm/panel/Makefile                |   2 +
>  .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 145 +++++++++++++++++
>  .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 101 ++++++++++++
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 146 ++++++++++--------
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0.h |  13 ++
>  6 files changed, 363 insertions(+), 67 deletions(-)
>  create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
>  create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
>  create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
> 
> -- 
> 2.26.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport
  2020-08-18 17:10 ` [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Sam Ravnborg
@ 2020-08-27  9:04   ` Linus Walleij
  2020-09-01 17:55     ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2020-08-27  9:04 UTC (permalink / raw)
  To: Sam Ravnborg, Paul Cercueil
  Cc: Thierry Reding, open list:DRM PANEL DRIVERS, Stephan Gerhold,
	Paweł Chmiel

On Tue, Aug 18, 2020 at 7:10 PM Sam Ravnborg <sam@ravnborg.org> wrote:

> How does this patchset relate to the patchset posted by Paul?
> https://lore.kernel.org/dri-devel/20200727164613.19744-1-paul@crapouillou.net/

Not much. S6E63M0 uses "spi" as it is right now and is not using
the existing DBI code.

So it would require it to start using the DBI core to begin with.
If it can. Which is kind of an orthogonal task.

What would be the defining character for it to
be "DBI"? I do see that the driver sends MIPI standard commands
over SPI. I suspect this is another standard without public specs...

> Seems that two different approcahes are used for the same type of
> problem.

This approach is based on the approach from IIO, se e.g.:
drivers/iio/accel/bmc150-accel-core.c
drivers/iio/accel/bmc150-accel.h
drivers/iio/accel/bmc150-accel-i2c.c
drivers/iio/accel/bmc150-accel-spi.c

> Is it possible to find a common solution?

I'm happy to rework it any direction. If the other patch set is going to
take time to finalize (as in: will not merge it the coming week, need to
hack and stuff) then I'd prefer to apply this so I know my display works
in v5.10. I can certainly rework it into Paul's framework when that
arrives.

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

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

* Re: [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport
  2020-08-27  9:04   ` Linus Walleij
@ 2020-09-01 17:55     ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2020-09-01 17:55 UTC (permalink / raw)
  To: Sam Ravnborg, Paul Cercueil
  Cc: Thierry Reding, open list:DRM PANEL DRIVERS, Stephan Gerhold,
	Paweł Chmiel

On Thu, Aug 27, 2020 at 11:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Aug 18, 2020 at 7:10 PM Sam Ravnborg <sam@ravnborg.org> wrote:
>
> > How does this patchset relate to the patchset posted by Paul?
> > https://lore.kernel.org/dri-devel/20200727164613.19744-1-paul@crapouillou.net/
>
> Not much. S6E63M0 uses "spi" as it is right now and is not using
> the existing DBI code.
>
> So it would require it to start using the DBI core to begin with.
> If it can. Which is kind of an orthogonal task.
>
> What would be the defining character for it to
> be "DBI"? I do see that the driver sends MIPI standard commands
> over SPI. I suspect this is another standard without public specs...
>
> > Seems that two different approcahes are used for the same type of
> > problem.
>
> This approach is based on the approach from IIO, se e.g.:
> drivers/iio/accel/bmc150-accel-core.c
> drivers/iio/accel/bmc150-accel.h
> drivers/iio/accel/bmc150-accel-i2c.c
> drivers/iio/accel/bmc150-accel-spi.c
>
> > Is it possible to find a common solution?
>
> I'm happy to rework it any direction. If the other patch set is going to
> take time to finalize (as in: will not merge it the coming week, need to
> hack and stuff) then I'd prefer to apply this so I know my display works
> in v5.10. I can certainly rework it into Paul's framework when that
> arrives.

Is it OK to merge this as-is? I'm fishing for an ACK here...

I will certainly adapt to the DBI framework when/if it arrives,
and I think my track record makes that claim believeable.

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

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

end of thread, other threads:[~2020-09-01 17:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-09 21:51 [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
2020-08-09 21:51 ` [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport Linus Walleij
2020-08-09 21:51 ` [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport Linus Walleij
2020-08-14 15:34   ` Stephan Gerhold
2020-08-09 21:51 ` [PATCH 3/4] drm/panel: s6e63m0: Add reading functionality Linus Walleij
2020-08-09 21:51 ` [PATCH 4/4] drm/panel: s6e63m0: Add code to identify panel Linus Walleij
2020-08-18 17:10 ` [PATCH 0/4] drm/panel: s6e63m0: Add DSI transport Sam Ravnborg
2020-08-27  9:04   ` Linus Walleij
2020-09-01 17:55     ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).