From patchwork Fri Mar 12 17:30:16 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: 398660 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1383333jai; Fri, 12 Mar 2021 09:29:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiSrgalpAN2jhK9gElEYRL0gL35geyWH5I/U+XovioSAJSfN3qyfXYD4AFERl0KBJgeXmf X-Received: by 2002:a17:906:a86:: with SMTP id y6mr9986383ejf.354.1615570194613; Fri, 12 Mar 2021 09:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615570194; cv=none; d=google.com; s=arc-20160816; b=UgesOo6VcutgyrAQZS+fThoaaSSa1acSRKfjwRqQuzkAcAKsgKUXTbQY459C3xQoXY PcIPxGy0Z6O6C1jWVjfkL+7AsRbV+6ZQeUf3NgGvgi0IOEApKi1ltWUipHNvNKwzLeyc efYb7AVGMXH0Dj7bdLVNUAq2/1prKYubYupu0MTt2b5FD75nfeeR08V+VWatfqjLIdos zJOJJa7K6AsQ407AqPDJcYHy9yMDU+Xr/+RQvGkkns7p9eH/LVGHnfpLM3frT0rlDLk6 CO9RD/W/RzZkQJiGT3SYvFBpUCdml9lF92pbXsADdYrlGyVxy1HiVIH99izIipfuYqMX sr7w== 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=x83uovnMOJTdyefGlIGHI08yYtXPvr91w/2f/jSvlJs=; b=0unFS9/7FDgkOzbw0uSfGe97/QxG3N0vQVupdZK+3bgpXVEw/xr8VzJQfiBRIL/8uG vnwexW+s3fHwKJg/aNwDNBNR6ld1jn1L90LA/mT65s0DVj3k2/1b/iWxFdL2xN9febhs aNDOJyURjCG+H4Q6qb5eSthjt2s0eYxQU3a066iLPFV4Y6jpJy9vRrW/2L/qjRH2/HVZ v5MPuDCsTBV/cWw4kgDyPLPaYakvkKjfInDQTvXom1nkqLTjq1z1xkwSOW609KjWmbZH Li7bpSL4PptHl4c0QFBH+0RihjbwOdkJ1gJqtpiMWWEqXYHM1ePgST9e59YySCZEI9Vt 57MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XLFeT9Dg; 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 ot6si4540497ejb.337.2021.03.12.09.29.54; Fri, 12 Mar 2021 09:29:54 -0800 (PST) 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=XLFeT9Dg; 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 S232507AbhCLR3X (ORCPT + 16 others); Fri, 12 Mar 2021 12:29:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232679AbhCLR3P (ORCPT ); Fri, 12 Mar 2021 12:29:15 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B158AC061574 for ; Fri, 12 Mar 2021 09:29:14 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id d139-20020a1c1d910000b029010b895cb6f2so15620467wmd.5 for ; Fri, 12 Mar 2021 09:29:14 -0800 (PST) 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=x83uovnMOJTdyefGlIGHI08yYtXPvr91w/2f/jSvlJs=; b=XLFeT9DgpJGU0vi3RKLjF+R3QIgBsbcQn2/gV7k9okAcaAvXEh+UVM9GEiUoGpjsiX OWIGNYhuPtEE0ufgzuulkBLtVJKMWZJpy3Pj6Ol5s6QjhcvPuhH5+hJdyot9CfPzErwn u7xZLOwALJjdxsh8I3R8E2+AzaTJ2Lbd0nvzd0+jlZyLo8PAHC4LSxV0OsxWKCMsAspW KSekZ3ka34AugII3VrYu74RSyJDmv6/N96ejGzUD7U6P3zDg9zl6m8YqknQjiGQZeUlx IFBY0FFl0xpzytnkz15h0oKgVkUdPtHks2PQJ4Qp+Vhj+nBcJVJLWf3urHjnCD2CuHYF 6XQQ== 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=x83uovnMOJTdyefGlIGHI08yYtXPvr91w/2f/jSvlJs=; b=iWaWc7WvNCNTlnnqXKt/W8W5qmg7Qo6muWYHwaIzd5YXOWkfeER8SMpAvTs3kxyKxH pDacLy1vqdWisTEH0HezDJBAXy67szevLUGw5JQYTOuSvfdcOM+rNCDbxcsHq2lCKrmx eQaJK8jkBPG03k/Wds8RZlYIkQ5aFXt3ZssHDy9HhhVeVvArZlndbkor0kvaJbj3MV8F VqVoAWRsVBMApDgmTCIA/X/4kJmvCyGgJ9laYT+PeXcyK3A33a4lPqiWqFL72ku8rZqV JKMSe0wns1+1FLhxualjXDonV1kKK5489qQLEWSto+6eXg5781RHFPhsUIP7P0a2u/rx jsKg== X-Gm-Message-State: AOAM532Is3d4ZdJ/B1Zu4bcZuSanITbzB286KpJCdICKX/E2VMvAkQNU po7UiRY40E5zBymVHo3F4ZF2Pw== X-Received: by 2002:a05:600c:220d:: with SMTP id z13mr14177471wml.1.1615570153435; Fri, 12 Mar 2021 09:29:13 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id 18sm2876375wmj.21.2021.03.12.09.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:29:12 -0800 (PST) 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 v2 02/25] media: venus: core,pm: Add handling for resets Date: Fri, 12 Mar 2021 17:30:16 +0000 Message-Id: <20210312173039.1387617-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210312173039.1387617-1-bryan.odonoghue@linaro.org> References: <20210312173039.1387617-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 --- 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); }