From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 982D2C3A5A4 for ; Fri, 30 Aug 2019 11:33:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 60CC621874 for ; Fri, 30 Aug 2019 11:33:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ufdelH/W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60CC621874 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sigxcpu.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YhTZJ5WbViMsKPB4TRr56/eO3XpEvQqi2XxRn7l2Xew=; b=ufdelH/WkeZIQA cUUvPUaIIqHBZXgvfQ/TCBdQ7darFcOKCYxOHFjXqhKtfeS1/vIStgA56eyWSoS2w+rZ8CfAa1ee7 esqcv0xVTugNILOskfSbrqZAUJlnJsbyxu8VoPXIFNrw2GbsPw8Orw3W6UN+fBYx3Si0VhdnuJBp3 sYp5pNiaLrAL3OggjGwqUBosylcV0vsQaXCBJMws+F5ZLD0dsf8Df7y7mEwn3u5EejGM7jzs9JQeL 27azxex7nOdzJs9F0hdp9Zkr8hoUvGkqTIxlG8gIQbP/jfANRKKSRaLIXCcPLHbQQ6ekWLG4yL3DD x0LERtmtv1KYlny83MFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i3f9x-00011y-Dp; Fri, 30 Aug 2019 11:33:41 +0000 Received: from honk.sigxcpu.org ([24.134.29.49]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i3f9r-00010k-3m for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2019 11:33:40 +0000 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id E5A7AFB03; Fri, 30 Aug 2019 13:33:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at honk.sigxcpu.org Received: from honk.sigxcpu.org ([127.0.0.1]) by localhost (honk.sigxcpu.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8yXjlzumpADU; Fri, 30 Aug 2019 13:33:22 +0200 (CEST) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 5998846CBB; Fri, 30 Aug 2019 13:33:22 +0200 (CEST) Date: Fri, 30 Aug 2019 13:33:22 +0200 From: Guido =?iso-8859-1?Q?G=FCnther?= To: Robert Chiras Subject: Re: [EXT] [PATCH v3 2/2] drm/bridge: Add NWL MIPI DSI host controller support Message-ID: <20190830113322.GA18591@bogon.m.sigxcpu.org> References: <1567071617.3209.127.camel@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1567071617.3209.127.camel@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190830_043335_657095_4012CE95 X-CRM114-Status: GOOD ( 28.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "mark.rutland@arm.com" , "devicetree@vger.kernel.org" , "jernej.skrabec@siol.net" , "kernel@pengutronix.de" , "sam@ravnborg.org" , "narmstrong@baylibre.com" , "airlied@linux.ie" , "festevam@gmail.com" , "s.hauer@pengutronix.de" , "jonas@kwiboo.se" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "a.hajda@samsung.com" , "robh+dt@kernel.org" , "arnd@arndb.de" , dl-linux-imx , "daniel@ffwll.ch" , "shawnguo@kernel.org" , "lee.jones@linaro.org" , "linux-arm-kernel@lists.infradead.org" , "Laurent.pinchart@ideasonboard.com" Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Thu, Aug 29, 2019 at 09:40:20AM +0000, Robert Chiras wrote: > Hi Guido, > = > One more thing for you to add in v4, see inline. > = > On Jo, 2019-08-22 at 12:44 +0200, Guido G=FCnther wrote: > > This adds initial support for the NWL MIPI DSI Host controller found > > on > > i.MX8 SoCs. > > = > > It adds support for the i.MX8MQ but the same IP can be found on > > e.g. the i.MX8QXP. > > = > > It has been tested on the Librem 5 devkit using mxsfb. > > = > > Signed-off-by: Guido G=FCnther > > Co-developed-by: Robert Chiras > > --- > > =A0drivers/gpu/drm/bridge/Kconfig=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|=A0= =A0=A02 + > > =A0drivers/gpu/drm/bridge/Makefile=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|=A0=A0= =A01 + > > =A0drivers/gpu/drm/bridge/nwl-dsi/Kconfig=A0=A0=A0|=A0=A016 + > > =A0drivers/gpu/drm/bridge/nwl-dsi/Makefile=A0=A0|=A0=A0=A04 + > > =A0drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.c | 501 ++++++++++++++++ > > =A0drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.h |=A0=A065 +++ > > =A0drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.c | 700 > > +++++++++++++++++++++++ > > =A0drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.h | 112 ++++ > > =A08 files changed, 1401 insertions(+) > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/Kconfig > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/Makefile > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.c > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.h > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.c > > =A0create mode 100644 drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.h > > = > > diff --git a/drivers/gpu/drm/bridge/Kconfig > > b/drivers/gpu/drm/bridge/Kconfig > > index 1cc9f502c1f2..7980b5c2156f 100644 > > --- a/drivers/gpu/drm/bridge/Kconfig > > +++ b/drivers/gpu/drm/bridge/Kconfig > > @@ -154,6 +154,8 @@ source "drivers/gpu/drm/bridge/analogix/Kconfig" > > = > > =A0source "drivers/gpu/drm/bridge/adv7511/Kconfig" > > = > > +source "drivers/gpu/drm/bridge/nwl-dsi/Kconfig" > > + > > =A0source "drivers/gpu/drm/bridge/synopsys/Kconfig" > > = > > =A0endmenu > > diff --git a/drivers/gpu/drm/bridge/Makefile > > b/drivers/gpu/drm/bridge/Makefile > > index 4934fcf5a6f8..d9f6c0f77592 100644 > > --- a/drivers/gpu/drm/bridge/Makefile > > +++ b/drivers/gpu/drm/bridge/Makefile > > @@ -16,4 +16,5 @@ obj-$(CONFIG_DRM_ANALOGIX_DP) +=3D analogix/ > > =A0obj-$(CONFIG_DRM_I2C_ADV7511) +=3D adv7511/ > > =A0obj-$(CONFIG_DRM_TI_SN65DSI86) +=3D ti-sn65dsi86.o > > =A0obj-$(CONFIG_DRM_TI_TFP410) +=3D ti-tfp410.o > > +obj-$(CONFIG_DRM_NWL_MIPI_DSI) +=3D nwl-dsi/ > > =A0obj-y +=3D synopsys/ > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi/Kconfig > > b/drivers/gpu/drm/bridge/nwl-dsi/Kconfig > > new file mode 100644 > > index 000000000000..3b157a9f2229 > > --- /dev/null > > +++ b/drivers/gpu/drm/bridge/nwl-dsi/Kconfig > > @@ -0,0 +1,16 @@ > > +config DRM_NWL_MIPI_DSI > > +=A0=A0=A0=A0=A0=A0=A0tristate "Support for Northwest Logic MIPI DSI Ho= st > > controller" > > +=A0=A0=A0=A0=A0=A0=A0depends on DRM > > +=A0=A0=A0=A0=A0=A0=A0depends on COMMON_CLK > > +=A0=A0=A0=A0=A0=A0=A0depends on OF && HAS_IOMEM > > +=A0=A0=A0=A0=A0=A0=A0select DRM_KMS_HELPER > > +=A0=A0=A0=A0=A0=A0=A0select DRM_MIPI_DSI > > +=A0=A0=A0=A0=A0=A0=A0select DRM_PANEL_BRIDGE > > +=A0=A0=A0=A0=A0=A0=A0select GENERIC_PHY_MIPI_DPHY > > +=A0=A0=A0=A0=A0=A0=A0select MFD_SYSCON > > +=A0=A0=A0=A0=A0=A0=A0select MULTIPLEXER > > +=A0=A0=A0=A0=A0=A0=A0select REGMAP_MMIO > > +=A0=A0=A0=A0=A0=A0=A0help > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0This enables the Northwest Logic MIPI DSI H= ost controller > > as > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0for example found on NXP's i.MX8 Processors. > > + > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi/Makefile > > b/drivers/gpu/drm/bridge/nwl-dsi/Makefile > > new file mode 100644 > > index 000000000000..804baf2f1916 > > --- /dev/null > > +++ b/drivers/gpu/drm/bridge/nwl-dsi/Makefile > > @@ -0,0 +1,4 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +nwl-mipi-dsi-y :=3D nwl-drv.o nwl-dsi.o > > +obj-$(CONFIG_DRM_NWL_MIPI_DSI) +=3D nwl-mipi-dsi.o > > +header-test-y +=3D nwl-drv.h nwl-dsi.h > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.c > > b/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.c > > new file mode 100644 > > index 000000000000..e457438738c0 > > --- /dev/null > > +++ b/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.c > > @@ -0,0 +1,501 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * i.MX8 NWL MIPI DSI host driver > > + * > > + * Copyright (C) 2017 NXP > > + * Copyright (C) 2019 Purism SPC > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include "nwl-drv.h" > > +#include "nwl-dsi.h" > > + > > +#define DRV_NAME "nwl-dsi" > > + > > +/* Possible platform specific clocks */ > > +#define NWL_DSI_CLK_CORE=A0=A0=A0=A0=A0=A0=A0"core" > > + > > +static const struct regmap_config nwl_dsi_regmap_config =3D { > > +=A0=A0=A0=A0=A0=A0=A0.reg_bits =3D 16, > > +=A0=A0=A0=A0=A0=A0=A0.val_bits =3D 32, > > +=A0=A0=A0=A0=A0=A0=A0.reg_stride =3D 4, > > +=A0=A0=A0=A0=A0=A0=A0.max_register =3D NWL_DSI_IRQ_MASK2, > > +=A0=A0=A0=A0=A0=A0=A0.name =3D DRV_NAME, > > +}; > > + > > +struct nwl_dsi_platform_data { > > +=A0=A0=A0=A0=A0=A0=A0int (*poweron)(struct nwl_dsi *dsi); > > +=A0=A0=A0=A0=A0=A0=A0int (*poweroff)(struct nwl_dsi *dsi); > > +=A0=A0=A0=A0=A0=A0=A0int (*select_input)(struct nwl_dsi *dsi); > > +=A0=A0=A0=A0=A0=A0=A0int (*deselect_input)(struct nwl_dsi *dsi); > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi_plat_clk_config > > clk_config[NWL_DSI_MAX_PLATFORM_CLOCKS]; > > +}; > > + > > +static inline struct nwl_dsi *bridge_to_dsi(struct drm_bridge > > *bridge) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0return container_of(bridge, struct nwl_dsi, bridg= e); > > +} > > + > > +static int nwl_dsi_set_platform_clocks(struct nwl_dsi *dsi, bool > > enable) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct device *dev =3D dsi->dev; > > +=A0=A0=A0=A0=A0=A0=A0const char *id; > > +=A0=A0=A0=A0=A0=A0=A0struct clk *clk; > > +=A0=A0=A0=A0=A0=A0=A0size_t i; > > +=A0=A0=A0=A0=A0=A0=A0unsigned long rate; > > +=A0=A0=A0=A0=A0=A0=A0int ret, result =3D 0; > > + > > +=A0=A0=A0=A0=A0=A0=A0DRM_DEV_DEBUG_DRIVER(dev, "%s platform clocks\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0enable ? "enabling" : "disabling"); > > +=A0=A0=A0=A0=A0=A0=A0for (i =3D 0; i < ARRAY_SIZE(dsi->pdata->clk_conf= ig); i++) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (!dsi->clk_config[i].p= resent) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= ontinue; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0id =3D dsi->clk_config[i]= .id; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0clk =3D dsi->clk_config[i= ].clk; > > + > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (enable) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0r= et =3D clk_prepare_enable(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0i= f (ret < 0) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dev, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0"Failed t= o enable %s > > clk: %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0id, ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0result =3D result ?: ret; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0r= ate =3D clk_get_rate(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0D= RM_DEV_DEBUG_DRIVER(dev, "Enabled %s clk > > @%lu Hz\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0id, rate); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} else { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= lk_disable_unprepare(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0D= RM_DEV_DEBUG_DRIVER(dev, "Disabled %s > > clk\n", id); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0return result; > > +} > > + > > +static int nwl_dsi_plat_enable(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct device *dev =3D dsi->dev; > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->pdata->select_input) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0dsi->pdata->select_input(= dsi); > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D nwl_dsi_set_platform_clocks(dsi, true); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D dsi->pdata->poweron(dsi); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dev, "Faile= d to power on DSI: %d\n", > > ret); > > +=A0=A0=A0=A0=A0=A0=A0return ret; > > +} > > + > > +static void nwl_dsi_plat_disable(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0dsi->pdata->poweroff(dsi); > > +=A0=A0=A0=A0=A0=A0=A0nwl_dsi_set_platform_clocks(dsi, false); > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->pdata->deselect_input) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0dsi->pdata->deselect_inpu= t(dsi); > > +} > > + > > +static void nwl_dsi_bridge_disable(struct drm_bridge *bridge) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D bridge_to_dsi(bridge); > > + > > +=A0=A0=A0=A0=A0=A0=A0nwl_dsi_disable(dsi); > > +=A0=A0=A0=A0=A0=A0=A0nwl_dsi_plat_disable(dsi); > > +=A0=A0=A0=A0=A0=A0=A0pm_runtime_put(dsi->dev); > > +} > > + > > +static int nwl_dsi_get_dphy_params(struct nwl_dsi *dsi, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0const struct drm_display_mode > > *mode, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0union phy_configure_opts > > *phy_opts) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0unsigned long rate; > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->lanes < 1 || dsi->lanes > 4) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -EINVAL; > > + > > +=A0=A0=A0=A0=A0=A0=A0/* > > +=A0=A0=A0=A0=A0=A0=A0=A0* So far the DPHY spec minimal timings work fo= r both mixel > > +=A0=A0=A0=A0=A0=A0=A0=A0* dphy and nwl dsi host > > +=A0=A0=A0=A0=A0=A0=A0=A0*/ > > +=A0=A0=A0=A0=A0=A0=A0ret =3D phy_mipi_dphy_get_default_config( > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0mode->crtc_clock * 1000, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0mipi_dsi_pixel_format_to_= bpp(dsi->format), dsi- > > >lanes, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0&phy_opts->mipi_dphy); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0rate =3D clk_get_rate(dsi->tx_esc_clk); > > +=A0=A0=A0=A0=A0=A0=A0DRM_DEV_DEBUG_DRIVER(dsi->dev, "LP clk is @%lu Hz= \n", rate); > > +=A0=A0=A0=A0=A0=A0=A0phy_opts->mipi_dphy.lp_clk_rate =3D rate; > > + > > +=A0=A0=A0=A0=A0=A0=A0return 0; > > +} > > + > > +static bool nwl_dsi_bridge_mode_fixup(struct drm_bridge *bridge, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0const struct drm_display_mode > > *mode, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0struct drm_display_mode > > *adjusted_mode) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0/* At least LCDIF + NWL needs active high sync */ > > +=A0=A0=A0=A0=A0=A0=A0adjusted_mode->flags |=3D (DRM_MODE_FLAG_PHSYNC | > > DRM_MODE_FLAG_PVSYNC); > > +=A0=A0=A0=A0=A0=A0=A0adjusted_mode->flags &=3D ~(DRM_MODE_FLAG_NHSYNC | > > DRM_MODE_FLAG_NVSYNC); > > + > > +=A0=A0=A0=A0=A0=A0=A0return true; > > +} > > + > > +static enum drm_mode_status > > +nwl_dsi_bridge_mode_valid(struct drm_bridge *bridge, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0const struct drm_display_mode *mode) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D bridge_to_dsi(bridge); > > +=A0=A0=A0=A0=A0=A0=A0int bpp =3D mipi_dsi_pixel_format_to_bpp(dsi->for= mat); > > + > > +=A0=A0=A0=A0=A0=A0=A0if (mode->clock * bpp > 15000000) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return MODE_CLOCK_HIGH; > > + > > +=A0=A0=A0=A0=A0=A0=A0if (mode->clock * bpp < 80000) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return MODE_CLOCK_LOW; > > + > > +=A0=A0=A0=A0=A0=A0=A0return MODE_OK; > > +} > > + > > +static void > > +nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= onst struct drm_display_mode *mode, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= onst struct drm_display_mode *adjusted_mode) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D bridge_to_dsi(bridge); > > +=A0=A0=A0=A0=A0=A0=A0struct device *dev =3D dsi->dev; > > +=A0=A0=A0=A0=A0=A0=A0union phy_configure_opts new_cfg; > > +=A0=A0=A0=A0=A0=A0=A0unsigned long phy_ref_rate; > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D nwl_dsi_get_dphy_params(dsi, adjusted_mod= e, &new_cfg); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return; > > + > > +=A0=A0=A0=A0=A0=A0=A0/* > > +=A0=A0=A0=A0=A0=A0=A0=A0* If hs clock is unchanged, we're all good - a= ll parameters > > are > > +=A0=A0=A0=A0=A0=A0=A0=A0* derived from it atm. > > +=A0=A0=A0=A0=A0=A0=A0=A0*/ > > +=A0=A0=A0=A0=A0=A0=A0if (new_cfg.mipi_dphy.hs_clk_rate =3D=3D dsi- > > >phy_cfg.mipi_dphy.hs_clk_rate) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return; > > + > > +=A0=A0=A0=A0=A0=A0=A0phy_ref_rate =3D clk_get_rate(dsi->phy_ref_clk); > > +=A0=A0=A0=A0=A0=A0=A0DRM_DEV_DEBUG_DRIVER(dev, "PHY at ref rate: %lu\n= ", > > phy_ref_rate); > > +=A0=A0=A0=A0=A0=A0=A0/* Save the new desired phy config */ > > +=A0=A0=A0=A0=A0=A0=A0memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg)); > > + > > +=A0=A0=A0=A0=A0=A0=A0memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mod= e)); > > +=A0=A0=A0=A0=A0=A0=A0drm_mode_debug_printmodeline(adjusted_mode); > > +} > > + > > +static void nwl_dsi_bridge_pre_enable(struct drm_bridge *bridge) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D bridge_to_dsi(bridge); > > + > > +=A0=A0=A0=A0=A0=A0=A0pm_runtime_get_sync(dsi->dev); > > +=A0=A0=A0=A0=A0=A0=A0nwl_dsi_plat_enable(dsi); > > +=A0=A0=A0=A0=A0=A0=A0nwl_dsi_enable(dsi); > > +} > > + > > +static int nwl_dsi_bridge_attach(struct drm_bridge *bridge) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D bridge->driver_private; > > + > > +=A0=A0=A0=A0=A0=A0=A0return drm_bridge_attach(bridge->encoder, dsi->pa= nel_bridge, > > bridge); > Have you tested this as a module? I tested this as built-in and it > worked, but today I ran a test with drivers as modules and it fails > here, since the panel is not yet probed (hence, dsi->panel_bridge is > NULL). Here is my dmesg: > [=A0=A0=A011.141177] mxsfb 30320000.lcdif: Cannot connect bridge: -22 > [=A0=A0=A011.161062] mxsfb: probe of 30320000.lcdif failed with error -22 > ... > [=A0=A0=A012.416964] nwl-dsi 30a00000.mipi_dsi: [drm:nwl_dsi_host_attach > [nwl_mipi_dsi]] lanes=3D4, format=3D0x0 flags=3D0x15 > You can see that the panel attaches later on, but there is no retry > scenario here. > = > So, I think you should handle this case here, otherwise the driver will > fail as a module. this was caused by a too eager (and duplicate) drm_bridge_add() in probe (we're doing it correctly when registering the dsi). With that dropped it works compiled in and as module. Thanks for testing! -- Guido > > +} > > + > > +static const struct drm_bridge_funcs nwl_dsi_bridge_funcs =3D { > > +=A0=A0=A0=A0=A0=A0=A0.pre_enable =3D nwl_dsi_bridge_pre_enable, > > +=A0=A0=A0=A0=A0=A0=A0.disable=A0=A0=A0=A0=3D nwl_dsi_bridge_disable, > > +=A0=A0=A0=A0=A0=A0=A0.mode_fixup =3D nwl_dsi_bridge_mode_fixup, > > +=A0=A0=A0=A0=A0=A0=A0.mode_set=A0=A0=A0=3D nwl_dsi_bridge_mode_set, > > +=A0=A0=A0=A0=A0=A0=A0.mode_valid =3D nwl_dsi_bridge_mode_valid, > > +=A0=A0=A0=A0=A0=A0=A0.attach=A0=A0=A0=A0=A0=3D nwl_dsi_bridge_attach, > > +}; > > + > > +static int nwl_dsi_parse_dt(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct platform_device *pdev =3D to_platform_devi= ce(dsi->dev); > > +=A0=A0=A0=A0=A0=A0=A0struct clk *clk; > > +=A0=A0=A0=A0=A0=A0=A0const char *clk_id; > > +=A0=A0=A0=A0=A0=A0=A0void __iomem *base; > > +=A0=A0=A0=A0=A0=A0=A0int i, ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->phy =3D devm_phy_get(dsi->dev, "dphy"); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(dsi->phy)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(dsi->phy); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (ret !=3D -EPROBE_DEFE= R) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0D= RM_DEV_ERROR(dsi->dev, "Could not get PHY: > > %d\n", ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0/* Platform dependent clocks */ > > +=A0=A0=A0=A0=A0=A0=A0memcpy(dsi->clk_config, dsi->pdata->clk_config, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0sizeof(dsi->pdata->clk_confi= g)); > > + > > +=A0=A0=A0=A0=A0=A0=A0for (i =3D 0; i < ARRAY_SIZE(dsi->pdata->clk_conf= ig); i++) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (!dsi->clk_config[i].p= resent) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= ontinue; > > + > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0clk_id =3D dsi->clk_confi= g[i].id; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0clk =3D devm_clk_get(dsi-= >dev, clk_id); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(clk)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0r= et =3D PTR_ERR(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0D= RM_DEV_ERROR(dsi->dev, "Failed to get %s > > clock: %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0clk_id, ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0r= eturn ret; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_DEBUG_DRIVER(dsi-= >dev, "Setup clk %s (rate: > > %lu)\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0clk_id, clk_get_rate(clk)); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0dsi->clk_config[i].clk = =3D clk; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0/* DSI clocks */ > > +=A0=A0=A0=A0=A0=A0=A0clk =3D devm_clk_get(dsi->dev, "phy_ref"); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(clk)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to get phy_ref clock: > > %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0dsi->phy_ref_clk =3D clk; > > + > > +=A0=A0=A0=A0=A0=A0=A0clk =3D devm_clk_get(dsi->dev, "rx_esc"); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(clk)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to get rx_esc clock: > > %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0dsi->rx_esc_clk =3D clk; > > + > > +=A0=A0=A0=A0=A0=A0=A0clk =3D devm_clk_get(dsi->dev, "tx_esc"); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(clk)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(clk); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to get tx_esc clock: > > %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0dsi->tx_esc_clk =3D clk; > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->mux =3D devm_mux_control_get(dsi->dev, NULL); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(dsi->mux)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(dsi->mux); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (ret !=3D -EPROBE_DEFE= R) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0D= RM_DEV_ERROR(dsi->dev, "Failed to get mux: > > %d\n", ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0base =3D devm_platform_ioremap_resource(pdev, 0); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(base)) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return PTR_ERR(base); > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->regmap =3D > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0devm_regmap_init_mmio(dsi= ->dev, base, > > &nwl_dsi_regmap_config); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(dsi->regmap)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D PTR_ERR(dsi->regm= ap); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to create NWL DSI > > regmap: %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->irq =3D platform_get_irq(pdev, 0); > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->irq < 0) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to get device IRQ: > > %d\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0dsi->irq); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return dsi->irq; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->rstc =3D devm_reset_control_array_get(dsi->d= ev, false, > > true); > > +=A0=A0=A0=A0=A0=A0=A0if (IS_ERR(dsi->rstc)) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to get resets: > > %ld\n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0PTR_ERR(dsi->rstc)); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return PTR_ERR(dsi->rstc); > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0return 0; > > +} > > + > > +static int imx8mq_dsi_select_input(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct device_node *remote; > > +=A0=A0=A0=A0=A0=A0=A0u32 use_dcss =3D 1; > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0remote =3D of_graph_get_remote_node(dsi->dev->of_= node, 0, 0); > > +=A0=A0=A0=A0=A0=A0=A0if (strcmp(remote->name, "lcdif") =3D=3D 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0use_dcss =3D 0; > > + > > +=A0=A0=A0=A0=A0=A0=A0DRM_DEV_INFO(dsi->dev, "Using %s as input source\= n", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0(use_dcss)= ? "DCSS" : "LCDIF"); > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D mux_control_try_select(dsi->mux, use_dcss= ); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to select input: > > %d\n", ret); > > + > > +=A0=A0=A0=A0=A0=A0=A0of_node_put(remote); > > +=A0=A0=A0=A0=A0=A0=A0return ret; > > +} > > + > > + > > +static int imx8mq_dsi_deselect_input(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D mux_control_deselect(dsi->mux); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dsi->dev, "= Failed to deselect input: > > %d\n", ret); > > + > > +=A0=A0=A0=A0=A0=A0=A0return ret; > > +} > > + > > + > > +static int imx8mq_dsi_poweron(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0int ret =3D 0; > > + > > +=A0=A0=A0=A0=A0=A0=A0/* otherwise the display stays blank */ > > +=A0=A0=A0=A0=A0=A0=A0usleep_range(200, 300); > > + > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->rstc) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D reset_control_dea= ssert(dsi->rstc); > > + > > +=A0=A0=A0=A0=A0=A0=A0return ret; > > +} > > + > > +static int imx8mq_dsi_poweroff(struct nwl_dsi *dsi) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0int ret =3D 0; > > + > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->quirks & SRC_RESET_QUIRK) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return 0; > > + > > +=A0=A0=A0=A0=A0=A0=A0if (dsi->rstc) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret =3D reset_control_ass= ert(dsi->rstc); > > +=A0=A0=A0=A0=A0=A0=A0return ret; > > +} > > + > > +static const struct drm_bridge_timings nwl_dsi_timings =3D { > > +=A0=A0=A0=A0=A0=A0=A0.input_bus_flags =3D DRM_BUS_FLAG_DE_LOW, > > +}; > > + > > +static const struct nwl_dsi_platform_data imx8mq_dev =3D { > > +=A0=A0=A0=A0=A0=A0=A0.poweron =3D &imx8mq_dsi_poweron, > > +=A0=A0=A0=A0=A0=A0=A0.poweroff =3D &imx8mq_dsi_poweroff, > > +=A0=A0=A0=A0=A0=A0=A0.select_input =3D &imx8mq_dsi_select_input, > > +=A0=A0=A0=A0=A0=A0=A0.deselect_input =3D &imx8mq_dsi_deselect_input, > > +=A0=A0=A0=A0=A0=A0=A0.clk_config =3D { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0{ .id =3D NWL_DSI_CLK_COR= E, .present =3D true }, > > +=A0=A0=A0=A0=A0=A0=A0}, > > +}; > > + > > +static const struct of_device_id nwl_dsi_dt_ids[] =3D { > > +=A0=A0=A0=A0=A0=A0=A0{ .compatible =3D "fsl,imx8mq-nwl-dsi", .data =3D= &imx8mq_dev, }, > > +=A0=A0=A0=A0=A0=A0=A0{ /* sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, nwl_dsi_dt_ids); > > + > > +static const struct soc_device_attribute nwl_dsi_quirks_match[] =3D { > > +=A0=A0=A0=A0=A0=A0=A0{ .soc_id =3D "i.MX8MQ", .revision =3D "2.0", > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0.data =3D (void *)(E11418_HS_MODE_QUIRK | S= RC_RESET_QUIRK) }, > > +=A0=A0=A0=A0=A0=A0=A0{ /* sentinel. */ }, > > +}; > > + > > +static int nwl_dsi_probe(struct platform_device *pdev) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct device *dev =3D &pdev->dev; > > +=A0=A0=A0=A0=A0=A0=A0const struct of_device_id *of_id =3D > > of_match_device(nwl_dsi_dt_ids, dev); > > +=A0=A0=A0=A0=A0=A0=A0const struct nwl_dsi_platform_data *pdata =3D of_= id->data; > > +=A0=A0=A0=A0=A0=A0=A0const struct soc_device_attribute *attr; > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi; > > +=A0=A0=A0=A0=A0=A0=A0int ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi =3D devm_kzalloc(dev, sizeof(*dsi), GFP_KERNE= L); > > +=A0=A0=A0=A0=A0=A0=A0if (!dsi) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -ENOMEM; > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->dev =3D dev; > > +=A0=A0=A0=A0=A0=A0=A0dsi->pdata =3D pdata; > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D nwl_dsi_parse_dt(dsi); > > +=A0=A0=A0=A0=A0=A0=A0if (ret) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > + > > +=A0=A0=A0=A0=A0=A0=A0ret =3D devm_request_irq(dev, dsi->irq, nwl_dsi_i= rq_handler, 0, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0dev_name(dev), dsi); > > +=A0=A0=A0=A0=A0=A0=A0if (ret < 0) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dev, "Faile= d to request IRQ %d: %d\n", > > dsi->irq, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->dsi_host.ops =3D &nwl_dsi_host_ops; > > +=A0=A0=A0=A0=A0=A0=A0dsi->dsi_host.dev =3D dev; > > +=A0=A0=A0=A0=A0=A0=A0ret =3D mipi_dsi_host_register(&dsi->dsi_host); > > +=A0=A0=A0=A0=A0=A0=A0if (ret) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DRM_DEV_ERROR(dev, "Faile= d to register MIPI host: > > %d\n", ret); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return ret; > > +=A0=A0=A0=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0=A0=A0=A0attr =3D soc_device_match(nwl_dsi_quirks_match); > > +=A0=A0=A0=A0=A0=A0=A0if (attr) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0dsi->quirks =3D (uintptr_= t)attr->data; > > + > > +=A0=A0=A0=A0=A0=A0=A0dsi->bridge.driver_private =3D dsi; > > +=A0=A0=A0=A0=A0=A0=A0dsi->bridge.funcs =3D &nwl_dsi_bridge_funcs; > > +=A0=A0=A0=A0=A0=A0=A0dsi->bridge.of_node =3D dev->of_node; > > +=A0=A0=A0=A0=A0=A0=A0dsi->bridge.timings =3D &nwl_dsi_timings; > > + > > +=A0=A0=A0=A0=A0=A0=A0drm_bridge_add(&dsi->bridge); > > + > > +=A0=A0=A0=A0=A0=A0=A0dev_set_drvdata(dev, dsi); > > +=A0=A0=A0=A0=A0=A0=A0pm_runtime_enable(dev); > > +=A0=A0=A0=A0=A0=A0=A0return 0; > > +} > > + > > +static int nwl_dsi_remove(struct platform_device *pdev) > > +{ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi *dsi =3D platform_get_drvdata(pdev= ); > > + > > +=A0=A0=A0=A0=A0=A0=A0mipi_dsi_host_unregister(&dsi->dsi_host); > > +=A0=A0=A0=A0=A0=A0=A0pm_runtime_disable(&pdev->dev); > > +=A0=A0=A0=A0=A0=A0=A0return 0; > > +} > > + > > +static struct platform_driver nwl_dsi_driver =3D { > > +=A0=A0=A0=A0=A0=A0=A0.probe=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=3D nwl_dsi_p= robe, > > +=A0=A0=A0=A0=A0=A0=A0.remove=A0=A0=A0=A0=A0=A0=A0=A0=A0=3D nwl_dsi_rem= ove, > > +=A0=A0=A0=A0=A0=A0=A0.driver=A0=A0=A0=A0=A0=A0=A0=A0=A0=3D { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0.of_match_table =3D nwl_d= si_dt_ids, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0.name=A0=A0=A0=3D DRV_NAM= E, > > +=A0=A0=A0=A0=A0=A0=A0}, > > +}; > > + > > +module_platform_driver(nwl_dsi_driver); > > + > > +MODULE_AUTHOR("NXP Semiconductor"); > > +MODULE_AUTHOR("Purism SPC"); > > +MODULE_DESCRIPTION("Northwest Logic MIPI-DSI driver"); > > +MODULE_LICENSE("GPL"); /* GPLv2 or later */ > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.h > > b/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.h > > new file mode 100644 > > index 000000000000..1e72a9221401 > > --- /dev/null > > +++ b/drivers/gpu/drm/bridge/nwl-dsi/nwl-drv.h > > @@ -0,0 +1,65 @@ > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > +/* > > + * NWL MIPI DSI host driver > > + * > > + * Copyright (C) 2017 NXP > > + * Copyright (C) 2019 Purism SPC > > + */ > > + > > +#ifndef __NWL_DRV_H__ > > +#define __NWL_DRV_H__ > > + > > +#include > > +#include > > + > > +#include > > +#include > > + > > +struct nwl_dsi_platform_data; > > + > > +/* i.MX8 NWL quirks */ > > +/* i.MX8MQ errata E11418 */ > > +#define E11418_HS_MODE_QUIRK=A0=A0=A0=A0=A0=A0=A0BIT(0) > > +/* Skip DSI bits in SRC on disable to avoid blank display on enable > > */ > > +#define SRC_RESET_QUIRK=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0BIT(1) > > + > > +#define NWL_DSI_MAX_PLATFORM_CLOCKS 1 > > +struct nwl_dsi_plat_clk_config { > > +=A0=A0=A0=A0=A0=A0=A0const char *id; > > +=A0=A0=A0=A0=A0=A0=A0struct clk *clk; > > +=A0=A0=A0=A0=A0=A0=A0bool present; > > +}; > > + > > +struct nwl_dsi { > > +=A0=A0=A0=A0=A0=A0=A0struct drm_bridge bridge; > > +=A0=A0=A0=A0=A0=A0=A0struct mipi_dsi_host dsi_host; > > +=A0=A0=A0=A0=A0=A0=A0struct drm_bridge *panel_bridge; > > +=A0=A0=A0=A0=A0=A0=A0struct device *dev; > > +=A0=A0=A0=A0=A0=A0=A0struct phy *phy; > > +=A0=A0=A0=A0=A0=A0=A0union phy_configure_opts phy_cfg; > > +=A0=A0=A0=A0=A0=A0=A0unsigned int quirks; > > + > > +=A0=A0=A0=A0=A0=A0=A0struct regmap *regmap; > > +=A0=A0=A0=A0=A0=A0=A0int irq; > > +=A0=A0=A0=A0=A0=A0=A0struct reset_control *rstc; > > +=A0=A0=A0=A0=A0=A0=A0struct mux_control *mux; > > + > > +=A0=A0=A0=A0=A0=A0=A0/* DSI clocks */ > > +=A0=A0=A0=A0=A0=A0=A0struct clk *phy_ref_clk; > > +=A0=A0=A0=A0=A0=A0=A0struct clk *rx_esc_clk; > > +=A0=A0=A0=A0=A0=A0=A0struct clk *tx_esc_clk; > > +=A0=A0=A0=A0=A0=A0=A0/* Platform dependent clocks */ > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi_plat_clk_config > > clk_config[NWL_DSI_MAX_PLATFORM_CLOCKS]; > > + > > +=A0=A0=A0=A0=A0=A0=A0/* dsi lanes */ > > +=A0=A0=A0=A0=A0=A0=A0u32 lanes; > > +=A0=A0=A0=A0=A0=A0=A0enum mipi_dsi_pixel_format format; > > +=A0=A0=A0=A0=A0=A0=A0struct drm_display_mode mode; > > +=A0=A0=A0=A0=A0=A0=A0unsigned long dsi_mode_flags; > > + > > +=A0=A0=A0=A0=A0=A0=A0struct nwl_dsi_transfer *xfer; > > + > > +=A0=A0=A0=A0=A0=A0=A0const struct nwl_dsi_platform_data *pdata; > > +}; > > + > > +#endif /* __NWL_DRV_H__ */ > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.c > > b/drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.c > > new file mode 100644 > > index 000000000000..fd030af55bb4 > > --- /dev/null > > +++ b/drivers/gpu/drm/bridge/nwl-dsi/nwl-dsi.c > > @@ -0,0 +1,700 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * NWL MIPI DSI host driver > > + * > > + * Copyright (C) 2017 NXP > > + * Copyright (C) 2019 Purism SPC > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include