From patchwork Sun Feb 14 19:40:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1632 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BB9CB3F158 for ; Sun, 14 Feb 2021 20:41:29 +0100 (CET) Received: by mail-pl1-f200.google.com with SMTP id u14sf4859129plf.4 for ; Sun, 14 Feb 2021 11:41:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613331688; cv=pass; d=google.com; s=arc-20160816; b=A5C+mdxhOAwAZdTDEGnouT7NsdF5G2pKdN01pOa437qMzFuPDHDD4G8sEM3T4+5Sup qahJNb8qsimKUuGIXWvhE807AhSIt7pTTFU50TpnonBK8rjtkdEwFIl7TT84P6/AQsTa ZqhcntfJKa1d2CrMl9obWEQJrVAIYB76lzD4JlIRda59kgrZE+L1X1vAkoFdfqu2UGc1 PwSBeiEkejMZvc3Lm0FoDPtNfScpN4Ys8dC6OxkWQzV/IcgmVLs7vQJ4yUI6Qs3B6i6X lngsKquAZwOfJQK6Om4MobYSLUGKeyYoii4stjTunzTQGpkQVqHgarGGdt9ZVn11qD7Z ZylA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vzRMd8SCoSACTXTmvXLf7jWh7Y2cBJT6fCvDuyywCXQ=; b=TX3u0Hp+CS9BjCCWfqnJINkJh0SUlGW2SYo3IY68qoGvzhTFC/dzxC5/rPHTSgxZWc mlBkhkbfiwkCKRCARkrpcloNXjmfTpxUag5KNplQdwqzkbeAlwUgLm/6ok4o/sdrcRSQ hvxHbjnIoxpzQhkS4pADVQOwtC0+0dwtJsc0AoYHqWsIQqZjK55bUTykwo2rvBf8CUfI /+97U+MOZGy7DinvyAALXk19z9hbzxNhW1aig20RmsKciKedYhXx1qhBomN2YfOpVZrb BDbQiMVshHKWIA9kw0bJfwNdnPKEnYFsr1FU06T4L2Kmz4tvx7aoVhtAZkYuDMYV+8TY a26Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFSNtSVX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=vzRMd8SCoSACTXTmvXLf7jWh7Y2cBJT6fCvDuyywCXQ=; b=nQlSwf60k/5BFshJ/29SZA91rNLmwXf83xbQK3wBcv+fwD2zn0JfVyFy/AndB4yl0G tcGMSAOCKw8ZDeuzcK+gZuXbigXKJHfAc19+nj2Au1wZaHw5coJxVw3lAv3yJjJZkDOf npoBB+fA5TeXWRUaajdM1D9NQd42QZG053JSE= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=vzRMd8SCoSACTXTmvXLf7jWh7Y2cBJT6fCvDuyywCXQ=; b=S3lj5vgmj/lejU3zWddGqQPobYQwfNzb7ZnBnE6Hxx/hgUnUvKAk7naEWmke5dt9nz Q05bp6HRH9oReqxq19JvEy+ssPyjZv8Gj4GCY+Js+jxTHk+GkHZ1/o82nqfi+KPUnUEt wAzTUtuhgfsQtK0fbm9ItJahIRWbpVuqr7waHTDSnAFJw79H1A74eK+FUu5kD3nHEsI0 Wu6Btxlg81ocTZYCYnVO7JKGFWsttSJqB7fTjeGDQrl2q5jN9ziht7fqV/OB6K1ACcq5 MAtAd1Vid4yFYVSDhSmGuGyjDvD7Ia3Jwnvu/xo9yJPyrFycsl29mNlxmBoSrvOnsuEx ykRw== X-Gm-Message-State: AOAM530KTSFEg+9MEpE7MXwqIIA82myGIu47Hnehkxi6zuxWC15jfxxp Vr/rEe7Zgwl0z4/FUNtEaud3UMc0 X-Google-Smtp-Source: ABdhPJyG5Lb1waJ98vstmUZ4dRC8xRFJSo+mngFvSY23dCiAbYh4USIFxs/9PE2t9/T3jGRz8XG+nA== X-Received: by 2002:a17:90a:6c62:: with SMTP id x89mr12992604pjj.124.1613331687954; Sun, 14 Feb 2021 11:41:27 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:31c7:: with SMTP id v7ls6297730ple.2.gmail; Sun, 14 Feb 2021 11:41:27 -0800 (PST) X-Received: by 2002:a17:90a:b115:: with SMTP id z21mr3952442pjq.50.1613331687317; Sun, 14 Feb 2021 11:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613331687; cv=none; d=google.com; s=arc-20160816; b=nCtUfQbSiZpqE7Jmfb6G6kQ7k+tIDmy6fMoG4iOZmc9fcxP507du8EVr4s60oHjJc/ TiSxxQqC0WXDfKxvFVrMIKd5CtrsmDreTL0m+mx8xYGQEgdxPebgQiVa258DhncyI+QS TPNmSxrZt1KTd+IsmpzYjtD6FuibjTqGL+rIne70JTv3VxzOXqdWppALQMCs1uOrpImf Olsc3yuCBvUmPwTMTtLRxNCXACgKr+iBqN4iAQzHoxeYKIpcv5hnH97kaQ/Pu6aKAJFT fWYo4KTGTKVOobghpR+t4rUWkrNffdfLTfDZdOjeU30tU0ir1lH/0jgwQ8Lxs1hFOrY4 NQxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8WZPMnqVXps+lPno6HH29XofDRK8cGk3vtrNY/1y3YY=; b=dNRjmxGntnQuEsDbV2ZmuLFqHlKeOQWPgYwllp7JVk28HUnS3GYIg/CvSeWoU8+ffJ Ifc7lgBeTSp9AgYCr30sw0LGaPAh5l4RysiFPh3zAagFq9orrF5Ytt/GTH0naI0wp8sh AE7oiZU6QtZLVBsOq+yZrG/eoT7qR3exhSZeOQKaIhcmFz6DVY+dhYbtTyuvX/dQaA21 00hbrDhTEkroEeA+3bafSEUxvydWyEizaQZIyISmzgdz3EKkfg2bUxgEKzsYRFEcNxZS sFYgL08GuqahqgPZxNIQZ19YrS7Bc7WJFWCxDiyyAutfVYmDEICNz4ApvhW7iezPAp83 +qOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFSNtSVX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id gw4sor207307pjb.16.2021.02.14.11.41.27 for (Google Transport Security); Sun, 14 Feb 2021 11:41:27 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:90a:fe09:: with SMTP id ck9mr12857176pjb.67.1613331687102; Sun, 14 Feb 2021 11:41:27 -0800 (PST) Received: from ub-XPS-13-9350.domain.name ([45.249.78.214]) by smtp.gmail.com with ESMTPSA id 125sm15129247pfu.7.2021.02.14.11.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 11:41:26 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki , Samuel Holland Subject: [PATCH v3 2/7] drm: sun4i: dsi: Add bridge support Date: Mon, 15 Feb 2021 01:10:57 +0530 Message-Id: <20210214194102.126146-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214194102.126146-1-jagan@amarulasolutions.com> References: <20210214194102.126146-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFSNtSVX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Some display panels would come up with a non-DSI output which can have an option to connect DSI interface by means of bridge converter. This DSI to non-DSI bridge converter would require a bridge driver that would communicate the DSI controller for bridge functionalities. So, add support for bridge functionalities in Allwinner DSI controller. Cc: Samuel Holland Signed-off-by: Jagan Teki --- Note: Samuel Holland, The existing kms hotplug dropped in order to attach the bridge properly. However, I did try several ways to support hotplug with the bridge but it's resulting in a deadlock where bind never attach bridge until bridge pointer found and bridge pointer cannot found until bind finishes. Any inputs on this would be appreciated. Changes for v3: - updated with new API's drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 34 +++++++++++++++++--------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 2e9e7b2d4145..39321299dc27 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -773,6 +773,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (dsi->panel) drm_panel_prepare(dsi->panel); + if (dsi->panel_bridge) + dsi->panel_bridge->funcs->pre_enable(dsi->panel_bridge); + /* * FIXME: This should be moved after the switch to HS mode. * @@ -788,6 +791,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (dsi->panel) drm_panel_enable(dsi->panel); + if (dsi->panel_bridge) + dsi->panel_bridge->funcs->enable(dsi->panel_bridge); + sun6i_dsi_start(dsi, DSI_START_HSC); udelay(1000); @@ -804,6 +810,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) if (dsi->panel) { drm_panel_disable(dsi->panel); drm_panel_unprepare(dsi->panel); + } else if (dsi->panel_bridge) { + dsi->panel_bridge->funcs->disable(dsi->panel_bridge); + dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge); } phy_power_off(dsi->dphy); @@ -964,23 +973,17 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); - struct drm_panel *panel; int ret; ret = drm_of_find_panel_or_bridge(dsi->dev->of_node, 0, 0, - &panel, NULL); + &dsi->panel, &dsi->panel_bridge); if (ret) return ret; - if (!dsi->drm || !dsi->drm->registered) - return -EPROBE_DEFER; - - dsi->panel = panel; dsi->device = device; - drm_kms_helper_hotplug_event(dsi->drm); - - dev_info(host->dev, "Attached device %s\n", device->name); + dev_info(host->dev, "Attached %s %s\n", + device->name, dsi->panel ? "panel" : "bridge"); return 0; } @@ -991,9 +994,10 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); dsi->panel = NULL; + dsi->panel_bridge = NULL; dsi->device = NULL; - drm_kms_helper_hotplug_event(dsi->drm); + drm_of_panel_bridge_remove(dsi->dev->of_node, 0, 0); return 0; } @@ -1082,7 +1086,13 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - dsi->drm = drm; + if (dsi->panel_bridge) { + ret = drm_bridge_attach(&dsi->encoder, dsi->panel_bridge, NULL, 0); + if (ret) { + dev_err(dsi->dev, "Couldn't attach drm bridge\n"); + goto err_cleanup_connector; + } + } return 0; @@ -1096,7 +1106,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, { struct sun6i_dsi *dsi = dev_get_drvdata(dev); - dsi->drm = NULL; + drm_encoder_cleanup(&dsi->encoder); } static const struct component_ops sun6i_dsi_ops = { diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index c863900ae3b4..370ecb356a63 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -29,8 +29,8 @@ struct sun6i_dsi { struct device *dev; struct mipi_dsi_device *device; - struct drm_device *drm; struct drm_panel *panel; + struct drm_bridge *panel_bridge; }; static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)