From patchwork Mon Apr 11 08:55:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 65490 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp1346910lbl; Mon, 11 Apr 2016 02:02:28 -0700 (PDT) X-Received: by 10.67.30.163 with SMTP id kf3mr31330357pad.45.1460365348339; Mon, 11 Apr 2016 02:02:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t73si2367714pfa.240.2016.04.11.02.02.28; Mon, 11 Apr 2016 02:02:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754005AbcDKJCG (ORCPT + 7 others); Mon, 11 Apr 2016 05:02:06 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35121 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752848AbcDKJCD (ORCPT ); Mon, 11 Apr 2016 05:02:03 -0400 Received: by mail-pa0-f43.google.com with SMTP id td3so117923256pab.2 for ; Mon, 11 Apr 2016 02:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AKeZWJ3EnEn4xQm9dF9amfvi022wzl5VUKi82rP07wQ=; b=BO+kY2y+neMYPQeepHnQRE8sp5WPogEeTofYJrvRtvLZFvU+tsaEge+lxEwh85DmQo VTy8D2iJD++vlXiBr74ig2XJvT3W/O/StkfYwSrqqIkPuBRYAmGpCzAhCTZULDDyDmi3 bQ6jQqfipNX1cU39pwq1dJUQGY0DVAVcOIj1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AKeZWJ3EnEn4xQm9dF9amfvi022wzl5VUKi82rP07wQ=; b=kBju5zcO/SCsUdbNpx6so8yWEy+MS5T4IOLHaq14blUZ2ClETu/gGI49GL+qax4H65 W69W4sBlQaIA+sNb+1gJ2hTGTvmYLPP1qKw/LMosUazztIuslfxRDl8RzBefATWO5cCT MJ8O2TW9Kyl+zvw7KDKORQGFqV8APHJVbV9FtyCQxFCqWmsj+M7tCXbbXVZSfmypbuY2 XAZ0LBs3+IlBCYxx2LaDB0v6f+UtDy/K7mfxepHM6uOcQMio3HyOdz2J0tJF1hF45uxK dc9eZTCkHXl85Tob++fzJjs0N0GyC7z4KiPW7JZ5NzY8xzKyB8o/12TLwCmnPaKprBv7 QRIw== X-Gm-Message-State: AD7BkJIX4eHuAtzWOMKbIAVlEplhcwvlRPmTitJsoLcRh7zX+Y9tFGCOGgY2oiKywPDM3wsT X-Received: by 10.66.219.170 with SMTP id pp10mr31111710pac.110.1460365321751; Mon, 11 Apr 2016 02:02:01 -0700 (PDT) Received: from localhost.localdomain ([14.154.190.52]) by smtp.gmail.com with ESMTPSA id v9sm34360332pfi.50.2016.04.11.02.01.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Apr 2016 02:02:00 -0700 (PDT) From: Xinliang Liu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, daniel@ffwll.ch, robh@kernel.org, daniel@fooishbar.org, architt@codeaurora.org, airlied@linux.ie, corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com, emil.l.velikov@gmail.com, mark.rutland@arm.com Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, andy.green@linaro.org, haojian.zhuang@linaro.org, liguozhu@hisilicon.com, xuwei5@hisilicon.com, w.f@huawei.com, puck.chen@hisilicon.com, bintian.wang@huawei.com, benjamin.gaignard@linaro.org, xuyiping@hisilicon.com, kong.kongxinwei@hisilicon.com, zourongrong@huawei.com, lijianhua@huawei.com, sumit.semwal@linaro.org, guodong.xu@linaro.org, Xinliang Liu Subject: [PATCH v8 09/10] drm/hisilicon: Add support for external bridge Date: Mon, 11 Apr 2016 16:55:42 +0800 Message-Id: <1460364943-76135-10-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1460364943-76135-1-git-send-email-xinliang.liu@linaro.org> References: <1460364943-76135-1-git-send-email-xinliang.liu@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for external HDMI bridge. v8: None. v7: None. v6: None. v5: None. v4: None. v3: - Fix a typo: s/exteranl/external. v2: - Remove abtraction layer. Signed-off-by: Xinliang Liu Signed-off-by: Xinwei Kong Reviewed-by: Archit Taneja --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) -- 2.8.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index ea7711832959..bfbc2159250d 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -80,6 +80,7 @@ struct dsi_hw_ctx { struct dw_dsi { struct drm_encoder encoder; + struct drm_bridge *bridge; struct mipi_dsi_host host; struct drm_display_mode cur_mode; struct dsi_hw_ctx *ctx; @@ -700,6 +701,25 @@ static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) return 0; } +static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi) +{ + struct drm_encoder *encoder = &dsi->encoder; + struct drm_bridge *bridge = dsi->bridge; + int ret; + + /* associate the bridge to dsi encoder */ + encoder->bridge = bridge; + bridge->encoder = encoder; + + ret = drm_bridge_attach(dev, bridge); + if (ret) { + DRM_ERROR("failed to attach external bridge\n"); + return ret; + } + + return 0; +} + static int dsi_bind(struct device *dev, struct device *master, void *data) { struct dsi_data *ddata = dev_get_drvdata(dev); @@ -715,6 +735,10 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; + ret = dsi_bridge_init(drm_dev, dsi); + if (ret) + return ret; + return 0; } @@ -731,8 +755,36 @@ static const struct component_ops dsi_ops = { static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) { struct dsi_hw_ctx *ctx = dsi->ctx; + struct device_node *np = pdev->dev.of_node; + struct device_node *endpoint, *bridge_node; + struct drm_bridge *bridge; struct resource *res; + /* + * Get the endpoint node. In our case, dsi has one output port1 + * to which the external HDMI bridge is connected. + */ + endpoint = of_graph_get_endpoint_by_regs(np, 1, -1); + if (!endpoint) { + DRM_ERROR("no valid endpoint node\n"); + return -ENODEV; + } + of_node_put(endpoint); + + bridge_node = of_graph_get_remote_port_parent(endpoint); + if (!bridge_node) { + DRM_ERROR("no valid bridge node\n"); + return -ENODEV; + } + of_node_put(bridge_node); + + bridge = of_drm_find_bridge(bridge_node); + if (!bridge) { + DRM_INFO("wait for external HDMI bridge driver.\n"); + return -EPROBE_DEFER; + } + dsi->bridge = bridge; + ctx->pclk = devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(ctx->pclk)) { DRM_ERROR("failed to get pclk clock\n");