media: qcom: camss: Convert to per-VFE pointer for power-domain linkages
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Thu, 23 Nov 2023 17:03:01 +0000 (17:03 +0000)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 7 Dec 2023 07:31:15 +0000 (08:31 +0100)
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 <konrad.dybcio@linaro.org>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/qcom/camss/camss-vfe-170.c
drivers/media/platform/qcom/camss/camss-vfe-4-7.c
drivers/media/platform/qcom/camss/camss-vfe-4-8.c
drivers/media/platform/qcom/camss/camss-vfe-480.c
drivers/media/platform/qcom/camss/camss-vfe.c
drivers/media/platform/qcom/camss/camss-vfe.h

index 0b211fed127605a91482fdf0f7a3013ff91aeb01..7451484317cc3804dc8f0aae74f78aa528fcedf3 100644 (file)
@@ -638,7 +638,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe)
        if (vfe->id >= camss->res->vfe_num)
                return;
 
-       device_link_del(camss->genpd_link[vfe->id]);
+       device_link_del(vfe->genpd_link);
 }
 
 /*
@@ -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 = vfe->camss;
-       enum vfe_line_id id = vfe->id;
 
-       if (id >= camss->res->vfe_num)
+       if (vfe->id >= camss->res->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])
+       vfe->genpd_link = 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;
index b65ed0fef595e8e6fb8914f0ffb6e00a23ce6b0d..2b4e7e039407b33e559c05f7707e5345b2a8b9a9 100644 (file)
@@ -1109,14 +1109,10 @@ 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;
-
        if (!vfe)
                return;
 
-       camss = vfe->camss;
-
-       device_link_del(camss->genpd_link[vfe->id]);
+       device_link_del(vfe->genpd_link);
 }
 
 /*
@@ -1126,13 +1122,12 @@ 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;
 
-       camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS |
-                                               DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
+       vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS |
+                                         DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
 
-       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;
        }
 
index 7b3805177f037fe9a6bbb8ebc27355d3017f906c..5e95343241304bb1b8c3432de560441b06c802c8 100644 (file)
@@ -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 = vfe->camss;
-
-       device_link_del(camss->genpd_link[vfe->id]);
+       device_link_del(vfe->genpd_link);
 }
 
 /*
@@ -1111,13 +1109,12 @@ 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;
 
-       camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS |
-                                               DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
+       vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS |
+                                         DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
 
-       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;
        }
 
index f2368b77fc6d6a0029b68483f8d17f9706666240..a70b8633bb3eb7672d4a743dcef26538b0b2d34e 100644 (file)
@@ -463,7 +463,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe)
        if (vfe->id >= camss->res->vfe_num)
                return;
 
-       device_link_del(camss->genpd_link[vfe->id]);
+       device_link_del(vfe->genpd_link);
 }
 
 /*
@@ -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 = vfe->camss;
-       enum vfe_line_id id = vfe->id;
 
-       if (id >= camss->res->vfe_num)
+       if (vfe->id >= camss->res->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])
+       vfe->genpd_link = 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;
index 74fe577a84aaeb8d25d8fe438174021d9b605aac..32a9cd32ffde80d6271e0dcf5f043eaceda3a975 100644 (file)
@@ -1345,6 +1345,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
        if (!res->line_num)
                return -EINVAL;
 
+       if (res->has_pd)
+               vfe->genpd = camss->genpd[id];
+
        vfe->line_num = res->line_num;
        vfe->ops->subdev_init(dev, vfe);
 
index 09baded0dcdd63ef7e56c0bf7b2873d4bcdf2119..c1c50023d48768b4933f4ff6726b52b0022bdf30 100644 (file)
@@ -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;
 };
 
 struct camss_subdev_resources;