Skip to contentSkip to conversation

Allow VADC_LR_MUX2_BAT_ID channel proper reading

PATCH Applied Jonathan Albrieux 3 participants 6 messages Jan 13, 2021 – Jan 16, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Allow VADC_LR_MUX2_BAT_ID channel proper reading

Working on a battery charger and fuel gauge driver it happened to have the need to read from VADC_LR_MUX2_BAT_ID channel. Here is the declaration from downstream msm8916.dtsi:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

Those two patches set channel scaling accordingly and add it to pm8916 device tree.

Jonathan Albrieux (2):
iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel
arm64: dts: qcom: pm8916: Add batt_id channel node

 arch/arm64/boot/dts/qcom/pm8916.dtsi | 5 +++++
 drivers/iio/adc/qcom-spmi-vadc.c     | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel

Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream it is indicated that "batt_id" channel has to be scaled with the default function:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

Change LR_MUX2_BAT_ID scaling accordingly.

---
 drivers/iio/adc/qcom-spmi-vadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/qcom-spmi-vadc.c +1 -1
index b0388f8a69f4..7e7d408452ec 100644
@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
 
 	VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
-	VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
+	VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
 	VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
Signature · 1 line
2.17.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel

Quoted 15 lines · Jonathan Albrieux

Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream it is indicated that "batt_id" channel has to be scaled with the default function:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};
Quoted 2 lines

Change LR_MUX2_BAT_ID scaling accordingly.

Not entirely sure, but looking at the history I think this used to work
- but it's obvious that no one has read this channel for a while...

But I think below is a regression and should be mentioned:

Fixes 7c271eea7b8a ("iio: adc: spmi-vadc: Changes to support different scaling")
Quoted 1 line

Jonathan Cameron, if you merge this through your tree I can take the dts addition through the Qualcomm tree.

Regards,
Bjorn

Quoted 20 lines
---
 drivers/iio/adc/qcom-spmi-vadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/qcom-spmi-vadc.c +1 -1
index b0388f8a69f4..7e7d408452ec 100644
@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
 
 	VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
-	VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
+	VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
 	VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
Signature · 1 line
2.17.1
maintainer Applied
#3 lore raw

Re: [PATCH 1/2] iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel

Quoted 20 lines · On Fri, 15 Jan 2021 10:30:49 -0600 Bjorn Andersson…
Quoted 15 lines · Jonathan Albrieux

Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream it is indicated that "batt_id" channel has to be scaled with the default function:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};
Quoted 2 lines

Change LR_MUX2_BAT_ID scaling accordingly.

Quoted 9 lines

Not entirely sure, but looking at the history I think this used to work
- but it's obvious that no one has read this channel for a while...

But I think below is a regression and should be mentioned:

Fixes 7c271eea7b8a ("iio: adc: spmi-vadc: Changes to support different scaling")

Yikes that was a while ago :)

Quoted 4 lines
Quoted 1 line

Jonathan Cameron, if you merge this through your tree I can take the dts addition through the Qualcomm tree.

Applied to the fixes-togreg branch of iio.git and marked for stable.

I'm not going to rush this one given age of the bug, but if I happen to have anything else going it'll make it before the end of this cycle.

Thanks,

Jonathan

Quoted 24 lines

Regards,
Bjorn

Quoted 20 lines
---
 drivers/iio/adc/qcom-spmi-vadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/qcom-spmi-vadc.c +1 -1
index b0388f8a69f4..7e7d408452ec 100644
@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
 
 	VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
-	VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
+	VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
 	VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 1/2] iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel

Quoted 64 lines · Jonathan Cameron
Quoted 20 lines · On Fri, 15 Jan 2021 10:30:49 -0600 Bjorn Andersson…
Quoted 15 lines · Jonathan Albrieux

Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream it is indicated that "batt_id" channel has to be scaled with the default function:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};
Quoted 2 lines

Change LR_MUX2_BAT_ID scaling accordingly.

Quoted 9 lines

Not entirely sure, but looking at the history I think this used to work
- but it's obvious that no one has read this channel for a while...

But I think below is a regression and should be mentioned:

Fixes 7c271eea7b8a ("iio: adc: spmi-vadc: Changes to support different scaling")

Yikes that was a while ago :)

Quoted 4 lines
Quoted 1 line

Jonathan Cameron, if you merge this through your tree I can take the dts addition through the Qualcomm tree.

Applied to the fixes-togreg branch of iio.git and marked for stable.

I'm not going to rush this one given age of the bug, but if I happen to have anything else going it'll make it before the end of this cycle.

Thanks,

Jonathan

Quoted 15 lines

Regards,
Bjorn

Quoted 11 lines
---
 drivers/iio/adc/qcom-spmi-vadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/qcom-spmi-vadc.c +0 -0
index b0388f8a69f4..7e7d408452ec 100644
@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
 
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
drivers/iio/adc/qcom-spmi-vadc.c +1 -1
 	VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
-	VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
+	VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
 	VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
 	VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
Signature · 1 line
2.17.1

Thank you Bjorn, thank you Jonathan,

Regards,

Jonathan

#5 lore raw

PATCH 2/2 arm64: dts: qcom: pm8916: Add batt_id channel node

In reply to Jonathan Albrieux

Working on a battery charger and fuel gauge driver it happened to have the need to read from VADC_LR_MUX2_BAT_ID channel. Here is the declaration from downstream msm8916.dtsi:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

Add VADC_LR_MUX2_BAT_ID accordingly.

---
 arch/arm64/boot/dts/qcom/pm8916.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/pm8916.dtsi +5 -0
index a7663bf867ec..854e51883289 100644
@@ -95,6 +95,11 @@
 			adc-chan@f {
 				reg = <VADC_VDD_VADC>;
 			};
+			adc-chan@g {
+				reg = <VADC_LR_MUX2_BAT_ID>;
+				qcom,hw-settle-time = <2000>;
+				qcom,ratiometric;
+			};
 		};
 
 		rtc@6000 {
Signature · 1 line
2.17.1