Skip to contentSkip to conversation

iio: adc: aspeed: Remove the trim valid dts property.

PATCH In review Billy Tsai 2 participants 3 messages Nov 14, 2022

Subsystems (3)
lore
Share & tools
lore

Billy Tsai

author reviewer
#0 lore raw

PATCH v3 1/2 iio: adc: aspeed: Remove the trim valid dts property.

The dts property "aspeed,trim-data-valid" is currently used to determine whether to read trimming data from the OTP register. If this is set on a device without valid trimming data in the OTP the ADC will not function correctly. This patch drops the use of this property and instead uses the default (unprogrammed) OTP value of 0 to detect when a fallback value of 0x8 should be used rather then the value read from the OTP.

Fixes d0a4c17b4073 ("iio: adc: aspeed: Get and set trimming data.")
---
 drivers/iio/adc/aspeed_adc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/adc/aspeed_adc.c +5 -6
index 9341e0e0eb55..998e8bcc06e1 100644
@@ -202,6 +202,8 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
 				((scu_otp) &
 				 (data->model_data->trim_locate->field)) >>
 				__ffs(data->model_data->trim_locate->field);
+			if (!trimming_val)
+				trimming_val = 0x8;
 		}
 		dev_dbg(data->dev,
 			"trimming val = %d, offset = %08x, fields = %08x\n",
@@ -563,12 +565,9 @@ static int aspeed_adc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid",
-			     NULL)) {
-		ret = aspeed_adc_set_trim_data(indio_dev);
-		if (ret)
-			return ret;
-	}
+	ret = aspeed_adc_set_trim_data(indio_dev);
+	if (ret)
+		return ret;
 
 	if (of_find_property(data->dev->of_node, "aspeed,battery-sensing",
 			     NULL)) {
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH v3 2/2 dt-bindings: iio: adc: Remove the property "aspeed,trim-data-valid"

If the property is set on a device without valid trimming data in the OTP the ADC will not function correctly. Therefore, this patch drops the use of this property to avoid this scenario.

Fixes 2bdb2f00a895 ("dt-bindings: iio: adc: Add ast2600-adc bindings")
---
 .../devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml    | 7 -------
 1 file changed, 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml +0 -7
index b283c8ca2bbf..5c08d8b6e995 100644
@@ -62,13 +62,6 @@ properties:
     description:
       Inform the driver that last channel will be used to sensor battery.
 
-  aspeed,trim-data-valid:
-    type: boolean
-    description: |
-      The ADC reference voltage can be calibrated to obtain the trimming
-      data which will be stored in otp. This property informs the driver that
-      the data store in the otp is valid.
-
 required:
   - compatible
   - reg
Signature · 1 line
2.25.1
maintainer
#2 lore raw
In reply to Billy Tsai
Quoted 9 lines · On Mon, 14 Nov 2022 10:50:56 +0800 Billy Tsai <[email protected]> wrote:

The dts property "aspeed,trim-data-valid" is currently used to determine whether to read trimming data from the OTP register. If this is set on a device without valid trimming data in the OTP the ADC will not function correctly. This patch drops the use of this property and instead uses the default (unprogrammed) OTP value of 0 to detect when a fallback value of 0x8 should be used rather then the value read from the OTP.

Fixes d0a4c17b4073 ("iio: adc: aspeed: Get and set trimming data.")

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

Thanks,

Jonathan

Quoted 33 lines
---
 drivers/iio/adc/aspeed_adc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/adc/aspeed_adc.c +5 -6
index 9341e0e0eb55..998e8bcc06e1 100644
@@ -202,6 +202,8 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
 				((scu_otp) &
 				 (data->model_data->trim_locate->field)) >>
 				__ffs(data->model_data->trim_locate->field);
+			if (!trimming_val)
+				trimming_val = 0x8;
 		}
 		dev_dbg(data->dev,
 			"trimming val = %d, offset = %08x, fields = %08x\n",
@@ -563,12 +565,9 @@ static int aspeed_adc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid",
-			     NULL)) {
-		ret = aspeed_adc_set_trim_data(indio_dev);
-		if (ret)
-			return ret;
-	}
+	ret = aspeed_adc_set_trim_data(indio_dev);
+	if (ret)
+		return ret;
 
 	if (of_find_property(data->dev->of_node, "aspeed,battery-sensing",
 			     NULL)) {