From patchwork Mon Mar 22 14:01:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1714 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D029A3F067 for ; Mon, 22 Mar 2021 15:02:28 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id p1sf28157198pgi.16 for ; Mon, 22 Mar 2021 07:02:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1616421747; cv=pass; d=google.com; s=arc-20160816; b=NAjteQAR/eDzh9sJX7zx08/TvIvzXJCtObngkHzZbJub+/ponjoxWsLzStH0FFUVMW SZ+1FgThE1VA1h7LIOelN26IcD1o/0ttN4R9zOgVJeX4EImoukGv0yNnvKeJCFj/8+gJ J5Wt+onkCHs5lUwt2xwFr66H+eFXd5z9DMbmjlheoWD70rESTScJVYeAJV3/3g5O38FO lqwqDfcWKoc5pt0r+t2Mk2A1HCKGqrVcjgX7z+am+fHKyUEK2iONU0iXv8Nir2CF7EFS Q6jJ96zPhVCj32bN3SalfbC9V8NEwH3Shksn7BdnZxSJF8b8dnbyuuTKGdMABrLC2kAM wU7g== 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=PH7J/jAv3KcOBEMBK2DWcNLbG8TH7KLnqUXPwIl7Zfg=; b=S3HiKWuUD5dosFYGYt/C5vEVkoaBtexb3gNyYGA9Q362RmTCRD2+Il7JN1ghDCSe12 8x6gLrj5cR+0MXfysNzu3UZcD0EG4w1w4Ueh78+blfJUC4ePn+O8JLcFmSLOu5e/nNuh zHJx8C55hYDhJljRJX6YE5u/X42qTi1pXM7RjuwUOiY09+7HAsRuwy/td298OjOm+oZj Q2ukqkHRKv/GFjWAd0Beeu5xONYFeUa1aTyeMj3HuowUiufp16C/XPo+O17ttuPap1gI 1Vo47DRT5xV2esCmCbojDZNkFdPUsXkHWClq3Ops8lXp8X4GVZs3+UbhMPlh89k9ROsC W8KQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Idm1TRUw; 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=PH7J/jAv3KcOBEMBK2DWcNLbG8TH7KLnqUXPwIl7Zfg=; b=RZOukOKzbz3bO3YR3ovZoEGI8TSNkg8c1EQ0c9fzbiPPaLM7A/+LDdJ2h1K0Gc0kP2 SeUVsdpTp5RyeBcdCezEXhYGo1ptdVfLobUBZVuzufqURHnUqz01VGVLfqi9SNpy73t2 ikn90dtLIGjdmZamQX+B9FtAsoU5tVZxZ/czg= 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=PH7J/jAv3KcOBEMBK2DWcNLbG8TH7KLnqUXPwIl7Zfg=; b=ezEjF+XmVLx/mdSobd9ttuwEQBj2XmbO1JZKRHxIOe5K0h/YcIew/hKK4utKv9xvHD oXsAPNOXp+m37/P18K2TK4ADOiUhKLFsee9Qet9z5n1lFlbUPZ9DavXRNLxXH3fPc2B3 V/AugjTar3gtWaFp6t0LUKpOFkMzvI8Js+jSg4Pi/4PbepOpkiIqb6quj2I6Ty1gaPF5 j811vIrv08xQEowDEL2q5T6y6rJCPu+WVpIS35ppxDokaKOVKWcHIwdBFqq9ECjWqUGH svCHcIOEu/2YAU9ADQ7LiwuHvDsuO5QztMDcnw27tAkXHz9wO4OfVkdAcV0uZSrmSt7w cu+A== X-Gm-Message-State: AOAM533muRn/XzJYMoa4OHhlJPXH1JXwFRI9l7dIvukg51DuSBIy0Ifg jPcZGIxynNEmr39dV27466Zc6r/u X-Google-Smtp-Source: ABdhPJx+EOqDGQB+p8HxmDQ9zo/KpPT1y2Myyub0cpzNePyWGh3Pr2YHSwoTuoOaTjrXhbTTRlKwvw== X-Received: by 2002:a17:902:9a81:b029:e6:db2b:3ad8 with SMTP id w1-20020a1709029a81b02900e6db2b3ad8mr13975379plp.61.1616421747235; Mon, 22 Mar 2021 07:02:27 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:4115:: with SMTP id r21ls6752849pld.1.gmail; Mon, 22 Mar 2021 07:02:26 -0700 (PDT) X-Received: by 2002:a17:90a:e2ca:: with SMTP id fr10mr13471686pjb.154.1616421746623; Mon, 22 Mar 2021 07:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616421746; cv=none; d=google.com; s=arc-20160816; b=Qy5PxWO/VCaZ4+FZc9lAeGooCJkGZY2cf6UsNByxdbxwHbzahXhoPLKJBIwgvMtkza g+uOyxZbS9sI0gry0WWhueC95DLJhFAzem/WUGLkolIiSUYCwEIumT/BxxRP5R9xPm5U pmeDUmoHuZhvZ87cA73ee3YNuiFuqqHHV/rukKCCChi9/2fTeXnT5BVTlF/7E9VtlQvp vyTFtR1UI0fH42Ymb8zwlzUMbNRO6W8aE456BGY5YY3NgKGqFXkaDZQfk/UuBFJC7eUz MqUJk0QrTw9KMQpdJXrbRXYwySFccIiB9ymb4hbjgO3YTsJhJ2hdie+jzzwrvP++A3nT uFjg== 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=tNbrx86DmSZYrQGPtYW/NrYWvp0JiJ6t7g8UyTa2yps=; b=YaSzYc8mNZumDKQRDjOfPx//k0MmP/6m9uObR+q2sAyQWwrJh6jdAIE6FXnsGYZHsw FeXno15dbHVctYNYlrP+aZWptynaue6FTAef+V6jeuJrx9KytiuIUebSziB/wsBPn0gX pT6Ew9jaCM19wYse384be8M8ts18N/rs8XFSTycF/hrb5Pt7HYUe5rocVMLOmpp31AlW zKgNT/TtGSVw8zSJLEvaP48c8cNFBpxuxkBSKlzf6xYCOf024whCunfCLrnwXs9DEtnB rlf92STM5gxkw3ypDFLNbabcIe8MoqDyD3Shv9ftiARYkLFnpfyqrg0ML3cIuN79qLDl L2ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Idm1TRUw; 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 o10sor6190745pgr.39.2021.03.22.07.02.26 for (Google Transport Security); Mon, 22 Mar 2021 07:02:26 -0700 (PDT) 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:a63:5044:: with SMTP id q4mr22407823pgl.178.1616421746216; Mon, 22 Mar 2021 07:02:26 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a884:15c1:9a30:414f:d84b]) by smtp.gmail.com with ESMTPSA id gg22sm14112997pjb.20.2021.03.22.07.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 07:02:25 -0700 (PDT) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Laurent Pinchart , Samuel Holland Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, linux-sunxi@googlegroups.com, Jagan Teki Subject: [PATCH v4 2/4] drm: sun4i: dsi: Add bridge support Date: Mon, 22 Mar 2021 19:31:50 +0530 Message-Id: <20210322140152.101709-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210322140152.101709-1-jagan@amarulasolutions.com> References: <20210322140152.101709-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=Idm1TRUw; 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 v4: - none 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)