From patchwork Fri Apr 2 10:06:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 414327 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1283877jai; Fri, 2 Apr 2021 03:05:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Af4sweDiX/fl4xQpPfRGa8Y7+RxwncF96i6FdtntR6d1fNmXfvvA6fsKuEm6GG5iGBNZ X-Received: by 2002:a02:cd33:: with SMTP id h19mr11998478jaq.88.1617357959906; Fri, 02 Apr 2021 03:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617357959; cv=none; d=google.com; s=arc-20160816; b=cAFKukLx07eHK12OmsWnpGpbDxybUFy8xRQsloK0H/Lv3kYXqxdkUFZAkddG7HR2I2 qLDxggQgcoFPN4yz2ABxV/5dRArEQoMaakzrZHR6l+Dx0sLL1lgne1nyculvRHmUzHCj p6zHDcu+gi5gtSNpGAHv2Blf1VDY1VAZ7fGnJSj+0tTgWQ1WxCRM1l1dzYP9ATvrzGPg TvtfWl0oYHGacWnrD2Jpm9JCIAdtzc2hHKRcnon/3C1qnX7VkY7tC7TGXGwB+fALNTjt HyRl+lfPYPhSvDHWSrABn+lB8YgwmvL4iMnkfVogVagDtqKp+dHBXp1v1FDvnMDq6ub2 G6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gu1aUpypBdZ1g5qKxxRYnsFtYrUSNKGTe+yXVLDDZJw=; b=rxiBNWzZyBa1MkSfN99j6UJEzX/MqrggGhRnBlr3Ql/yP3seFPVH6hfPRdJwOkfJM0 M1ka33FjMSodqYPhsfIECtjS3Zoa7Mzdjx+FQBSU6VCGlvN2PGWrmFlwL2HlXBhOa21B VSgV6ejpT3SOd3N5uuf50oYFeKy2PDY7G8PxJnDPZiz8szdmzi7Y35yle+At9vDVxeir X3dfNqVpB7keRtiC2ot++9w57pflCkFIY9qewg3C+5so/eigi1N/xngMDL73k+uKGZvK CjazPm3xp17DvhKARKiwOU5IRkAqr78nQJ6QzHuJT+9HOCx4FvMx5jhsLLTYOzwkJOBv jTOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ksnOHVig; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si6942838ile.30.2021.04.02.03.05.49; Fri, 02 Apr 2021 03:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ksnOHVig; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbhDBKF2 (ORCPT + 17 others); Fri, 2 Apr 2021 06:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhDBKFZ (ORCPT ); Fri, 2 Apr 2021 06:05:25 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15461C061793 for ; Fri, 2 Apr 2021 03:05:20 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so2149030wmj.1 for ; Fri, 02 Apr 2021 03:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gu1aUpypBdZ1g5qKxxRYnsFtYrUSNKGTe+yXVLDDZJw=; b=ksnOHVigXlc06+QGymJwGypYZ0yHUSBjvgJ9S5ox1SFQaJuQX67kRqXCPyqRTy75cp KYE2Gq2pwsfTlbvQluFyIispAcWQ/O7+PljGRqxk6K6IWsl9gOtRV3Pt29TXpFmI1DJt DuXpDPsplc36VdxUb5nsn4wJ826xjsJNIzh9vq/XbjFkKFpT84ndzDsxTfdHSL2kmOEO rdDXOX80pWt5dgCIdzuz0YsjT39e6DIArQzXXnbHe7rqnOiGJwrGtgqAvNk9NHpsTTdw HOefLyGda9up2QVD9cpVzIgfWnMB/Zteng29+f23vahUwwSPDfgA7U5YnhkMNfYmsQ7i e7uQ== 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:mime-version:content-transfer-encoding; bh=Gu1aUpypBdZ1g5qKxxRYnsFtYrUSNKGTe+yXVLDDZJw=; b=l/2w+TsrmgFD5hcp3MBgg2GDqgdVcyydOIzdZ2AXsByHWNJtUo/mNPqA4+RKNk5dCA jnCq3siYvOTAX0oJHrz3wRMKzEWfv5/JsQ+S/shDxRseeCybiPkpvp8/OwvotYai6DKp pxR9M0f6qDAtoQ7iJUjMKpbPgr4uj3rwvbiSKkWmmqvGzyr8yfBBeZRJI9lbTWvvGCJH iZPW1AhNJLUq2ReM+N0N9pk50qKM9mcGeUiyG2K1CbY7d+vn8rX6hEXxO2jPIYRyywPY UNTQqsGu6MtlHwsKWZk5xB7Vso9Wms5ookUoWDj16LGV6auSqH1G37hLBzVPCooZTHcy bs8g== X-Gm-Message-State: AOAM530Y8hzqUP7CGW2R5ltHUBelELvtil8HHlA0+M/cuW2kVsmedZEo JLd9fQfHapxicLcnnE3QCBaVjw== X-Received: by 2002:a1c:6855:: with SMTP id d82mr12367791wmc.169.1617357918717; Fri, 02 Apr 2021 03:05:18 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id v18sm15466618wrf.41.2021.04.02.03.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 03:05:18 -0700 (PDT) From: Bryan O'Donoghue To: stanimir.varbanov@linaro.org, agross@kernel.org, bjorn.andersson@linaro.org, mchehab@kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: bryan.odonoghue@linaro.org, dikshita@codeaurora.org, jonathan@marek.ca, vgarodia@codeaurora.org Subject: [PATCH v3 02/25] media: venus: core,pm: Add handling for resets Date: Fri, 2 Apr 2021 11:06:25 +0100 Message-Id: <20210402100648.1815854-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210402100648.1815854-1-bryan.odonoghue@linaro.org> References: <20210402100648.1815854-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Stanimir Varbanov The Venus driver has to control two reset signals related to gcc video_axi0 and videocc mvs0c for v6. Add it. Signed-off-by: Stanimir Varbanov Signed-off-by: Bryan O'Donoghue Acked-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 4 ++ .../media/platform/qcom/venus/pm_helpers.c | 60 +++++++++++++++++++ 2 files changed, 64 insertions(+) -- 2.30.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 13c18c49714d..0a90cd79104b 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -24,6 +24,7 @@ #define VIDC_CLKS_NUM_MAX 4 #define VIDC_VCODEC_CLKS_NUM_MAX 2 #define VIDC_PMDOMAINS_NUM_MAX 3 +#define VIDC_RESETS_NUM_MAX 2 extern int venus_fw_debug; @@ -64,6 +65,8 @@ struct venus_resources { unsigned int vcodec_pmdomains_num; const char **opp_pmdomain; unsigned int vcodec_num; + const char * const resets[VIDC_RESETS_NUM_MAX]; + unsigned int resets_num; enum hfi_version hfi_version; u32 max_load; unsigned int vmem_id; @@ -130,6 +133,7 @@ struct venus_core { struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX]; struct device_link *opp_dl_venus; struct device *opp_pmdomain; + struct reset_control *resets[VIDC_RESETS_NUM_MAX]; struct video_device *vdev_dec; struct video_device *vdev_enc; struct v4l2_device v4l2_dev; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index 95b4d40ff6a5..794c2d6f0543 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -847,6 +848,52 @@ static void vcodec_domains_put(struct venus_core *core) dev_pm_opp_detach_genpd(core->opp_table); } +static int core_resets_reset(struct venus_core *core) +{ + const struct venus_resources *res = core->res; + unsigned char i; + int ret; + + if (!res->resets_num) + return 0; + + for (i = 0; i < res->resets_num; i++) { + ret = reset_control_assert(core->resets[i]); + if (ret) + goto err; + + usleep_range(150, 250); + ret = reset_control_deassert(core->resets[i]); + if (ret) + goto err; + } + +err: + return ret; +} + +static int core_resets_get(struct venus_core *core) +{ + struct device *dev = core->dev; + const struct venus_resources *res = core->res; + unsigned char i; + int ret; + + if (!res->resets_num) + return 0; + + for (i = 0; i < res->resets_num; i++) { + core->resets[i] = + devm_reset_control_get_exclusive(dev, res->resets[i]); + if (IS_ERR(core->resets[i])) { + ret = PTR_ERR(core->resets[i]); + return ret; + } + } + + return 0; +} + static int core_get_v4(struct venus_core *core) { struct device *dev = core->dev; @@ -870,6 +917,10 @@ static int core_get_v4(struct venus_core *core) if (ret) return ret; + ret = core_resets_get(core); + if (ret) + return ret; + if (legacy_binding) return 0; @@ -929,6 +980,13 @@ static int core_power_v4(struct venus_core *core, int on) } } + ret = core_resets_reset(core); + if (ret) { + if (pmctrl) + pm_runtime_put_sync(pmctrl); + return ret; + } + ret = core_clks_enable(core); if (ret < 0 && pmctrl) pm_runtime_put_sync(pmctrl); @@ -939,6 +997,8 @@ static int core_power_v4(struct venus_core *core, int on) core_clks_disable(core); + ret = core_resets_reset(core); + if (pmctrl) pm_runtime_put_sync(pmctrl); }