From patchwork Mon Jul 4 22:15:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 587540 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 122C0CCA479 for ; Mon, 4 Jul 2022 22:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbiGDWQA (ORCPT ); Mon, 4 Jul 2022 18:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiGDWP7 (ORCPT ); Mon, 4 Jul 2022 18:15:59 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6A6B484 for ; Mon, 4 Jul 2022 15:15:57 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id s14so12455444ljs.3 for ; Mon, 04 Jul 2022 15:15:57 -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=qMaaTD6K4yj5INE84+CHyBEn/aNUZ8YByRBxEmdS9GY=; b=cZp6xF6fylogO2aUg0wHko3yH//q6LGiNN+1IhlU5LoNjPWOdFXC/fN7M+HvJCPI0y DuRRYMcYzsNxaAJE8LrLYwXZ2FAqm4rHYwxLXwv90mXG2xjU7zh1UEA4cKSDcxb6FYo1 VOVY/CbVp7RWZf8Ir1LlHmHBz8fZODr1Ux4BZca2Y5BCbkHd/tDcbW84CdKJSpyPCCvN tNAki2maSPNLYOqlNoUo/s32SAkgKC9EKj8d61NpyakLy4y40MG5hOcpkB134FrQ/aSE 65y42G/QjTEHdCrgtZD2tROEhuflMESL/V04XO9nQDQz/EgWbZGcWMwktYOsz20aHGLn PRQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qMaaTD6K4yj5INE84+CHyBEn/aNUZ8YByRBxEmdS9GY=; b=HiOXGRA6d0WxxM8PDk2jhSgsb/9akF1sYqlriWZMOdYo6JEg7zowGWmCORY9BfReFz wW1a4F5wYdtHN0ulgw3v468FOSlZpH3QjsB+6TN6QWo/bpIYnzIcQuAMhrYb57wPsMiD c3rAANxDkl6GKyM+v9E+C9bQoH9Dif6I1eCtHuMs2YNJ9RPe/3O7LgFTZoi2t2MQ4yip rZpbJ83AUQaMp4Ws+I125D4Ws6zx47POIm2UKVEZOr+CPIdnwGusFivRI3WCbIygmh9f WSJQ6UAsnmmaUcWD8VSjDBds5qc6JMT08tXZ3u7x9OvrV9dyzcsKDmUSJ0UDuy7qzjBb 7OaA== X-Gm-Message-State: AJIora/iOSPAZvWT0tIxmoWs5Z3uf3K03PulPVlvC5viY13yTVNiyZ7M gdrYqzSsOpRjogyTt0q5FykdIw== X-Google-Smtp-Source: AGRyM1uFR3sxlz1crihojTuAgbEK6rvojI9bAu9oS76JB1qsAORtNrh7zczoLh7mVZr9RliEguiU/Q== X-Received: by 2002:a2e:b004:0:b0:25a:8d4e:a3f6 with SMTP id y4-20020a2eb004000000b0025a8d4ea3f6mr18256085ljk.70.1656972956285; Mon, 04 Jul 2022 15:15:56 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id o13-20020ac25e2d000000b0047f660822e0sm5319931lfg.289.2022.07.04.15.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 15:15:56 -0700 (PDT) From: Vladimir Zapolskiy To: Robert Foss , Bryan O'Donoghue , Todor Tomov Cc: Bjorn Andersson , Andy Gross , Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/2] media: camss: Collect information about a number of lite VFEs Date: Tue, 5 Jul 2022 01:15:47 +0300 Message-Id: <20220704221548.629302-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220704221548.629302-1-vladimir.zapolskiy@linaro.org> References: <20220704221548.629302-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org VFE lite IPs are found on CAMSS with TITAN_TOP power domains, and in some aspects these types of VFEs are different, in particular there is no need to enable VFE power domains to operate over VFE lite IPs. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- drivers/media/platform/qcom/camss/camss.c | 20 +++++++++++--------- drivers/media/platform/qcom/camss/camss.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 7a929f19e79b..795eebd9af6c 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1170,7 +1170,7 @@ static int camss_init_subdevices(struct camss *camss) } /* note: SM8250 requires VFE to be initialized before CSID */ - for (i = 0; i < camss->vfe_num; i++) { + for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { ret = msm_vfe_subdev_init(camss, &camss->vfe[i], &vfe_res[i], i); if (ret < 0) { @@ -1242,7 +1242,7 @@ static int camss_register_entities(struct camss *camss) goto err_reg_ispif; } - for (i = 0; i < camss->vfe_num; i++) { + for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { ret = msm_vfe_register_entities(&camss->vfe[i], &camss->v4l2_dev); if (ret < 0) { @@ -1314,7 +1314,7 @@ static int camss_register_entities(struct camss *camss) } } else { for (i = 0; i < camss->csid_num; i++) - for (k = 0; k < camss->vfe_num; k++) + for (k = 0; k < camss->vfe_num + camss->vfe_lite_num; k++) for (j = 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *csid = &camss->csid[i].subdev; struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; @@ -1338,7 +1338,7 @@ static int camss_register_entities(struct camss *camss) return 0; err_link: - i = camss->vfe_num; + i = camss->vfe_num + camss->vfe_lite_num; err_reg_vfe: for (i--; i >= 0; i--) msm_vfe_unregister_entities(&camss->vfe[i]); @@ -1377,7 +1377,7 @@ static void camss_unregister_entities(struct camss *camss) msm_ispif_unregister_entities(camss->ispif); - for (i = 0; i < camss->vfe_num; i++) + for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) msm_vfe_unregister_entities(&camss->vfe[i]); } @@ -1579,13 +1579,15 @@ static int camss_probe(struct platform_device *pdev) camss->version = CAMSS_845; camss->csiphy_num = 4; camss->csid_num = 3; - camss->vfe_num = 3; + camss->vfe_num = 2; + camss->vfe_lite_num = 1; } else if (of_device_is_compatible(dev->of_node, "qcom,sm8250-camss")) { camss->version = CAMSS_8250; camss->csiphy_num = 6; camss->csid_num = 4; - camss->vfe_num = 4; + camss->vfe_num = 2; + camss->vfe_lite_num = 2; } else { return -EINVAL; } @@ -1607,8 +1609,8 @@ static int camss_probe(struct platform_device *pdev) return -ENOMEM; } - camss->vfe = devm_kcalloc(dev, camss->vfe_num, sizeof(*camss->vfe), - GFP_KERNEL); + camss->vfe = devm_kcalloc(dev, camss->vfe_num + camss->vfe_lite_num, + sizeof(*camss->vfe), GFP_KERNEL); if (!camss->vfe) return -ENOMEM; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 0db80cadbbaa..3acd2b3403e8 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -97,6 +97,7 @@ struct camss { struct csid_device *csid; struct ispif_device *ispif; int vfe_num; + int vfe_lite_num; struct vfe_device *vfe; atomic_t ref_count; int genpd_num; From patchwork Mon Jul 4 22:15:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 587147 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 B9F60C43334 for ; Mon, 4 Jul 2022 22:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbiGDWQB (ORCPT ); Mon, 4 Jul 2022 18:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbiGDWQA (ORCPT ); Mon, 4 Jul 2022 18:16:00 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D283663CD for ; Mon, 4 Jul 2022 15:15:58 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id a13so17632126lfr.10 for ; Mon, 04 Jul 2022 15:15:58 -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=0Et5zSnUjb9Vbw9zKwungPD4S4Sn12m5sCI/BTFYnGg=; b=wfmydPEJU94kzohYIYDa9N7AxHy9mfImDiKTsMkO2HZV2ORGwM/45OnuuPkmduN0l0 7MECdhpyNyWEBDA8qEZLkWMfj7SLAEYCgZpthtKMi1uza5Z1u/5prktGMGoUq+vmivYt XPSlAMMXMu8128qNv8luGzBjyVxOwlGrbKwxrvc3dXqfbvecM9J23pZ7wAGfAwpHOSye O1aY8dnswInPiMwDgTweWUzly+ZvyR9yY7ItWJe/wm6EC/OjgTxq8OCw6YfhbLEkX82U x/QHGk9v2ATaurVKGE376qDTp9+M8XS0Q4JFypXPePtynJmTp6b5DWL3DJCM0BXa4eYg le5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Et5zSnUjb9Vbw9zKwungPD4S4Sn12m5sCI/BTFYnGg=; b=FqRE9C1470imfgphROKEwD3e1bekweTnC2JLfonr8ROX2yNfLwmAGUYVBVm2An2Bho JegV1yKva4CC9z9m6RxnJSY3D5h+PR1OgyD42XB8jDOnMh+EjRmL5qEwjl4xo00yJVqD aqKjRoeiuj+ZyQfkmSPK+L0xVGlcn6R0rIHN+nOvvaHD78cFMbqBz8/le3RxHxkpk8+d WId7epRCtzi2w3H0MkWoZXEN4yNHQPIIsz5RLajoTyC4dXjnfd2WcIwqZW2LXoHU4T2H WmogaLQQKh0l0X9uy07RaEnREYA+TXD60/lufiOluNHH1rHjDWPjYBPn7jKpANid28iU QKYg== X-Gm-Message-State: AJIora8eZ7UEUTsHBe1sWGbVQIai++L5CfVpEOSTIhxo85lvMpUWaHrN g140TCOZMX0qYGxWjPa52Qq46g== X-Google-Smtp-Source: AGRyM1spudlSV3k6+r9Wc7PmnnKaV3A6USLu0C9Bl5I/oQ3zhXoEoGMw5qY7/Il3Dij/8bFuHzkugg== X-Received: by 2002:a05:6512:128f:b0:480:fd23:6647 with SMTP id u15-20020a056512128f00b00480fd236647mr20798608lfs.136.1656972957112; Mon, 04 Jul 2022 15:15:57 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id o13-20020ac25e2d000000b0047f660822e0sm5319931lfg.289.2022.07.04.15.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 15:15:56 -0700 (PDT) From: Vladimir Zapolskiy To: Robert Foss , Bryan O'Donoghue , Todor Tomov Cc: Bjorn Andersson , Andy Gross , Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] media: camss: Split power domain management Date: Tue, 5 Jul 2022 01:15:48 +0300 Message-Id: <20220704221548.629302-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220704221548.629302-1-vladimir.zapolskiy@linaro.org> References: <20220704221548.629302-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There are three cases of power domain management on supported platforms: 1) CAMSS on MSM8916, where a single VFE power domain is operated outside of the camss device driver, 2) CAMSS on MSM8996 and SDM630/SDM660, where two VFE power domains are managed separately by the camss device driver, the power domains are linked and unlinked on demand by their functions vfe_pm_domain_on() and vfe_pm_domain_off() respectively, 3) CAMSS on SDM845 and SM8250 platforms, and there are two VFE power domains and their parent power domain TITAN_TOP, the latter one shall be turned on prior to turning on any of VFE power domains. Due to a previously missing link between TITAN_TOP and VFEx power domains in the latter case, which is now fixed by [1], it was decided always to turn on all found VFE power domains and TITAN_TOP power domain, even if just one particular VFE is needed to be enabled or none of VFE power domains are required, for instance the latter case is when vfe_lite is in use. This misusage becomes more incovenient and clumsy, if next generations are to be supported, for instance CAMSS on SM8450 has three VFE power domains. The change splits the power management support for platforms with TITAN_TOP parent power domain, and, since 'power-domain-names' property is not present in camss device tree nodes, the assumption is that the first N power domains from the 'power-domains' list correspond to VFE power domains, and, if the number of power domains is greater than number of non-lite VFEs, then the last power domain from the list is the TITAN_TOP power domain. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- .../media/platform/qcom/camss/camss-vfe-170.c | 20 ++++++++++++- .../media/platform/qcom/camss/camss-vfe-480.c | 20 ++++++++++++- drivers/media/platform/qcom/camss/camss.c | 30 ++++++++++--------- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 600150cfc4f7..8e506a805d11 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -687,7 +687,12 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - /* nop */ + struct camss *camss = vfe->camss; + + if (vfe->id >= camss->vfe_num) + return; + + device_link_del(camss->genpd_link[vfe->id]); } /* @@ -696,6 +701,19 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) */ static int vfe_pm_domain_on(struct vfe_device *vfe) { + struct camss *camss = vfe->camss; + enum vfe_line_id id = vfe->id; + + if (id >= camss->vfe_num) + return 0; + + camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!camss->genpd_link[id]) + return -EINVAL; + return 0; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index 129585110393..3aa962b5663b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -494,7 +494,12 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - /* nop */ + struct camss *camss = vfe->camss; + + if (vfe->id >= camss->vfe_num) + return; + + device_link_del(camss->genpd_link[vfe->id]); } /* @@ -503,6 +508,19 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) */ static int vfe_pm_domain_on(struct vfe_device *vfe) { + struct camss *camss = vfe->camss; + enum vfe_line_id id = vfe->id; + + if (id >= camss->vfe_num) + return 0; + + camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!camss->genpd_link[id]) + return -EINVAL; + return 0; } diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 795eebd9af6c..f009297ba182 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1453,7 +1453,6 @@ static const struct media_device_ops camss_media_ops = { static int camss_configure_pd(struct camss *camss) { struct device *dev = camss->dev; - int last_pm_domain = 0; int i; int ret; @@ -1484,32 +1483,34 @@ static int camss_configure_pd(struct camss *camss) if (!camss->genpd_link) return -ENOMEM; + /* + * 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 = 0; i < camss->genpd_num; i++) { camss->genpd[i] = dev_pm_domain_attach_by_id(camss->dev, i); if (IS_ERR(camss->genpd[i])) { ret = PTR_ERR(camss->genpd[i]); goto fail_pm; } + } - camss->genpd_link[i] = device_link_add(camss->dev, camss->genpd[i], - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[i]) { - dev_pm_domain_detach(camss->genpd[i], true); + if (i > camss->vfe_num) { + camss->genpd_link[i - 1] = 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 = -EINVAL; goto fail_pm; } - - last_pm_domain = i; } return 0; fail_pm: - for (i = 0; i < last_pm_domain; i++) { - device_link_del(camss->genpd_link[i]); + for (--i ; i >= 0; i--) dev_pm_domain_detach(camss->genpd[i], true); - } return ret; } @@ -1711,10 +1712,11 @@ void camss_delete(struct camss *camss) if (camss->genpd_num == 1) return; - for (i = 0; i < camss->genpd_num; i++) { - device_link_del(camss->genpd_link[i]); + if (camss->genpd_num > camss->vfe_num) + device_link_del(camss->genpd_link[camss->genpd_num - 1]); + + for (i = 0; i < camss->genpd_num; i++) dev_pm_domain_detach(camss->genpd[i], true); - } } /*