V4:
- Updates camss_configure_pd() to use has_pd to determine if
a VFE has a pd instead of comparing to vfe_num
- Brings in is_lite fixes from Matti
The determination of IS_LITE() has been a running sore in this code for
some time.
Named power domains remove magic index dependencies.
Similarly adding an "is_lite" flag to our resources removes the last
of the magic indexing sins, so this is an opportune series to add it in.
Link: https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/b4/b4-camss-named-power-domains-v4
sm8250-testable: https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/b4/b4-camss-named-power-domains-v4+sm8250
Link: https://lore.kernel.org/r/20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org
V3:
- Includes bugfix reported on IRC
genpd_link and genpd should be checked for NULL on the cleanup path.
Matti Lehtimäki
- Retains NULL check before dev_pm_domain_attach_by_name()
I experimented with the suggested drop but of_property_match_string()
chokes
Link: https://lore.kernel.org/lkml/[email protected]/T/#m10e5a43d0245f13eca177ef2f65b24259c641030
Konrad
- Fixes spelling caught by codespell - Konrad
Link: https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/b4/b4-camss-named-power-domains-v3
sm8250-testable: https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/b4/b4-camss-named-power-domains-v3+sm8250
V2:
- Incorporates Konrad's suggestion re: removing 'id'
- Adds RB - Konrad
- Adds in a flag to indicate if a VFE has a power domain.
As I rebased this series I realised we had some magic indexing for VFE v
VFE Lite, which isn't the root cause of my bug bear in this series but is
the same sin - inferring functionality from indexing.
Once we transition fully to named pds we won't need a 'has_pd' to flag
which VFEs need power-domain attachment and which don't.
That transition will require populating all upstream dtsi with pd-names
and then deprecating the old way.
has_pd is a far better choice than inferring from indexes so, I've added.
Link: https://git.codelinaro.org/bryan.odonoghue/kernel/-/commits/aa45a2b58aa1e187a2698a65164d694251f08fa1
V1:
At the moment the Qcom CAMSS driver relies on the declaration order of
power-domains within the dtsi to determine which power-domain relates to a
VFE and which power-domain relates to the top-level (top) CAMSS
power-domain.
VFE power-domains must be declared prior to the top power-domain. The top
power-domain must be declared last. Early SoCs have just one top
power-domain with later SoCs introducing VFE specific power-domains.
Differentiating between the number of power-domains results in lots of code
which is brittle and which we can mostly get rid of with named
power-domains.
The reliance on declaration ordering is in-effect magic number indexing.
This series introduces named power-domains for CAMSS and refactors some of
the code in CAMSS to support the new named power-domains. We continue to
support the legacy indexing model with an intention to remove after a
reasonable transition period.
New SoC additions should use named power-domains from now on.
Tested on x13s, rb5, db410c
Link: https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/linux-next-23-10-23-camss-named-power-domains
Bryan O'Donoghue (5):
media: qcom: camss: Flag which VFEs require a power-domain
media: qcom: camss: Convert to per-VFE pointer for power-domain
linkages
media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where
applicable
media: qcom: camss: Move VFE power-domain specifics into vfe.c
media: qcom: camss: Add support for named power-domains
.../media/platform/qcom/camss/camss-vfe-170.c | 36 --------
.../media/platform/qcom/camss/camss-vfe-4-1.c | 8 +-
.../media/platform/qcom/camss/camss-vfe-4-7.c | 36 --------
.../media/platform/qcom/camss/camss-vfe-4-8.c | 31 -------
.../media/platform/qcom/camss/camss-vfe-480.c | 36 --------
drivers/media/platform/qcom/camss/camss-vfe.c | 77 ++++++++++++++++
drivers/media/platform/qcom/camss/camss-vfe.h | 16 ++++
drivers/media/platform/qcom/camss/camss.c | 87 ++++++++++++-------
drivers/media/platform/qcom/camss/camss.h | 7 +-
9 files changed, 156 insertions(+), 178 deletions(-)
--
2.42.0
---
Bryan O'Donoghue (5):
media: qcom: camss: Flag which VFEs require a power-domain
media: qcom: camss: Convert to per-VFE pointer for power-domain linkages
media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable
media: qcom: camss: Move VFE power-domain specifics into vfe.c
media: qcom: camss: Add support for named power-domains
Matti Lehtimäki (2):
media: qcom: camss: Flag VFE-lites to support more VFEs
media: qcom: camss: Flag CSID-lites to support more CSIDs
.../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-vfe-170.c | 36 -------
drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 8 +-
drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 36 -------
drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 31 ------
drivers/media/platform/qcom/camss/camss-vfe-480.c | 69 +++---------
drivers/media/platform/qcom/camss/camss-vfe.c | 84 +++++++++++++++
drivers/media/platform/qcom/camss/camss-vfe.h | 26 +++++
drivers/media/platform/qcom/camss/camss.c | 117 +++++++++++++--------
drivers/media/platform/qcom/camss/camss.h | 10 +-
12 files changed, 237 insertions(+), 223 deletions(-)
---
base-commit: 48016737a9af47328dd321df4dd3479ed5e2041d
change-id: 20231031-b4-camss-named-power-domains-cc2ac2722543
Best regards,
--
Bryan O'Donoghue <[email protected]>
From: Matti Lehtimäki <[email protected]>
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äki <[email protected]>
Signed-off-by: Bryan O'Donoghue <[email protected]>
---
.../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 >= 2 ? 1 : 0)
#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
-#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))
#define CSID_TOP_IRQ_STATUS 0x70
@@ -73,7 +72,7 @@
#define CGC_MODE_DYNAMIC_GATING 0
#define CGC_MODE_ALWAYS_ON 1
-#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
-#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
-#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
-#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((IS_LITE ? 0x20C : 0x30C)\
+#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x20C : 0x30C)\
+ 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 : 0x310)\
+ 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))
#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 *csid)
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;
+/*
+ * 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);
#endif /* QC_MSM_CAMSS_CSID_H */
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index f5226eb8bf4fc..51ad12f1d9d7d 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[] = {
{ 384000000 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
+ .is_lite = true,
.ops = &csid_ops_gen2
}
};
@@ -812,6 +813,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
+ .is_lite = true,
.ops = &csid_ops_gen2
},
/* CSID3 */
@@ -824,6 +826,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
+ .is_lite = true,
.ops = &csid_ops_gen2
}
};
--
2.42.0
On 3.11.2023 13:29, Bryan O'Donoghue wrote:
> From: Matti Lehtimäki <[email protected]>
>
> 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äki <[email protected]>
> Signed-off-by: Bryan O'Donoghue <[email protected]>
> ---Reviewed-by: Konrad Dybcio <[email protected]>
something something kerneldoc something csid storing a res ptr
Konrad