From nobody Wed Dec 17 09:50:03 2025 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 EEF45C5AD4C for ; Thu, 23 Nov 2023 17:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345215AbjKWRDE (ORCPT ); Thu, 23 Nov 2023 12:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjKWRC7 (ORCPT ); Thu, 23 Nov 2023 12:02:59 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38213D4A for ; Thu, 23 Nov 2023 09:03:05 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-332ce50450dso702528f8f.1 for ; Thu, 23 Nov 2023 09:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758983; x=1701363783; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=X26+8wItEuS2j+BVlRHOHS9xadXwL+/+KykUmMySayM=; b=U1NGys4jSXa478wAcCoNa4IIy5tjcOydyInU0h3s6KQ0M7pFJKxjmXq9X+ARqlPpy7 pSgr0V0ec0kVVflR5Sy7EODi1d2D+wuAWnqkY+cLd725bUjBZkK+K1LOANiPxHwVQyWS 0AJXXtd6x1aPjx//Pfo04CBOUWiFWTw9sjuFrPYcvCqqLFWmDbnmnCipYRWNyTum8EoY rB1xYzPGChS56b0NVaU/hfkJt91yDfmCjmMAEkmZLsVgE1qZB2x8XWToNBkyOduGQrl7 fWYxmjfflN/+R1WvKeytRT5nnGyr67sxHEyuzO5lVWvn3hfbIOAzClTUSY3q1SzldH9l JVfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758983; x=1701363783; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X26+8wItEuS2j+BVlRHOHS9xadXwL+/+KykUmMySayM=; b=tOcUc3BfPGCLguSHv32g7TWLZI+VC8vF8Jnux4zP2KfQlrX9VtiRj7JQrhKU5hSgBZ u29NCWohMnDyDrSWOWbQ7N+yC8bAzizUcCmUFjL3lDyCva7ZzkOjVJc4x3jumpmzvvt9 5ol4C/2Sy/O6hm0y+xF42jDXodXeCSnu2IkqRV6wCmBNrkqS705Eoy0SwrzYcAUeZl14 3N/eeJUaNPRzTnt22q4T2J1n/nHIRNUIhxS/JIeigH+S4WvVkveceV04RTsRJUI0Gj+5 lNOJZYb3gIQg9Ux4JMQjRshBnWqO9WlUPKi8MZUiipzt+qzYgPNiNigfZrIXIX1Ff0hc s7VA== X-Gm-Message-State: AOJu0Yy2rslEFTQLsQOEZZb8tb6mDS1LK3NIs/TCHG97mgYVxlLQnk8/ eE/jsOYJAZ5DUQPGfSpHIBa6cA== X-Google-Smtp-Source: AGHT+IHtQTwXimrf79Wlg5jnvUDF/YuL90RVlWtpebD3jhmxWckb7X/7abp/KkIBDc8SOLJF86HENg== X-Received: by 2002:adf:ed09:0:b0:332:e7b9:b671 with SMTP id a9-20020adfed09000000b00332e7b9b671mr75060wro.14.1700758983681; Thu, 23 Nov 2023 09:03:03 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:03 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:00 +0000 Subject: [PATCH v6 1/8] media: qcom: camss: Flag which VFEs require a power-domain MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-1-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment we have some complex code for determining if a VFE requires a power-domain attachment. Particularly discordant in this scheme is the subtle reliance on VFE and VFE Lite declaration ordering in our resources. VFE id is used to determine if a VFE is lite or not and consequently if a VFE requires power-domain attachment. VFE Lite though is not a correct delineation between power-domain and non power-domain state since early SoCs have neither VFE Lite nor power-domains attached to VFEs. Introduce has_pd to the VFE resource structure to allow the CAMSS code to understand if it needs to try to attach a power-domain for a given VFE. As a side-effect from this we no longer need to care about VFE Lite or non-Lite or the id number associated with either and which order the VFE/VFE Lite was declared in. Reviewed-by: Konrad Dybcio Tested-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 8 ++++++++ drivers/media/platform/qcom/camss/camss.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 8e78dd8d5961e..ed01a3ac7a38e 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -278,6 +278,7 @@ static const struct camss_subdev_resources vfe_res_8x96= [] =3D { .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_4_7 }, =20 @@ -298,6 +299,7 @@ static const struct camss_subdev_resources vfe_res_8x96= [] =3D { .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_4_7 } }; @@ -468,6 +470,7 @@ static const struct camss_subdev_resources vfe_res_660[= ] =3D { .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_4_8 }, =20 @@ -491,6 +494,7 @@ static const struct camss_subdev_resources vfe_res_660[= ] =3D { .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_4_8 } }; @@ -658,6 +662,7 @@ static const struct camss_subdev_resources vfe_res_845[= ] =3D { .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, .line_num =3D 4, + .has_pd =3D true, .ops =3D &vfe_ops_170 }, =20 @@ -680,6 +685,7 @@ static const struct camss_subdev_resources vfe_res_845[= ] =3D { .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, .line_num =3D 4, + .has_pd =3D true, .ops =3D &vfe_ops_170 }, =20 @@ -840,6 +846,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_480 }, /* VFE1 */ @@ -860,6 +867,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, .line_num =3D 3, + .has_pd =3D true, .ops =3D &vfe_ops_480 }, /* VFE2 (lite) */ diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 8acad7321c09d..b854cff1774d4 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -49,6 +49,7 @@ struct camss_subdev_resources { char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; u8 line_num; + bool has_pd; const void *ops; }; =20 --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 59C5FC61D97 for ; Thu, 23 Nov 2023 17:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345321AbjKWRDH (ORCPT ); Thu, 23 Nov 2023 12:03:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345172AbjKWRDB (ORCPT ); Thu, 23 Nov 2023 12:03:01 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C51CBCB for ; Thu, 23 Nov 2023 09:03:07 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-332d2948170so697773f8f.2 for ; Thu, 23 Nov 2023 09:03:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758986; x=1701363786; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FU64yB094w/k/dpqAQjQeJG192Ggsw7tuSAo8zmyjiE=; b=o6YE4no9U23wnZL3/dAs/vjuYoAWzWSyRa8sKcShGMYxSrfhUt8W2FbjNUwlDJKWDf wAJnAC9dJpvaRtF929XwoE910+s1XXblJ6+CiLNI7W4f7CfXZL2xdmV70bhr0+TZyGy6 resbZojeCzmjXLFmpvQWMzn0z0yu5aUJDG5/ENqA6+mBAOlsnAkMkEqNjAvJOVRClSya T7z3IdgCenV7cLJjU6WDhQEDzDuTPiLYVnIhkrU0m/rahmjLn9mjwAYXQtd/4J48Tdeh G4v/SiHod10CvRIisHVLwjZFq2BudGpRTDIoyCrUxzIp/9BccsT6Y4Dri9UmtEaD+xI2 9DfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758986; x=1701363786; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FU64yB094w/k/dpqAQjQeJG192Ggsw7tuSAo8zmyjiE=; b=oP3vuPIsEUPydZbX+gBPwePmOUcXmOPXIbqLAAWrKNqNmg4beWcAxvXeHiIUMuSmPt pOt0mPtmGrYLG5ubbfg9hLkJEUAogGWyogZBDZcnztzNEzfX4ZMu72o/qctDw95h1OnQ 4SCTjBiUuOol1/MOWchBc90MmB+FMcLI7LwgT4jFNwQ1BtAaM6k9fieLMNrA+ZiGCk6R /0wO0KhLqHjI5G90iqkTTQ1htSFF0C2QtURqbrfdrj7/NnMWXk80ks1jWNSyqHWcslGz 1IUfsW3K8ukuxL2u0VgEeTSIZPbVZccpRhRi20z1ON3dnxY075FAhKd97XD2qu7XaBwh rSHg== X-Gm-Message-State: AOJu0YwRpL39vdDVeOUzqirtvf/tH+vXsaTQ89xif0KLfzlNLf+pLqfT ght/mizNcLrGFXNJmaZskIn+wQ== X-Google-Smtp-Source: AGHT+IG2iNyDmurr/XZExCjpPEpXvcJ3Ks4CXtVmZNjv0oma+f1lSiyhJ5Qyr25J93s6IFOu54EYrA== X-Received: by 2002:adf:fdcf:0:b0:332:e58b:ab58 with SMTP id i15-20020adffdcf000000b00332e58bab58mr72910wrs.1.1700758984912; Thu, 23 Nov 2023 09:03:04 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:04 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:01 +0000 Subject: [PATCH v6 2/8] media: qcom: camss: Convert to per-VFE pointer for power-domain linkages MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-2-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right now we use the top-level camss structure to provide pointers via VFE id index back to genpd linkages. In effect this hard-codes VFE indexes to power-domain indexes in the dtsi and mandates a very particular ordering of power domains in the dtsi, which bears no relationship to a real hardware dependency. As a first step to rationalising the VFE power-domain code and breaking the magic indexing in dtsi use per-VFE pointers to genpd linkages. The top-level index in msm_vfe_subdev_init is still used to attain the initial so no functional or logical change arises from this change. Reviewed-by: Konrad Dybcio Tested-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 15 +++++---------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 13 +++++-------- drivers/media/platform/qcom/camss/camss-vfe-480.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe.c | 3 +++ drivers/media/platform/qcom/camss/camss-vfe.h | 2 ++ 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-170.c index 0b211fed12760..7451484317cc3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -638,7 +638,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >=3D camss->res->vfe_num) return; =20 - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } =20 /* @@ -648,16 +648,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; - enum vfe_line_id id =3D vfe->id; =20 - if (id >=3D camss->res->vfe_num) + if (vfe->id >=3D camss->res->vfe_num) return 0; =20 - camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; =20 return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-4-7.c index b65ed0fef595e..2b4e7e039407b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1109,14 +1109,10 @@ static void vfe_isr_read(struct vfe_device *vfe, u3= 2 *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss; - if (!vfe) return; =20 - camss =3D vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } =20 /* @@ -1126,13 +1122,12 @@ static void vfe_pm_domain_off(struct vfe_device *vf= e) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; - enum vfe_line_id id =3D vfe->id; =20 - camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], D= L_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATE= LESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); =20 - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->= id); return -EINVAL; } =20 diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-4-8.c index 7b3805177f037..5e95343241304 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1099,9 +1099,7 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 = *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss =3D vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } =20 /* @@ -1111,13 +1109,12 @@ static void vfe_pm_domain_off(struct vfe_device *vf= e) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; - enum vfe_line_id id =3D vfe->id; =20 - camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], D= L_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATE= LESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); =20 - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->= id); return -EINVAL; } =20 diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-480.c index f2368b77fc6d6..a70b8633bb3eb 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -463,7 +463,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >=3D camss->res->vfe_num) return; =20 - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } =20 /* @@ -473,16 +473,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; - enum vfe_line_id id =3D vfe->id; =20 - if (id >=3D camss->res->vfe_num) + if (vfe->id >=3D camss->res->vfe_num) return 0; =20 - camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; =20 return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 4839e2cedfe58..94267b9974554 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1347,6 +1347,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, if (!res->line_num) return -EINVAL; =20 + if (res->has_pd) + vfe->genpd =3D camss->genpd[id]; + vfe->line_num =3D res->line_num; vfe->ops->subdev_init(dev, vfe); =20 diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/= platform/qcom/camss/camss-vfe.h index 09baded0dcdd6..c1c50023d4876 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -150,6 +150,8 @@ struct vfe_device { const struct vfe_hw_ops_gen1 *ops_gen1; struct vfe_isr_ops isr_ops; struct camss_video_ops video_ops; + struct device *genpd; + struct device_link *genpd_link; }; =20 struct camss_subdev_resources; --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 1FB0CC5AD4C for ; Thu, 23 Nov 2023 17:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbjKWRDL (ORCPT ); Thu, 23 Nov 2023 12:03:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345140AbjKWRDD (ORCPT ); Thu, 23 Nov 2023 12:03:03 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E62D5C for ; Thu, 23 Nov 2023 09:03:08 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b2ad4953cso12562095e9.0 for ; Thu, 23 Nov 2023 09:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758987; x=1701363787; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1OpluDSI7ifwDeNDFUHoJfsbGgfPas9u/8aOkEgqU+o=; b=Z1aUfSDBziV49hx56JI7lrrbhRwcHgg/f3ytWLZyS7r97fRDPJXEl6AgOCZ8QgKHXt v92D76OyxW6Cn7Pv3qAlrNS0SPiOl7S+p4UMaGnHRw3c+fKdPiKb971eFw/DOuQH1Y1p iu74u55fB8+XxvOIzHKcwz/pROWV2IAJcV571CjkTbEKrIAIaBck757UKgX6bTQ3RQD7 Sa/p+2u/UaGPG2F0wc6qPt1wf0adQCJxdi9w+AIQ0XocGs7RngD9u9sbUxkO3aeLntnv 1kvK1JDc05lcbLtOF3Dlscs5MXM2ZO/VtjtgWaxN34GuU/TG4B205VSNMkn9vGyjI0zH 6MvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758987; x=1701363787; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1OpluDSI7ifwDeNDFUHoJfsbGgfPas9u/8aOkEgqU+o=; b=Q0zetsVPNlt9iYwbavtWbugOGP5KSMyuP+4PnLfKtNV6xfJYuRGAXSrGiVR3WCbXV0 zYDYKfvfeoU9paAzU+N3TG390AxNZFQt0o+dg20QKSZuUQjjNH2wS6rLjmhjP51Hln3w G0/ZqOMIu5F7MrduLDxPtdR6ybRJbGblj2c/6llQ8LfWDXt+ZoUEg8de4DsFdVSac/B9 hFiMDss636epDByQ6QnZKaeUUwOwa8IIqNydz0UNooJTvEeXMUdEOYjqum2HB03DMVyx /CLw3VWGuVdzTftzCor4VzN68Hwew7GiUrfaQqOLJswYT2qR7VjulnBConUheDiuazGF /Q/w== X-Gm-Message-State: AOJu0Ywbnrgse6sYtN1XaSqUq4aXigPz2C4wPAL9k7Sgex52yOM+XhrL ZXj+qcDlUHqrbP1TxBxzYEjxjQ== X-Google-Smtp-Source: AGHT+IGtzyISPBLbiOHMyxIZ98uxj/2D1Dlqg4SdqUj59+rijk0o6q8lf64LXcqmGvfUppa3IZhT6w== X-Received: by 2002:adf:ce8f:0:b0:332:e697:3a71 with SMTP id r15-20020adfce8f000000b00332e6973a71mr1005036wrn.6.1700758987209; Thu, 23 Nov 2023 09:03:07 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:06 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:02 +0000 Subject: [PATCH v6 3/8] media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-3-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the various versions of VFE we have a boiler-plate pm_domain_on/pm_domain_off callback pair of the general form. - Error check. Not always done but applicable to all. - device_link_add (DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - Error check returning -EINVAL on error. - Return 0 Reduce the pattern down to a common callback. VFE 4.1 is a special case which to me also indicates that it is worthwhile maintaining an indirection for the vfe_pm_domain_{on|off} for now. Otherwise lets chuck out a bunch of needlessly replicated code. Reviewed-by: Konrad Dybcio Suggested-by: Matti Lehtim=C3=A4ki Tested-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 35 -------------------= ---- drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 8 +++--- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 31 -------------------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 28 ------------------ drivers/media/platform/qcom/camss/camss-vfe-480.c | 35 -------------------= ---- drivers/media/platform/qcom/camss/camss-vfe.c | 34 +++++++++++++++++++= +++ drivers/media/platform/qcom/camss/camss-vfe.h | 12 ++++++++ 7 files changed, 50 insertions(+), 133 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-170.c index 7451484317cc3..795ac3815339a 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -627,41 +627,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8= wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } =20 -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - if (vfe->id >=3D camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - if (vfe->id >=3D camss->res->vfe_num) - return 0; - - vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-4-1.c index 2911e4126e7ad..ef6b34c915df1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c @@ -936,7 +936,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) * vfe_pm_domain_off - Disable power domains specific to this VFE. * @vfe: VFE Device */ -static void vfe_pm_domain_off(struct vfe_device *vfe) +static void vfe_4_1_pm_domain_off(struct vfe_device *vfe) { /* nop */ } @@ -945,7 +945,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) * vfe_pm_domain_on - Enable power domains specific to this VFE. * @vfe: VFE Device */ -static int vfe_pm_domain_on(struct vfe_device *vfe) +static int vfe_4_1_pm_domain_on(struct vfe_device *vfe) { return 0; } @@ -999,8 +999,8 @@ const struct vfe_hw_ops vfe_ops_4_1 =3D { .hw_version =3D vfe_hw_version, .isr_read =3D vfe_isr_read, .isr =3D vfe_isr, - .pm_domain_off =3D vfe_pm_domain_off, - .pm_domain_on =3D vfe_pm_domain_on, + .pm_domain_off =3D vfe_4_1_pm_domain_off, + .pm_domain_on =3D vfe_4_1_pm_domain_on, .reg_update_clear =3D vfe_reg_update_clear, .reg_update =3D vfe_reg_update, .subdev_init =3D vfe_subdev_init, diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-4-7.c index 2b4e7e039407b..7655d22a9fda2 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1103,37 +1103,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32= *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } =20 -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - if (!vfe) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATE= LESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->= id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation =3D readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-4-8.c index 5e95343241304..f52fa30f3853e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1093,34 +1093,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32= *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } =20 -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATE= LESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->= id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation =3D readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-480.c index a70b8633bb3eb..4652e8b4cff58 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -452,41 +452,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8= wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } =20 -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - if (vfe->id >=3D camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss =3D vfe->camss; - - if (vfe->id >=3D camss->res->vfe_num) - return 0; - - vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 94267b9974554..5172eb5612a1c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -474,6 +474,40 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) complete(&vfe->reset_complete); } =20 +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe) +{ + if (!vfe->genpd) + return; + + device_link_del(vfe->genpd_link); + vfe->genpd_link =3D NULL; +} + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe) +{ + struct camss *camss =3D vfe->camss; + + if (!vfe->genpd) + return 0; + + vfe->genpd_link =3D device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) + return -EINVAL; + + return 0; +} + static int vfe_match_clock_names(struct vfe_device *vfe, struct camss_clock *clock) { diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/= platform/qcom/camss/camss-vfe.h index c1c50023d4876..992a2103ec44c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -203,6 +203,18 @@ int vfe_reset(struct vfe_device *vfe); */ int vfe_disable(struct vfe_line *line); =20 +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe); + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe); + extern const struct vfe_hw_ops vfe_ops_4_1; extern const struct vfe_hw_ops vfe_ops_4_7; extern const struct vfe_hw_ops vfe_ops_4_8; --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 AA700C5AD4C for ; Thu, 23 Nov 2023 17:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345369AbjKWRDO (ORCPT ); Thu, 23 Nov 2023 12:03:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345250AbjKWRDG (ORCPT ); Thu, 23 Nov 2023 12:03:06 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82CB2D67 for ; Thu, 23 Nov 2023 09:03:10 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-331733acbacso709815f8f.1 for ; Thu, 23 Nov 2023 09:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758989; x=1701363789; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TyWn2sWxlTw7Q4m48/J6zzoO/2iT3h6vpulSOl0sgCs=; b=YJtdT+YmXnIhouHywAi4cBznt6yjyWiPPYUu8LLOytzVHFRkQLo21hGIdMLF6cd4Rv 8DMx1EqGOPNSJjI8UIw9qFC3iy8w9Ntl4eEOOFJKJolGaK0wbsXGqAP+7sFb8k2A7ON6 lvYVdKeCUe62WHWeSb0Z977Xkpg2sJ8UVH+kiJdUtI4dxtk6YXZeA785q84JbcCtdObr cquuS5LNARySxQOpa5novOdDhl34/j4vI2oDrjfyG4cnwMqGaTvT+G9WkMXY49SDJDBL cactSPX+yE6ZIq4CWNQW/pUdtsLN4NU+K4GT65aHtxVbjdKQi4JRJka6n4NXxYm+RQuF HBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758989; x=1701363789; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TyWn2sWxlTw7Q4m48/J6zzoO/2iT3h6vpulSOl0sgCs=; b=ObNRfZjevrlL/FnmJLPB+9CEbjj1dSk/qRXFghiTD1dEOengmLyLU5D6Ds6bDSgMO5 8gMjPiJJrx34JLLc0LzAzcQAkj/zS0Ve+J8HRnDWYeSXCohJofshrcxopj31LFxitL3s 502p3DGJzMfqBSJM2dvjpZ+VvIn4PqnyewW5c65FNCjAr6hAfHV9Vjf2Vlv27sep1pb5 qFcC66fRnkeecvRH9+kzTlQCFwEcwS3poEHh1vCmcd/beBhGAEhgDLhMQP/lDRflwsGa 4ZqbI+E14BTaRQZPal9w/hnEd5sJ59WEHjLKuBPscAbvT6uQQ6Neo4AZ8lS79qAGTobx LZTw== X-Gm-Message-State: AOJu0YyR3KA/B4IyggOTCqmTp06vz5/KypJZD4c65YThsEHYLH1FJ+Gb EXFMmySvpfzhDXC5MJD2zS6U2w== X-Google-Smtp-Source: AGHT+IGoRDNG3Y2Y7PxYDIKNVIzgwP52fladAKcN1qHbzB/PK+KvafYLWpVHqldA1ebLNOZf9o060g== X-Received: by 2002:a5d:640e:0:b0:332:c9e7:3d16 with SMTP id z14-20020a5d640e000000b00332c9e73d16mr36403wru.54.1700758988995; Thu, 23 Nov 2023 09:03:08 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:07 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:03 +0000 Subject: [PATCH v6 4/8] media: qcom: camss: Move VFE power-domain specifics into vfe.c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-4-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving the location of the hooks to VFE power domains has several advantages. 1. Separation of concerns and functional decomposition. vfe.c should be responsible for and know best how manage power-domains for a VFE, excising from camss.c follows this principle. 2. Embedding a pointer to genpd in struct camss_vfe{} meas that we can dispense with a bunch of kmalloc array inside of camss.c. 3. Splitting up titan top gdsc from vfe/ife gdsc provides a base for breaking up magic indexes in dtsi. Suggested-by: Matti Lehtim=C3=A4ki Tested-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio Reviewed-by: Konrad Dybcio --- drivers/media/platform/qcom/camss/camss-vfe.c | 21 ++++++++- drivers/media/platform/qcom/camss/camss-vfe.h | 2 + drivers/media/platform/qcom/camss/camss.c | 67 ++++++++++++++---------= ---- drivers/media/platform/qcom/camss/camss.h | 4 +- 4 files changed, 59 insertions(+), 35 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 5172eb5612a1c..60c4730e7c9d1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1381,8 +1382,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct = vfe_device *vfe, if (!res->line_num) return -EINVAL; =20 - if (res->has_pd) - vfe->genpd =3D camss->genpd[id]; + if (res->has_pd) { + vfe->genpd =3D dev_pm_domain_attach_by_id(camss->dev, id); + if (IS_ERR(vfe->genpd)) + return PTR_ERR(vfe->genpd); + } =20 vfe->line_num =3D res->line_num; vfe->ops->subdev_init(dev, vfe); @@ -1506,6 +1510,19 @@ int msm_vfe_subdev_init(struct camss *camss, struct = vfe_device *vfe, return 0; } =20 +/* + * msm_vfe_genpd_cleanup - Cleanup VFE genpd linkages + * @vfe: VFE device + */ +void msm_vfe_genpd_cleanup(struct vfe_device *vfe) +{ + if (vfe->genpd_link) + device_link_del(vfe->genpd_link); + + if (vfe->genpd) + dev_pm_domain_detach(vfe->genpd, true); +} + /* * vfe_link_setup - Setup VFE connections * @entity: Pointer to media entity structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/= platform/qcom/camss/camss-vfe.h index 992a2103ec44c..cdbe59d8d437e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -159,6 +159,8 @@ struct camss_subdev_resources; int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, const struct camss_subdev_resources *res, u8 id); =20 +void msm_vfe_genpd_cleanup(struct vfe_device *vfe); + int msm_vfe_register_entities(struct vfe_device *vfe, struct v4l2_device *v4l2_dev); =20 diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index ed01a3ac7a38e..35918cf837bdd 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1486,7 +1486,9 @@ static const struct media_device_ops camss_media_ops = =3D { =20 static int camss_configure_pd(struct camss *camss) { + const struct camss_resources *res =3D camss->res; struct device *dev =3D camss->dev; + int vfepd_num; int i; int ret; =20 @@ -1506,45 +1508,41 @@ static int camss_configure_pd(struct camss *camss) if (camss->genpd_num =3D=3D 1) return 0; =20 - camss->genpd =3D devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd), GFP_KERNEL); - if (!camss->genpd) - return -ENOMEM; + /* count the # of VFEs which have flagged power-domain */ + for (vfepd_num =3D i =3D 0; i < camss->vfe_total_num; i++) { + if (res->vfe_res[i].has_pd) + vfepd_num++; + } =20 - camss->genpd_link =3D devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd_link), - GFP_KERNEL); - if (!camss->genpd_link) - return -ENOMEM; + /* + * If the number of power-domains is greater than the number of VFEs + * then the additional power-domain is for the entire CAMSS block. + */ + if (!(camss->genpd_num > vfepd_num)) + return 0; =20 /* * VFE power domains are in the beginning of the list, and while all * power domains should be attached, only if TITAN_TOP power domain is * found in the list, it should be linked over here. */ - for (i =3D 0; i < camss->genpd_num; i++) { - camss->genpd[i] =3D dev_pm_domain_attach_by_id(camss->dev, i); - if (IS_ERR(camss->genpd[i])) { - ret =3D PTR_ERR(camss->genpd[i]); - goto fail_pm; - } + camss->genpd =3D dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num = - 1); + if (IS_ERR(camss->genpd)) { + ret =3D PTR_ERR(camss->genpd); + goto fail_pm; } - - if (i > camss->res->vfe_num) { - camss->genpd_link[i - 1] =3D device_link_add(camss->dev, camss->genpd[i = - 1], - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[i - 1]) { - ret =3D -EINVAL; - goto fail_pm; - } + camss->genpd_link =3D device_link_add(camss->dev, camss->genpd, + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!camss->genpd_link) { + ret =3D -EINVAL; + goto fail_pm; } =20 return 0; =20 fail_pm: - for (--i ; i >=3D 0; i--) - dev_pm_domain_detach(camss->genpd[i], true); + dev_pm_domain_detach(camss->genpd, true); =20 return ret; } @@ -1566,18 +1564,25 @@ static int camss_icc_get(struct camss *camss) return 0; } =20 -static void camss_genpd_cleanup(struct camss *camss) +static void camss_genpd_subdevice_cleanup(struct camss *camss) { int i; =20 + for (i =3D 0; i < camss->vfe_total_num; i++) + msm_vfe_genpd_cleanup(&camss->vfe[i]); +} + +static void camss_genpd_cleanup(struct camss *camss) +{ if (camss->genpd_num =3D=3D 1) return; =20 - if (camss->genpd_num > camss->res->vfe_num) - device_link_del(camss->genpd_link[camss->genpd_num - 1]); + camss_genpd_subdevice_cleanup(camss); + + if (camss->genpd_link) + device_link_del(camss->genpd_link); =20 - for (i =3D 0; i < camss->genpd_num; i++) - dev_pm_domain_detach(camss->genpd[i], true); + dev_pm_domain_detach(camss->genpd, true); } =20 /* diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index b854cff1774d4..1ba824a2cb76c 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -107,8 +107,8 @@ struct camss { struct vfe_device *vfe; atomic_t ref_count; int genpd_num; - struct device **genpd; - struct device_link **genpd_link; + struct device *genpd; + struct device_link *genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; const struct camss_resources *res; unsigned int vfe_total_num; --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 DEE36C61D97 for ; Thu, 23 Nov 2023 17:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345383AbjKWRDS (ORCPT ); Thu, 23 Nov 2023 12:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345268AbjKWRDG (ORCPT ); Thu, 23 Nov 2023 12:03:06 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDE6B10C1 for ; Thu, 23 Nov 2023 09:03:11 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3316bb1303bso613221f8f.0 for ; Thu, 23 Nov 2023 09:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758990; x=1701363790; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KYgDwoAJq7y7oFUTHWIIkWneJ3qvbnWcKjXymT7sa6E=; b=X7pzJpLEqM+a7Ts7CN5/iomE6U46vZkxkqhgAPxtz/h9eTBPBlHut/VBhXjXbnipKA FvajjMCenS02klFjJzlG1d9bvylUrnQ6/ynEaJs8L++fcoP227etxu7xSz3i3S3RhcS3 HEF+02E4dKiXCrTF5Yp5YT6/Vduhey4pbWCFfcqWvw5YynWIpXwtKPt+PwxYgU1ebSf2 1jpVnGe8+0s0In+ceclgEIP3nykOelQXGEW9SoxZG1/+bppVnK6bIimsotiJ+tWyeSkF l5TKJQhr+AA3lvHEworxQojLvOL0N6qbdtyr3DeHFJt5Ajuz0n/obPqIgqtALZjAaaXn ++dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758990; x=1701363790; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KYgDwoAJq7y7oFUTHWIIkWneJ3qvbnWcKjXymT7sa6E=; b=jibSEu0x09DfYSZWOLkuooPaUxWmgYjjyCVa/TZjj2q0n6KArTPtlX/YSIY/KoCP1S fJFIN1PetJURS0GZO5UIp/GHCB1i4uLYOAlv4qWGpLfqti3oOzcHJQib5i+Jl+geZsMP +UHXrNPw8+aamWt9eflMcaKLk20Hs2W9cLdzuJk1Hq3fh4LStWnLbo4hiyoATr2d0X7L GzXXyU1lnYzfvAul/7uMsSnp5iwR1G8JZkZTNcb44Djs6mLPp32qdhjSkdyXxUlFTaIj cGZnisCb02Z/dIe90dSAEPLzVnCz6F/C+TwKzKfiIN/wStbmDtF7GErD6c+//oi0orx8 XQHQ== X-Gm-Message-State: AOJu0YxJHh90KjwBCtqwwiQh/BtNoj0jvYkY2A5P3WMTZsfJFO1Y3j90 fG8BidPbtR76LybxR4dhOkXE5w== X-Google-Smtp-Source: AGHT+IH1Vkw86Iv7kW71SUH5fgOm1NS7o8ehGiAsdoxdu0GDNgio32qmgxpH6qq9CWdpIqhiH9krlA== X-Received: by 2002:adf:f64b:0:b0:331:8e29:44e3 with SMTP id x11-20020adff64b000000b003318e2944e3mr43348wrp.58.1700758990247; Thu, 23 Nov 2023 09:03:10 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:09 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:04 +0000 Subject: [PATCH v6 5/8] media: qcom: camss: Add support for named power-domains MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-5-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right now we use fixed indexes to assign power-domains, with a requirement for the TOP GDSC to come last in the list. Adding support for named power-domains means the declaration in the dtsi can come in any order. After this change we continue to support the old indexing - if a SoC resource declaration or the in-use dtb doesn't declare power-domain names we fall back to the default legacy indexing. From this point on though new SoC additions should contain named power-domains, eventually we will drop support for legacy indexing. Tested-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe.c | 24 +++++++++++++++++++++++- drivers/media/platform/qcom/camss/camss.c | 26 +++++++++++++++++++++--= --- drivers/media/platform/qcom/camss/camss.h | 2 ++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 60c4730e7c9d1..083d1445a6e25 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1382,7 +1382,29 @@ int msm_vfe_subdev_init(struct camss *camss, struct = vfe_device *vfe, if (!res->line_num) return -EINVAL; =20 - if (res->has_pd) { + /* Power domain */ + + if (res->pd_name) { + vfe->genpd =3D dev_pm_domain_attach_by_name(camss->dev, + res->pd_name); + if (IS_ERR(vfe->genpd)) { + ret =3D PTR_ERR(vfe->genpd); + return ret; + } + } + + if (!vfe->genpd && res->has_pd) { + /* + * Legacy magic index. + * Requires + * power-domain =3D , + * , + * + * id must correspondng to the index of the VFE which must + * come before the TOP GDSC. VFE Lite has no individually + * collapasible domain which is why id < vfe_num is a valid + * check. + */ vfe->genpd =3D dev_pm_domain_attach_by_id(camss->dev, id); if (IS_ERR(vfe->genpd)) return PTR_ERR(vfe->genpd); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 35918cf837bdd..f2d2317c38b5b 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1522,12 +1522,28 @@ static int camss_configure_pd(struct camss *camss) return 0; =20 /* - * VFE power domains are in the beginning of the list, and while all - * power domains should be attached, only if TITAN_TOP power domain is - * found in the list, it should be linked over here. + * If a power-domain name is defined try to use it. + * It is possible we are running a new kernel with an old dtb so + * fallback to indexes even if a pd_name is defined but not found. */ - camss->genpd =3D dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num = - 1); - if (IS_ERR(camss->genpd)) { + if (camss->res->pd_name) { + camss->genpd =3D dev_pm_domain_attach_by_name(camss->dev, + camss->res->pd_name); + if (IS_ERR(camss->genpd)) { + ret =3D PTR_ERR(camss->genpd); + goto fail_pm; + } + } + + if (!camss->genpd) { + /* + * Legacy magic index. TITAN_TOP GDSC must be the last + * item in the power-domain list. + */ + camss->genpd =3D dev_pm_domain_attach_by_id(camss->dev, + camss->genpd_num - 1); + } + if (IS_ERR_OR_NULL(camss->genpd)) { ret =3D PTR_ERR(camss->genpd); goto fail_pm; } diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 1ba824a2cb76c..cd8186fe1797b 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -48,6 +48,7 @@ struct camss_subdev_resources { u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; + char *pd_name; u8 line_num; bool has_pd; const void *ops; @@ -84,6 +85,7 @@ enum icc_count { =20 struct camss_resources { enum camss_version version; + const char *pd_name; const struct camss_subdev_resources *csiphy_res; const struct camss_subdev_resources *csid_res; const struct camss_subdev_resources *ispif_res; --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 CF7A9C5AD4C for ; Thu, 23 Nov 2023 17:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345426AbjKWRDb (ORCPT ); Thu, 23 Nov 2023 12:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345186AbjKWRDX (ORCPT ); Thu, 23 Nov 2023 12:03:23 -0500 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E02D6C for ; Thu, 23 Nov 2023 09:03:13 -0800 (PST) Received: by mail-lj1-x244.google.com with SMTP id 38308e7fff4ca-2c878e228b4so13708391fa.1 for ; Thu, 23 Nov 2023 09:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758992; x=1701363792; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=K2oLvmaqR7ZQqKyuNCjR+v7IrIpMiJ4TCDxYGIq4gEE=; b=TBn9Khm8f4nrPtKYFStaddYoqSnii4lcXwX5cCEMD5FzJzzL7Qu3G8WGHb7VsNpnrX MQ/QzrBFCo5GUu5AujGpdS4XNUW3aOA5vD8QYrrJJlwCeDk+Fy6xNCQcloOSXXaNOOZF oZzFejonGw9/ZLmSDVltIEAXUWjzJOy3Z1CbJWjKRrx7P6vTTzDyGFUEnoc0mXFX+Sek FFE4r9S7P4OyO4Tnzo4Tz6jENLGI+mNl0UXw1HsoKpjiMmmNSJKQNgUhQ3//X6vhHqpf Mwsd4mgBVKkhYmyVSz/tENa79PhENLD0Dc89TqdXXd/gqDVQiOiUC1XdTnevO6J/JbhG T5uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758992; x=1701363792; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K2oLvmaqR7ZQqKyuNCjR+v7IrIpMiJ4TCDxYGIq4gEE=; b=GdcJCEvy4rxcyb9Z9Zjd6m9E+iEJz4V9WesuqFTMfC6XiDQvnWnoYFi+E8RuGmlA8/ QEpDhIjMQvCjgGa9p4B4fdC57pgSrvpvQm3B7YH3OAE1cUpCvd/wzQ7KC2MPxQvyKyfi tvbfbOGRAdICwLRvM6/qEQfUYlldDjW14FP24FzjKwkTSFlFM/UcRmZFqz2qAU3bvhF+ 7ciaE6MFQc3gfwzf3D/vYgtH46sOnPniwvxtK+mNsUoGaFwUl4IX2K+rL7LT52YO25fI 6yCm/nYzHDohPkAgOe4RIGGeXku1VMk8cyI8HlgH5n52NrKggLEiWxX4uoHQ6YGEfcT3 TK4A== X-Gm-Message-State: AOJu0YwSgtS+eUtEyrqQ3qy4gPnusBWkGLgpD5a6EOLishyWptASMwIh pfd4AZXY8a5JVqWi0WU6TsZfaA== X-Google-Smtp-Source: AGHT+IHy6ITM2gT4J9dAV6hIznwg0fVt/iGVOaabCg0wAaw5kvQqwYS70GTKrZlF+bdDTLiJVOSxMQ== X-Received: by 2002:a2e:a4a8:0:b0:2c8:3b12:776d with SMTP id g8-20020a2ea4a8000000b002c83b12776dmr4457576ljm.6.1700758991451; Thu, 23 Nov 2023 09:03:11 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:10 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:05 +0000 Subject: [PATCH v6 6/8] media: qcom: camss: Flag VFE-lites to support more VFEs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-6-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matti Lehtim=C3=A4ki Some platforms such as SC7280 have three VFEs and two VFE-lites. Current code has hard-coded two as the maximum number of VFEs. Remove the hard-coded maximum number of VFEs to handle all possible combinations of VFEs and VFE-lites. Signed-off-by: Matti Lehtim=C3=A4ki Reviewed-by: Konrad Dybcio Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202311200405.h6G4L9oe-lkp@int= el.com Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-480.c | 33 +++++++++++--------= ---- drivers/media/platform/qcom/camss/camss-vfe.c | 5 ++++ drivers/media/platform/qcom/camss/camss-vfe.h | 10 +++++++ drivers/media/platform/qcom/camss/camss.c | 26 +++++++++--------- drivers/media/platform/qcom/camss/camss.h | 3 +-- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-480.c index 4652e8b4cff58..dc2735476c823 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -15,31 +15,28 @@ #include "camss.h" #include "camss-vfe.h" =20 -/* VFE 2/3 are lite and have a different register layout */ -#define IS_LITE (vfe->id >=3D 2 ? 1 : 0) - #define VFE_HW_VERSION (0x00) =20 -#define VFE_GLOBAL_RESET_CMD (IS_LITE ? 0x0c : 0x1c) -#define GLOBAL_RESET_HW_AND_REG (IS_LITE ? BIT(1) : BIT(0)) +#define VFE_GLOBAL_RESET_CMD (vfe_is_lite(vfe) ? 0x0c : 0x1c) +#define GLOBAL_RESET_HW_AND_REG (vfe_is_lite(vfe) ? BIT(1) : BIT(0)) =20 -#define VFE_REG_UPDATE_CMD (IS_LITE ? 0x20 : 0x34) +#define VFE_REG_UPDATE_CMD (vfe_is_lite(vfe) ? 0x20 : 0x34) static inline int reg_update_rdi(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(n) : BIT(1 + (n)); + return vfe_is_lite(vfe) ? BIT(n) : BIT(1 + (n)); } =20 #define REG_UPDATE_RDI reg_update_rdi -#define VFE_IRQ_CMD (IS_LITE ? 0x24 : 0x38) +#define VFE_IRQ_CMD (vfe_is_lite(vfe) ? 0x24 : 0x38) #define IRQ_CMD_GLOBAL_CLEAR BIT(0) =20 -#define VFE_IRQ_MASK(n) ((IS_LITE ? 0x28 : 0x3c) + (n) * 4) -#define IRQ_MASK_0_RESET_ACK (IS_LITE ? BIT(17) : BIT(0)) -#define IRQ_MASK_0_BUS_TOP_IRQ (IS_LITE ? BIT(4) : BIT(7)) -#define VFE_IRQ_CLEAR(n) ((IS_LITE ? 0x34 : 0x48) + (n) * 4) -#define VFE_IRQ_STATUS(n) ((IS_LITE ? 0x40 : 0x54) + (n) * 4) +#define VFE_IRQ_MASK(n) ((vfe_is_lite(vfe) ? 0x28 : 0x3c) + (n) * 4) +#define IRQ_MASK_0_RESET_ACK (vfe_is_lite(vfe) ? BIT(17) : BIT(0)) +#define IRQ_MASK_0_BUS_TOP_IRQ (vfe_is_lite(vfe) ? BIT(4) : BIT(7)) +#define VFE_IRQ_CLEAR(n) ((vfe_is_lite(vfe) ? 0x34 : 0x48) + (n) * 4) +#define VFE_IRQ_STATUS(n) ((vfe_is_lite(vfe) ? 0x40 : 0x54) + (n) * 4) =20 -#define BUS_REG_BASE (IS_LITE ? 0x1a00 : 0xaa00) +#define BUS_REG_BASE (vfe_is_lite(vfe) ? 0x1a00 : 0xaa00) =20 #define VFE_BUS_WM_CGC_OVERRIDE (BUS_REG_BASE + 0x08) #define WM_CGC_OVERRIDE_ALL (0x3FFFFFF) @@ -49,13 +46,13 @@ static inline int reg_update_rdi(struct vfe_device *vfe= , int n) #define VFE_BUS_IRQ_MASK(n) (BUS_REG_BASE + 0x18 + (n) * 4) static inline int bus_irq_mask_0_rdi_rup(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(n) : BIT(3 + (n)); + return vfe_is_lite(vfe) ? BIT(n) : BIT(3 + (n)); } =20 #define BUS_IRQ_MASK_0_RDI_RUP bus_irq_mask_0_rdi_rup static inline int bus_irq_mask_0_comp_done(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(4 + (n)) : BIT(6 + (n)); + return vfe_is_lite(vfe) ? BIT(4 + (n)) : BIT(6 + (n)); } =20 #define BUS_IRQ_MASK_0_COMP_DONE bus_irq_mask_0_comp_done @@ -90,8 +87,8 @@ static inline int bus_irq_mask_0_comp_done(struct vfe_dev= ice *vfe, int n) /* for titan 480, each bus client is hardcoded to a specific path * and each bus client is part of a hardcoded "comp group" */ -#define RDI_WM(n) ((IS_LITE ? 0 : 23) + (n)) -#define RDI_COMP_GROUP(n) ((IS_LITE ? 0 : 11) + (n)) +#define RDI_WM(n) ((vfe_is_lite(vfe) ? 0 : 23) + (n)) +#define RDI_COMP_GROUP(n) ((vfe_is_lite(vfe) ? 0 : 11) + (n)) =20 #define MAX_VFE_OUTPUT_LINES 4 =20 diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 083d1445a6e25..b6ec0dc425b2d 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1739,3 +1739,8 @@ void msm_vfe_unregister_entities(struct vfe_device *v= fe) media_entity_cleanup(&sd->entity); } } + +bool vfe_is_lite(struct vfe_device *vfe) +{ + return vfe->camss->res->vfe_res[vfe->id].is_lite; +} diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/= platform/qcom/camss/camss-vfe.h index cdbe59d8d437e..0572c9b08e112 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -226,4 +226,14 @@ extern const struct vfe_hw_ops vfe_ops_480; int vfe_get(struct vfe_device *vfe); void vfe_put(struct vfe_device *vfe); =20 +/* + * vfe_is_lite - Return if VFE is VFE lite. + * @vfe: VFE Device + * + * Some VFE lites have a different register layout. + * + * Return whether VFE is VFE lite + */ +bool vfe_is_lite(struct vfe_device *vfe); + #endif /* QC_MSM_CAMSS_VFE_H */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index f2d2317c38b5b..7c49654a12964 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -706,6 +706,7 @@ static const struct camss_subdev_resources vfe_res_845[= ] =3D { { 384000000 } }, .reg =3D { "vfe_lite" }, .interrupt =3D { "vfe_lite" }, + .is_lite =3D true, .line_num =3D 4, .ops =3D &vfe_ops_170 } @@ -886,6 +887,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { { 0 } }, .reg =3D { "vfe_lite0" }, .interrupt =3D { "vfe_lite0" }, + .is_lite =3D true, .line_num =3D 4, .ops =3D &vfe_ops_480 }, @@ -905,6 +907,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { { 0 } }, .reg =3D { "vfe_lite1" }, .interrupt =3D { "vfe_lite1" }, + .is_lite =3D true, .line_num =3D 4, .ops =3D &vfe_ops_480 }, @@ -1204,7 +1207,7 @@ static int camss_init_subdevices(struct camss *camss) } =20 /* note: SM8250 requires VFE to be initialized before CSID */ - for (i =3D 0; i < camss->vfe_total_num; i++) { + for (i =3D 0; i < camss->res->vfe_num; i++) { ret =3D msm_vfe_subdev_init(camss, &camss->vfe[i], &res->vfe_res[i], i); if (ret < 0) { @@ -1276,7 +1279,7 @@ static int camss_register_entities(struct camss *cams= s) goto err_reg_ispif; } =20 - for (i =3D 0; i < camss->vfe_total_num; i++) { + for (i =3D 0; i < camss->res->vfe_num; i++) { ret =3D msm_vfe_register_entities(&camss->vfe[i], &camss->v4l2_dev); if (ret < 0) { @@ -1348,7 +1351,7 @@ static int camss_register_entities(struct camss *cams= s) } } else { for (i =3D 0; i < camss->res->csid_num; i++) - for (k =3D 0; k < camss->vfe_total_num; k++) + for (k =3D 0; k < camss->res->vfe_num; k++) for (j =3D 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *csid =3D &camss->csid[i].subdev; struct v4l2_subdev *vfe =3D &camss->vfe[k].line[j].subdev; @@ -1372,7 +1375,7 @@ static int camss_register_entities(struct camss *cams= s) return 0; =20 err_link: - i =3D camss->vfe_total_num; + i =3D camss->res->vfe_num; err_reg_vfe: for (i--; i >=3D 0; i--) msm_vfe_unregister_entities(&camss->vfe[i]); @@ -1411,7 +1414,7 @@ static void camss_unregister_entities(struct camss *c= amss) =20 msm_ispif_unregister_entities(camss->ispif); =20 - for (i =3D 0; i < camss->vfe_total_num; i++) + for (i =3D 0; i < camss->res->vfe_num; i++) msm_vfe_unregister_entities(&camss->vfe[i]); } =20 @@ -1509,7 +1512,7 @@ static int camss_configure_pd(struct camss *camss) return 0; =20 /* count the # of VFEs which have flagged power-domain */ - for (vfepd_num =3D i =3D 0; i < camss->vfe_total_num; i++) { + for (vfepd_num =3D i =3D 0; i < camss->res->vfe_num; i++) { if (res->vfe_res[i].has_pd) vfepd_num++; } @@ -1584,7 +1587,7 @@ static void camss_genpd_subdevice_cleanup(struct cams= s *camss) { int i; =20 - for (i =3D 0; i < camss->vfe_total_num; i++) + for (i =3D 0; i < camss->res->vfe_num; i++) msm_vfe_genpd_cleanup(&camss->vfe[i]); } =20 @@ -1641,8 +1644,7 @@ static int camss_probe(struct platform_device *pdev) return -ENOMEM; } =20 - camss->vfe_total_num =3D camss->res->vfe_num + camss->res->vfe_lite_num; - camss->vfe =3D devm_kcalloc(dev, camss->vfe_total_num, + camss->vfe =3D devm_kcalloc(dev, camss->res->vfe_num, sizeof(*camss->vfe), GFP_KERNEL); if (!camss->vfe) return -ENOMEM; @@ -1800,8 +1802,7 @@ static const struct camss_resources sdm845_resources = =3D { .vfe_res =3D vfe_res_845, .csiphy_num =3D ARRAY_SIZE(csiphy_res_845), .csid_num =3D ARRAY_SIZE(csid_res_845), - .vfe_num =3D 2, - .vfe_lite_num =3D 1, + .vfe_num =3D ARRAY_SIZE(vfe_res_845), }; =20 static const struct camss_resources sm8250_resources =3D { @@ -1813,8 +1814,7 @@ static const struct camss_resources sm8250_resources = =3D { .icc_path_num =3D ARRAY_SIZE(icc_res_sm8250), .csiphy_num =3D ARRAY_SIZE(csiphy_res_8250), .csid_num =3D ARRAY_SIZE(csid_res_8250), - .vfe_num =3D 2, - .vfe_lite_num =3D 2, + .vfe_num =3D ARRAY_SIZE(vfe_res_8250), }; =20 static const struct of_device_id camss_dt_match[] =3D { diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index cd8186fe1797b..a0c2dcc779f05 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -51,6 +51,7 @@ struct camss_subdev_resources { char *pd_name; u8 line_num; bool has_pd; + bool is_lite; const void *ops; }; =20 @@ -95,7 +96,6 @@ struct camss_resources { const unsigned int csiphy_num; const unsigned int csid_num; const unsigned int vfe_num; - const unsigned int vfe_lite_num; }; =20 struct camss { @@ -113,7 +113,6 @@ struct camss { struct device_link *genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; const struct camss_resources *res; - unsigned int vfe_total_num; }; =20 struct camss_camera_interface { --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 6C6BAC5AD4C for ; Thu, 23 Nov 2023 17:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345140AbjKWRDg (ORCPT ); Thu, 23 Nov 2023 12:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345412AbjKWRDY (ORCPT ); Thu, 23 Nov 2023 12:03:24 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 628E31A8 for ; Thu, 23 Nov 2023 09:03:14 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40b36e31b57so5731775e9.3 for ; Thu, 23 Nov 2023 09:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758992; x=1701363792; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lK2SI9aHXKsbBQPMSODnSDZ93FbVmuXumfrpjOscrSE=; b=wNaPuiPy35ox6m5EMw2FFM9JLv4B0SE1sMRx+IHZXJNxN5hINuS2hRHuJBd/gbuDeJ ppebC5S/QdQfCyhl1fdsC5V3NFcSXaMLvN2ZK0nticR76mB6shTDMf/8T1xjXWIml9YI By1q+tLkwoSivJExrlhM7DUo6ut3dLXMAKeLUsAU0mfuJDLkJA9AS1aZo4scupNvpuCi /BS6LTt84nytjbqFAh2KzTcUjesH5/aGE57wN2nRaSy6zpOYSD0Qlw33S7w8YCmHBjFN mlhLt6H+GZmi8tfwOqir7x8fpSew05w6L2HyeJK4utrg3hh8ADwDbmqKix6D3pBeSPRH G9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758992; x=1701363792; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lK2SI9aHXKsbBQPMSODnSDZ93FbVmuXumfrpjOscrSE=; b=hLUHIAEkB3ycJAB4NnmaChtbzvcanAcHLA3MckEgVNXaVr1TpCob4W+dUdaQ6qRSlY aGuoaM5Dxxo2CnNgiyHmRjk0mzZ3WKvFQzv44T0qgFnpckOCV4LXww2ttVWBl3UTzwuK 6FjlqL1iFZZARUywIZkLDA+0wmLyG9yPqbanfC3B85lEiyfQV85KBrusws7Be1RFZOjo aXByJQc6c1fB/1RZQwgTozahphROpPEI+MubYzio2yV2h40BPeZKa3yfAEoTq7jIjenp i2QAqwMkEu9Tz2GXAdJ4E5pBCvtQ7iMI/kbkXveQ4Fu2hbkHDrz7h+0uuECE/CQiiOE3 dmSw== X-Gm-Message-State: AOJu0YzJAypSPz98JdqfO9tFvpIyWNTYeu+C59twswuhYAEFLs4SU85s IJlIfn4Th84yOQ1gQhLqt+D2og== X-Google-Smtp-Source: AGHT+IH53IcrTy1ooYVyzwy4btXf3w7oCDF53B0r9Iyb7M7ljWIwbZ62fzNNWwGFLKw3Yb1IvjMfAQ== X-Received: by 2002:adf:f388:0:b0:332:c768:8aff with SMTP id m8-20020adff388000000b00332c7688affmr90825wro.3.1700758992617; Thu, 23 Nov 2023 09:03:12 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:12 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:06 +0000 Subject: [PATCH v6 7/8] media: qcom: camss: Flag CSID-lites to support more CSIDs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-7-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matti Lehtim=C3=A4ki Some platforms such as SC7280 have 3 CSIDs and 2 CSID-lites but current code has hardcoded 2 as the maximum number of CSIDs. Remove the hardcoded maximum number of VFEs to handle all possible combinations of CSIDs and CSID-lites. Signed-off-by: Matti Lehtim=C3=A4ki Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio --- .../media/platform/qcom/camss/camss-csid-gen2.c | 31 +++++++++++-------= ---- drivers/media/platform/qcom/camss/camss-csid.c | 5 ++++ drivers/media/platform/qcom/camss/camss-csid.h | 7 +++++ drivers/media/platform/qcom/camss/camss.c | 3 +++ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/= media/platform/qcom/camss/camss-csid-gen2.c index 05ff5fa8095a8..b11de4797ccae 100644 --- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c +++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c @@ -21,7 +21,6 @@ * interface support. As a result of that it has an * alternate register layout. */ -#define IS_LITE (csid->id >=3D 2 ? 1 : 0) =20 #define CSID_HW_VERSION 0x0 #define HW_VERSION_STEPPING 0 @@ -35,13 +34,13 @@ #define CSID_CSI2_RX_IRQ_MASK 0x24 #define CSID_CSI2_RX_IRQ_CLEAR 0x28 =20 -#define CSID_CSI2_RDIN_IRQ_STATUS(rdi) ((IS_LITE ? 0x30 : 0x40) \ +#define CSID_CSI2_RDIN_IRQ_STATUS(rdi) ((csid_is_lite(csid) ? 0x30 : 0x40= ) \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_MASK(rdi) ((IS_LITE ? 0x34 : 0x44) \ +#define CSID_CSI2_RDIN_IRQ_MASK(rdi) ((csid_is_lite(csid) ? 0x34 : 0x44) \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_CLEAR(rdi) ((IS_LITE ? 0x38 : 0x48) \ +#define CSID_CSI2_RDIN_IRQ_CLEAR(rdi) ((csid_is_lite(csid) ? 0x38 : 0x48)= \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_SET(rdi) ((IS_LITE ? 0x3C : 0x4C) \ +#define CSID_CSI2_RDIN_IRQ_SET(rdi) ((csid_is_lite(csid) ? 0x3C : 0x4C) \ + 0x10 * (rdi)) =20 #define CSID_TOP_IRQ_STATUS 0x70 @@ -73,7 +72,7 @@ #define CGC_MODE_DYNAMIC_GATING 0 #define CGC_MODE_ALWAYS_ON 1 =20 -#define CSID_RDI_CFG0(rdi) ((IS_LITE ? 0x200 : 0x300) \ +#define CSID_RDI_CFG0(rdi) ((csid_is_lite(csid) ? 0x200 : 0x300) \ + 0x100 * (rdi)) #define RDI_CFG0_BYTE_CNTR_EN 0 #define RDI_CFG0_FORMAT_MEASURE_EN 1 @@ -98,32 +97,32 @@ #define RDI_CFG0_PACKING_FORMAT 30 #define RDI_CFG0_ENABLE 31 =20 -#define CSID_RDI_CFG1(rdi) ((IS_LITE ? 0x204 : 0x304)\ +#define CSID_RDI_CFG1(rdi) ((csid_is_lite(csid) ? 0x204 : 0x304)\ + 0x100 * (rdi)) #define RDI_CFG1_TIMESTAMP_STB_SEL 0 =20 -#define CSID_RDI_CTRL(rdi) ((IS_LITE ? 0x208 : 0x308)\ +#define CSID_RDI_CTRL(rdi) ((csid_is_lite(csid) ? 0x208 : 0x308)\ + 0x100 * (rdi)) #define RDI_CTRL_HALT_CMD 0 #define HALT_CMD_HALT_AT_FRAME_BOUNDARY 0 #define HALT_CMD_RESUME_AT_FRAME_BOUNDARY 1 #define RDI_CTRL_HALT_MODE 2 =20 -#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((IS_LITE ? 0x20C : 0x30C)\ +#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x20C : 0x= 30C)\ + 0x100 * (rdi)) -#define CSID_RDI_FRM_DROP_PERIOD(rdi) ((IS_LITE ? 0x210 : 0x310)\ +#define CSID_RDI_FRM_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x210 : 0x3= 10)\ + 0x100 * (rdi)) -#define CSID_RDI_IRQ_SUBSAMPLE_PATTERN(rdi) ((IS_LITE ? 0x214 : 0x314)\ +#define CSID_RDI_IRQ_SUBSAMPLE_PATTERN(rdi) ((csid_is_lite(csid) ? 0x214 = : 0x314)\ + 0x100 * (rdi)) -#define CSID_RDI_IRQ_SUBSAMPLE_PERIOD(rdi) ((IS_LITE ? 0x218 : 0x318)\ +#define CSID_RDI_IRQ_SUBSAMPLE_PERIOD(rdi) ((csid_is_lite(csid) ? 0x218 := 0x318)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_PIX_DROP_PATTERN(rdi) ((IS_LITE ? 0x224 : 0x324)\ +#define CSID_RDI_RPP_PIX_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x224 := 0x324)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_PIX_DROP_PERIOD(rdi) ((IS_LITE ? 0x228 : 0x328)\ +#define CSID_RDI_RPP_PIX_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x228 : = 0x328)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_LINE_DROP_PATTERN(rdi) ((IS_LITE ? 0x22C : 0x32C)\ +#define CSID_RDI_RPP_LINE_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x22C = : 0x32C)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_LINE_DROP_PERIOD(rdi) ((IS_LITE ? 0x230 : 0x330)\ +#define CSID_RDI_RPP_LINE_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x230 := 0x330)\ + 0x100 * (rdi)) =20 #define CSID_TPG_CTRL 0x600 diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media= /platform/qcom/camss/camss-csid.c index 95873f988f7e2..d393618ed54cb 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -897,3 +897,8 @@ void msm_csid_unregister_entity(struct csid_device *csi= d) media_entity_cleanup(&csid->subdev.entity); v4l2_ctrl_handler_free(&csid->ctrls); } + +inline bool csid_is_lite(struct csid_device *csid) +{ + return csid->camss->res->csid_res[csid->id].is_lite; +} diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media= /platform/qcom/camss/camss-csid.h index 30d94eb2eb041..fddccb69da13a 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.h +++ b/drivers/media/platform/qcom/camss/camss-csid.h @@ -215,5 +215,12 @@ extern const struct csid_hw_ops csid_ops_4_1; extern const struct csid_hw_ops csid_ops_4_7; extern const struct csid_hw_ops csid_ops_gen2; =20 +/* + * csid_is_lite - Check if CSID is CSID lite. + * @csid: CSID Device + * + * Return whether CSID is CSID lite + */ +bool csid_is_lite(struct csid_device *csid); =20 #endif /* QC_MSM_CAMSS_CSID_H */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 7c49654a12964..942db0dffa59f 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -638,6 +638,7 @@ static const struct camss_subdev_resources csid_res_845= [] =3D { { 384000000 } }, .reg =3D { "csid2" }, .interrupt =3D { "csid2" }, + .is_lite =3D true, .ops =3D &csid_ops_gen2 } }; @@ -812,6 +813,7 @@ static const struct camss_subdev_resources csid_res_825= 0[] =3D { { 0 } }, .reg =3D { "csid2" }, .interrupt =3D { "csid2" }, + .is_lite =3D true, .ops =3D &csid_ops_gen2 }, /* CSID3 */ @@ -824,6 +826,7 @@ static const struct camss_subdev_resources csid_res_825= 0[] =3D { { 0 } }, .reg =3D { "csid3" }, .interrupt =3D { "csid3" }, + .is_lite =3D true, .ops =3D &csid_ops_gen2 } }; --=20 2.42.0 From nobody Wed Dec 17 09:50:03 2025 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 569A7C5AD4C for ; Thu, 23 Nov 2023 17:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345468AbjKWRDl (ORCPT ); Thu, 23 Nov 2023 12:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345436AbjKWRDZ (ORCPT ); Thu, 23 Nov 2023 12:03:25 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B3310F0 for ; Thu, 23 Nov 2023 09:03:15 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40b2b3da41eso7254395e9.3 for ; Thu, 23 Nov 2023 09:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758994; x=1701363794; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ib96ZmK5LO+Py4E9hj9+63+qAtneu0ywuXljodtPMuY=; b=U6x5YaXszv099+Rk8xUiToMirZjVQ4Cefr3zDfKmRhXwx3YnbIuJ/jbZtuuAPKDzBU kXf5v2RRD6UDJESXHk3GD7a2oc45RqS0K5QKm+0ikTSM97o+I4ViNzpYHk6bGAOrnK4n HLZmms2usNkO9wV05qluLhOsaoW6sswIAS9xK47HFZeBOgohZIc9gDQ1yhgQpClzYyMD WlBF9DVqlHNkNj/0Ad/ENKrZ1GEpFpdXihJemXBcuuMQ3LU4ROamgjJbgUk8fI5Rean5 OHl4gVDnQ5Im5Fdy9f5u3+fNt13dlsi8brLIVC98JjEWdTVO2cu55FuMK7sXxoLA6cLs oyyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758994; x=1701363794; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ib96ZmK5LO+Py4E9hj9+63+qAtneu0ywuXljodtPMuY=; b=emTv8fXvujdxZRXoR5VzDiYRS6o+eKKmjv/GknywvL0DIwveHmyyFY9MNVMBht7REN u6OO7n2vQX3acVUJAjMtuH6WNQtw8oA4cAYo/UkZyOiv1rZlEiy5uJTJst3SAPyTYcAd UI6xKx1HmA3d1fqRR/tuU2OrZv+lcY1oFUMb+OI/DpXABcW51phDx/NVhZ8jAP4/+BLc DvGuNIDl1ePzG0Ig1pCjNt1eKCq1nmu3ERrHRndkdiOW0Cob8m56CStTb8gND/7yoyWX bxr0icZ1Yf9Dae4ePVW+V6c7rhcuOndSAlRWkxalQeUAtvrFj5V2yAtlNQuCTlHs0mWZ 0Ogw== X-Gm-Message-State: AOJu0YxmLpZL8MsWVTJD6xwD6RFjYU5IcEa0UsPa7shqKzChOjpHruXW ue15VGfbnzzDFETEIAljvG+cZg== X-Google-Smtp-Source: AGHT+IE2ZsqjgtFXfB0jHpQJO9dliYDAYlVpzG4gO7GaQKDTrmrF47UPTmiVBiwsPE265TSI2nmWKg== X-Received: by 2002:a05:600c:3505:b0:405:3d41:5646 with SMTP id h5-20020a05600c350500b004053d415646mr159586wmq.2.1700758993999; Thu, 23 Nov 2023 09:03:13 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:13 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:07 +0000 Subject: [PATCH v6 8/8] media: qcom: camss: Add sm8250 named power-domain support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231123-b4-camss-named-power-domains-v6-8-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Declare power-domain names "top", "ife0" and "ife1" eponymously for the power-domains TITAN_TOP_GDSC, IFE_0_GDSC and IFE_1_GDSC respectively. Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio --- drivers/media/platform/qcom/camss/camss.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 942db0dffa59f..3bb23fd29959c 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -849,6 +849,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { { 0 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, + .pd_name =3D "ife0", .line_num =3D 3, .has_pd =3D true, .ops =3D &vfe_ops_480 @@ -870,6 +871,7 @@ static const struct camss_subdev_resources vfe_res_8250= [] =3D { { 0 } }, .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, + .pd_name =3D "ife1", .line_num =3D 3, .has_pd =3D true, .ops =3D &vfe_ops_480 @@ -1810,6 +1812,7 @@ static const struct camss_resources sdm845_resources = =3D { =20 static const struct camss_resources sm8250_resources =3D { .version =3D CAMSS_8250, + .pd_name =3D "top", .csiphy_res =3D csiphy_res_8250, .csid_res =3D csid_res_8250, .vfe_res =3D vfe_res_8250, --=20 2.42.0