From patchwork Sun Jun 7 13:38:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11592055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3698A13B1 for ; Sun, 7 Jun 2020 19:13:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13F962073B for ; Sun, 7 Jun 2020 19:13:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="fGH9Nhsb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13F962073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C88626E3D2; Sun, 7 Jun 2020 19:13:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id C90B76E117 for ; Sun, 7 Jun 2020 13:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1591537134; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FOWmwRmqX4DuTe+vROvPFvUfPPtiRZ4MS+mELI//ba4=; b=fGH9NhsbhX3Xzs6sFHEGU0tPNAbmpRB23reN1HU5EIYaIPd8t0oR4jD8vGxki4wdtbBkKn s3ukzGzhVR2ZLCKePgjOGbz5A1rPi/1Ny2vGz0u7OWZVkfJ6GwRWAExy7s4QYDlE1RDBdi qbAYb7N6G25FSnXOhQqjEYXO7ChrWq0= From: Paul Cercueil To: =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Emil Velikov , Daniel Vetter , Sam Ravnborg Subject: [RFC PATCH 1/4] gpu/drm: dsi: Let host and device specify supported bus Date: Sun, 7 Jun 2020 15:38:29 +0200 Message-Id: <20200607133832.1730288-2-paul@crapouillou.net> In-Reply-To: <20200607133832.1730288-1-paul@crapouillou.net> References: <20200607133832.1730288-1-paul@crapouillou.net> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 07 Jun 2020 19:13:00 +0000 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: Paul Cercueil , od@zcrc.me, dri-devel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current MIPI DSI framework can very well be used to support MIPI DBI panels. In order to add support for the various bus types supported by DBI, the DRM panel drivers should specify the bus type they will use, and the DSI host drivers should specify the bus types they are compatible with. The DSI host driver can then use the information provided by the DBI/DSI device driver, such as the bus type and the number of lanes, to configure its hardware properly. Signed-off-by: Paul Cercueil --- drivers/gpu/drm/drm_mipi_dsi.c | 9 +++++++++ include/drm/drm_mipi_dsi.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 55531895dde6..fe0d874d1594 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -282,6 +282,9 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) { struct device_node *node; + if (WARN_ON_ONCE(!host->bus_types)) + host->bus_types = MIPI_DEVICE_TYPE_DSI; + for_each_available_child_of_node(host->dev->of_node, node) { /* skip nodes without reg property */ if (!of_find_property(node, "reg", NULL)) @@ -324,6 +327,12 @@ int mipi_dsi_attach(struct mipi_dsi_device *dsi) { const struct mipi_dsi_host_ops *ops = dsi->host->ops; + if (WARN_ON_ONCE(!dsi->bus_type)) + dsi->bus_type = MIPI_DEVICE_TYPE_DSI; + + if (!(dsi->bus_type & dsi->host->bus_types)) + return -ENOTSUPP; + if (!ops || !ops->attach) return -ENOSYS; diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 360e6377e84b..65d2961fc054 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -63,6 +63,14 @@ struct mipi_dsi_packet { int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, const struct mipi_dsi_msg *msg); +/* MIPI bus types */ +#define MIPI_DEVICE_TYPE_DSI BIT(0) +#define MIPI_DEVICE_TYPE_DBI_SPI_MODE1 BIT(1) +#define MIPI_DEVICE_TYPE_DBI_SPI_MODE2 BIT(2) +#define MIPI_DEVICE_TYPE_DBI_SPI_MODE3 BIT(3) +#define MIPI_DEVICE_TYPE_DBI_M6800 BIT(4) +#define MIPI_DEVICE_TYPE_DBI_I8080 BIT(5) + /** * struct mipi_dsi_host_ops - DSI bus operations * @attach: attach DSI device to DSI host @@ -94,11 +102,13 @@ struct mipi_dsi_host_ops { * struct mipi_dsi_host - DSI host device * @dev: driver model device node for this DSI host * @ops: DSI host operations + * @bus_types: Bitmask of supported MIPI bus types * @list: list management */ struct mipi_dsi_host { struct device *dev; const struct mipi_dsi_host_ops *ops; + unsigned int bus_types; struct list_head list; }; @@ -162,6 +172,7 @@ struct mipi_dsi_device_info { * @host: DSI host for this peripheral * @dev: driver model device node for this peripheral * @name: DSI peripheral chip type + * @bus_type: MIPI bus type (MIPI_DEVICE_TYPE_DSI/...) * @channel: virtual channel assigned to the peripheral * @format: pixel format for video mode * @lanes: number of active data lanes @@ -178,6 +189,7 @@ struct mipi_dsi_device { struct device dev; char name[DSI_DEV_NAME_SIZE]; + unsigned int bus_type; unsigned int channel; unsigned int lanes; enum mipi_dsi_pixel_format format; From patchwork Sun Jun 7 13:38:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11592037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1D0813B1 for ; Sun, 7 Jun 2020 19:13:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C1F4206D5 for ; Sun, 7 Jun 2020 19:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="P2uLhfqG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C1F4206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D36D66E391; Sun, 7 Jun 2020 19:13:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3EFA16E123 for ; Sun, 7 Jun 2020 13:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1591537135; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KzRVUml0maXfgFVq+MitCsYwSMuF5r+FxpSe47uLMi8=; b=P2uLhfqGzC9wEIm/6Szi8vmSZW6nCycQu4lIb1AehFYyY/ld0I99gKnqWNC3bomoL73c2v QntrwuI0Q7jR0Ot+gD1UQRkutMu4/4eaeeZRj6r+wba1E+kLkC9xDNhRbrrOiwu4Kpo9tC b3+cRS9Ch9kAhG6VlgV8FA1WQPB8Llk= From: Paul Cercueil To: =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Emil Velikov , Daniel Vetter , Sam Ravnborg Subject: [RFC PATCH 2/4] gpu/drm: Add SPI DBI host driver Date: Sun, 7 Jun 2020 15:38:30 +0200 Message-Id: <20200607133832.1730288-3-paul@crapouillou.net> In-Reply-To: <20200607133832.1730288-1-paul@crapouillou.net> References: <20200607133832.1730288-1-paul@crapouillou.net> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 07 Jun 2020 19:13:00 +0000 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: Paul Cercueil , od@zcrc.me, dri-devel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This driver will register a DBI host driver for panels connected over SPI. For now, only DBI type c3 is supported, which is a SPI protocol with 8 bits per word, with the data/command information carried by a separate GPIO. Signed-off-by: Paul Cercueil --- drivers/gpu/drm/bridge/Kconfig | 8 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/dbi-spi.c | 159 +++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 drivers/gpu/drm/bridge/dbi-spi.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index aaed2347ace9..61587bc4d6e6 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -180,6 +180,14 @@ config DRM_TI_TPD12S015 Texas Instruments TPD12S015 HDMI level shifter and ESD protection driver. +config DRM_MIPI_DBI_SPI + tristate "SPI host support for MIPI DBI" + depends on OF && SPI + select DRM_MIPI_DSI + select DRM_MIPI_DBI + help + Driver to support DBI over SPI. + source "drivers/gpu/drm/bridge/analogix/Kconfig" source "drivers/gpu/drm/bridge/adv7511/Kconfig" diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 6fb062b5b0f0..17fdf7de498d 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/ obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o obj-$(CONFIG_DRM_TI_TPD12S015) += ti-tpd12s015.o +obj-$(CONFIG_DRM_MIPI_DBI_SPI) += dbi-spi.o obj-y += analogix/ obj-y += synopsys/ diff --git a/drivers/gpu/drm/bridge/dbi-spi.c b/drivers/gpu/drm/bridge/dbi-spi.c new file mode 100644 index 000000000000..c790514b7372 --- /dev/null +++ b/drivers/gpu/drm/bridge/dbi-spi.c @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * MIPI Display Bus Interface (DBI) SPI support + * + * Copyright 2016 Noralf Trønnes + * Copyright 2020 Paul Cercueil + */ + +#include +#include +#include + +#include +#include + +#include