From patchwork Mon Jan 16 10:08:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9518365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA4DE6020B for ; Mon, 16 Jan 2017 10:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7A5A28364 for ; Mon, 16 Jan 2017 10:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C87228435; Mon, 16 Jan 2017 10:09:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, URIBL_BLACK autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47D4E28364 for ; Mon, 16 Jan 2017 10:09:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 014E76E2CA; Mon, 16 Jan 2017 10:09:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0887B6E2CA for ; Mon, 16 Jan 2017 10:09:15 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id t6so952578pgt.1 for ; Mon, 16 Jan 2017 02:09:15 -0800 (PST) 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; bh=NhUt6plx+atV54vdDSGp9i011zNCZnKvbjiUccp2XRA=; b=co+nmgCw/Dy7zMvv71ubntZgIALoN33XJfsC8goZDP3Gd5YorKF56POcL2mXnOMyd0 lGsmvozZ62ptFWyt7rxchWZrHjTsytE6BkAGyCpW430fFY1eb3PKL91z32qzbuABtjSC kusQF7yh4OPb36dr8BUhPhfv9p3IusZYQuQHB3XIYwzna9vb3rdWhtCvRtEhiUwjtQI7 Uy3EeEIMQ/vrUYMl4FWyRnUfzbAfGjqBzkZfNIG7UNnz1JXGcxRX45p02heAws/iE8cT QXz2VNf9QfgrqHGBIi0FxEIG1CDGWDCuKd8dGgkYlHdEusjNQjOhicaGb3oeSOn2duKN zVEw== X-Gm-Message-State: AIkVDXITNkfjWT0gMmPM8Vi/v8iAHL0I9UfD0ngWZPU9w/9xtK+0wPLQTikLvRop29MkFQ== X-Received: by 10.99.161.17 with SMTP id b17mr25326643pgf.72.1484561354639; Mon, 16 Jan 2017 02:09:14 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id k78sm46351848pfb.93.2017.01.16.02.09.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jan 2017 02:09:14 -0800 (PST) From: Chris Zhong To: dianders@chromium.org, tfiga@chromium.org, heiko@sntech.de, yzq@rock-chips.com, mark.rutland@arm.com, devicetree@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, pawel.moll@arm.com, seanpaul@chromium.org Subject: [PATCH v2 07/11] drm/rockchip/dsi: fix mipi display can't found at init time Date: Mon, 16 Jan 2017 18:08:27 +0800 Message-Id: <1484561311-494-8-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1484561311-494-1-git-send-email-zyw@rock-chips.com> References: <1484561311-494-1-git-send-email-zyw@rock-chips.com> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Chris Zhong , 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Mark Yao The problem is that: mipi panel probe request mipi_dsi_host_register. mipi host attach is call from panel device, so the defer function always can't works. So at the first bind time, always can't found mipi panel. Signed-off-by: Mark Yao Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 57 +++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 5e3f031..4ec82f6 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -551,11 +551,9 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, dsi->panel = of_drm_find_panel(device->dev.of_node); if (!dsi->panel) { DRM_ERROR("failed to find panel\n"); - return -EPROBE_DEFER; + return -ENODEV; } - drm_panel_attach(dsi->panel, &dsi->connector); - return 0; } @@ -567,6 +565,7 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, if (dsi->panel) drm_panel_detach(dsi->panel); + dsi->panel = NULL; return 0; } @@ -1048,6 +1047,8 @@ static int dw_mipi_dsi_register(struct drm_device *drm, &dw_mipi_dsi_atomic_connector_funcs, DRM_MODE_CONNECTOR_DSI); + drm_panel_attach(dsi->panel, &dsi->connector); + drm_mode_connector_attach_encoder(connector, encoder); return 0; @@ -1097,23 +1098,17 @@ MODULE_DEVICE_TABLE(of, dw_mipi_dsi_dt_ids); static int dw_mipi_dsi_bind(struct device *dev, struct device *master, void *data) { - const struct of_device_id *of_id = - of_match_device(dw_mipi_dsi_dt_ids, dev); - const struct dw_mipi_dsi_plat_data *pdata = of_id->data; struct platform_device *pdev = to_platform_device(dev); struct drm_device *drm = data; - struct dw_mipi_dsi *dsi; + struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); struct resource *res; int ret; - dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); - if (!dsi) - return -ENOMEM; - - dsi->dev = dev; - dsi->pdata = pdata; dsi->dpms_mode = DRM_MODE_DPMS_OFF; + if (!dsi->panel) + return -EPROBE_DEFER; + ret = rockchip_mipi_parse_dt(dsi); if (ret) return ret; @@ -1160,9 +1155,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, pm_runtime_enable(dev); - dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; - dsi->dsi_host.dev = dev; - return mipi_dsi_host_register(&dsi->dsi_host); + return 0; err_pllref: clk_disable_unprepare(dsi->pllref_clk); @@ -1174,7 +1167,6 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master, { struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); - mipi_dsi_host_unregister(&dsi->dsi_host); pm_runtime_disable(dev); clk_disable_unprepare(dsi->pllref_clk); } @@ -1186,11 +1178,40 @@ static const struct component_ops dw_mipi_dsi_ops = { static int dw_mipi_dsi_probe(struct platform_device *pdev) { - return component_add(&pdev->dev, &dw_mipi_dsi_ops); + struct device *dev = &pdev->dev; + const struct of_device_id *of_id = + of_match_device(dw_mipi_dsi_dt_ids, dev); + const struct dw_mipi_dsi_plat_data *pdata = of_id->data; + struct dw_mipi_dsi *dsi; + int ret; + + dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL); + if (!dsi) + return -ENOMEM; + + dsi->dev = dev; + dsi->pdata = pdata; + dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; + dsi->dsi_host.dev = &pdev->dev; + + ret = mipi_dsi_host_register(&dsi->dsi_host); + if (ret) + return ret; + + platform_set_drvdata(pdev, dsi); + ret = component_add(&pdev->dev, &dw_mipi_dsi_ops); + if (ret) + mipi_dsi_host_unregister(&dsi->dsi_host); + + return ret; } static int dw_mipi_dsi_remove(struct platform_device *pdev) { + struct dw_mipi_dsi *dsi = dev_get_drvdata(&pdev->dev); + + if (dsi) + mipi_dsi_host_unregister(&dsi->dsi_host); component_del(&pdev->dev, &dw_mipi_dsi_ops); return 0; }