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: 172 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 33E4F3F033 for ; Fri, 15 Mar 2019 14:08:54 +0100 (CET) Received: by mail-pg1-f199.google.com with SMTP id d10sf9997493pgv.23 for ; Fri, 15 Mar 2019 06:08:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1552655333; cv=pass; d=google.com; s=arc-20160816; b=nUqMP7o2u/UBzBxG77R13/rRZExtDOd28A8PAacn2Sg4jIgAkC1u0K5lewJVPcXHx5 9O7tlP6W1IzMRRCqJyxL3IIssHfpZJttbs4/nTDdA9XDSzbMF5DUxRBuEgekvxsVjXXx Ga1+IEum1ci0Np21LdHWaM+n5w4HF/syPtKtFbWVi6q4KKzGP30qYE3O0mHOra7KLylu h+26K6/MOeksvEuiN4sbS+WjqVVbYQBJ/Rk+I5wdYCyHDYMTISZpK3wbdMBAdAMIi4lm Zz9c0RaB6FGK1h671RXqeyOz6cvnq4HRg+haQ0ZId3KSyKBwn/GSJ3MyF3XdEtr0GOVw CQGw== 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=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=EGldVFHUOCYBYptIBkG+4njOgxg1r0wzaTQ2Z9YHDfZs8yayYJl8jBwJTqw9qFFJdu 7W9r8Zl+r1M8xYMWKwJ5hzlw+KYatfU6f/AZGHMlaoksXDeXTSOwlMTizeOMD+cHS0gp AxblLQ6yjVZlvP0watczLGTebuzw71Vi+sPvHHhermCTX4aOFIHh3tLKJd1NG1lmwqyo j/dPxc+wZiUSQNOxVx0jzlDgXaJ9wa0FJfLyO+DSQtz46QsZwaHkA2p/hfuxJQWrvguo OJm6lZ8DbNP9LM4eDN+yY0jGjPtyezoXZt89BemcJtw+Q2DKpg5K7XULj0+QU7UCjqwx QmGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 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=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=qCBeiaBTbMlghav4Th7YCjXbuYw10sEgL95wiEgNyvbvOddfzKVCOlhp0UcWEzWgoE wESb5Sr1SyhjB9c1lr/yPkexucZGBT0rGrbiugrMCPhmMr3ILZGRaPGtuHrWphGf8qmR HdCE/Bju6+RPWeFBODj2IEf1GXqiuyrQ9dW2E= 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=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=qSOKWMUkKCNg5OHZmpKShCefzaUoqvVaBaUWUa6QZlekjhMKMUiRkswPEJ8wYgcIWK AZae1ZXVkX1z0a6NSgbbIjiQZVjOt7az6G1/k6xWR7arlJzoaiZBa6LUEzQ9bD5972dr lUXvk1lJWzUPrTFph+LafgtYgNj4RkPtSX7wvShMHxyGuVU40pgPn2MrSRXacn8VZHOf qNO96dtETchI8T+BQlIE+JnT6yk0nqX9d0lxFeypHEoMp/1zhiV53dzvrZ4nm2hrntl0 mpz5rMOMPVhL6g8bHaz2z17ZoT6Rp17aSXiafvqNjV0VLT3dckjeD421Q5U/VOCwxtzs +Big== X-Gm-Message-State: APjAAAWTKHPIx70cpHFhN/HBZo+yfslzHVq3rxQcvKgS2P3eoJqTMQbh SLK1HTzdxdZZ/vps8WyuHa8juUJ+ X-Google-Smtp-Source: APXvYqxlaPRCaSOS7m26CvyikpN/3rRO2ckXyAxFGF7tdViyQhEmJeVoWTK1HGb+v0PVdtVRMrxtNw== X-Received: by 2002:a17:902:b60a:: with SMTP id b10mr1131656pls.147.1552655333012; Fri, 15 Mar 2019 06:08:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:6257:: with SMTP id q23ls3551741pgv.6.gmail; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) X-Received: by 2002:a62:489d:: with SMTP id q29mr3927963pfi.119.1552655332517; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552655332; cv=none; d=google.com; s=arc-20160816; b=LoRUwN/dp5zzODLm3jefjm3vNWbtt0XtxaHg/0xcESpL7lUd0g7XOElslH6BNpy2RN qHZjNodS54D8JdO61C+mLAV5yoH5no4T+7t2E1gRV3Z2BZLRAx9uUsV2udPRoxDpnyXF ljAXKRpsQdafhgskePwJvoaePbgTIq+v066m7mATIGrCoZu57ploxeAtQg6yoo6U22HG NhG6LxFwFvVtrqO/h58c6tIFeL5+4pidZVTN4wQFO6ym/Xe6G8ZtoRwbZswlUzzUSJeH ALyFPENUXRtFhu4QvtuJ8WE6ImAgiMHvt9MJ6i1tbkrzJOo4deTazcMEXecQBxkS/T0w KtHQ== 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=MUOsJO/ekVDHiTmtCVq8d27ElQS89ZxoIWk8a+ZsNC8=; b=JtwHAGCQ7RTiCcsErvYF2ssXom4QTpEYzfvE+c1PfinRWIaekvgQc0eGVagt3wSppc D1KXlM9ZW0kdAlbT4R497HZq/J6es1qIyXWXM885W9DoZ5qsDbbRzmn89/qecCyQZ64g IvulI5NSLj01NO2jnJrSZBRX5q0nvYkAXBrMuD2LDmgu+EjRB2AeX8iSqRYvX7GsxC4e V3F97+g2S8sVsF5cO4Qi0MWpQVXXGz3OvmY+RiIJ9+0PG2I1gFO1rx2EUtI9PtA70RYG pfdqkdPP17H0QQ2yJe1iZf9UkxXkgARB64O6JbnMKsJlLG1rihSMp2ez2IZvPlFEPJW/ U4Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g14sor2918771pgn.40.2019.03.15.06.08.52 for (Google Transport Security); Fri, 15 Mar 2019 06:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; 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 Cc: Michael Trimarchi , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki 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-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 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 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; };