From patchwork Tue Jul 4 17:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 699721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86B71EB64DA for ; Tue, 4 Jul 2023 17:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjGDRp7 (ORCPT ); Tue, 4 Jul 2023 13:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjGDRp6 (ORCPT ); Tue, 4 Jul 2023 13:45:58 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4466110D7 for ; Tue, 4 Jul 2023 10:45:57 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4faaaa476a9so9445751e87.2 for ; Tue, 04 Jul 2023 10:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688492755; x=1691084755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y62jOGwoLkRx2s8sLUVgr34ikoHyPLMwXSSE5xWIknI=; b=TzUDS4NIWLhl82RJllpN7bNhIQfbbewvB9BnnPSJSh6j6kC268hgdUxSjOr2cBr1NS kL1Y7IrSyuNTVhYOU8EJOqZ5Q5s6W8/OnQfPK3FdWkQ3cnqJ32hstOMNBtQsGW9i+b6H KSf0WBXxavQScz9MWkXKbUsq5Ily6k+9dmxFtkROCaS9dHBBkXJYZ9MxCZ7lMmjhzqQn Xxl2CDlxbfplITulEq8PbpPfIqWmgAMY98/3AbFeaNTJ8GUpw8GKdgkX6vdbECAGs/nq 2NEOfm6UjrF3GgiYlTDgEGBKbv8Sgnm4OFl/a7/uara+tA28qsof/p9BpTWKRb6RmdU1 MBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688492755; x=1691084755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y62jOGwoLkRx2s8sLUVgr34ikoHyPLMwXSSE5xWIknI=; b=XZJGSCehDgeHHrjs+ckyukBFw1mpijtcdqYNGAxhpEMpep3pzDLL8FecmN61j9vd+i 3p036VpMYf9p1MfgQ9HkNNiR3p5En4T9t2Vp3sbJ1sdPfYoCmuYk2shYtuZX6WKfdNBF JCJnNAKOuMCVTcj7scbAKoXywl5zLMISp+Zu/4VUBUKZ2s9kQFWGOtxC4HNmiHrV9yhX Oq99xGfRJFrUpc+AbpWaC1iI7PbE4QLCtwfuEI+97irlEd2ALj/5O+kZnlUiGxvGNlgw 1R1Bo6cRlIfPDLVAfH7qY+k0Wx2NlW+spMG3t+9QOuOl2whYD4zYPAFsf7vX50vH53Nu 23GA== X-Gm-Message-State: ABy/qLYev1yaXoJPY4DB3zup4OBIafK7AyaR1G6GiHbxcowiadvkVEzh lSu7ihFUFIU//k4TwDEMEc8OMQ== X-Google-Smtp-Source: APBJJlHl2m3O9Fnv7tb/dTtAFgub1GypmSBUjcod6x0kEY0TXWJrS6A9DSMeCkYlCzs89du3buKWCQ== X-Received: by 2002:ac2:5e2c:0:b0:4fb:81f2:4228 with SMTP id o12-20020ac25e2c000000b004fb81f24228mr8458767lfg.31.1688492755392; Tue, 04 Jul 2023 10:45:55 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id n25-20020a195519000000b004fb6c61e79bsm4709779lfe.117.2023.07.04.10.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 10:45:54 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Marijn Suijten Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v4 1/4] drm/msm: allow passing struct msm_kms to msm_drv_probe() Date: Tue, 4 Jul 2023 20:45:50 +0300 Message-Id: <20230704174553.216248-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> References: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In preparation of moving resource allocation to the probe time, allow MSM KMS drivers to pass struct msm_kms pointer via msm_drv_probe(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 2 +- drivers/gpu/drm/msm/msm_drv.c | 6 ++++-- drivers/gpu/drm/msm/msm_drv.h | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 44b0daf70c4e..22e5b430770e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -1244,7 +1244,7 @@ static int dpu_kms_init(struct drm_device *ddev) static int dpu_dev_probe(struct platform_device *pdev) { - return msm_drv_probe(&pdev->dev, dpu_kms_init); + return msm_drv_probe(&pdev->dev, dpu_kms_init, NULL); } static int dpu_dev_remove(struct platform_device *pdev) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index 6e37072ed302..e57a1e5f9da0 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -558,7 +558,7 @@ static const struct dev_pm_ops mdp4_pm_ops = { static int mdp4_probe(struct platform_device *pdev) { - return msm_drv_probe(&pdev->dev, mdp4_kms_init); + return msm_drv_probe(&pdev->dev, mdp4_kms_init, NULL); } static int mdp4_remove(struct platform_device *pdev) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c index 323079cfd698..83a5b3bd09d9 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c @@ -939,7 +939,7 @@ static int mdp5_dev_probe(struct platform_device *pdev) if (ret) return ret; - return msm_drv_probe(&pdev->dev, mdp5_kms_init); + return msm_drv_probe(&pdev->dev, mdp5_kms_init, NULL); } static int mdp5_dev_remove(struct platform_device *pdev) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 891eff8433a9..f06a06ab26fa 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1233,7 +1233,8 @@ const struct component_master_ops msm_drm_ops = { }; int msm_drv_probe(struct device *master_dev, - int (*kms_init)(struct drm_device *dev)) + int (*kms_init)(struct drm_device *dev), + struct msm_kms *kms) { struct msm_drm_private *priv; struct component_match *match = NULL; @@ -1243,6 +1244,7 @@ int msm_drv_probe(struct device *master_dev, if (!priv) return -ENOMEM; + priv->kms = kms; priv->kms_init = kms_init; dev_set_drvdata(master_dev, priv); @@ -1278,7 +1280,7 @@ int msm_drv_probe(struct device *master_dev, static int msm_pdev_probe(struct platform_device *pdev) { - return msm_drv_probe(&pdev->dev, NULL); + return msm_drv_probe(&pdev->dev, NULL, NULL); } static int msm_pdev_remove(struct platform_device *pdev) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index e13a8cbd61c9..6787bd302dfa 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -562,7 +562,8 @@ int msm_pm_prepare(struct device *dev); void msm_pm_complete(struct device *dev); int msm_drv_probe(struct device *dev, - int (*kms_init)(struct drm_device *dev)); + int (*kms_init)(struct drm_device *dev), + struct msm_kms *kms); void msm_drv_shutdown(struct platform_device *pdev); From patchwork Tue Jul 4 17:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 698981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B08C001B0 for ; Tue, 4 Jul 2023 17:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229645AbjGDRqA (ORCPT ); Tue, 4 Jul 2023 13:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjGDRp7 (ORCPT ); Tue, 4 Jul 2023 13:45:59 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE8410D5 for ; Tue, 4 Jul 2023 10:45:57 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4fb73ba3b5dso9438170e87.1 for ; Tue, 04 Jul 2023 10:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688492756; x=1691084756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nHTrgKfFcRKzVIctqRvTHb6iki9OEIlz2ugj/l8crtg=; b=UNTo8TA9fqjrRbfVe/oQN+adhrLgZ4XQlDfyPoT2EQv7p9VQnEhA5ZXvIAkIS4Z40k 61oYc4rlhSV6kmKz2/V0z0F+oAt8LTOPkWM98R0K6aysk6KMxnlVpyB42SN/j00Ay/Dz tdqyFsud24MmfDxH+w0maO5MJR+ag/o4JzFfW37Q/qCURkJyt9Xwubx7nRGd1fVreF9T sK5gRj0ceOCWeYUGI4bK/pPivDUpjG1GuRoUSOHVW5GyMwFKopT+5GbfE/C3IjXcEEvt sAao2imTwtDOFp9JnpWjgQygJXW6mwav+Z+iHshWjRkN8WeIldAjIPBZzwd8xFIIu5Jc s8hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688492756; x=1691084756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nHTrgKfFcRKzVIctqRvTHb6iki9OEIlz2ugj/l8crtg=; b=GFIShZK2AgleXx/XjCeHeIwVLGAaIdaRaC4rIrsaWBtCHOZ2EwlWhB4fw7f1Udw9Rm 8lx3uyPhNvqnZdQS1ux/n2gcHOmTWpbH5AXgdckdsRzEBgJH8wNHUffmsbTrCtwtvys4 7VvB9TGQW5ZCg1GvRMG2QPunSlsVb9eiMUvep7JVlNdZUwSvRdi2aRs3sROq3AXWG6Ty kyIYpaMpqZbvBGy4WjeuuGk3XYeLkFNjA+Mi9LGMOr1AIl2JuwJvvkMQXiZYoNkDbhV6 GUfOPcxBEdshVDyki5QARI9/cIoepbVLXVNHL70Xkyssl52jBIym9xQ6HXSUdClPPyOM 3zHg== X-Gm-Message-State: ABy/qLbeWE7P4/Z+hFVDC1qrVgDfNTj2u3FCBKfvUZlN0xNzTRI1FB6M T+l3Yiy9D7oBW5bAbK6lCr532A== X-Google-Smtp-Source: APBJJlE5Lp8TBm59s/LU7Cyadob3uPlibX65Ol1LdMcnX5Wqk+FiXBs7nOXaPnS2f9pE1MkhnTuiDw== X-Received: by 2002:a05:6512:3d0f:b0:4f9:58bd:9e5c with SMTP id d15-20020a0565123d0f00b004f958bd9e5cmr10738953lfv.3.1688492756172; Tue, 04 Jul 2023 10:45:56 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id n25-20020a195519000000b004fb6c61e79bsm4709779lfe.117.2023.07.04.10.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 10:45:55 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Marijn Suijten Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v4 2/4] drm/msm/dpu: move resource allocation to the _probe function Date: Tue, 4 Jul 2023 20:45:51 +0300 Message-Id: <20230704174553.216248-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> References: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org To let the probe function bail early if any of the resources is unavailable, move resource allocattion from kms_init directly to the probe callback. While we are at it, replace irq_of_parse_and_map() with platform_get_irq(). This also drops devm_iounmap() calls. It is too early to have them _dpu_kms_hw_destroy() (or it will break if for some reason DPU device is rebound into the composite device) and it doesn't make sense to have them in dpu_dev_remove (as everything will be torn down by the devres anyway after the device is unbound from the driver). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 133 +++++++++++------------- 1 file changed, 61 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 22e5b430770e..e819e6f47bc1 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -388,8 +388,7 @@ static int dpu_kms_parse_data_bus_icc_path(struct dpu_kms *dpu_kms) { struct icc_path *path0; struct icc_path *path1; - struct drm_device *dev = dpu_kms->dev; - struct device *dpu_dev = dev->dev; + struct device *dpu_dev = &dpu_kms->pdev->dev; path0 = msm_icc_get(dpu_dev, "mdp0-mem"); path1 = msm_icc_get(dpu_dev, "mdp1-mem"); @@ -830,21 +829,9 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) dpu_kms->catalog = NULL; - if (dpu_kms->vbif[VBIF_NRT]) - devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_NRT]); - dpu_kms->vbif[VBIF_NRT] = NULL; - - if (dpu_kms->vbif[VBIF_RT]) - devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]); - dpu_kms->vbif[VBIF_RT] = NULL; - if (dpu_kms->hw_mdp) dpu_hw_mdp_destroy(dpu_kms->hw_mdp); dpu_kms->hw_mdp = NULL; - - if (dpu_kms->mmio) - devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio); - dpu_kms->mmio = NULL; } static void dpu_kms_destroy(struct msm_kms *kms) @@ -1038,30 +1025,6 @@ static int dpu_kms_hw_init(struct msm_kms *kms) atomic_set(&dpu_kms->bandwidth_ref, 0); - dpu_kms->mmio = msm_ioremap(dpu_kms->pdev, "mdp"); - if (IS_ERR(dpu_kms->mmio)) { - rc = PTR_ERR(dpu_kms->mmio); - DPU_ERROR("mdp register memory map failed: %d\n", rc); - dpu_kms->mmio = NULL; - goto error; - } - DRM_DEBUG("mapped dpu address space @%pK\n", dpu_kms->mmio); - - dpu_kms->vbif[VBIF_RT] = msm_ioremap(dpu_kms->pdev, "vbif"); - if (IS_ERR(dpu_kms->vbif[VBIF_RT])) { - rc = PTR_ERR(dpu_kms->vbif[VBIF_RT]); - DPU_ERROR("vbif register memory map failed: %d\n", rc); - dpu_kms->vbif[VBIF_RT] = NULL; - goto error; - } - dpu_kms->vbif[VBIF_NRT] = msm_ioremap_quiet(dpu_kms->pdev, "vbif_nrt"); - if (IS_ERR(dpu_kms->vbif[VBIF_NRT])) { - dpu_kms->vbif[VBIF_NRT] = NULL; - DPU_DEBUG("VBIF NRT is not defined"); - } - - dpu_kms_parse_data_bus_icc_path(dpu_kms); - rc = pm_runtime_resume_and_get(&dpu_kms->pdev->dev); if (rc < 0) goto error; @@ -1186,33 +1149,11 @@ static int dpu_kms_init(struct drm_device *ddev) struct msm_drm_private *priv = ddev->dev_private; struct device *dev = ddev->dev; struct platform_device *pdev = to_platform_device(dev); - struct dpu_kms *dpu_kms; - int irq; + struct dpu_kms *dpu_kms = to_dpu_kms(priv->kms); struct dev_pm_opp *opp; int ret = 0; unsigned long max_freq = ULONG_MAX; - dpu_kms = devm_kzalloc(&pdev->dev, sizeof(*dpu_kms), GFP_KERNEL); - if (!dpu_kms) - return -ENOMEM; - - ret = devm_pm_opp_set_clkname(dev, "core"); - if (ret) - return ret; - /* OPP table is optional */ - ret = devm_pm_opp_of_add_table(dev); - if (ret && ret != -ENODEV) { - dev_err(dev, "invalid OPP table in device tree\n"); - return ret; - } - - ret = devm_clk_bulk_get_all(&pdev->dev, &dpu_kms->clocks); - if (ret < 0) { - DPU_ERROR("failed to parse clocks, ret=%d\n", ret); - return ret; - } - dpu_kms->num_clocks = ret; - opp = dev_pm_opp_find_freq_floor(dev, &max_freq); if (!IS_ERR(opp)) dev_pm_opp_put(opp); @@ -1225,26 +1166,74 @@ static int dpu_kms_init(struct drm_device *ddev) return ret; } dpu_kms->dev = ddev; - dpu_kms->pdev = pdev; pm_runtime_enable(&pdev->dev); dpu_kms->rpm_enabled = true; - priv->kms = &dpu_kms->base; - - irq = irq_of_parse_and_map(dpu_kms->pdev->dev.of_node, 0); - if (!irq) { - DPU_ERROR("failed to get irq\n"); - return -EINVAL; - } - dpu_kms->base.irq = irq; - return 0; } static int dpu_dev_probe(struct platform_device *pdev) { - return msm_drv_probe(&pdev->dev, dpu_kms_init, NULL); + struct device *dev = &pdev->dev; + struct dpu_kms *dpu_kms; + int irq; + int ret = 0; + + dpu_kms = devm_kzalloc(dev, sizeof(*dpu_kms), GFP_KERNEL); + if (!dpu_kms) + return -ENOMEM; + + dpu_kms->pdev = pdev; + + ret = devm_pm_opp_set_clkname(dev, "core"); + if (ret) + return ret; + /* OPP table is optional */ + ret = devm_pm_opp_of_add_table(dev); + if (ret && ret != -ENODEV) + return dev_err_probe(dev, ret, "invalid OPP table in device tree\n"); + + ret = devm_clk_bulk_get_all(&pdev->dev, &dpu_kms->clocks); + if (ret < 0) + return dev_err_probe(dev, ret, "failed to parse clocks\n"); + + dpu_kms->num_clocks = ret; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return dev_err_probe(dev, irq, "failed to get irq\n"); + + dpu_kms->base.irq = irq; + + dpu_kms->mmio = msm_ioremap(pdev, "mdp"); + if (IS_ERR(dpu_kms->mmio)) { + ret = PTR_ERR(dpu_kms->mmio); + DPU_ERROR("mdp register memory map failed: %d\n", ret); + dpu_kms->mmio = NULL; + return ret; + } + DRM_DEBUG("mapped dpu address space @%pK\n", dpu_kms->mmio); + + dpu_kms->vbif[VBIF_RT] = msm_ioremap(pdev, "vbif"); + if (IS_ERR(dpu_kms->vbif[VBIF_RT])) { + ret = PTR_ERR(dpu_kms->vbif[VBIF_RT]); + DPU_ERROR("vbif register memory map failed: %d\n", ret); + dpu_kms->vbif[VBIF_RT] = NULL; + return ret; + } + + dpu_kms->vbif[VBIF_NRT] = msm_ioremap_quiet(pdev, "vbif_nrt"); + if (IS_ERR(dpu_kms->vbif[VBIF_NRT])) { + dpu_kms->vbif[VBIF_NRT] = NULL; + DPU_DEBUG("VBIF NRT is not defined"); + } + + ret = dpu_kms_parse_data_bus_icc_path(dpu_kms); + if (ret) + return ret; + + return msm_drv_probe(&pdev->dev, dpu_kms_init, &dpu_kms->base); } static int dpu_dev_remove(struct platform_device *pdev) From patchwork Tue Jul 4 17:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 698980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A768EB64D9 for ; Tue, 4 Jul 2023 17:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbjGDRqB (ORCPT ); Tue, 4 Jul 2023 13:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjGDRqA (ORCPT ); Tue, 4 Jul 2023 13:46:00 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99A07E3 for ; Tue, 4 Jul 2023 10:45:58 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fba74870abso6499617e87.0 for ; Tue, 04 Jul 2023 10:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688492757; x=1691084757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JLtmYKXatBp2JCqPhIqTtQESCJxKhNtCmzZEzwR81PI=; b=M5wSHdGR/Kh56Gj9CQVaU98PNQTHNsmIv0z12tr5iUoW0zDNHWPnrlqzRUJdlMwQFk yiGbVmhQuL9lioMlt8IhusGDNwV5yvqhYoak96Mgjb83T4dDQBLuBTImLRamk2yjFRyW 9Y0s2FQicrQiwgwuwPiGPFcm6FNYQWiBlpBzgMA1tynaXWJtSdsvFTIswd28T7blUJra nItM5zvBYOspvQmp42r5IQQwiuUoDBj/9egj2hJyWsE9q4bLH87IgaMscPq5A4GOaQoN /PSUQzip0bdaZke3ISHRtlkwKMLVoTUQH4Z+rJcRePmZHe8mf/ZBJurnKYZImRxdq7H6 zMLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688492757; x=1691084757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JLtmYKXatBp2JCqPhIqTtQESCJxKhNtCmzZEzwR81PI=; b=cPPHRtSM0En0iKQLLqeE3Faa/NA0tTMw+TBHo+79/rFr9Wl48MMs/zoxaPhrKFOMtb WLO+ZWr1zYQTsjuRefdVxs3wKQaYzOagK0vwAfIM5cLLuRPb05lu9Chhv2Ws/57QS+f6 quiXVoSXGmsWGSd04ymisbEM3QsYsX/CuSYjodJ5upUNEGkxVuKwmb0j5rFSVSD317hV xzhd0hbfGIpbRhk3/uLwdpsa9Kk8niOeKC8LsYzeQcNhvkNxIXSbpVR4wdgGARztWeW8 /dlyhyrI05taqVqpQmr2yVfvv0OWKddO2Fn4P0YWSd07iOb8EZQw0et4IXz+7+HuL/ae JVtw== X-Gm-Message-State: ABy/qLZW8/WP3ktmsxuoDw4YGnUN0SKiN/tPPZWj8Pu7YYf9o5WFbUpy VF7ZJgSV1gGiu0rhy3VXyk6Htw== X-Google-Smtp-Source: APBJJlEYMgvTt5EFoW1ynqDjrVM8LMhbKmXTaE1VO9zJ9JmJjY+PZhPyfO70+jimLkb0vnQw2cuqTQ== X-Received: by 2002:a05:6512:34cb:b0:4f8:d385:41bd with SMTP id w11-20020a05651234cb00b004f8d38541bdmr8805063lfr.8.1688492756887; Tue, 04 Jul 2023 10:45:56 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id n25-20020a195519000000b004fb6c61e79bsm4709779lfe.117.2023.07.04.10.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 10:45:56 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Marijn Suijten Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v4 3/4] drm/msm/mdp4: move resource allocation to the _probe function Date: Tue, 4 Jul 2023 20:45:52 +0300 Message-Id: <20230704174553.216248-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> References: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org To let the probe function bail early if any of the resources is unavailable, move resource allocattion from kms_init directly to the probe callback. While we are at it, replace irq_of_parse_and_map() with platform_get_irq(). Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 107 +++++++++++------------ 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index e57a1e5f9da0..a3f1da3382e8 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -135,8 +135,6 @@ static void mdp4_destroy(struct msm_kms *kms) pm_runtime_disable(dev); mdp_kms_destroy(&mdp4_kms->base); - - kfree(mdp4_kms); } static const struct mdp_kms_funcs kms_funcs = { @@ -380,57 +378,27 @@ static int mdp4_kms_init(struct drm_device *dev) { struct platform_device *pdev = to_platform_device(dev->dev); struct msm_drm_private *priv = dev->dev_private; - struct mdp4_kms *mdp4_kms; + struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(priv->kms)); struct msm_kms *kms = NULL; struct msm_mmu *mmu; struct msm_gem_address_space *aspace; - int irq, ret; + int ret; u32 major, minor; unsigned long max_clk; /* TODO: Chips that aren't apq8064 have a 200 Mhz max_clk */ max_clk = 266667000; - mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL); - if (!mdp4_kms) { - DRM_DEV_ERROR(dev->dev, "failed to allocate kms\n"); - return -ENOMEM; - } - ret = mdp_kms_init(&mdp4_kms->base, &kms_funcs); if (ret) { DRM_DEV_ERROR(dev->dev, "failed to init kms\n"); goto fail; } - priv->kms = &mdp4_kms->base.base; kms = priv->kms; mdp4_kms->dev = dev; - mdp4_kms->mmio = msm_ioremap(pdev, NULL); - if (IS_ERR(mdp4_kms->mmio)) { - ret = PTR_ERR(mdp4_kms->mmio); - goto fail; - } - - irq = platform_get_irq(pdev, 0); - if (irq < 0) { - ret = irq; - DRM_DEV_ERROR(dev->dev, "failed to get irq: %d\n", ret); - goto fail; - } - - kms->irq = irq; - - /* NOTE: driver for this regulator still missing upstream.. use - * _get_exclusive() and ignore the error if it does not exist - * (and hope that the bootloader left it on for us) - */ - mdp4_kms->vdd = devm_regulator_get_exclusive(&pdev->dev, "vdd"); - if (IS_ERR(mdp4_kms->vdd)) - mdp4_kms->vdd = NULL; - if (mdp4_kms->vdd) { ret = regulator_enable(mdp4_kms->vdd); if (ret) { @@ -439,24 +407,6 @@ static int mdp4_kms_init(struct drm_device *dev) } } - mdp4_kms->clk = devm_clk_get(&pdev->dev, "core_clk"); - if (IS_ERR(mdp4_kms->clk)) { - DRM_DEV_ERROR(dev->dev, "failed to get core_clk\n"); - ret = PTR_ERR(mdp4_kms->clk); - goto fail; - } - - mdp4_kms->pclk = devm_clk_get(&pdev->dev, "iface_clk"); - if (IS_ERR(mdp4_kms->pclk)) - mdp4_kms->pclk = NULL; - - mdp4_kms->axi_clk = devm_clk_get(&pdev->dev, "bus_clk"); - if (IS_ERR(mdp4_kms->axi_clk)) { - DRM_DEV_ERROR(dev->dev, "failed to get axi_clk\n"); - ret = PTR_ERR(mdp4_kms->axi_clk); - goto fail; - } - clk_set_rate(mdp4_kms->clk, max_clk); read_mdp_hw_revision(mdp4_kms, &major, &minor); @@ -471,10 +421,9 @@ static int mdp4_kms_init(struct drm_device *dev) mdp4_kms->rev = minor; if (mdp4_kms->rev >= 2) { - mdp4_kms->lut_clk = devm_clk_get(&pdev->dev, "lut_clk"); - if (IS_ERR(mdp4_kms->lut_clk)) { + if (!mdp4_kms->lut_clk) { DRM_DEV_ERROR(dev->dev, "failed to get lut_clk\n"); - ret = PTR_ERR(mdp4_kms->lut_clk); + ret = -ENODEV; goto fail; } clk_set_rate(mdp4_kms->lut_clk, max_clk); @@ -558,7 +507,53 @@ static const struct dev_pm_ops mdp4_pm_ops = { static int mdp4_probe(struct platform_device *pdev) { - return msm_drv_probe(&pdev->dev, mdp4_kms_init, NULL); + struct device *dev = &pdev->dev; + struct mdp4_kms *mdp4_kms; + int irq; + + mdp4_kms = devm_kzalloc(dev, sizeof(*mdp4_kms), GFP_KERNEL); + if (!mdp4_kms) + return dev_err_probe(dev, -ENOMEM, "failed to allocate kms\n"); + + mdp4_kms->mmio = msm_ioremap(pdev, NULL); + if (IS_ERR(mdp4_kms->mmio)) + return PTR_ERR(mdp4_kms->mmio); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return dev_err_probe(dev, irq, "failed to get irq\n"); + + mdp4_kms->base.base.irq = irq; + + /* NOTE: driver for this regulator still missing upstream.. use + * _get_exclusive() and ignore the error if it does not exist + * (and hope that the bootloader left it on for us) + */ + mdp4_kms->vdd = devm_regulator_get_exclusive(&pdev->dev, "vdd"); + if (IS_ERR(mdp4_kms->vdd)) + mdp4_kms->vdd = NULL; + + mdp4_kms->clk = devm_clk_get(&pdev->dev, "core_clk"); + if (IS_ERR(mdp4_kms->clk)) + return dev_err_probe(dev, PTR_ERR(mdp4_kms->clk), "failed to get core_clk\n"); + + mdp4_kms->pclk = devm_clk_get(&pdev->dev, "iface_clk"); + if (IS_ERR(mdp4_kms->pclk)) + mdp4_kms->pclk = NULL; + + mdp4_kms->axi_clk = devm_clk_get(&pdev->dev, "bus_clk"); + if (IS_ERR(mdp4_kms->axi_clk)) + return dev_err_probe(dev, PTR_ERR(mdp4_kms->axi_clk), "failed to get axi_clk\n"); + + /* + * This is required for revn >= 2. Handle errors here and let the kms + * init bail out if the clock is not provided. + */ + mdp4_kms->lut_clk = devm_clk_get_optional(&pdev->dev, "lut_clk"); + if (IS_ERR(mdp4_kms->lut_clk)) + return dev_err_probe(dev, PTR_ERR(mdp4_kms->lut_clk), "failed to get lut_clk\n"); + + return msm_drv_probe(&pdev->dev, mdp4_kms_init, &mdp4_kms->base.base); } static int mdp4_remove(struct platform_device *pdev) From patchwork Tue Jul 4 17:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 699720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3228DEB64DD for ; Tue, 4 Jul 2023 17:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbjGDRqC (ORCPT ); Tue, 4 Jul 2023 13:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjGDRqA (ORCPT ); Tue, 4 Jul 2023 13:46:00 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50EBB10D7 for ; Tue, 4 Jul 2023 10:45:59 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fba8f2197bso6086025e87.3 for ; Tue, 04 Jul 2023 10:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688492757; x=1691084757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cq361WQvKwVqcRhufIcUtyn4OTZxaeJsGxBGpt0ut4M=; b=RmZaSCRwC3f5Td1ec785rzY2U9dq0a9UbOX3/qsLSZiS+zjluov7Cxd+3UW14pcXlJ 15axgdX996cq+vI9ik9iq6UwIHBViWRn79cA4XV5CS0iDOnjuDKa1dn+7YquKP+NR3S0 PYRU4MIc5vPtNx2ve43VaxSSCPQDDG0IvgMevKJC8VwEfD/LwYEw1rKbLtHWFTJrDs2S A6imxMWkOn+N3zjoM/azVuMAC10e50eiYU2dd03cTnXOhgtfvanw8ROY3dM+5vsZSbGH N4Og5rDcXP2wvQmjzyebf60DWIrR7exReDX+OLCONYxDr3SaK3klYshFgM/4JuLes4Xl +VTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688492757; x=1691084757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cq361WQvKwVqcRhufIcUtyn4OTZxaeJsGxBGpt0ut4M=; b=fJh3HyayCVZ2qc55d9eRNPiAnk/1OcPzfHfy+C362Gk1d3tIMoTSwre+1bCk6fVXV5 x19rWjZaqQMs7S0lCCckoVKxY3A9+WUIvN6F349zaFBw+z8T4ZbpMJVdVonssXsfcveX PAmVT5eaZ9ieQs2/GwVKfMolkhzGVQYECxXCvUpX14+bORUfJJr6tHROLnRL3UxYkRzI ABGr289nSSQIiF5kgcGW6TeqvRdYQw2nPI6n6MDV2143PjuovjJaaPcdlkFAqm53vEqx q3a3vkdpq3DNtJZU7pZKW311b1Cr8xxdJZ3NwnvmMK9qYSOCvdpEfki6UqfTVT1VNc1E MHOw== X-Gm-Message-State: ABy/qLatO2fxQ+8321RSO8BaauRUTxcR6frbJIK4GLFGWDX9BK7I2NDh T+s0Jzyc9hzDhXSt8dNqXKDUWQ== X-Google-Smtp-Source: APBJJlFUl00WT8jzitBemmiM1JfL7aZEEnyTzC7J0Eu8HDfCZLRVLU6X7aT/bRGwEtUVrBQ3mE3pZw== X-Received: by 2002:a05:6512:1590:b0:4fb:7666:3bbf with SMTP id bp16-20020a056512159000b004fb76663bbfmr11483586lfb.26.1688492757635; Tue, 04 Jul 2023 10:45:57 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id n25-20020a195519000000b004fb6c61e79bsm4709779lfe.117.2023.07.04.10.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 10:45:57 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Marijn Suijten Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v4 4/4] drm/msm/mdp5: move resource allocation to the _probe function Date: Tue, 4 Jul 2023 20:45:53 +0300 Message-Id: <20230704174553.216248-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> References: <20230704174553.216248-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org To let the probe function bail early if any of the resources is unavailable, move resource allocattion from kms_init directly to the probe callback. Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 100 ++++++++++------------- 1 file changed, 44 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c index 83a5b3bd09d9..52f176e08690 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c @@ -554,20 +554,16 @@ static int mdp5_kms_init(struct drm_device *dev) struct platform_device *pdev; struct mdp5_kms *mdp5_kms; struct mdp5_cfg *config; - struct msm_kms *kms; + struct msm_kms *kms = priv->kms; struct msm_gem_address_space *aspace; - int irq, i, ret; + int i, ret; ret = mdp5_init(to_platform_device(dev->dev), dev); if (ret) return ret; - /* priv->kms would have been populated by the MDP5 driver */ - kms = priv->kms; - if (!kms) - return -ENOMEM; - mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); + pdev = mdp5_kms->pdev; ret = mdp_kms_init(&mdp5_kms->base, &kms_funcs); @@ -576,15 +572,6 @@ static int mdp5_kms_init(struct drm_device *dev) goto fail; } - irq = irq_of_parse_and_map(pdev->dev.of_node, 0); - if (!irq) { - ret = -EINVAL; - DRM_DEV_ERROR(&pdev->dev, "failed to get irq\n"); - goto fail; - } - - kms->irq = irq; - config = mdp5_cfg_get_config(mdp5_kms->cfg); /* make sure things are off before attaching iommu (bootloader could @@ -787,60 +774,23 @@ static int interface_init(struct mdp5_kms *mdp5_kms) static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; - struct mdp5_kms *mdp5_kms; + struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms)); struct mdp5_cfg *config; u32 major, minor; int ret; - mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL); - if (!mdp5_kms) { - ret = -ENOMEM; - goto fail; - } - - spin_lock_init(&mdp5_kms->resource_lock); - mdp5_kms->dev = dev; - mdp5_kms->pdev = pdev; ret = mdp5_global_obj_init(mdp5_kms); if (ret) goto fail; - mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys"); - if (IS_ERR(mdp5_kms->mmio)) { - ret = PTR_ERR(mdp5_kms->mmio); - goto fail; - } - - /* mandatory clocks: */ - ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true); - if (ret) - goto fail; - ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true); - if (ret) - goto fail; - ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true); - if (ret) - goto fail; - ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true); - if (ret) - goto fail; - - /* optional clocks: */ - get_clk(pdev, &mdp5_kms->lut_clk, "lut", false); - get_clk(pdev, &mdp5_kms->tbu_clk, "tbu", false); - get_clk(pdev, &mdp5_kms->tbu_rt_clk, "tbu_rt", false); - /* we need to set a default rate before enabling. Set a safe * rate first, then figure out hw revision, and then set a * more optimal rate: */ clk_set_rate(mdp5_kms->core_clk, 200000000); - /* set uninit-ed kms */ - priv->kms = &mdp5_kms->base.base; - pm_runtime_enable(&pdev->dev); mdp5_kms->rpm_enabled = true; @@ -931,15 +881,53 @@ static int mdp5_setup_interconnect(struct platform_device *pdev) static int mdp5_dev_probe(struct platform_device *pdev) { - int ret; + struct mdp5_kms *mdp5_kms; + int ret, irq; DBG(""); + mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL); + if (!mdp5_kms) + return -ENOMEM; + ret = mdp5_setup_interconnect(pdev); if (ret) return ret; - return msm_drv_probe(&pdev->dev, mdp5_kms_init, NULL); + mdp5_kms->pdev = pdev; + + spin_lock_init(&mdp5_kms->resource_lock); + + mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys"); + if (IS_ERR(mdp5_kms->mmio)) + return PTR_ERR(mdp5_kms->mmio); + + /* mandatory clocks: */ + ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true); + if (ret) + return ret; + ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true); + if (ret) + return ret; + ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true); + if (ret) + return ret; + ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true); + if (ret) + return ret; + + /* optional clocks: */ + get_clk(pdev, &mdp5_kms->lut_clk, "lut", false); + get_clk(pdev, &mdp5_kms->tbu_clk, "tbu", false); + get_clk(pdev, &mdp5_kms->tbu_rt_clk, "tbu_rt", false); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return dev_err_probe(&pdev->dev, irq, "failed to get irq\n"); + + mdp5_kms->base.base.irq = irq; + + return msm_drv_probe(&pdev->dev, mdp5_kms_init, &mdp5_kms->base.base); } static int mdp5_dev_remove(struct platform_device *pdev)