From patchwork Fri Feb 26 08:40:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 62967 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp592601lbc; Fri, 26 Feb 2016 00:43:37 -0800 (PST) X-Received: by 10.98.69.78 with SMTP id s75mr456113pfa.102.1456476217745; Fri, 26 Feb 2016 00:43:37 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k68si18496851pfj.138.2016.02.26.00.43.37; Fri, 26 Feb 2016 00:43:37 -0800 (PST) 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; 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932715AbcBZInR (ORCPT + 6 others); Fri, 26 Feb 2016 03:43:17 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34397 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753571AbcBZInO (ORCPT ); Fri, 26 Feb 2016 03:43:14 -0500 Received: by mail-pf0-f175.google.com with SMTP id x65so48727981pfb.1 for ; Fri, 26 Feb 2016 00:43:09 -0800 (PST) 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=dmzw5KpzOIciTlnHXLkbO3jY2ApkD8RV0xNF35AMiBg=; b=C60mQLTwj6OqxiahX3Rv2U0B7cH8xpvZxUaFad+efWacywMOv/Uy4qPL2SOtv3m1Xu /DBTQKlgqR6sfhpl5e0hoJ9R+5Qg7rzSDbWDu7mwjfJQ7IegSU3CwB4HKW+pCmFOWjrR Jq6sBKiDDf8NaMjkALhy4B+o4eQP9SalC6FuA= 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=dmzw5KpzOIciTlnHXLkbO3jY2ApkD8RV0xNF35AMiBg=; b=CWCCVlF4P2rVbB0mhRFK5PNG4wGS2SXsdZ4M+izO7b1FminAK3TTnXgaDf7y7x+vC2 7C74l9TrUh9gz0pAiW6iVwQAgpBhoplmbocRE7Y7cfirfu81r0LIlMK/c9ZsQq1P/ati C8emGM7l/xFGEMBNrBi1TBzesMM9s44UtYCMESe0/e92g+N6JkjA13RhcNG4nWMOyMYZ K1mPtT3ggnDmhMqWBvyt5DY4g23Z/tlDXC2NMTfwbABr3m1V51wV9nEeHIUk+eNhIgct CFsyLhKyR8wAPoNHzT2UuP7259G8jMKCC2pnqV7+itE+awVNYrudt7/rpwW7WnCCDBeE ATWA== X-Gm-Message-State: AD7BkJLbDjfgiBAChxr2DdzTXLHwfd2k3Kw5HLl6T2xsIFQtMEjfjJORBtIyxUDrKDrFh1Iw X-Received: by 10.98.65.206 with SMTP id g75mr451638pfd.94.1456476188968; Fri, 26 Feb 2016 00:43:08 -0800 (PST) Received: from localhost.localdomain ([119.139.127.18]) by smtp.gmail.com with ESMTPSA id r68sm17470178pfb.51.2016.02.26.00.43.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 00:43:08 -0800 (PST) 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 v6 09/11] drm/hisilicon: Add support for external bridge Date: Fri, 26 Feb 2016 16:40:26 +0800 Message-Id: <1456476028-36880-10-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456476028-36880-1-git-send-email-xinliang.liu@linaro.org> References: <1456476028-36880-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. v6: None. v5: None. v4: None. v3: - Fix a typo: s/exteranl/external. v2: - Remove abtraction layer. Signed-off-by: Xinliang Liu --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) -- 2.7.1 -- 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 f15798b61451..c2c406446513 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -79,6 +79,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; @@ -688,6 +689,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); @@ -703,6 +723,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; } @@ -719,8 +743,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");