From patchwork Fri Mar 15 13:08:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10854695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB42E17EF for ; Fri, 15 Mar 2019 13:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3ACD2A9B4 for ; Fri, 15 Mar 2019 13:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A78842A9B7; Fri, 15 Mar 2019 13:08:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2FC812A9B4 for ; Fri, 15 Mar 2019 13:08:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 110666E40A; Fri, 15 Mar 2019 13:08:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9E4E6E40A for ; Fri, 15 Mar 2019 13:08:52 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id n22so6338823pfa.3 for ; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) 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=MUOsJO/ekVDHiTmtCVq8d27ElQS89ZxoIWk8a+ZsNC8=; b=HWk3eAyF7fncQTknAdn7s9GGwrPsjMMSf+15gKY5mGuaCKGysZKR4U0mN93K7U95wQ O2MgqNxQTJ6AfvBk8NSJ/S7mEfKCy/HaxaHa1KsYXY1Kmx9FMHe47L61r1QJ3KdNXPK+ oIyU8rwd4mKQJMjee9X21CEoPXiZ5ZnkYWQWJlTTauyMe0orJ9l3GImO6RY1MkPPmz/K KZ/lS5zPG59CT4mU9Wj/y30DBC34+hAYzR4l8qWkPL2mujPKp0VvH7P9LyqUtbSreUPq mme3OQh79MVQGgladov+ce8y4CoTuMQOYdbqKXb4Rblq611o8T6KDg12clSfySChrfCP qMGA== X-Gm-Message-State: APjAAAVhVJpluUUpsRPE7SeSknGBwNyWCDkXrQoMguDyBoLNbvJ7B9Rv 9Jjzf03KM+IX7olu7bc2CGMvTA== X-Google-Smtp-Source: APXvYqyPmR5Date1E23A+mrwxJzoBMabdA1BAZmkp5dMCISLQ8NpBn1aclAupLxAkrJgT0eBGNdF0A== X-Received: by 2002:a63:5321:: with SMTP id h33mr3378181pgb.168.1552655332222; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) Received: from localhost.localdomain ([183.82.230.185]) by smtp.gmail.com with ESMTPSA id e2sm854008pfa.64.2019.03.15.06.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 06:08:51 -0700 (PDT) From: Jagan Teki To: Andrzej Hajda , Laurent Pinchart , Chen-Yu Tsai , Maxime Ripard , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland Subject: [PATCH 3/6] drm/sun4i: dsi: Add bridge support Date: Fri, 15 Mar 2019 18:38:22 +0530 Message-Id: <20190315130825.9005-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190315130825.9005-1-jagan@amarulasolutions.com> References: <20190315130825.9005-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-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:content-transfer-encoding; bh=MUOsJO/ekVDHiTmtCVq8d27ElQS89ZxoIWk8a+ZsNC8=; b=B2hki3AVn28hYRpt5WblRY/Vca49463pFaNwvrqpHWdi3Q+mwBSfv1Vs2vjfcAGpRm 7h24qEjbfhNQ/C15zsOs0GEucNfdebhmiBYEC71Sl8tHFCMhamO1C/BCjEuHSy5LPNdX 22yifrbUWp3bv2AUBl5Qu6ljUpOc/zESnsyIQ= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some display panels would come up with a non-DSI output which can have an option to connect DSI interface by means of bridge convertor. This DSI to non-DSI bridge convertor would require a bridge driver that would communicate the DSI controller for bridge functionalities. So, add support for bridge functionalities in Allwinner DSI controller. Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 0960b96b62cc..64d74313b842 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) drm_panel_prepare(dsi->panel); + if (!IS_ERR(dsi->bridge)) + drm_bridge_pre_enable(dsi->bridge); + /* * FIXME: This should be moved after the switch to HS mode. * @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) drm_panel_enable(dsi->panel); + if (!IS_ERR(dsi->bridge)) + drm_bridge_enable(dsi->bridge); + sun6i_dsi_start(dsi, DSI_START_HSC); udelay(1000); @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) { drm_panel_disable(dsi->panel); drm_panel_unprepare(dsi->panel); + } else if (!IS_ERR(dsi->bridge)) { + drm_bridge_disable(dsi->bridge); + drm_bridge_post_disable(dsi->bridge); } phy_power_off(dsi->dphy); @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); dsi->device = device; - dsi->panel = of_drm_find_panel(device->dev.of_node); - if (IS_ERR(dsi->panel)) - return PTR_ERR(dsi->panel); - dev_info(host->dev, "Attached device %s\n", device->name); + dsi->bridge = of_drm_find_bridge(device->dev.of_node); + if (!dsi->bridge) { + dsi->panel = of_drm_find_panel(device->dev.of_node); + if (IS_ERR(dsi->panel)) + return PTR_ERR(dsi->panel); + } + + dev_info(host->dev, "Attached %s %s\n", + dsi->bridge ? "bridge" : "panel", device->name); return 0; } @@ -1055,8 +1069,10 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm); int ret; - if (!dsi->panel) + if (!(dsi->panel || dsi->bridge)) { + dev_info(drm->dev, "No panel or bridge found... DSI output disabled\n"); return -EPROBE_DEFER; + } dsi->drv = drv; @@ -1078,19 +1094,29 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, } dsi->encoder.possible_crtcs = BIT(0); - drm_connector_helper_add(&dsi->connector, - &sun6i_dsi_connector_helper_funcs); - ret = drm_connector_init(drm, &dsi->connector, - &sun6i_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); - if (ret) { - dev_err(dsi->dev, - "Couldn't initialise the DSI connector\n"); - goto err_cleanup_connector; + if (dsi->panel) { + drm_connector_helper_add(&dsi->connector, + &sun6i_dsi_connector_helper_funcs); + ret = drm_connector_init(drm, &dsi->connector, + &sun6i_dsi_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + if (ret) { + dev_err(dsi->dev, + "Couldn't initialise the DSI connector\n"); + goto err_cleanup_connector; + } + + drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + drm_panel_attach(dsi->panel, &dsi->connector); } - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - drm_panel_attach(dsi->panel, &dsi->connector); + if (dsi->bridge) { + ret = drm_bridge_attach(&dsi->encoder, dsi->bridge, NULL); + if (ret) { + dev_err(dsi->dev, "Couldn't attach the DSI bridge\n"); + goto err_cleanup_connector; + } + } return 0; @@ -1104,7 +1130,12 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, { struct sun6i_dsi *dsi = dev_get_drvdata(dev); - drm_panel_detach(dsi->panel); + if (dsi->panel) + drm_panel_detach(dsi->panel); + + if (dsi->bridge) + drm_bridge_detach(dsi->bridge); + } 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 5c4983212f89..76874ff8e3ef 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -36,6 +36,7 @@ struct sun6i_dsi { struct sun4i_tcon *tcon; struct mipi_dsi_device *device; struct drm_panel *panel; + struct drm_bridge *bridge; const struct sun6i_dsi_variant *variant; };