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: 9518413 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 DA3AD6020B for ; Mon, 16 Jan 2017 10:10:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A766328364 for ; Mon, 16 Jan 2017 10:10:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C29A28435; Mon, 16 Jan 2017 10:10:32 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 340A928364 for ; Mon, 16 Jan 2017 10:10:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cT4FC-0003cG-MV; Mon, 16 Jan 2017 10:10:30 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cT4EF-0000Gp-KS; Mon, 16 Jan 2017 10:09:34 +0000 Received: by mail-pg0-f66.google.com with SMTP id 75so5058276pgf.3; 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=O1rxo2whXvye1a0p0kTFx1je5OhKu+HgZaWtLUlZm24AyyQMTdQd7j+pG0Ytg7vcVm 3Gkq0++7myeCJU/Y26JADfNNLe2MP5dNzPjffsaW+QaiaRIgN4Ao3wgsjRw04+2c1ibG 0mbwIxfBNOQEASky4zXiT6wa/8NiMP5Um93cUqSvYQtSXO/Qja2YGeUD5Rs9UoIAGdQI FemvHWR6Ao5uhlbWvbA0AcLY4NvxZSrPeM3hTPKuOehEY8DtVOVHkusUg5p7eGeXBQ4s /eUabH8HAlAp04yb4Htw7tgnhaygLfxEuPtAVOV6VSsXRpJWyFVQCRKR/+7TmE11VMc2 KLMQ== X-Gm-Message-State: AIkVDXKyoYtPsY03YLK1mfZCURBxpZnu9jLkJu9nnWqgk1gwPnPuLNEFysANNqv8wC2mPw== 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170116_020932_047735_260FAC41 X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Chris Zhong , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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; }