From patchwork Fri Aug 26 09:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 600369 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 D3D6AECAAA3 for ; Fri, 26 Aug 2022 09:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238963AbiHZJje (ORCPT ); Fri, 26 Aug 2022 05:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245226AbiHZJjc (ORCPT ); Fri, 26 Aug 2022 05:39:32 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D270ACD535 for ; Fri, 26 Aug 2022 02:39:31 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id n15so1294503lfe.3 for ; Fri, 26 Aug 2022 02:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qWb9HqeFqbEjNo0sX8LWqplCuUfM7JNEP4wMIZnoIBI=; b=NGf+DQWXQ5hozu+8Vb2gZUGGz9qnwo3us1L8EiFM6rrC0BncmtMMMJIPszws1Bj9bg 8jwSi6yw41MGbMCL3hLaxH6QfANE00+UJ/4Sr5+PE6WHtNIxLXKhBY+SZHY6uPuIDHZ9 MBWLSDGh8yYnl1mHIvWNsMFWqb4rJ2ClyVldRS2ZhxfqFHOA6oPCwaqgThHbWo3lO2sa bIS1nyCeIpwMugQk5u7o8tZFwtZiLf0HaS2+m3vcKRCIuHh4+cujd9acAgPZ0l5pvtwl tJOweNonRWYXB9wvFgKC1DXD4X2jQ7vDyikduNH6xdp5sFeu7cXH1AdGv7uyeUvRHTMt 26Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qWb9HqeFqbEjNo0sX8LWqplCuUfM7JNEP4wMIZnoIBI=; b=BmJGxKUuZ3JhhdHmoK2PfU/bamSt8kVV3A4H4p9tgIHpdl1pEbfL8Z5A2OyKVUt3bl nP5j26L0LgUF+loSxe1ufNK4MKssSMLnVpT/1yLCl+QQZsv5Unr2dw25zBJZwPfDbQ6A a37RUKkfVdQz0GKK7scvE1pUwUev5hJwuUNjiM2vqVgtOv2+laQCvBES097xmFdh/Gyj 6D8p3eHPmyBAAyBo/Bk83X36coS6jDmHA0TsuTIcNjEh3zsOwnMv+ln8y0uJL4e7B6f4 X0mVLUdF6jvR/wMM+IR/96akcqOdg8z40TWph9bjwd4Vy97LWXgLRM73sDNBOfV2k0iU Hj5g== X-Gm-Message-State: ACgBeo0LP7ZIQu0s395/4R7b658kv4KlFmabMA+H0lB/5hkQcAfsp7Mb ldQ2mLYPET0dLfiC+AeonRRbDw== X-Google-Smtp-Source: AA6agR6KpPktXTIffRko51lBRjKetKH/0kFJEkJQx8jlsskHvwLVgjRaJr32l9jyc9jbvgrgjVhqDg== X-Received: by 2002:a19:f010:0:b0:492:ca3b:e34 with SMTP id p16-20020a19f010000000b00492ca3b0e34mr2196875lfc.563.1661506770071; Fri, 26 Aug 2022 02:39:30 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m6-20020a195206000000b004886508ca5csm329055lfb.68.2022.08.26.02.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 02:39:29 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar 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 v2 1/5] drm/msm/hdmi: use devres helper for runtime PM management Date: Fri, 26 Aug 2022 12:39:23 +0300 Message-Id: <20220826093927.851597-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> References: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use devm_pm_runtime_enable() to enable runtime PM. This way its effect will be reverted on device unbind/destruction. Fixes: 6ed9ed484d04 ("drm/msm/hdmi: Set up runtime PM for HDMI") Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/hdmi/hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 93fe61b86967..1d4557de6872 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -252,7 +252,7 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) if (hdmi->hpd_gpiod) gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); - pm_runtime_enable(&pdev->dev); + devm_pm_runtime_enable(&pdev->dev); hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); From patchwork Fri Aug 26 09:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 600758 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 0917BECAAD7 for ; Fri, 26 Aug 2022 09:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343666AbiHZJjf (ORCPT ); Fri, 26 Aug 2022 05:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245226AbiHZJje (ORCPT ); Fri, 26 Aug 2022 05:39:34 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A36AE216 for ; Fri, 26 Aug 2022 02:39:32 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id q7so1286713lfu.5 for ; Fri, 26 Aug 2022 02:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=7YUg2IHSNg4TVR8qYeviWm/ECZ9CIuXhHqOU5RIbXkQ=; b=DGoCIxWWrW2/VoRj+jrd91hN2aaNVrzXGlkg4Kqm9dl299QpxnjB8RJtk0SAty9hFr AdHB0T9j6Aa9bpD73Muif/oyT4wYvrirpeoMJgQ2r7/PIxsyAEr4wnZQRrrlYMqTuRLz ykzNkn2POvZMAoKv6A2Sung0u7iN+sKlx+oyHQIox66zWjkaEFGgtmBDnnm0thoM6wML v3zPf7ROCTn6ym3U3w5OE0kc+SICWWPVhNikUjPvHRdiBdHS3iUQgCqZK33ktw/XlVOS Sjb2ofeacudtwDyXSpowFi8Phkbp7RNBlc/Ihxk9f/MDMCsL8msuzG2uisROeDrbI0IV B4AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=7YUg2IHSNg4TVR8qYeviWm/ECZ9CIuXhHqOU5RIbXkQ=; b=MpCu07T2dutcj1RkJC0TOl+1yS9y+utVTLJTBTLDT3mwGEwu2FI75Ff6voUurom08s Q7dl4svuZKcSP67bSPPVXXKkdfpi3Les8/n3VLE9wLCVVsj61VutSZzOgGDGno2AzKZ1 dh0ZVkie5uHM+exqn05S58LdkPskZKBVWbNZbFYtH8zBkRq4MXbZfUpgPUZ17TSOqHWY /ZkleCPIsXiZbfkVeK1iLGA8BE7mWJxt/RE6Dhte4fVn6jYkW4nCtruJJCgT8nzTZwbp gJXTDGfIuJ0oLiBd6aoIQ+MTTg6f5EtdSWsHigMXmlj3q08bVVuD+FGHYeaGur+Xl3r2 ERmA== X-Gm-Message-State: ACgBeo1TTVhs7WJPi29ZrGiPmmmSdZu6GkOjFhqK1ze896ES4rPwQs/+ re2MvTmS01oFueqMT9ARqCRYIjac1c67Jg== X-Google-Smtp-Source: AA6agR79CJxCFxffslGvyGXwcgEEYTlbztrVDxkZgULrWvLmVydKZ3hfgbf3j+a4UVtOzl6PTl8hOw== X-Received: by 2002:a05:6512:3b14:b0:492:dbf2:a5a0 with SMTP id f20-20020a0565123b1400b00492dbf2a5a0mr2163261lfv.46.1661506771006; Fri, 26 Aug 2022 02:39:31 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m6-20020a195206000000b004886508ca5csm329055lfb.68.2022.08.26.02.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 02:39:30 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar 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 v2 2/5] drm/msm/hdmi: drop constant resource names from platform config Date: Fri, 26 Aug 2022 12:39:24 +0300 Message-Id: <20220826093927.851597-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> References: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org All MSM HDMI devices use "core_physical" and "qfprom_physical" names for register areas. Drop them from the platform config. Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/hdmi/hdmi.c | 9 +++------ drivers/gpu/drm/msm/hdmi/hdmi.h | 3 --- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 1d4557de6872..4a364d8f4c0b 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -138,7 +138,7 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) if (ret && ret != -ENODEV) goto fail; - hdmi->mmio = msm_ioremap(pdev, config->mmio_name); + hdmi->mmio = msm_ioremap(pdev, "core_physical"); if (IS_ERR(hdmi->mmio)) { ret = PTR_ERR(hdmi->mmio); goto fail; @@ -146,14 +146,14 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) /* HDCP needs physical address of hdmi register */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - config->mmio_name); + "core_physical"); if (!res) { ret = -EINVAL; goto fail; } hdmi->mmio_phy_addr = res->start; - hdmi->qfprom_mmio = msm_ioremap(pdev, config->qfprom_mmio_name); + hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical"); if (IS_ERR(hdmi->qfprom_mmio)) { DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); hdmi->qfprom_mmio = NULL; @@ -524,9 +524,6 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) return -ENXIO; } - hdmi_cfg->mmio_name = "core_physical"; - hdmi_cfg->qfprom_mmio_name = "qfprom_physical"; - dev->platform_data = hdmi_cfg; hdmi = msm_hdmi_init(to_platform_device(dev)); diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h index 04a74381aaf7..e8dbee50637f 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.h +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h @@ -86,9 +86,6 @@ struct hdmi { /* platform config data (ie. from DT, or pdata) */ struct hdmi_platform_config { - const char *mmio_name; - const char *qfprom_mmio_name; - /* regulators that need to be on for hpd: */ const char **hpd_reg_names; int hpd_reg_cnt; From patchwork Fri Aug 26 09:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 600368 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 22AD8ECAAD2 for ; Fri, 26 Aug 2022 09:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343678AbiHZJjg (ORCPT ); Fri, 26 Aug 2022 05:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343830AbiHZJjf (ORCPT ); Fri, 26 Aug 2022 05:39:35 -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 DD0A19DB41 for ; Fri, 26 Aug 2022 02:39:33 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id s1so1282339lfp.6 for ; Fri, 26 Aug 2022 02:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=yN51z3L37xg9k1dPcMKg59FVaQzj5cOVbXNla1FnXzY=; b=HRVrAWFxauQEuhOpIb07WBC0BbEtL48koCql+EETTUWXWQ9+RXiLqCABdikbgMdHv2 rUuU388UI8ziibFs8usCB7r1vxTp836bqI7gBxe3bPy/yTGmHbUB37ac9kiFp0TNm65I 5tT9UdLPQSfWpe2ZUWnjPM2JqnV3lxuPDbOogFerDI+02X4qKMxK5zP8rECuSEil0LkZ xu/h/CHF2jSwH2YSIV0qHqsMWy7Lp5CDm3RZWgSOFH0loYtF7SaVA0xgOmp81sBHpNav VQxzFhmVK5hyLlWh828iAwy0Tm23YEEFUWakjtmWORxRqXRjvoDl8Y+iIeQhhG2IU8Ny ylnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=yN51z3L37xg9k1dPcMKg59FVaQzj5cOVbXNla1FnXzY=; b=EEMyT1XRwOZumQeb3lCNAua5X3UjnC6MkZ0favDxRJKYT8K9p98+pV/nKMWmvy/dB/ lsku602WwUE/pNCecN7HuQyFYUbeCjxbKLhyGL3gHAZt3hsyUTIgDnxhap9UzMKG5E1h hYR3OCubarMzpTx81D2hcgbzMhKf3mbyxH8EUvCKWH6WRBFgYFKKzrsH/tuAeoRr+AMJ s/wjWf90GRgiT+YLwiAXJAXBGxYOg1PEP0JKcH01/QOlAFNcMDoSCxVzIR1fu/DIVoEb MLZpdi/vy8ui1IRWSFsO4UkXoW3AntoHSWvFMUJahGVJzy7L4EnM5hmuj2lQHSL8hV73 UEhw== X-Gm-Message-State: ACgBeo12GhjPCPSSpptkX6m5GCj0fUh7bsaKJe8hTm1UWyP8zf3bMagm hZb7X4cQ2UMbIBlBiIeyi8pMhA== X-Google-Smtp-Source: AA6agR4FMVhUYbyKFeevY/leOuSUqG+rtv/P4Q3AcO4JwXUrrUXyFfSMbL5X9NssuHt8w7V5Pn71EA== X-Received: by 2002:ac2:4e8d:0:b0:493:ac:7dbd with SMTP id o13-20020ac24e8d000000b0049300ac7dbdmr2130469lfr.688.1661506772226; Fri, 26 Aug 2022 02:39:32 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m6-20020a195206000000b004886508ca5csm329055lfb.68.2022.08.26.02.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 02:39:31 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar 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 v2 3/5] drm/msm/hdmi: move resource allocation to probe function Date: Fri, 26 Aug 2022 12:39:25 +0300 Message-Id: <20220826093927.851597-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> References: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rather than having all resource allocation happen in the _bind function (resulting in possible EPROBE_DEFER returns and component bind/unbind cycles) allocate and check all resources in _probe function. While we are at it, use platform_get_irq() to get the IRQ rather than going through the irq_of_parse_and_map(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi.c | 303 +++++++++++++++----------------- 1 file changed, 138 insertions(+), 165 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 4a364d8f4c0b..c298a36f3b42 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -76,8 +76,6 @@ static void msm_hdmi_destroy(struct hdmi *hdmi) if (hdmi->i2c) msm_hdmi_i2c_destroy(hdmi->i2c); - - platform_set_drvdata(hdmi->pdev, NULL); } static int msm_hdmi_get_phy(struct hdmi *hdmi) @@ -117,142 +115,10 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi) * we are to EPROBE_DEFER we want to do it here, rather than later * at modeset_init() time */ -static struct hdmi *msm_hdmi_init(struct platform_device *pdev) +static int msm_hdmi_init(struct hdmi *hdmi) { - struct hdmi_platform_config *config = pdev->dev.platform_data; - struct hdmi *hdmi = NULL; - struct resource *res; - int i, ret; - - hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); - if (!hdmi) { - ret = -ENOMEM; - goto fail; - } - - hdmi->pdev = pdev; - hdmi->config = config; - spin_lock_init(&hdmi->reg_lock); - - ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge); - if (ret && ret != -ENODEV) - goto fail; - - hdmi->mmio = msm_ioremap(pdev, "core_physical"); - if (IS_ERR(hdmi->mmio)) { - ret = PTR_ERR(hdmi->mmio); - goto fail; - } - - /* HDCP needs physical address of hdmi register */ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "core_physical"); - if (!res) { - ret = -EINVAL; - goto fail; - } - hdmi->mmio_phy_addr = res->start; - - hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical"); - if (IS_ERR(hdmi->qfprom_mmio)) { - DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); - hdmi->qfprom_mmio = NULL; - } - - hdmi->hpd_regs = devm_kcalloc(&pdev->dev, - config->hpd_reg_cnt, - sizeof(hdmi->hpd_regs[0]), - GFP_KERNEL); - if (!hdmi->hpd_regs) { - ret = -ENOMEM; - goto fail; - } - for (i = 0; i < config->hpd_reg_cnt; i++) - hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; - - ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); - if (ret) { - DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %d\n", ret); - goto fail; - } - - hdmi->pwr_regs = devm_kcalloc(&pdev->dev, - config->pwr_reg_cnt, - sizeof(hdmi->pwr_regs[0]), - GFP_KERNEL); - if (!hdmi->pwr_regs) { - ret = -ENOMEM; - goto fail; - } - - for (i = 0; i < config->pwr_reg_cnt; i++) - hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; - - ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs); - if (ret) { - DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %d\n", ret); - goto fail; - } - - hdmi->hpd_clks = devm_kcalloc(&pdev->dev, - config->hpd_clk_cnt, - sizeof(hdmi->hpd_clks[0]), - GFP_KERNEL); - if (!hdmi->hpd_clks) { - ret = -ENOMEM; - goto fail; - } - for (i = 0; i < config->hpd_clk_cnt; i++) { - struct clk *clk; - - clk = msm_clk_get(pdev, config->hpd_clk_names[i]); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - DRM_DEV_ERROR(&pdev->dev, "failed to get hpd clk: %s (%d)\n", - config->hpd_clk_names[i], ret); - goto fail; - } - - hdmi->hpd_clks[i] = clk; - } - - hdmi->pwr_clks = devm_kcalloc(&pdev->dev, - config->pwr_clk_cnt, - sizeof(hdmi->pwr_clks[0]), - GFP_KERNEL); - if (!hdmi->pwr_clks) { - ret = -ENOMEM; - goto fail; - } - for (i = 0; i < config->pwr_clk_cnt; i++) { - struct clk *clk; - - clk = msm_clk_get(pdev, config->pwr_clk_names[i]); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - DRM_DEV_ERROR(&pdev->dev, "failed to get pwr clk: %s (%d)\n", - config->pwr_clk_names[i], ret); - goto fail; - } - - hdmi->pwr_clks[i] = clk; - } - - hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); - /* This will catch e.g. -EPROBE_DEFER */ - if (IS_ERR(hdmi->hpd_gpiod)) { - ret = PTR_ERR(hdmi->hpd_gpiod); - DRM_DEV_ERROR(&pdev->dev, "failed to get hpd gpio: (%d)\n", ret); - goto fail; - } - - if (!hdmi->hpd_gpiod) - DBG("failed to get HPD gpio"); - - if (hdmi->hpd_gpiod) - gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); - - devm_pm_runtime_enable(&pdev->dev); + struct platform_device *pdev = hdmi->pdev; + int ret; hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); @@ -276,13 +142,13 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->hdcp_ctrl = NULL; } - return hdmi; + return 0; fail: if (hdmi) msm_hdmi_destroy(hdmi); - return ERR_PTR(ret); + return ret; } /* Second part of initialization, the drm/kms level modeset_init, @@ -332,13 +198,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, drm_connector_attach_encoder(hdmi->connector, hdmi->encoder); - hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); - if (!hdmi->irq) { - ret = -EINVAL; - DRM_DEV_ERROR(dev->dev, "failed to get irq\n"); - goto fail; - } - ret = devm_request_irq(&pdev->dev, hdmi->irq, msm_hdmi_irq, IRQF_TRIGGER_HIGH, "hdmi_isr", hdmi); @@ -358,8 +217,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, priv->bridges[priv->num_bridges++] = hdmi->bridge; - platform_set_drvdata(pdev, hdmi); - return 0; fail: @@ -387,7 +244,7 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, static const char *hpd_reg_names_8960[] = {"core-vdda"}; static const char *hpd_clk_names_8960[] = {"core", "master_iface", "slave_iface"}; -static struct hdmi_platform_config hdmi_tx_8960_config = { +const static struct hdmi_platform_config hdmi_tx_8960_config = { HDMI_CFG(hpd_reg, 8960), HDMI_CFG(hpd_clk, 8960), }; @@ -397,7 +254,7 @@ static const char *pwr_clk_names_8x74[] = {"extp", "alt_iface"}; static const char *hpd_clk_names_8x74[] = {"iface", "core", "mdp_core"}; static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0}; -static struct hdmi_platform_config hdmi_tx_8974_config = { +const static struct hdmi_platform_config hdmi_tx_8974_config = { HDMI_CFG(pwr_reg, 8x74), HDMI_CFG(pwr_clk, 8x74), HDMI_CFG(hpd_clk, 8x74), @@ -512,23 +369,12 @@ static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) { struct msm_drm_private *priv = dev_get_drvdata(master); - struct hdmi_platform_config *hdmi_cfg; - struct hdmi *hdmi; - struct device_node *of_node = dev->of_node; + struct hdmi *hdmi = dev_get_drvdata(dev); int err; - hdmi_cfg = (struct hdmi_platform_config *) - of_device_get_match_data(dev); - if (!hdmi_cfg) { - DRM_DEV_ERROR(dev, "unknown hdmi_cfg: %pOFn\n", of_node); - return -ENXIO; - } - - dev->platform_data = hdmi_cfg; - - hdmi = msm_hdmi_init(to_platform_device(dev)); - if (IS_ERR(hdmi)) - return PTR_ERR(hdmi); + err = msm_hdmi_init(hdmi); + if (err) + return err; priv->hdmi = hdmi; err = msm_hdmi_register_audio_driver(hdmi, dev); @@ -561,6 +407,133 @@ static const struct component_ops msm_hdmi_ops = { static int msm_hdmi_dev_probe(struct platform_device *pdev) { + const struct hdmi_platform_config *config; + struct device *dev = &pdev->dev; + struct hdmi *hdmi; + struct resource *res; + int i, ret; + + config = of_device_get_match_data(dev); + if (!config) + return -EINVAL; + + hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); + if (!hdmi) + return -ENOMEM; + + hdmi->pdev = pdev; + hdmi->config = config; + spin_lock_init(&hdmi->reg_lock); + + ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge); + if (ret && ret != -ENODEV) + return ret; + + hdmi->mmio = msm_ioremap(pdev, "core_physical"); + if (IS_ERR(hdmi->mmio)) + return PTR_ERR(hdmi->mmio); + + /* HDCP needs physical address of hdmi register */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + "core_physical"); + if (!res) + return -EINVAL; + hdmi->mmio_phy_addr = res->start; + + hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical"); + if (IS_ERR(hdmi->qfprom_mmio)) { + DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); + hdmi->qfprom_mmio = NULL; + } + + hdmi->irq = platform_get_irq(pdev, 0); + if (hdmi->irq < 0) + return hdmi->irq; + + hdmi->hpd_regs = devm_kcalloc(&pdev->dev, + config->hpd_reg_cnt, + sizeof(hdmi->hpd_regs[0]), + GFP_KERNEL); + if (!hdmi->hpd_regs) + return -ENOMEM; + + for (i = 0; i < config->hpd_reg_cnt; i++) + hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; + + ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); + if (ret) + return dev_err_probe(dev, ret, "failed to get hpd regulators\n"); + + hdmi->pwr_regs = devm_kcalloc(&pdev->dev, + config->pwr_reg_cnt, + sizeof(hdmi->pwr_regs[0]), + GFP_KERNEL); + if (!hdmi->pwr_regs) + return -ENOMEM; + + for (i = 0; i < config->pwr_reg_cnt; i++) + hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; + + ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs); + if (ret) + return dev_err_probe(dev, ret, "failed to get pwr regulators\n"); + + hdmi->hpd_clks = devm_kcalloc(&pdev->dev, + config->hpd_clk_cnt, + sizeof(hdmi->hpd_clks[0]), + GFP_KERNEL); + if (!hdmi->hpd_clks) + return -ENOMEM; + + for (i = 0; i < config->hpd_clk_cnt; i++) { + struct clk *clk; + + clk = msm_clk_get(pdev, config->hpd_clk_names[i]); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "failed to get hpd clk: %s\n", + config->hpd_clk_names[i]); + + hdmi->hpd_clks[i] = clk; + } + + hdmi->pwr_clks = devm_kcalloc(&pdev->dev, + config->pwr_clk_cnt, + sizeof(hdmi->pwr_clks[0]), + GFP_KERNEL); + if (!hdmi->pwr_clks) + return -ENOMEM; + + for (i = 0; i < config->pwr_clk_cnt; i++) { + struct clk *clk; + + clk = msm_clk_get(pdev, config->pwr_clk_names[i]); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "failed to get pwr clk: %s\n", + config->pwr_clk_names[i]); + + hdmi->pwr_clks[i] = clk; + } + + hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); + /* This will catch e.g. -EPROBE_DEFER */ + if (IS_ERR(hdmi->hpd_gpiod)) + return dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod), + "failed to get hpd gpio\n"); + + if (!hdmi->hpd_gpiod) + DBG("failed to get HPD gpio"); + + if (hdmi->hpd_gpiod) + gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); + + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; + + platform_set_drvdata(pdev, hdmi); + return component_add(&pdev->dev, &msm_hdmi_ops); } From patchwork Fri Aug 26 09:39:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 600757 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 A59E6ECAAA3 for ; Fri, 26 Aug 2022 09:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343966AbiHZJjg (ORCPT ); Fri, 26 Aug 2022 05:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245226AbiHZJjf (ORCPT ); Fri, 26 Aug 2022 05:39:35 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4570AE216 for ; Fri, 26 Aug 2022 02:39:34 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id s1so1282380lfp.6 for ; Fri, 26 Aug 2022 02:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=XJBZo86NwzlYcDfKiueYzUkDbZYleRySpVsik2jGH+A=; b=qpR7kKD1V3xBxJwj/wDBDO/SFHHHvlDYnlDrpv2aTla7l7Bj4pq1d8enTjpRnpHyOL JFrcTElR51YXfx7D8/A5baErgAx6mSa6V5OxSBF67SGUvWDHF18O423UGhbIXXi3Daen mcgUicIXXgq/Tek4pesS7vw4IHg30mihFUX/+hJ/dacuXegYwujWZeQ6q3HhUC260bnb 4RaGeovYLe/gjJz1VSubMQHyrHAttkgcGqA5/qVDk1ZdzQZVD0ludYmRI3rIbO2Y+11k o8m2ent+YZyehIkednJG0R0ssgYxtNqK8lG3pT+qI9tH5UlZJ2Xv8VPLm5QKzP6zYeDo j0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=XJBZo86NwzlYcDfKiueYzUkDbZYleRySpVsik2jGH+A=; b=T3O7JfR3IV7Fx4FGXnlYbYv6FO7jXhwmJR+XhfICdnPjdchU/2wRP5dT4jsttxzNb5 i4HDhM1dtTTT2OjbLj3QDM0B1+EZOCi0NcNsEGagJVtbHBPk+qvs4Fa78Xye3i+5b4N6 huLXKsaiNO35/uDUhCj45ly0ccwoRfrm2suU7+lClIHXZ76qQtqtboxvp4Yzy+9Ovciw 2trR8zCc0ydBl4S2ctm5okHxjQ7P8vzsa/izqf4WF7O+pH90WMa+ELe+gudfQs1do6+X 1wWv6siO/FrL/1xXs9vv26Ku7SpMxTsJLrXnWKK1nF2HU3jav5mzWX6PyPK4Goa/9ygZ l5vQ== X-Gm-Message-State: ACgBeo1B0+6i8rGygYbxjyk7HGm1ta3m1ceDR+0/4e91LeCJYcRTQy3f caLuWcLEOcn4anX84ZO2IntjeQ== X-Google-Smtp-Source: AA6agR5dRIkH6udc5pKFMe1bhIYgbLLZvNUngMjDNapUvHnC/ilmRHVTVwwJnT4S7oGbP+Stft24mw== X-Received: by 2002:a05:6512:acd:b0:492:b8e0:2ef4 with SMTP id n13-20020a0565120acd00b00492b8e02ef4mr2091002lfu.360.1661506773119; Fri, 26 Aug 2022 02:39:33 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m6-20020a195206000000b004886508ca5csm329055lfb.68.2022.08.26.02.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 02:39:32 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar 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 v2 4/5] drm/msm/hdmi: don't take extra reference on PHY device Date: Fri, 26 Aug 2022 12:39:26 +0300 Message-Id: <20220826093927.851597-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> References: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The of_find_device_by_node() already increments the device's usage count, so there is no need to increment it again using get_device(). Drop this extra get_device(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index c298a36f3b42..926274eeee25 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -106,7 +106,7 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi) return -EPROBE_DEFER; } - hdmi->phy_dev = get_device(&phy_pdev->dev); + hdmi->phy_dev = &phy_pdev->dev; return 0; } From patchwork Fri Aug 26 09:39:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 600367 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 1EC1CECAAD9 for ; Fri, 26 Aug 2022 09:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343980AbiHZJjh (ORCPT ); Fri, 26 Aug 2022 05:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343971AbiHZJjh (ORCPT ); Fri, 26 Aug 2022 05:39:37 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D64FAC2E8B for ; Fri, 26 Aug 2022 02:39:35 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id m5so1297752lfj.4 for ; Fri, 26 Aug 2022 02:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=+1bTBy3Qw5DuGoK8+Tzb6Ah6TNqnmwTNraiwhKdmwR4=; b=KFQFh51NXldRfmWT+gLJbwjEPJH4OXGKTJ1OPeKDKoW0cC4+Xm6fDQqMfrmOFCeiAa ji4BkNcCnvd7B0NYLzkJcfFYgoAoHl2awys2xtMoThO0ol4f9e1sVrdjBTfJAW2fney/ E9APrOwdQPiQ6gibX+bDaeTLsjYkvIPuqvMDEUugYN97oVl1UEfioNEwDDIKyE8ZOWRI nLlbQknq/L92oZXcAzi2mhotP+SXjGrOtgMyuoZSW0AOjgh3zA0sgoYFCnVbDLai6pLH 9NaGcsAhyHrSGJCAsCloGNCO+e8plOWhUGUBtmZ+l21eNZov5XSXlQEv95rAP4tUiKWc lbiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=+1bTBy3Qw5DuGoK8+Tzb6Ah6TNqnmwTNraiwhKdmwR4=; b=thx51phXth01Zod7fW71by5I8VZfNlTzT6Uc2UJSAOzJlY05WWZVmhxjKqQk6+7rYi yUSrHp27B6wIct1C1LjnpDZkzm0Pqh97eQDLwnDFspy2b7QR0kElmasZbaisiGo8zluf d0hJHPQZS5UqiU3C+5BMcExxMOuYWjmhvvsWIcImmj+FPDlEWv/jdWkotI9Tk4z00B9S xCzA76W+wS2hd/cobwV4JfxStThu3Z3nZgTbIUEp8R0DIiTcAAXyQsExJUcwWIj/ooLw H6kU9BJuuUbJ9GqJ/DSeP9BhwJ6J0k4GNTSA+2ePNz8D7OM0foykB3sKLy2VyzUkrw2K WUfQ== X-Gm-Message-State: ACgBeo1/OEuUaHZ7r2gTNkXJN07V1QlB6qmAQwn69CnhELHZEyPKO31g oZCGld0jmdiCxmt+UzVugiKGETl0ovgWYg== X-Google-Smtp-Source: AA6agR4MjTSK2a1wzZxnLil7UixcsK3+uoWW4eB3KQNvXFBfuAFSTWRzpvfb3Zi9fnV7B7YxwTWPiA== X-Received: by 2002:a05:6512:6c8:b0:48a:f375:9ecc with SMTP id u8-20020a05651206c800b0048af3759eccmr2151757lff.206.1661506774245; Fri, 26 Aug 2022 02:39:34 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m6-20020a195206000000b004886508ca5csm329055lfb.68.2022.08.26.02.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 02:39:33 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar 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 v2 5/5] drm/msm/hdmi: move msm_hdmi_get_phy() to msm_hdmi_dev_probe() Date: Fri, 26 Aug 2022 12:39:27 +0300 Message-Id: <20220826093927.851597-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> References: <20220826093927.851597-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org To continue the idea of failing the probe() rather than failing the bind(), move the call to msm_hdmi_get_phy() function to msm_hdmi_dev_probe(), so that the driver fails the probe if PHY is not yet available rather than succeeding the probe and then failing the bind() with -EPROBE_DEFER. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi.c | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 926274eeee25..adaa67d9a78d 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -68,14 +68,17 @@ static void msm_hdmi_destroy(struct hdmi *hdmi) destroy_workqueue(hdmi->workq); msm_hdmi_hdcp_destroy(hdmi); + if (hdmi->i2c) + msm_hdmi_i2c_destroy(hdmi->i2c); +} + +static void msm_hdmi_put_phy(struct hdmi *hdmi) +{ if (hdmi->phy_dev) { put_device(hdmi->phy_dev); hdmi->phy = NULL; hdmi->phy_dev = NULL; } - - if (hdmi->i2c) - msm_hdmi_i2c_destroy(hdmi->i2c); } static int msm_hdmi_get_phy(struct hdmi *hdmi) @@ -91,19 +94,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi) } phy_pdev = of_find_device_by_node(phy_node); - if (phy_pdev) - hdmi->phy = platform_get_drvdata(phy_pdev); - of_node_put(phy_node); - if (!phy_pdev) { - DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); - return -EPROBE_DEFER; - } + if (!phy_pdev) + return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n"); + + hdmi->phy = platform_get_drvdata(phy_pdev); if (!hdmi->phy) { - DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); put_device(&phy_pdev->dev); - return -EPROBE_DEFER; + return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n"); } hdmi->phy_dev = &phy_pdev->dev; @@ -130,12 +129,6 @@ static int msm_hdmi_init(struct hdmi *hdmi) goto fail; } - ret = msm_hdmi_get_phy(hdmi); - if (ret) { - DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n"); - goto fail; - } - hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi); if (IS_ERR(hdmi->hdcp_ctrl)) { dev_warn(&pdev->dev, "failed to init hdcp: disabled\n"); @@ -528,6 +521,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) if (hdmi->hpd_gpiod) gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); + ret = msm_hdmi_get_phy(hdmi); + if (ret) { + DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n"); + return ret; + } + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) return ret; @@ -539,7 +538,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) static int msm_hdmi_dev_remove(struct platform_device *pdev) { + struct hdmi *hdmi = dev_get_drvdata(&pdev->dev); + component_del(&pdev->dev, &msm_hdmi_ops); + + msm_hdmi_put_phy(hdmi); + return 0; }