From patchwork Sat Nov 28 10:39:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 57385 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp366196lbb; Sat, 28 Nov 2015 02:41:38 -0800 (PST) X-Received: by 10.98.65.2 with SMTP id o2mr54868037pfa.99.1448707298323; Sat, 28 Nov 2015 02:41:38 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id n14si10038856pfb.48.2015.11.28.02.41.38; Sat, 28 Nov 2015 02:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 433596E215; Sat, 28 Nov 2015 02:41:37 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vk0-f41.google.com (mail-vk0-f41.google.com [209.85.213.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C5756E215 for ; Sat, 28 Nov 2015 02:41:35 -0800 (PST) Received: by vkbs1 with SMTP id s1so79564052vkb.1 for ; Sat, 28 Nov 2015 02:41:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fpS3rXsxzu0y2NnLjY0bPFznvF+ZcePw6wCAd53NXWw=; b=vOUlOSFzISbK2Z6o+/kSqDI4nfqP1b/XQDMmbvxF0X1j/Ar2eSTVRu4OUIiU5AJ8QF EjfYMmYITRUVllu4bSM1MblkM1eQohu1SeLWTwKJvkv3ePmI88mUTvYecqwT05JGpRYn l1Xt/BMTLuhHO8CdGtnaexNMrcxVkTk3GGI1hN0zk5I5WCMyB4hPZrP2pu7XlF3cLW9s O8t6H03k3CC3z9/HOBn2us1+wTPSCtamtouJDlZfG5Oz5ZdSepvSEa3V6a0nRwSJJlN9 ykQ9ahfo4JzNZxhkxvA3JK3nQFzH09yDvmCibDv1th/GO+exTnDhdS10E7959hz7YpsC ZUBg== 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=fpS3rXsxzu0y2NnLjY0bPFznvF+ZcePw6wCAd53NXWw=; b=fOqDxkZyA4Ohuw04vIuonPocz0aFt6/pN0EILRSB8l5dslFI5V627q1ZteFFUEfOZ3 WGCvICyKhDNZKG8uI3XwTq4FIJ9s9KEnsDsmy+CBhmS1e28uiyHR4aXIZDUG/FvdRR0g 8gMr557A/i1CZLiB8DKjJEy7EDgSNjjNCQDQeqEWHV3XJjpbhU0c9eVHzG+nHOcIbE06 xbi6LX2LuMIqtXtCAhaXdhSwuQC1dCkeUB3zJ+H/+NHLMmOh0ABXel95y70PDJsyaT4e N2t7f3EtwqggO0zF4DLJ+IK4byat1bHGOUbGOKMi8V92VqC0VcVfu/0ItHsxN5KduJDM yETQ== X-Gm-Message-State: ALoCoQkCm4sgaJ24lqHFN7hR29ZRjfd7+N0SajpxqJ2867o28a+BSJliuTwftUMD+iXmzQw1IyzY X-Received: by 10.31.52.207 with SMTP id b198mr46102926vka.77.1448707294558; Sat, 28 Nov 2015 02:41:34 -0800 (PST) Received: from localhost.localdomain ([14.153.35.143]) by smtp.gmail.com with ESMTPSA id o135sm19989822vkd.3.2015.11.28.02.41.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Nov 2015 02:41:34 -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 Subject: [PATCH v2 10/10] drm/hisilicon: Add support for external bridge Date: Sat, 28 Nov 2015 18:39:05 +0800 Message-Id: <1448707145-69348-11-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448707145-69348-1-git-send-email-xinliang.liu@linaro.org> References: <1448707145-69348-1-git-send-email-xinliang.liu@linaro.org> Cc: andy.green@linaro.org, xuyiping@hisilicon.com, linux-doc@vger.kernel.org, w.f@huawei.com, zourongrong@huawei.com, linuxarm@huawei.com, xuwei5@hisilicon.com, bintian.wang@huawei.com, haojian.zhuang@linaro.org, benjamin.gaignard@linaro.org, puck.chen@hisilicon.com, lijianhua@huawei.com, liguozhu@hisilicon.com, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for external HDMI bridge. Signed-off-by: Xinliang Liu Signed-off-by: Xinwei Kong Signed-off-by: Andy Green --- drivers/gpu/drm/hisilicon/hisi_drm_dsi.c | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/hisi_drm_dsi.c b/drivers/gpu/drm/hisilicon/hisi_drm_dsi.c index 066e08d..9e056db 100644 --- a/drivers/gpu/drm/hisilicon/hisi_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/hisi_drm_dsi.c @@ -78,6 +78,7 @@ struct dsi_hw_ctx { struct hisi_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; @@ -671,6 +672,25 @@ static int dsi_host_init(struct device *dev, struct hisi_dsi *dsi) return 0; } +static int dsi_bridge_init(struct drm_device *dev, struct hisi_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 exteranl 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); @@ -686,6 +706,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; } @@ -702,8 +726,35 @@ static const struct component_ops dsi_ops = { static int dsi_parse_dt(struct platform_device *pdev, struct hisi_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 port + * to which the external HDMI bridge is connected. + */ + endpoint = of_graph_get_next_endpoint(np, NULL); + 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)) {