[PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY

Wenmeng Liu posted 1 patch 2 months, 1 week ago
There is a newer version of this series
drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
drivers/media/platform/qcom/camss/camss.h        |  1 +
3 files changed, 30 insertions(+), 1 deletion(-)
[PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY
Posted by Wenmeng Liu 2 months, 1 week ago
Some Qualcomm regulators are configured with initial mode as
HPM (High Power Mode), which may lead to higher power consumption.
To reduce power usage, it's preferable to set the initial mode
to LPM (Low Power Mode).

To ensure the regulator can switch from LPM to HPM when needed,
this patch adds current load configuration for CAMSS CSIPHY.
This allows the regulator framework to scale the mode dynamically
based on the load requirement.

The current default value for current is uninitialized or random.
To address this, initial current values are added for the
following platforms:
SDM670, SM8250, SC7280, SM8550, and X1E80100.

For SDM670, the value is set to -1, indicating that no default
current value is configured, the other values are derived
from the power grid.

---
Changes in v2:
- Change the source of the current value from DTS to CAMSS resource
- Link to v1: https://lore.kernel.org/all/20250620040736.3032667-1-quic_wenmliu@quicinc.com/
---

Signed-off-by: Wenmeng Liu <quic_wenmliu@quicinc.com>
---
 drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
 drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
 drivers/media/platform/qcom/camss/camss.h        |  1 +
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 2de97f58f9ae4f91e8bba39dcadf92bea8cf6f73..7a2d80a03dbd0884b614451b55cd27dce94af637 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -707,8 +707,10 @@ int msm_csiphy_subdev_init(struct camss *camss,
 			return -ENOMEM;
 	}
 
-	for (i = 0; i < csiphy->num_supplies; i++)
+	for (i = 0; i < csiphy->num_supplies; i++) {
 		csiphy->supplies[i].supply = res->regulators[i];
+		csiphy->supplies[i].init_load_uA = res->regulators_current[i];
+	}
 
 	ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
 				      csiphy->supplies);
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index e08e70b93824baa5714b3a736bc1d05405253aaa..daf21c944c2b4818b1656efc255e817551788658 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -750,6 +750,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
 	/* CSIPHY0 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { -1, -1 },
 		.clock = { "soc_ahb", "cpas_ahb",
 			   "csiphy0", "csiphy0_timer" },
 		.clock_rate = { { 0 },
@@ -768,6 +769,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
 	/* CSIPHY1 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { -1, -1 },
 		.clock = { "soc_ahb", "cpas_ahb",
 			   "csiphy1", "csiphy1_timer" },
 		.clock_rate = { { 0 },
@@ -786,6 +788,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
 	/* CSIPHY2 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { -1, -1 },
 		.clock = { "soc_ahb", "cpas_ahb",
 			   "csiphy2", "csiphy2_timer" },
 		.clock_rate = { { 0 },
@@ -1188,6 +1191,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY0 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy0", "csiphy0_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1202,6 +1206,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY1 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy1", "csiphy1_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1216,6 +1221,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY2 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy2", "csiphy2_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1230,6 +1236,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY3 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy3", "csiphy3_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1244,6 +1251,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY4 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy4", "csiphy4_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1258,6 +1266,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
 	/* CSIPHY5 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 17500, 10000 },
 		.clock = { "csiphy5", "csiphy5_timer" },
 		.clock_rate = { { 400000000 },
 				{ 300000000 } },
@@ -1472,6 +1481,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
 	/* CSIPHY0 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 16100, 9000 },
 
 		.clock = { "csiphy0", "csiphy0_timer" },
 		.clock_rate = { { 300000000, 400000000 },
@@ -1487,6 +1497,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
 	/* CSIPHY1 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 16100, 9000 },
 
 		.clock = { "csiphy1", "csiphy1_timer" },
 		.clock_rate = { { 300000000, 400000000 },
@@ -1502,6 +1513,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
 	/* CSIPHY2 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 16100, 9000 },
 
 		.clock = { "csiphy2", "csiphy2_timer" },
 		.clock_rate = { { 300000000, 400000000 },
@@ -1517,6 +1529,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
 	/* CSIPHY3 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 16100, 9000 },
 
 		.clock = { "csiphy3", "csiphy3_timer" },
 		.clock_rate = { { 300000000, 400000000 },
@@ -1532,6 +1545,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
 	/* CSIPHY4 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 16100, 9000 },
 
 		.clock = { "csiphy4", "csiphy4_timer" },
 		.clock_rate = { { 300000000, 400000000 },
@@ -2158,6 +2172,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY0 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy0", "csiphy0_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2172,6 +2187,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY1 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy1", "csiphy1_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2186,6 +2202,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY2 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy2", "csiphy2_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2200,6 +2217,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY3 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy3", "csiphy3_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2214,6 +2232,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY4 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy4", "csiphy4_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2228,6 +2247,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY5 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy5", "csiphy5_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2242,6 +2262,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY6 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy6", "csiphy6_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2256,6 +2277,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
 	/* CSIPHY7 */
 	{
 		.regulators = { "vdda-phy", "vdda-pll" },
+		.regulators_current = { 44000, 8900 },
 		.clock = { "csiphy7", "csiphy7_timer" },
 		.clock_rate = { { 400000000, 480000000 },
 				{ 400000000 } },
@@ -2488,6 +2510,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
 	{
 		.regulators = { "vdd-csiphy-0p8",
 				"vdd-csiphy-1p2" },
+		.regulators_current = { 105000, 58900 },
 		.clock = { "csiphy0", "csiphy0_timer" },
 		.clock_rate = { { 300000000, 400000000, 480000000 },
 				{ 266666667, 400000000 } },
@@ -2503,6 +2526,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
 	{
 		.regulators = { "vdd-csiphy-0p8",
 				"vdd-csiphy-1p2" },
+		.regulators_current = { 105000, 58900 },
 		.clock = { "csiphy1", "csiphy1_timer" },
 		.clock_rate = { { 300000000, 400000000, 480000000 },
 				{ 266666667, 400000000 } },
@@ -2518,6 +2542,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
 	{
 		.regulators = { "vdd-csiphy-0p8",
 				"vdd-csiphy-1p2" },
+		.regulators_current = { 105000, 58900 },
 		.clock = { "csiphy2", "csiphy2_timer" },
 		.clock_rate = { { 300000000, 400000000, 480000000 },
 				{ 266666667, 400000000 } },
@@ -2533,6 +2558,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
 	{
 		.regulators = { "vdd-csiphy-0p8",
 				"vdd-csiphy-1p2" },
+		.regulators_current = { 105000, 58900 },
 		.clock = { "csiphy4", "csiphy4_timer" },
 		.clock_rate = { { 300000000, 400000000, 480000000 },
 				{ 266666667, 400000000 } },
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index 63c0afee154a02194820016ccf554620d6521c8b..b46e92b10e096ca8e082ea2bb0b20032135e05b9 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -44,6 +44,7 @@
 
 struct camss_subdev_resources {
 	char *regulators[CAMSS_RES_MAX];
+	int  regulators_current[CAMSS_RES_MAX];
 	char *clock[CAMSS_RES_MAX];
 	char *clock_for_reset[CAMSS_RES_MAX];
 	u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];

---
base-commit: 0b90c3b6d76ea512dc3dac8fb30215e175b0019a
change-id: 20250729-camss_csiphy_current-7793c2fab66f

Best regards,
-- 
Wenmeng Liu <quic_wenmliu@quicinc.com>
Re: [PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY
Posted by Dmitry Baryshkov 1 month, 3 weeks ago
On Tue, Jul 29, 2025 at 03:24:55PM +0800, Wenmeng Liu wrote:
> Some Qualcomm regulators are configured with initial mode as
> HPM (High Power Mode), which may lead to higher power consumption.
> To reduce power usage, it's preferable to set the initial mode
> to LPM (Low Power Mode).
> 
> To ensure the regulator can switch from LPM to HPM when needed,
> this patch adds current load configuration for CAMSS CSIPHY.
> This allows the regulator framework to scale the mode dynamically
> based on the load requirement.
> 
> The current default value for current is uninitialized or random.
> To address this, initial current values are added for the
> following platforms:
> SDM670, SM8250, SC7280, SM8550, and X1E80100.
> 
> For SDM670, the value is set to -1, indicating that no default
> current value is configured, the other values are derived
> from the power grid.
> 
> ---
> Changes in v2:
> - Change the source of the current value from DTS to CAMSS resource
> - Link to v1: https://lore.kernel.org/all/20250620040736.3032667-1-quic_wenmliu@quicinc.com/
> ---
> 
> Signed-off-by: Wenmeng Liu <quic_wenmliu@quicinc.com>
> ---
>  drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
>  drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
>  drivers/media/platform/qcom/camss/camss.h        |  1 +
>  3 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 2de97f58f9ae4f91e8bba39dcadf92bea8cf6f73..7a2d80a03dbd0884b614451b55cd27dce94af637 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -707,8 +707,10 @@ int msm_csiphy_subdev_init(struct camss *camss,
>  			return -ENOMEM;
>  	}
>  
> -	for (i = 0; i < csiphy->num_supplies; i++)
> +	for (i = 0; i < csiphy->num_supplies; i++) {
>  		csiphy->supplies[i].supply = res->regulators[i];
> +		csiphy->supplies[i].init_load_uA = res->regulators_current[i];

Could you possibly refactor to use devm_regulator_bulk_get_const()? It
would save you from this data moving.

> +	}
>  
>  	ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
>  				      csiphy->supplies);
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index e08e70b93824baa5714b3a736bc1d05405253aaa..daf21c944c2b4818b1656efc255e817551788658 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -750,6 +750,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
>  	/* CSIPHY0 */
>  	{
>  		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { -1, -1 },

If it's unset, it should be 0, not -1.

>  		.clock = { "soc_ahb", "cpas_ahb",
>  			   "csiphy0", "csiphy0_timer" },
>  		.clock_rate = { { 0 },

-- 
With best wishes
Dmitry
Re: [PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY
Posted by Wenmeng Liu 1 month, 3 weeks ago

On 2025/8/11 18:39, Dmitry Baryshkov wrote:
> On Tue, Jul 29, 2025 at 03:24:55PM +0800, Wenmeng Liu wrote:
>> Some Qualcomm regulators are configured with initial mode as
>> HPM (High Power Mode), which may lead to higher power consumption.
>> To reduce power usage, it's preferable to set the initial mode
>> to LPM (Low Power Mode).
>>
>> To ensure the regulator can switch from LPM to HPM when needed,
>> this patch adds current load configuration for CAMSS CSIPHY.
>> This allows the regulator framework to scale the mode dynamically
>> based on the load requirement.
>>
>> The current default value for current is uninitialized or random.
>> To address this, initial current values are added for the
>> following platforms:
>> SDM670, SM8250, SC7280, SM8550, and X1E80100.
>>
>> For SDM670, the value is set to -1, indicating that no default
>> current value is configured, the other values are derived
>> from the power grid.
>>
>> ---
>> Changes in v2:
>> - Change the source of the current value from DTS to CAMSS resource
>> - Link to v1: https://lore.kernel.org/all/20250620040736.3032667-1-quic_wenmliu@quicinc.com/
>> ---
>>
>> Signed-off-by: Wenmeng Liu <quic_wenmliu@quicinc.com>
>> ---
>>   drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
>>   drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
>>   drivers/media/platform/qcom/camss/camss.h        |  1 +
>>   3 files changed, 30 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
>> index 2de97f58f9ae4f91e8bba39dcadf92bea8cf6f73..7a2d80a03dbd0884b614451b55cd27dce94af637 100644
>> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
>> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
>> @@ -707,8 +707,10 @@ int msm_csiphy_subdev_init(struct camss *camss,
>>   			return -ENOMEM;
>>   	}
>>   
>> -	for (i = 0; i < csiphy->num_supplies; i++)
>> +	for (i = 0; i < csiphy->num_supplies; i++) {
>>   		csiphy->supplies[i].supply = res->regulators[i];
>> +		csiphy->supplies[i].init_load_uA = res->regulators_current[i];
> 
> Could you possibly refactor to use devm_regulator_bulk_get_const()? It
> would save you from this data moving.
Initially, we were aiming for a minimal-change implementation.
Consider refactor for save data moving, will be refactored in the next 
version.
> 
>> +	}
>>   
>>   	ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
>>   				      csiphy->supplies);
>> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
>> index e08e70b93824baa5714b3a736bc1d05405253aaa..daf21c944c2b4818b1656efc255e817551788658 100644
>> --- a/drivers/media/platform/qcom/camss/camss.c
>> +++ b/drivers/media/platform/qcom/camss/camss.c
>> @@ -750,6 +750,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
>>   	/* CSIPHY0 */
>>   	{
>>   		.regulators = { "vdda-phy", "vdda-pll" },
>> +		.regulators_current = { -1, -1 },
> 
> If it's unset, it should be 0, not -1.
I considered existing implementations as a reference:
https://lore.kernel.org/all/20220804073608.v4.5.I55a9e65cb1c22221316629e98768ff473f47a067@changeid

but based on the implementation of regulator_bulk_get, setting it to 0 
seems to be a better approach:

drivers/regulator/core.c
consumers[i].init_load_uA > 0

Thanks,
Wenmeng
Re: [PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY
Posted by Dmitry Baryshkov 1 month, 3 weeks ago
On Tue, Aug 12, 2025 at 02:05:55PM +0800, Wenmeng Liu wrote:
> 
> 
> On 2025/8/11 18:39, Dmitry Baryshkov wrote:
> > On Tue, Jul 29, 2025 at 03:24:55PM +0800, Wenmeng Liu wrote:
> > > Some Qualcomm regulators are configured with initial mode as
> > > HPM (High Power Mode), which may lead to higher power consumption.
> > > To reduce power usage, it's preferable to set the initial mode
> > > to LPM (Low Power Mode).
> > > 
> > > To ensure the regulator can switch from LPM to HPM when needed,
> > > this patch adds current load configuration for CAMSS CSIPHY.
> > > This allows the regulator framework to scale the mode dynamically
> > > based on the load requirement.
> > > 
> > > The current default value for current is uninitialized or random.
> > > To address this, initial current values are added for the
> > > following platforms:
> > > SDM670, SM8250, SC7280, SM8550, and X1E80100.
> > > 
> > > For SDM670, the value is set to -1, indicating that no default
> > > current value is configured, the other values are derived
> > > from the power grid.
> > > 
> > > ---
> > > Changes in v2:
> > > - Change the source of the current value from DTS to CAMSS resource
> > > - Link to v1: https://lore.kernel.org/all/20250620040736.3032667-1-quic_wenmliu@quicinc.com/
> > > ---
> > > 
> > > Signed-off-by: Wenmeng Liu <quic_wenmliu@quicinc.com>
> > > ---
> > >   drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
> > >   drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
> > >   drivers/media/platform/qcom/camss/camss.h        |  1 +
> > >   3 files changed, 30 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> > > index 2de97f58f9ae4f91e8bba39dcadf92bea8cf6f73..7a2d80a03dbd0884b614451b55cd27dce94af637 100644
> > > --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> > > +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> > > @@ -707,8 +707,10 @@ int msm_csiphy_subdev_init(struct camss *camss,
> > >   			return -ENOMEM;
> > >   	}
> > > -	for (i = 0; i < csiphy->num_supplies; i++)
> > > +	for (i = 0; i < csiphy->num_supplies; i++) {
> > >   		csiphy->supplies[i].supply = res->regulators[i];
> > > +		csiphy->supplies[i].init_load_uA = res->regulators_current[i];
> > 
> > Could you possibly refactor to use devm_regulator_bulk_get_const()? It
> > would save you from this data moving.
> Initially, we were aiming for a minimal-change implementation.
> Consider refactor for save data moving, will be refactored in the next
> version.
> > 
> > > +	}
> > >   	ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
> > >   				      csiphy->supplies);
> > > diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> > > index e08e70b93824baa5714b3a736bc1d05405253aaa..daf21c944c2b4818b1656efc255e817551788658 100644
> > > --- a/drivers/media/platform/qcom/camss/camss.c
> > > +++ b/drivers/media/platform/qcom/camss/camss.c
> > > @@ -750,6 +750,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
> > >   	/* CSIPHY0 */
> > >   	{
> > >   		.regulators = { "vdda-phy", "vdda-pll" },
> > > +		.regulators_current = { -1, -1 },
> > 
> > If it's unset, it should be 0, not -1.
> I considered existing implementations as a reference:
> https://lore.kernel.org/all/20220804073608.v4.5.I55a9e65cb1c22221316629e98768ff473f47a067@changeid
> 
> but based on the implementation of regulator_bulk_get, setting it to 0 seems
> to be a better approach:

Ack. Also please try to provide a sensible value for all platforms, not
just the most recent ones.

> 
> drivers/regulator/core.c
> consumers[i].init_load_uA > 0
> 
> Thanks,
> Wenmeng
> 

-- 
With best wishes
Dmitry
Re: [PATCH v2] media: qcom: camss: Add support for regulator init_load_uA in CSIPHY
Posted by Bryan O'Donoghue 1 month, 3 weeks ago
On 29/07/2025 08:24, Wenmeng Liu wrote:
> Some Qualcomm regulators are configured with initial mode as
> HPM (High Power Mode), which may lead to higher power consumption.
> To reduce power usage, it's preferable to set the initial mode
> to LPM (Low Power Mode).
> 
> To ensure the regulator can switch from LPM to HPM when needed,
> this patch adds current load configuration for CAMSS CSIPHY.
> This allows the regulator framework to scale the mode dynamically
> based on the load requirement.
> 
> The current default value for current is uninitialized or random.
> To address this, initial current values are added for the
> following platforms:
> SDM670, SM8250, SC7280, SM8550, and X1E80100.
> 
> For SDM670, the value is set to -1, indicating that no default
> current value is configured, the other values are derived
> from the power grid.
> 
> ---
> Changes in v2:
> - Change the source of the current value from DTS to CAMSS resource
> - Link to v1: https://lore.kernel.org/all/20250620040736.3032667-1-quic_wenmliu@quicinc.com/
> ---
> 
> Signed-off-by: Wenmeng Liu <quic_wenmliu@quicinc.com>
> ---
>   drivers/media/platform/qcom/camss/camss-csiphy.c |  4 +++-
>   drivers/media/platform/qcom/camss/camss.c        | 26 ++++++++++++++++++++++++
>   drivers/media/platform/qcom/camss/camss.h        |  1 +
>   3 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 2de97f58f9ae4f91e8bba39dcadf92bea8cf6f73..7a2d80a03dbd0884b614451b55cd27dce94af637 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -707,8 +707,10 @@ int msm_csiphy_subdev_init(struct camss *camss,
>   			return -ENOMEM;
>   	}
>   
> -	for (i = 0; i < csiphy->num_supplies; i++)
> +	for (i = 0; i < csiphy->num_supplies; i++) {
>   		csiphy->supplies[i].supply = res->regulators[i];
> +		csiphy->supplies[i].init_load_uA = res->regulators_current[i];
> +	}
>   
>   	ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
>   				      csiphy->supplies);
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index e08e70b93824baa5714b3a736bc1d05405253aaa..daf21c944c2b4818b1656efc255e817551788658 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -750,6 +750,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
>   	/* CSIPHY0 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { -1, -1 },
>   		.clock = { "soc_ahb", "cpas_ahb",
>   			   "csiphy0", "csiphy0_timer" },
>   		.clock_rate = { { 0 },
> @@ -768,6 +769,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
>   	/* CSIPHY1 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { -1, -1 },
>   		.clock = { "soc_ahb", "cpas_ahb",
>   			   "csiphy1", "csiphy1_timer" },
>   		.clock_rate = { { 0 },
> @@ -786,6 +788,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
>   	/* CSIPHY2 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { -1, -1 },
>   		.clock = { "soc_ahb", "cpas_ahb",
>   			   "csiphy2", "csiphy2_timer" },
>   		.clock_rate = { { 0 },
> @@ -1188,6 +1191,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY0 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy0", "csiphy0_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1202,6 +1206,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY1 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy1", "csiphy1_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1216,6 +1221,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY2 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy2", "csiphy2_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1230,6 +1236,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY3 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy3", "csiphy3_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1244,6 +1251,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY4 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy4", "csiphy4_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1258,6 +1266,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
>   	/* CSIPHY5 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 17500, 10000 },
>   		.clock = { "csiphy5", "csiphy5_timer" },
>   		.clock_rate = { { 400000000 },
>   				{ 300000000 } },
> @@ -1472,6 +1481,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
>   	/* CSIPHY0 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 16100, 9000 },
>   
>   		.clock = { "csiphy0", "csiphy0_timer" },
>   		.clock_rate = { { 300000000, 400000000 },
> @@ -1487,6 +1497,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
>   	/* CSIPHY1 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 16100, 9000 },
>   
>   		.clock = { "csiphy1", "csiphy1_timer" },
>   		.clock_rate = { { 300000000, 400000000 },
> @@ -1502,6 +1513,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
>   	/* CSIPHY2 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 16100, 9000 },
>   
>   		.clock = { "csiphy2", "csiphy2_timer" },
>   		.clock_rate = { { 300000000, 400000000 },
> @@ -1517,6 +1529,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
>   	/* CSIPHY3 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 16100, 9000 },
>   
>   		.clock = { "csiphy3", "csiphy3_timer" },
>   		.clock_rate = { { 300000000, 400000000 },
> @@ -1532,6 +1545,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
>   	/* CSIPHY4 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 16100, 9000 },
>   
>   		.clock = { "csiphy4", "csiphy4_timer" },
>   		.clock_rate = { { 300000000, 400000000 },
> @@ -2158,6 +2172,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY0 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy0", "csiphy0_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2172,6 +2187,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY1 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy1", "csiphy1_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2186,6 +2202,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY2 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy2", "csiphy2_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2200,6 +2217,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY3 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy3", "csiphy3_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2214,6 +2232,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY4 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy4", "csiphy4_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2228,6 +2247,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY5 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy5", "csiphy5_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2242,6 +2262,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY6 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy6", "csiphy6_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2256,6 +2277,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
>   	/* CSIPHY7 */
>   	{
>   		.regulators = { "vdda-phy", "vdda-pll" },
> +		.regulators_current = { 44000, 8900 },
>   		.clock = { "csiphy7", "csiphy7_timer" },
>   		.clock_rate = { { 400000000, 480000000 },
>   				{ 400000000 } },
> @@ -2488,6 +2510,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
>   	{
>   		.regulators = { "vdd-csiphy-0p8",
>   				"vdd-csiphy-1p2" },
> +		.regulators_current = { 105000, 58900 },
>   		.clock = { "csiphy0", "csiphy0_timer" },
>   		.clock_rate = { { 300000000, 400000000, 480000000 },
>   				{ 266666667, 400000000 } },
> @@ -2503,6 +2526,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
>   	{
>   		.regulators = { "vdd-csiphy-0p8",
>   				"vdd-csiphy-1p2" },
> +		.regulators_current = { 105000, 58900 },
>   		.clock = { "csiphy1", "csiphy1_timer" },
>   		.clock_rate = { { 300000000, 400000000, 480000000 },
>   				{ 266666667, 400000000 } },
> @@ -2518,6 +2542,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
>   	{
>   		.regulators = { "vdd-csiphy-0p8",
>   				"vdd-csiphy-1p2" },
> +		.regulators_current = { 105000, 58900 },
>   		.clock = { "csiphy2", "csiphy2_timer" },
>   		.clock_rate = { { 300000000, 400000000, 480000000 },
>   				{ 266666667, 400000000 } },
> @@ -2533,6 +2558,7 @@ static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
>   	{
>   		.regulators = { "vdd-csiphy-0p8",
>   				"vdd-csiphy-1p2" },
> +		.regulators_current = { 105000, 58900 },
>   		.clock = { "csiphy4", "csiphy4_timer" },
>   		.clock_rate = { { 300000000, 400000000, 480000000 },
>   				{ 266666667, 400000000 } },
> diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
> index 63c0afee154a02194820016ccf554620d6521c8b..b46e92b10e096ca8e082ea2bb0b20032135e05b9 100644
> --- a/drivers/media/platform/qcom/camss/camss.h
> +++ b/drivers/media/platform/qcom/camss/camss.h
> @@ -44,6 +44,7 @@
>   
>   struct camss_subdev_resources {
>   	char *regulators[CAMSS_RES_MAX];
> +	int  regulators_current[CAMSS_RES_MAX];
>   	char *clock[CAMSS_RES_MAX];
>   	char *clock_for_reset[CAMSS_RES_MAX];
>   	u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
> 
> ---
> base-commit: 0b90c3b6d76ea512dc3dac8fb30215e175b0019a
> change-id: 20250729-camss_csiphy_current-7793c2fab66f
> 
> Best regards,
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>