From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: laurent.pinchart@ideasonboard.com, rfoss@kernel.org,
todor.too@gmail.com, agross@kernel.org, andersson@kernel.org,
konrad.dybcio@linaro.org, mchehab@kernel.org,
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,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Subject: [PATCH v6.1] media: qcom: camss: Add support for named power-domains
Date: Wed, 6 Dec 2023 13:25:00 +0100 [thread overview]
Message-ID: <20231206122500.3798228-1-bryan.odonoghue@linaro.org> (raw)
In-Reply-To: <43621420-2482-4634-9c3e-1a3278481540@xs4all.nl>
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äki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
drivers/media/platform/qcom/camss/camss-vfe.c | 24 +++++++++++++-
drivers/media/platform/qcom/camss/camss.c | 31 +++++++++++++++----
drivers/media/platform/qcom/camss/camss.h | 2 ++
3 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 60c4730e7c9d..083d1445a6e2 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;
- if (res->has_pd) {
+ /* Power domain */
+
+ if (res->pd_name) {
+ vfe->genpd = dev_pm_domain_attach_by_name(camss->dev,
+ res->pd_name);
+ if (IS_ERR(vfe->genpd)) {
+ ret = PTR_ERR(vfe->genpd);
+ return ret;
+ }
+ }
+
+ if (!vfe->genpd && res->has_pd) {
+ /*
+ * Legacy magic index.
+ * Requires
+ * power-domain = <VFE_X>,
+ * <VFE_Y>,
+ * <TITAN_TOP>
+ * 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 = 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/platform/qcom/camss/camss.c
index 35918cf837bd..8de0e9e8d34b 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -1522,13 +1522,32 @@ static int camss_configure_pd(struct camss *camss)
return 0;
/*
- * 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 = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1);
- if (IS_ERR(camss->genpd)) {
- ret = PTR_ERR(camss->genpd);
+ if (camss->res->pd_name) {
+ camss->genpd = dev_pm_domain_attach_by_name(camss->dev,
+ camss->res->pd_name);
+ if (IS_ERR(camss->genpd)) {
+ ret = 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 = dev_pm_domain_attach_by_id(camss->dev,
+ camss->genpd_num - 1);
+ }
+ if (IS_ERR_OR_NULL(camss->genpd)) {
+ if (!camss->genpd)
+ ret = -ENODEV;
+ else
+ ret = PTR_ERR(camss->genpd);
goto fail_pm;
}
camss->genpd_link = device_link_add(camss->dev, camss->genpd,
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index 1ba824a2cb76..cd8186fe1797 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 {
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;
--
2.42.0
next prev parent reply other threads:[~2023-12-06 12:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 17:02 [PATCH v6 0/8] media: qcom: camss: Introduce " Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 1/8] media: qcom: camss: Flag which VFEs require a power-domain Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 2/8] media: qcom: camss: Convert to per-VFE pointer for power-domain linkages Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 3/8] media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 4/8] media: qcom: camss: Move VFE power-domain specifics into vfe.c Bryan O'Donoghue
2023-11-25 12:53 ` Konrad Dybcio
2023-11-25 12:54 ` Konrad Dybcio
2023-11-23 17:03 ` [PATCH v6 5/8] media: qcom: camss: Add support for named power-domains Bryan O'Donoghue
2023-12-06 11:35 ` Hans Verkuil
2023-12-06 12:25 ` Bryan O'Donoghue [this message]
2023-12-06 12:28 ` Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 6/8] media: qcom: camss: Flag VFE-lites to support more VFEs Bryan O'Donoghue
2023-11-23 17:03 ` [PATCH v6 7/8] media: qcom: camss: Flag CSID-lites to support more CSIDs Bryan O'Donoghue
2023-11-25 12:49 ` Konrad Dybcio
2023-11-23 17:03 ` [PATCH v6 8/8] media: qcom: camss: Add sm8250 named power-domain support Bryan O'Donoghue
2023-11-27 11:25 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231206122500.3798228-1-bryan.odonoghue@linaro.org \
--to=bryan.odonoghue@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=matti.lehtimaki@gmail.com \
--cc=mchehab@kernel.org \
--cc=quic_grosikop@quicinc.com \
--cc=rfoss@kernel.org \
--cc=todor.too@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®