From patchwork Sat Feb 6 03:24:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 61370 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp321489lbl; Fri, 5 Feb 2016 19:26:24 -0800 (PST) X-Received: by 10.66.129.232 with SMTP id nz8mr24900154pab.102.1454729183929; Fri, 05 Feb 2016 19:26:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si28086471pas.77.2016.02.05.19.26.23; Fri, 05 Feb 2016 19:26:23 -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 S1751375AbcBFD0X (ORCPT + 6 others); Fri, 5 Feb 2016 22:26:23 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36710 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbcBFD0W (ORCPT ); Fri, 5 Feb 2016 22:26:22 -0500 Received: by mail-pf0-f178.google.com with SMTP id n128so78269746pfn.3 for ; Fri, 05 Feb 2016 19:26:21 -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=9BxzKmeoMJCciUIV2sCCb5DCSCZFGzIVxdnyMA3V96g=; b=EJtK+xaH+jl8oXwfkvPpUGuc2O2RT3rRHZY/faYiMfdZaRn8YVe8+lKPpdQ2F1SHp1 4LcVzl0Ke/KcvmV2mWZa57u71hzENca4FipGL5caJiMjUv+p5kn+D4CSQqAhR7d0WFJP vRhJRXi8XLazSVgxM+Q8Fh5uUGujEcWJc1dfE= 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=9BxzKmeoMJCciUIV2sCCb5DCSCZFGzIVxdnyMA3V96g=; b=CpyOIbraYUqs1KTtMVI21Q9r0e1VRKQOlcGw6ytdeODr0VRQ9Pjp2wZqnYh5eDfDfE 4sdbAMk3MowSa1h6odUkkW7Wo59j6ufBHHbe334ELPpNuPq+6uSIKvGFmTLxI4VzUqUz /JXZWw4gFTL0erJO52gE+pnyiRiEYaoaLaphwNrLCuPVv8U7Eti6bJ1ee2vzri7EjYCP 1WyEL146QoANBkf0i+iuo4SZFcTSBpZwst1uxnwJqa2Vv85wmQ/6jSYs/heITptb9K+7 vs3vvvTzBpxfrocJHK3oKMvEfePrpG8GJOpDOd+3pVdE8AplFoTSac31j6J0jZuksSJk rdPg== X-Gm-Message-State: AG10YOQ2BB5+sI/+NpDrOsAoANsKB7aCc9tlSGigwsI/4YTc/auv9xHafPhkFnsyZTOX5Tk/ X-Received: by 10.98.12.29 with SMTP id u29mr24533937pfi.116.1454729181621; Fri, 05 Feb 2016 19:26:21 -0800 (PST) Received: from localhost.localdomain ([219.134.80.72]) by smtp.gmail.com with ESMTPSA id a21sm27472023pfj.40.2016.02.05.19.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Feb 2016 19:26:20 -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 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 v4 09/11] drm/hisilicon: Add support for external bridge Date: Sat, 6 Feb 2016 11:24:56 +0800 Message-Id: <1454729098-79807-10-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> References: <1454729098-79807-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. 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(+) -- 1.9.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 2837af01e935..1342d84d7c68 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->dsi_cfg_clk = devm_clk_get(&pdev->dev, "pclk_dsi"); if (IS_ERR(ctx->dsi_cfg_clk)) { DRM_ERROR("failed to get dsi plck clock\n");