From patchwork Sun Aug 9 21:51:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247577 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp4349745ilo; Sun, 9 Aug 2020 14:52:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCTDd+y/SvAyFNI5TqCpzWA9zmUoFT1IC/NwWuFr9xqXqz9A06233LCQiPTJ3ssJfHfB0O X-Received: by 2002:a17:90a:f83:: with SMTP id 3mr22847587pjz.7.1597009920299; Sun, 09 Aug 2020 14:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597009920; cv=none; d=google.com; s=arc-20160816; b=GcylMeVobmyBxClbEhMRjEYfUIvyAMgwJTBquz8vrm5tEGM1GO2rk5asLcp3dZ79I6 fNC7I5/uMqm+EqnF+hVj+ghILsfX2IWq2Mxwy4WkrO4Vsd8qDDTzpUIG+nJ9J81ft/CC zeEM7XxRuqAn2CHNCkZxmy4aE2OUVjP06zjA5mFc8VhLtL6yw7hrigmYbRyI5E0Y8YCc d4QeOybwFs/9BvW81T2tJzv0nFRzXhGQ7xFX8UMY2vWXA5bDJZQeGTI2WJggbgXvqSr3 efDMh0/B6RY6kv/RvajjXMaFh6CYEvE90zck49wX23mTggXNfNk/4xKl7mOgUVK22S68 13bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=fbaGeWYBgg8j8Q0mYXjbOnWFCiM5niVYJYffBMydxvM=; b=qMDKLVMzekcrjaOji+p9uqCx+SyMEAhFT5Uw14Dip2aOYbJUZLbjxZDor8v+bq4Zeo CiQnfNpcqLlXqLpDgws97qK9cRzqYNSgqwJ8viz6UQK72NJ6kCt0UpUCk2HyGkK34yGK baz4bw0HwBmXyxv3d6GgoZT+nUN1jkANrpnvCU+pDwdsin5Z0mU+pealvQjGBlQjgMut GIUYL4CgGCS73paSbBuYvaVfkWHMxDBAHb2YlKXE53IISXmJmAOjrPaiemOwnM8kurkY yDNi+ujl6/L/7TRMm1sGZbp1unjJlDWHq/2uJ0jg62oIGdr4kQD50gZOPTZyh6DDuRkS Miiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QUr914tY; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id m8si9582482pgq.429.2020.08.09.14.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:52:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QUr914tY; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 792156E09C; Sun, 9 Aug 2020 21:51:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by gabe.freedesktop.org (Postfix) with ESMTPS id 013BE89F6E for ; Sun, 9 Aug 2020 21:51:54 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id v15so3690433lfg.6 for ; Sun, 09 Aug 2020 14:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CA9KLtyWFVaEBrghbaJKMORLmjTCarU5xRaKy9GnXtY=; b=QUr914tY4T/78DNMcMlPvnjhYR3laqpMoMaOtZJi+qDg+25B//z+DAaWcgsBguXMWD 9Cb1AX0Zw1atfow6bN2ikLCWEobmplpXrySGV1BWVErCzV2JcMVt3RG/9Ncs5uQlA7SH b5RTwRv0th/kljDFghdEogzK6QQ/AWUlO9q63bx7fpG05B78tTJEY9bSyC4pkZVTEZME 7sX6d2WJaVriZdFwtwAmpmVOZntq1gh7osNNhnALgYcDs/SP0YBNtNNL4M+RaSeOfN9M gxertfOhbd2BAPF3S/BEyPANvei6Ta2pMeMcq7XVOsDLHQ6p/pjXACdjwwbDyGl8oXAu afVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CA9KLtyWFVaEBrghbaJKMORLmjTCarU5xRaKy9GnXtY=; b=iuSXt6589m4aI4npq+2EUAwVUOowGNIk7+xSIf7Io6rdpLzbf3TpSGFKFXVn1RKyvI 6IXcM17rw5lUwIUlrZNolp4G2DUz/fd+orBrTtuDQawrHaXQPuU1NQcFc46m3Vf5od+F muZvyRAzqv6546fzsw1J3GG/lF48e2CFF+uHltGTfc87DzS/SHmQ/aJ2MRqTls7z4Xi0 9TcIfAIDWvrh4KQ9tmA+44hDNl2GJ2DIBEQc1jUA0GtWsLiNjEdKEoSQdplDson1yxio 78WS3VxCvsC0LICVF4McbnGCbCi7r16M13smw108jSPZBp41PZtWSLm9rWA3aikBMJfJ 2qQA== X-Gm-Message-State: AOAM532zYS30S8fMkwIKtXumlTMGe0nw7DilhcGOBbyMBBWwqicpIxtd JRDMTWOkLSnmF8q3X6ZakOGhhSAcCp+2gQ== X-Received: by 2002:ac2:5335:: with SMTP id f21mr11363114lfh.114.1597009913314; Sun, 09 Aug 2020 14:51:53 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id t20sm8277045ljd.12.2020.08.09.14.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:51:52 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , Stephan Gerhold , =?utf-8?q?Pawe=C5=82_Chmiel?= Subject: [PATCH 2/4] drm/panel: s6e63m0: Add DSI transport Date: Sun, 9 Aug 2020 23:51:02 +0200 Message-Id: <20200809215104.1830206-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200809215104.1830206-1-linus.walleij@linaro.org> References: <20200809215104.1830206-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "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 Cc: Paweł Chmiel Signed-off-by: Linus Walleij Tested-by: Stephan Gerhold --- 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 +#include +#include + +#include +#include + +#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 "); +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 */