From patchwork Sun Aug 9 21:51:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247576 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp4349728ilo; Sun, 9 Aug 2020 14:51:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFBs/um7cGQhxtTyI0nRxCktWPYIrcH4/hT8NhY/NFaWpdYjoEUB9x09MRc+P0Dpjt2BCX X-Received: by 2002:a17:90a:fc86:: with SMTP id ci6mr24820782pjb.160.1597009917714; Sun, 09 Aug 2020 14:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597009917; cv=none; d=google.com; s=arc-20160816; b=P+t2cwWgQ5DZgqw8AiSDxZZDQj+QhO4AMxYOKPQ+ggurngYI4D4O08F1rD3w/+uo27 szaJhhmF08U1Qz59n3xi1Q/yU9k99mFgE9t3coLuy+Ks0NeF97invCa5m4+HJrBu25Cc Lf6NaczQBDnOI1xyVrkmHyPVDSpWJh/EtnC7tFlPRy5kKlKzak7kZuk/9bNyLxVArQis RezLQ+yTddunvocJ+yiElo9lV5fjaqS3LBimV2Zf2jzdFrF+WVYw4BbZ27SbNaHpFZ6K TuTaQXoHOaLtmOaPgpx7+8APZ/G1xathv+/9xIWOs2Heynp5SuZ7RnVM5zlvNMjIhy1p pDUg== 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=4jSuL1lssS71Zsj0XmShkawXvhMJSCvLA1O9elpIi7s=; b=VkUn0X6DwEewA4czelqlVsI/9D+Q9dB5cpNanhEP928ZxVvvSX7+e0DFQlQCuqUrUg A93Fi40TOeJT1DoDi08NbsuNOE20CsU5f0CdfLFTflnVh6MvEUUisor4ZeoNqP9Ikuvt dGw63ukHKdfRaZ9yvcmlDSH4ySjKeCXrs0Wq+hnitEBNEGGPJwOr3sOQrnnO8h6njDdy 617Mdo9xb4MTb5T2jOox36wG7qJRMBRaaAElfwuDF4pPt+K4WbVeEyvJdpSyXG+K7Nc2 7sU90pMzgsMZajm/osWX34yAjVwWb4KRO1eYc1XTqG0eATMXVAeUQ6cWvRI0Wh4PR/8Z Vmlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b6VlCs6U; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id s74si1636694pfs.24.2020.08.09.14.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:51:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b6VlCs6U; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 3585989F6E; Sun, 9 Aug 2020 21:51:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FB846E09C for ; Sun, 9 Aug 2020 21:51:53 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id z14so7559773ljm.1 for ; Sun, 09 Aug 2020 14:51:53 -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=nZug/K9T9YLES6b3uiFKmVKlVHWW69qDsPstRKMyoR8=; b=b6VlCs6UMYDp8r8nBTp8Qovyt4RWlZy4/NLi1CF+nJCN9G+OHV1vedz1gIeeXDx11d WqkrX7DSzbN81CdfVIttBNAcVmBK6AIO2AvfrDrD7MPNYLlrFWuHYXxs/sXU0S7FSf6X Ps4f4frh33yEyUnbRWt6QmccPHuopuMRRCO4bbV62ULUCggvw6lgGhvCNlhGe0ys7t30 6xn+IPt+XNZxNc/f0NKbltkV4SQvuNqzjE4ICJwDLQWRP7NPTA4vfXAQ4K0ag/pCBF6g wKy+KKSc0hhS6gthRDdiPQLA/YI36cn9eT9u11kUd1SuTHsavWMK1MJfakwIViZgr3eK OKlA== 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=nZug/K9T9YLES6b3uiFKmVKlVHWW69qDsPstRKMyoR8=; b=Yw+QvcjyCNuCYLK6SHmN2WebVykINQIYgeMBkQkLXFhs4ppajC1O04DxGQgE4ST4rp +MDGbTwlpiJvaOr7yCRoSeM240AcsMqrhbTvOvGXTGe0bDyWv2jdrzYja7sz9unHTpPl z9FPQa9gLIypEakDrqrpuHXSuLkHmiG442vTeqdVCi4l3B5FZ9y9Cjayo1Sn5eU/Vq4d +Seb/95u8rPvwrIEvm8JZEVoxdRoBhNgLNKBOvB5PZAhwBT+ngfXdXPpqoV0pm+zdcDQ HBOcDPb9sp42eAUHVukFgXx+Zw/vBtWvMngw4uS5vZhKByv8mJrJPSyJ0oxxYBqHTCJC 2pig== X-Gm-Message-State: AOAM533LLS9/WUUFaHMM4Ursq2vibUbnAfWW3m0TBxpxipys4rbroDtN bLWHIFdxqAEs3jOkmA17KWgUrA== X-Received: by 2002:a2e:2a04:: with SMTP id q4mr5535639ljq.192.1597009911605; Sun, 09 Aug 2020 14:51:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:51:51 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , Stephan Gerhold , =?utf-8?q?Pawe=C5=82_Chmiel?= Subject: [PATCH 1/4] drm/panel: s6e63m0: Break out SPI transport Date: Sun, 9 Aug 2020 23:51:01 +0200 Message-Id: <20200809215104.1830206-2-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 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 Cc: Paweł Chmiel Signed-off-by: Linus Walleij --- 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 +#include +#include +#include + +#include + +#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 "); +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 #include #include -#include #include