All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor
@ 2022-04-29 22:01 Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 01/10] iio: sx9324: Fix default precharge internal resistance register Gwendal Grignou
                   ` (10 more replies)
  0 siblings, 11 replies; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

For Semtech sensors SX9324 and SX9360, allow confugration of the
pre-charge resistor (9324/9360) and internal resistor (9324).

Fix register name spelling mistakes first and set default value properly
for sx9324 internal resistor register.

The 9360 changes are independent from the 9324 changes, but they are
very similar.

Changes since v4:
- Add analog gain setting
- Add missing test when property is not found
- Fix dt-schema errors.

Changes since v3:
- Rename reserved field as _RESERVED_
- Fix invalid string matching with match_string()
- Fix cut and paste error in device tree bindings.

Changes since v2:
- use -ohms instead of -kohms, as ohms is a defined unit in
  dt-schema.git dtschema/schemas/property-units.yaml

Changes sinve v1:
- Add kOhm Unit, add a new patch to fix invalid register setting.

Gwendal Grignou (10):
  iio: sx9324: Fix default precharge internal resistance register
  iio: sx9324: Fix register field spelling
  dt-bindings: iio: sx9324: Add precharge resistor setting
  iio: sx9324: Add precharge internal resistance setting
  dt-bindings: iio: sx9324: Add internal compensation resistor setting
  iio: sx9324: Add Setting for internal compensation resistor
  dt-bindings: iio: sx9324: Add input analog gain
  iio: sx9324: Add Setting for internal analog gain
  dt-bindings: iio: sx9360: Add precharge resistor setting
  iio: sx9360: Add pre-charge resistor setting

 .../iio/proximity/semtech,sx9324.yaml         | 30 +++++++++
 .../iio/proximity/semtech,sx9360.yaml         |  9 +++
 drivers/iio/proximity/sx9324.c                | 66 +++++++++++++++++--
 drivers/iio/proximity/sx9360.c                | 15 ++++-
 4 files changed, 114 insertions(+), 6 deletions(-)

-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v5 01/10] iio: sx9324: Fix default precharge internal resistance register
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 02/10] iio: sx9324: Fix register field spelling Gwendal Grignou
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Fix the default value for the register that set the resistance:
it has to be 0x10 per datasheet.

Fixes: 4c18a890dff8d ("iio:proximity:sx9324: Add SX9324 support")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
No changes since v4, already targeted for stable kernels.
Changes since v3:
- Fix commit, use RESERVED instead of RSVD.
Changes since v2:
- no changes

Changes since v1:
- new patch.

 drivers/iio/proximity/sx9324.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 0d9bbbb50cb45..378c2a17bae6e 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -70,7 +70,8 @@
 #define SX9324_REG_AFE_PH2		0x2a
 #define SX9324_REG_AFE_PH3		0x2b
 #define SX9324_REG_AFE_CTRL8		0x2c
-#define SX9324_REG_AFE_CTRL8_RESFILTN_4KOHM 0x02
+#define SX9324_REG_AFE_CTRL8_RESERVED	0x10
+#define SX9324_REG_AFE_CTRL8_RESFILTIN_4KOHM 0x02
 #define SX9324_REG_AFE_CTRL9		0x2d
 #define SX9324_REG_AFE_CTRL9_AGAIN_1	0x08
 
@@ -781,7 +782,8 @@ static const struct sx_common_reg_default sx9324_default_regs[] = {
 	{ SX9324_REG_AFE_PH2, 0x1a },
 	{ SX9324_REG_AFE_PH3, 0x16 },
 
-	{ SX9324_REG_AFE_CTRL8, SX9324_REG_AFE_CTRL8_RESFILTN_4KOHM },
+	{ SX9324_REG_AFE_CTRL8, SX9324_REG_AFE_CTRL8_RESERVED |
+		SX9324_REG_AFE_CTRL8_RESFILTIN_4KOHM },
 	{ SX9324_REG_AFE_CTRL9, SX9324_REG_AFE_CTRL9_AGAIN_1 },
 
 	{ SX9324_REG_PROX_CTRL0, SX9324_REG_PROX_CTRL0_GAIN_1 |
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 02/10] iio: sx9324: Fix register field spelling
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 01/10] iio: sx9324: Fix default precharge internal resistance register Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-06-04 16:19   ` Jonathan Cameron
  2022-04-29 22:01 ` [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting Gwendal Grignou
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Field for PROX_CTRL4 should contain PROX_CTRL4.

Fixes: 4c18a890dff8d ("iio:proximity:sx9324: Add SX9324 support")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
No Changes in v5.
Changes since v3:
- Added Review tags.

Changes since v2:
- no changes

Changes since v1:
- Add Fixes keyword in commit message.

 drivers/iio/proximity/sx9324.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 378c2a17bae6e..a7d9a53692a6d 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -90,7 +90,7 @@
 #define SX9324_REG_PROX_CTRL4_AVGNEGFILT_MASK	GENMASK(5, 3)
 #define SX9324_REG_PROX_CTRL4_AVGNEG_FILT_2 0x08
 #define SX9324_REG_PROX_CTRL4_AVGPOSFILT_MASK	GENMASK(2, 0)
-#define SX9324_REG_PROX_CTRL3_AVGPOS_FILT_256 0x04
+#define SX9324_REG_PROX_CTRL4_AVGPOS_FILT_256 0x04
 #define SX9324_REG_PROX_CTRL5		0x35
 #define SX9324_REG_PROX_CTRL5_HYST_MASK			GENMASK(5, 4)
 #define SX9324_REG_PROX_CTRL5_CLOSE_DEBOUNCE_MASK	GENMASK(3, 2)
@@ -794,7 +794,7 @@ static const struct sx_common_reg_default sx9324_default_regs[] = {
 	{ SX9324_REG_PROX_CTRL3, SX9324_REG_PROX_CTRL3_AVGDEB_2SAMPLES |
 		SX9324_REG_PROX_CTRL3_AVGPOS_THRESH_16K },
 	{ SX9324_REG_PROX_CTRL4, SX9324_REG_PROX_CTRL4_AVGNEG_FILT_2 |
-		SX9324_REG_PROX_CTRL3_AVGPOS_FILT_256 },
+		SX9324_REG_PROX_CTRL4_AVGPOS_FILT_256 },
 	{ SX9324_REG_PROX_CTRL5, 0x00 },
 	{ SX9324_REG_PROX_CTRL6, SX9324_REG_PROX_CTRL6_PROXTHRESH_32 },
 	{ SX9324_REG_PROX_CTRL7, SX9324_REG_PROX_CTRL6_PROXTHRESH_32 },
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 01/10] iio: sx9324: Fix default precharge internal resistance register Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 02/10] iio: sx9324: Fix register field spelling Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-06-04 16:20   ` Jonathan Cameron
  2022-04-29 22:01 ` [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting Gwendal Grignou
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd
  Cc: linux-iio, devicetree, Gwendal Grignou, Rob Herring

Allow configure the resistance used during precharge.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Rob Herring <robh@kernel.org>
---
Changes since v4:
- Add multipleOf propery
- Move description at the end, to match convension.

Changes since v3:
- Added Review tags.

Changes since v2:
- Change kOhms into ohms.

Changes since v1:
- Suffix field with kOhms unit.

 .../bindings/iio/proximity/semtech,sx9324.yaml           | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
index b8a6ee16854ff..d689b2bab71b4 100644
--- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
+++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
@@ -126,6 +126,14 @@ properties:
       UINT_MAX (4294967295) represents infinite. Other values
       represent 1-1/N.
 
+  semtech,input-precharge-resistor-ohms:
+    default: 4000
+    multipleOf: 2000
+    minimum: 0
+    maximum: 30000
+    description:
+      Pre-charge input resistance in Ohm.
+
 required:
   - compatible
   - reg
@@ -157,5 +165,6 @@ examples:
         semtech,ph01-proxraw-strength = <2>;
         semtech,ph23-proxraw-strength = <2>;
         semtech,avg-pos-strength = <64>;
+        semtech,input-precharge-resistor-ohms = <2000>;
       };
     };
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (2 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-06-04 16:21   ` Jonathan Cameron
  2022-04-29 22:01 ` [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting Gwendal Grignou
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Add ability to set the precharge internal resistance from the device
tree.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes since v4:
- Added missing tests when property is not found.

Changes since v3:
- Added Review tags.

Changes since v2:
- Change kOhms into ohms.

Changes since v1:
- Suffix field with kOhms unit.
- Split patch in 2.

 drivers/iio/proximity/sx9324.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index a7d9a53692a6d..8eec73f7641ee 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -72,6 +72,7 @@
 #define SX9324_REG_AFE_CTRL8		0x2c
 #define SX9324_REG_AFE_CTRL8_RESERVED	0x10
 #define SX9324_REG_AFE_CTRL8_RESFILTIN_4KOHM 0x02
+#define SX9324_REG_AFE_CTRL8_RESFILTIN_MASK GENMASK(3, 0)
 #define SX9324_REG_AFE_CTRL9		0x2d
 #define SX9324_REG_AFE_CTRL9_AGAIN_1	0x08
 
@@ -893,6 +894,18 @@ sx9324_get_default_reg(struct device *dev, int idx,
 		reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL4_RESOLUTION_MASK,
 					   raw);
 		break;
+	case SX9324_REG_AFE_CTRL8:
+		ret = device_property_read_u32(dev,
+				"semtech,input-precharge-resistor-ohms",
+				&raw);
+		if (ret)
+			break;
+
+		reg_def->def &= ~SX9324_REG_AFE_CTRL8_RESFILTIN_MASK;
+		reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL8_RESFILTIN_MASK,
+					   raw / 2000);
+		break;
+
 	case SX9324_REG_ADV_CTRL5:
 		ret = device_property_read_u32(dev, "semtech,startup-sensor",
 					       &start);
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (3 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-06-04 16:22   ` Jonathan Cameron
  2022-04-29 22:01 ` [PATCH v5 06/10] iio: sx9324: Add Setting for internal compensation resistor Gwendal Grignou
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd
  Cc: linux-iio, devicetree, Gwendal Grignou, Rob Herring

Allow setting the internal resistor used for compensation.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Rob Herring <robh@kernel.org>
---
Changes since v4:
- no changes

Changes since v3:
- Added Review tags.

Changes since v2:
- no changes

Changes since v1:
- no changes

 .../bindings/iio/proximity/semtech,sx9324.yaml         | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
index d689b2bab71b4..0be87ac05b97a 100644
--- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
+++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
@@ -126,6 +126,15 @@ properties:
       UINT_MAX (4294967295) represents infinite. Other values
       represent 1-1/N.
 
+  semtech,int-comp-resistor:
+    description:
+      Internal resistor setting for compensation.
+    enum:
+      - lowest
+      - low
+      - high
+      - highest
+
   semtech,input-precharge-resistor-ohms:
     default: 4000
     multipleOf: 2000
@@ -165,6 +174,7 @@ examples:
         semtech,ph01-proxraw-strength = <2>;
         semtech,ph23-proxraw-strength = <2>;
         semtech,avg-pos-strength = <64>;
+        semtech,int-comp-resistor = "lowest";
         semtech,input-precharge-resistor-ohms = <2000>;
       };
     };
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 06/10] iio: sx9324: Add Setting for internal compensation resistor
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (4 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Based on device tree setting, set the internal compensation resistor.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes since v4:
- No changes.

Changes since v3:
- Use match_string() to prevent incorrect matching.

Changes since v2:
- No changes.

Changes since v1:
- No changes.

 drivers/iio/proximity/sx9324.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 8eec73f7641ee..6806262eb1c92 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -52,6 +52,11 @@
 #define SX9324_REG_CLK_SPRD		0x15
 
 #define SX9324_REG_AFE_CTRL0		0x20
+#define SX9324_REG_AFE_CTRL0_RINT_SHIFT		6
+#define SX9324_REG_AFE_CTRL0_RINT_MASK \
+	GENMASK(SX9324_REG_AFE_CTRL0_RINT_SHIFT + 1, \
+		SX9324_REG_AFE_CTRL0_RINT_SHIFT)
+#define SX9324_REG_AFE_CTRL0_RINT_LOWEST	0x00
 #define SX9324_REG_AFE_CTRL1		0x21
 #define SX9324_REG_AFE_CTRL2		0x22
 #define SX9324_REG_AFE_CTRL3		0x23
@@ -769,7 +774,7 @@ static const struct sx_common_reg_default sx9324_default_regs[] = {
 	 */
 	{ SX9324_REG_GNRL_CTRL1, SX9324_REG_GNRL_CTRL1_PAUSECTRL },
 
-	{ SX9324_REG_AFE_CTRL0, 0x00 },
+	{ SX9324_REG_AFE_CTRL0, SX9324_REG_AFE_CTRL0_RINT_LOWEST },
 	{ SX9324_REG_AFE_CTRL3, 0x00 },
 	{ SX9324_REG_AFE_CTRL4, SX9324_REG_AFE_CTRL4_FREQ_83_33HZ |
 		SX9324_REG_AFE_CTRL4_RES_100 },
@@ -848,6 +853,8 @@ static const struct sx_common_reg_default *
 sx9324_get_default_reg(struct device *dev, int idx,
 		       struct sx_common_reg_default *reg_def)
 {
+	static const char * const sx9324_rints[] = { "lowest", "low", "high",
+		"highest" };
 #define SX9324_PIN_DEF "semtech,ph0-pin"
 #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution"
 #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength"
@@ -855,6 +862,7 @@ sx9324_get_default_reg(struct device *dev, int idx,
 	char prop[] = SX9324_PROXRAW_DEF;
 	u32 start = 0, raw = 0, pos = 0;
 	int ret, count, ph, pin;
+	const char *res;
 
 	memcpy(reg_def, &sx9324_default_regs[idx], sizeof(*reg_def));
 	switch (reg_def->reg) {
@@ -875,6 +883,17 @@ sx9324_get_default_reg(struct device *dev, int idx,
 			       SX9324_REG_AFE_PH0_PIN_MASK(pin);
 		reg_def->def = raw;
 		break;
+	case SX9324_REG_AFE_CTRL0:
+		ret = device_property_read_string(dev,
+				"semtech,int-comp-resistor", &res);
+		if (ret)
+			break;
+		ret = match_string(sx9324_rints, ARRAY_SIZE(sx9324_rints), res);
+		if (ret < 0)
+			break;
+		reg_def->def &= ~SX9324_REG_AFE_CTRL0_RINT_MASK;
+		reg_def->def |= ret << SX9324_REG_AFE_CTRL0_RINT_SHIFT;
+		break;
 	case SX9324_REG_AFE_CTRL4:
 	case SX9324_REG_AFE_CTRL7:
 		if (reg_def->reg == SX9324_REG_AFE_CTRL4)
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (5 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 06/10] iio: sx9324: Add Setting for internal compensation resistor Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-05-01 17:17   ` Jonathan Cameron
                     ` (2 more replies)
  2022-04-29 22:01 ` [PATCH v5 08/10] iio: sx9324: Add Setting for internal " Gwendal Grignou
                   ` (3 subsequent siblings)
  10 siblings, 3 replies; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Allow setting the configure the input analog gain.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
New in v5.

 .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
index 0be87ac05b97a..d265eb5258c84 100644
--- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
+++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
@@ -143,6 +143,17 @@ properties:
     description:
       Pre-charge input resistance in Ohm.
 
+  semtech,input-analog-gain:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 0
+    maximum: 3
+    description: |
+      Defines the input antenna analog gain
+      0: x1.247
+      1: x1 (default)
+      2: x0.768
+      3: x0.552
+
 required:
   - compatible
   - reg
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 08/10] iio: sx9324: Add Setting for internal analog gain
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (6 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-05-03 19:12   ` Stephen Boyd
  2022-04-29 22:01 ` [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting Gwendal Grignou
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Based on device tree setting, set the internal analog gain.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
New in v5.

 drivers/iio/proximity/sx9324.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 6806262eb1c92..851f2ff0ae7e8 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -79,6 +79,7 @@
 #define SX9324_REG_AFE_CTRL8_RESFILTIN_4KOHM 0x02
 #define SX9324_REG_AFE_CTRL8_RESFILTIN_MASK GENMASK(3, 0)
 #define SX9324_REG_AFE_CTRL9		0x2d
+#define SX9324_REG_AFE_CTRL9_AGAIN_MASK			GENMASK(3, 0)
 #define SX9324_REG_AFE_CTRL9_AGAIN_1	0x08
 
 #define SX9324_REG_PROX_CTRL0		0x30
@@ -925,6 +926,27 @@ sx9324_get_default_reg(struct device *dev, int idx,
 					   raw / 2000);
 		break;
 
+	case SX9324_REG_AFE_CTRL9:
+		ret = device_property_read_u32(dev,
+				"semtech,input-analog-gain", &raw);
+		if (ret)
+			break;
+		/*
+		 * The analog gain has the following setting:
+		 * +---------+----------------+----------------+
+		 * | dt(raw) | physical value | register value |
+		 * +---------+----------------+----------------+
+		 * |  0      |      x1.247    |      6         |
+		 * |  1      |      x1        |      8         |
+		 * |  2      |      x0.768    |     11         |
+		 * |  3      |      x0.552    |     15         |
+		 * +---------+----------------+----------------+
+		 */
+		reg_def->def &= ~SX9324_REG_AFE_CTRL9_AGAIN_MASK;
+		reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL9_AGAIN_MASK,
+					   6 + raw * (raw + 3) / 2);
+		break;
+
 	case SX9324_REG_ADV_CTRL5:
 		ret = device_property_read_u32(dev, "semtech,startup-sensor",
 					       &start);
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (7 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 08/10] iio: sx9324: Add Setting for internal " Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-05-03 18:03   ` Rob Herring
  2022-04-29 22:01 ` [PATCH v5 10/10] iio: sx9360: Add pre-charge " Gwendal Grignou
  2022-05-01 17:20 ` [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Jonathan Cameron
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Allow configure the resistance used during precharge.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes since v4:
- Add multipleOf propery
- Move description at the end, to match convension.

Changes since v3:
- Fix maximum field. Check make dt_binding_check passes.

Changes since v2:
- Change kOhms into ohms.

Changes since v1:
- Suffix property with kOhms.

 .../bindings/iio/proximity/semtech,sx9360.yaml           | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9360.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9360.yaml
index 63e1a1fd00d4c..f088c5d2be99c 100644
--- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9360.yaml
+++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9360.yaml
@@ -61,6 +61,14 @@ properties:
       UINT_MAX (4294967295) represents infinite. Other values
       represent 1-1/N.
 
+  semtech,input-precharge-resistor-ohms:
+    default: 0
+    multipleOf: 2000
+    minimum: 0
+    maximum: 30000
+    description:
+      Pre-charge input resistance in Ohm.
+
 required:
   - compatible
   - reg
@@ -85,5 +93,6 @@ examples:
         semtech,resolution = <256>;
         semtech,proxraw-strength = <2>;
         semtech,avg-pos-strength = <64>;
+        semtech,input-precharge-resistor-ohms = <4000>;
       };
     };
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v5 10/10] iio: sx9360: Add pre-charge resistor setting
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (8 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting Gwendal Grignou
@ 2022-04-29 22:01 ` Gwendal Grignou
  2022-06-04 16:26   ` Jonathan Cameron
  2022-05-01 17:20 ` [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Jonathan Cameron
  10 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-04-29 22:01 UTC (permalink / raw)
  To: jic23, robh+dt, swboyd; +Cc: linux-iio, devicetree, Gwendal Grignou

Add ability to set the precharge internal resistance from the device
tree.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes since v4:
- Added missing tests when property is not found.

Changes since v3:
- Added Review tags.

Changes since v2:
- Change kOhms into ohms.

Changes since v1:
- Suffix field with kOhms unit.

 drivers/iio/proximity/sx9360.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index 3ebb30c8a4f61..d9a12e6be6ca6 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -51,6 +51,8 @@
 #define SX9360_REG_GNRL_REG_2_FREQ(_r)  (SX9360_FOSC_HZ / ((_r) * 8192))
 
 #define SX9360_REG_AFE_CTRL1		0x21
+#define SX9360_REG_AFE_CTRL1_RESFILTIN_MASK GENMASK(3, 0)
+#define SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS 0
 #define SX9360_REG_AFE_PARAM0_PHR	0x22
 #define SX9360_REG_AFE_PARAM1_PHR	0x23
 #define SX9360_REG_AFE_PARAM0_PHM	0x24
@@ -671,7 +673,7 @@ static const struct sx_common_reg_default sx9360_default_regs[] = {
 	{ SX9360_REG_GNRL_CTRL1, 0x00 },
 	{ SX9360_REG_GNRL_CTRL2, SX9360_REG_GNRL_CTRL2_PERIOD_102MS },
 
-	{ SX9360_REG_AFE_CTRL1, 0x00 },
+	{ SX9360_REG_AFE_CTRL1, SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS },
 	{ SX9360_REG_AFE_PARAM0_PHR, SX9360_REG_AFE_PARAM0_RSVD |
 		SX9360_REG_AFE_PARAM0_RESOLUTION_128 },
 	{ SX9360_REG_AFE_PARAM1_PHR, SX9360_REG_AFE_PARAM1_AGAIN_PHM_6PF |
@@ -722,6 +724,17 @@ sx9360_get_default_reg(struct device *dev, int idx,
 
 	memcpy(reg_def, &sx9360_default_regs[idx], sizeof(*reg_def));
 	switch (reg_def->reg) {
+	case SX9360_REG_AFE_CTRL1:
+		ret = device_property_read_u32(dev,
+				"semtech,input-precharge-resistor-ohms",
+				&raw);
+		if (ret)
+			break;
+
+		reg_def->def &= ~SX9360_REG_AFE_CTRL1_RESFILTIN_MASK;
+		reg_def->def |= FIELD_PREP(SX9360_REG_AFE_CTRL1_RESFILTIN_MASK,
+					   raw / 2000);
+		break;
 	case SX9360_REG_AFE_PARAM0_PHR:
 	case SX9360_REG_AFE_PARAM0_PHM:
 		ret = device_property_read_u32(dev, "semtech,resolution", &raw);
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
@ 2022-05-01 17:17   ` Jonathan Cameron
  2022-05-10  5:48     ` Gwendal Grignou
  2022-05-03 18:02   ` Rob Herring
  2022-05-03 19:10   ` Stephen Boyd
  2 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2022-05-01 17:17 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Fri, 29 Apr 2022 15:01:41 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Allow setting the configure the input analog gain.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

Hi Gwendal.

So, my immediate thought on this is whether it make sense as a
dt controlled thing or not. It's the sort of thing hardwaregain
is for in the userspace ABI. However, I see that's already
in use for the digital gain. This one also unhelpfully applies
to all changes whereas the digital gain is pair wise. Hence
there is basically no way we can map the two controls to a
single ABI element.

So, how would we expect a board designer to set this value?

If the answer is we basically have no idea but some boards do
want it set then I'm fine with this basically being a somewhat magic
value that is in some vague way associated with the antenna setup...

Jonathan

> ---
> New in v5.
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> index 0be87ac05b97a..d265eb5258c84 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> @@ -143,6 +143,17 @@ properties:
>      description:
>        Pre-charge input resistance in Ohm.
>  
> +  semtech,input-analog-gain:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    minimum: 0
> +    maximum: 3
> +    description: |
> +      Defines the input antenna analog gain
> +      0: x1.247
> +      1: x1 (default)
> +      2: x0.768
> +      3: x0.552
> +
>  required:
>    - compatible
>    - reg


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor
  2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
                   ` (9 preceding siblings ...)
  2022-04-29 22:01 ` [PATCH v5 10/10] iio: sx9360: Add pre-charge " Gwendal Grignou
@ 2022-05-01 17:20 ` Jonathan Cameron
  10 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-05-01 17:20 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Fri, 29 Apr 2022 15:01:34 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> For Semtech sensors SX9324 and SX9360, allow confugration of the
> pre-charge resistor (9324/9360) and internal resistor (9324).
> 
> Fix register name spelling mistakes first and set default value properly
> for sx9324 internal resistor register.
> 
> The 9360 changes are independent from the 9324 changes, but they are
> very similar.

Other than the question I raised on the analog gain patch and
the need to leave time for a DT review of the last couple of 
binding patches, this looks good to me.  If it looks like that
might take a while I might pick up the first 6 patches without
waiting for the last 4.

Thanks,

Jonathan

> 
> Changes since v4:
> - Add analog gain setting
> - Add missing test when property is not found
> - Fix dt-schema errors.
> 
> Changes since v3:
> - Rename reserved field as _RESERVED_
> - Fix invalid string matching with match_string()
> - Fix cut and paste error in device tree bindings.
> 
> Changes since v2:
> - use -ohms instead of -kohms, as ohms is a defined unit in
>   dt-schema.git dtschema/schemas/property-units.yaml
> 
> Changes sinve v1:
> - Add kOhm Unit, add a new patch to fix invalid register setting.
> 
> Gwendal Grignou (10):
>   iio: sx9324: Fix default precharge internal resistance register
>   iio: sx9324: Fix register field spelling
>   dt-bindings: iio: sx9324: Add precharge resistor setting
>   iio: sx9324: Add precharge internal resistance setting
>   dt-bindings: iio: sx9324: Add internal compensation resistor setting
>   iio: sx9324: Add Setting for internal compensation resistor
>   dt-bindings: iio: sx9324: Add input analog gain
>   iio: sx9324: Add Setting for internal analog gain
>   dt-bindings: iio: sx9360: Add precharge resistor setting
>   iio: sx9360: Add pre-charge resistor setting
> 
>  .../iio/proximity/semtech,sx9324.yaml         | 30 +++++++++
>  .../iio/proximity/semtech,sx9360.yaml         |  9 +++
>  drivers/iio/proximity/sx9324.c                | 66 +++++++++++++++++--
>  drivers/iio/proximity/sx9360.c                | 15 ++++-
>  4 files changed, 114 insertions(+), 6 deletions(-)
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
  2022-05-01 17:17   ` Jonathan Cameron
@ 2022-05-03 18:02   ` Rob Herring
  2022-05-03 19:10   ` Stephen Boyd
  2 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2022-05-03 18:02 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: devicetree, jic23, swboyd, linux-iio, robh+dt

On Fri, 29 Apr 2022 15:01:41 -0700, Gwendal Grignou wrote:
> Allow setting the configure the input analog gain.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---
> New in v5.
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting
  2022-04-29 22:01 ` [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting Gwendal Grignou
@ 2022-05-03 18:03   ` Rob Herring
  2022-06-04 16:25     ` Jonathan Cameron
  0 siblings, 1 reply; 26+ messages in thread
From: Rob Herring @ 2022-05-03 18:03 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: swboyd, devicetree, linux-iio, jic23, robh+dt

On Fri, 29 Apr 2022 15:01:43 -0700, Gwendal Grignou wrote:
> Allow configure the resistance used during precharge.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> ---
> Changes since v4:
> - Add multipleOf propery
> - Move description at the end, to match convension.
> 
> Changes since v3:
> - Fix maximum field. Check make dt_binding_check passes.
> 
> Changes since v2:
> - Change kOhms into ohms.
> 
> Changes since v1:
> - Suffix property with kOhms.
> 
>  .../bindings/iio/proximity/semtech,sx9360.yaml           | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
  2022-05-01 17:17   ` Jonathan Cameron
  2022-05-03 18:02   ` Rob Herring
@ 2022-05-03 19:10   ` Stephen Boyd
  2 siblings, 0 replies; 26+ messages in thread
From: Stephen Boyd @ 2022-05-03 19:10 UTC (permalink / raw)
  To: Gwendal Grignou, jic23, robh+dt; +Cc: linux-iio, devicetree

Quoting Gwendal Grignou (2022-04-29 15:01:41)
> Allow setting the configure the input analog gain.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 08/10] iio: sx9324: Add Setting for internal analog gain
  2022-04-29 22:01 ` [PATCH v5 08/10] iio: sx9324: Add Setting for internal " Gwendal Grignou
@ 2022-05-03 19:12   ` Stephen Boyd
  2022-06-04 16:25     ` Jonathan Cameron
  0 siblings, 1 reply; 26+ messages in thread
From: Stephen Boyd @ 2022-05-03 19:12 UTC (permalink / raw)
  To: Gwendal Grignou, jic23, robh+dt; +Cc: linux-iio, devicetree

Quoting Gwendal Grignou (2022-04-29 15:01:42)
> Based on device tree setting, set the internal analog gain.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-05-01 17:17   ` Jonathan Cameron
@ 2022-05-10  5:48     ` Gwendal Grignou
  2022-06-04 16:23       ` Jonathan Cameron
  0 siblings, 1 reply; 26+ messages in thread
From: Gwendal Grignou @ 2022-05-10  5:48 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Sun, May 1, 2022 at 10:09 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Fri, 29 Apr 2022 15:01:41 -0700
> Gwendal Grignou <gwendal@chromium.org> wrote:
>
> > Allow setting the configure the input analog gain.
> >
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
>
> Hi Gwendal.
>
> So, my immediate thought on this is whether it make sense as a
> dt controlled thing or not. It's the sort of thing hardwaregain
> is for in the userspace ABI. However, I see that's already
> in use for the digital gain. This one also unhelpfully applies
> to all changes whereas the digital gain is pair wise. Hence
> there is basically no way we can map the two controls to a
> single ABI element.
>
> So, how would we expect a board designer to set this value?
>
> If the answer is we basically have no idea but some boards do
> want it set then I'm fine with this basically being a somewhat magic
> value that is in some vague way associated with the antenna setup...
More or less :-). All these parameters are set with the help of
Semtech application engineers. The input analog gain is directly
linked to the antenna design, as it is used by the AFE (Analog Front
End). The hardwaregain (aka digital gain) comes second during the
digital processing. We could have put all the settings in the device
tree, as we don't expect changes once the values are satisfactory to
pass regulatory testings, but the hybrid approach still allows some
tinkering: I've use to get a sense of the data amplitude when
collecting data with /dev/iio:devoceX.
>
> Jonathan
>
> > ---
> > New in v5.
> >
> >  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > index 0be87ac05b97a..d265eb5258c84 100644
> > --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > @@ -143,6 +143,17 @@ properties:
> >      description:
> >        Pre-charge input resistance in Ohm.
> >
> > +  semtech,input-analog-gain:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    minimum: 0
> > +    maximum: 3
> > +    description: |
> > +      Defines the input antenna analog gain
> > +      0: x1.247
> > +      1: x1 (default)
> > +      2: x0.768
> > +      3: x0.552
> > +
> >  required:
> >    - compatible
> >    - reg
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 02/10] iio: sx9324: Fix register field spelling
  2022-04-29 22:01 ` [PATCH v5 02/10] iio: sx9324: Fix register field spelling Gwendal Grignou
@ 2022-06-04 16:19   ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:19 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Fri, 29 Apr 2022 15:01:36 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Field for PROX_CTRL4 should contain PROX_CTRL4.
> 
> Fixes: 4c18a890dff8d ("iio:proximity:sx9324: Add SX9324 support")
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Applied

> ---
> No Changes in v5.
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - no changes
> 
> Changes since v1:
> - Add Fixes keyword in commit message.
> 
>  drivers/iio/proximity/sx9324.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> index 378c2a17bae6e..a7d9a53692a6d 100644
> --- a/drivers/iio/proximity/sx9324.c
> +++ b/drivers/iio/proximity/sx9324.c
> @@ -90,7 +90,7 @@
>  #define SX9324_REG_PROX_CTRL4_AVGNEGFILT_MASK	GENMASK(5, 3)
>  #define SX9324_REG_PROX_CTRL4_AVGNEG_FILT_2 0x08
>  #define SX9324_REG_PROX_CTRL4_AVGPOSFILT_MASK	GENMASK(2, 0)
> -#define SX9324_REG_PROX_CTRL3_AVGPOS_FILT_256 0x04
> +#define SX9324_REG_PROX_CTRL4_AVGPOS_FILT_256 0x04
>  #define SX9324_REG_PROX_CTRL5		0x35
>  #define SX9324_REG_PROX_CTRL5_HYST_MASK			GENMASK(5, 4)
>  #define SX9324_REG_PROX_CTRL5_CLOSE_DEBOUNCE_MASK	GENMASK(3, 2)
> @@ -794,7 +794,7 @@ static const struct sx_common_reg_default sx9324_default_regs[] = {
>  	{ SX9324_REG_PROX_CTRL3, SX9324_REG_PROX_CTRL3_AVGDEB_2SAMPLES |
>  		SX9324_REG_PROX_CTRL3_AVGPOS_THRESH_16K },
>  	{ SX9324_REG_PROX_CTRL4, SX9324_REG_PROX_CTRL4_AVGNEG_FILT_2 |
> -		SX9324_REG_PROX_CTRL3_AVGPOS_FILT_256 },
> +		SX9324_REG_PROX_CTRL4_AVGPOS_FILT_256 },
>  	{ SX9324_REG_PROX_CTRL5, 0x00 },
>  	{ SX9324_REG_PROX_CTRL6, SX9324_REG_PROX_CTRL6_PROXTHRESH_32 },
>  	{ SX9324_REG_PROX_CTRL7, SX9324_REG_PROX_CTRL6_PROXTHRESH_32 },


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting
  2022-04-29 22:01 ` [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting Gwendal Grignou
@ 2022-06-04 16:20   ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:20 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree, Rob Herring

On Fri, 29 Apr 2022 15:01:37 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Allow configure the resistance used during precharge.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Rob Herring <robh@kernel.org>
Applied

> ---
> Changes since v4:
> - Add multipleOf propery
> - Move description at the end, to match convension.
> 
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - Change kOhms into ohms.
> 
> Changes since v1:
> - Suffix field with kOhms unit.
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml           | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> index b8a6ee16854ff..d689b2bab71b4 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> @@ -126,6 +126,14 @@ properties:
>        UINT_MAX (4294967295) represents infinite. Other values
>        represent 1-1/N.
>  
> +  semtech,input-precharge-resistor-ohms:
> +    default: 4000
> +    multipleOf: 2000
> +    minimum: 0
> +    maximum: 30000
> +    description:
> +      Pre-charge input resistance in Ohm.
> +
>  required:
>    - compatible
>    - reg
> @@ -157,5 +165,6 @@ examples:
>          semtech,ph01-proxraw-strength = <2>;
>          semtech,ph23-proxraw-strength = <2>;
>          semtech,avg-pos-strength = <64>;
> +        semtech,input-precharge-resistor-ohms = <2000>;
>        };
>      };


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting
  2022-04-29 22:01 ` [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting Gwendal Grignou
@ 2022-06-04 16:21   ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:21 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Fri, 29 Apr 2022 15:01:38 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Add ability to set the precharge internal resistance from the device
> tree.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Applied
> ---
> Changes since v4:
> - Added missing tests when property is not found.
> 
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - Change kOhms into ohms.
> 
> Changes since v1:
> - Suffix field with kOhms unit.
> - Split patch in 2.
> 
>  drivers/iio/proximity/sx9324.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> index a7d9a53692a6d..8eec73f7641ee 100644
> --- a/drivers/iio/proximity/sx9324.c
> +++ b/drivers/iio/proximity/sx9324.c
> @@ -72,6 +72,7 @@
>  #define SX9324_REG_AFE_CTRL8		0x2c
>  #define SX9324_REG_AFE_CTRL8_RESERVED	0x10
>  #define SX9324_REG_AFE_CTRL8_RESFILTIN_4KOHM 0x02
> +#define SX9324_REG_AFE_CTRL8_RESFILTIN_MASK GENMASK(3, 0)
>  #define SX9324_REG_AFE_CTRL9		0x2d
>  #define SX9324_REG_AFE_CTRL9_AGAIN_1	0x08
>  
> @@ -893,6 +894,18 @@ sx9324_get_default_reg(struct device *dev, int idx,
>  		reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL4_RESOLUTION_MASK,
>  					   raw);
>  		break;
> +	case SX9324_REG_AFE_CTRL8:
> +		ret = device_property_read_u32(dev,
> +				"semtech,input-precharge-resistor-ohms",
> +				&raw);
> +		if (ret)
> +			break;
> +
> +		reg_def->def &= ~SX9324_REG_AFE_CTRL8_RESFILTIN_MASK;
> +		reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL8_RESFILTIN_MASK,
> +					   raw / 2000);
> +		break;
> +
>  	case SX9324_REG_ADV_CTRL5:
>  		ret = device_property_read_u32(dev, "semtech,startup-sensor",
>  					       &start);


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting
  2022-04-29 22:01 ` [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting Gwendal Grignou
@ 2022-06-04 16:22   ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:22 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree, Rob Herring

On Fri, 29 Apr 2022 15:01:39 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Allow setting the internal resistor used for compensation.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Rob Herring <robh@kernel.org>
Applied.
> ---
> Changes since v4:
> - no changes
> 
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - no changes
> 
> Changes since v1:
> - no changes
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml         | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> index d689b2bab71b4..0be87ac05b97a 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> @@ -126,6 +126,15 @@ properties:
>        UINT_MAX (4294967295) represents infinite. Other values
>        represent 1-1/N.
>  
> +  semtech,int-comp-resistor:
> +    description:
> +      Internal resistor setting for compensation.
> +    enum:
> +      - lowest
> +      - low
> +      - high
> +      - highest
> +
>    semtech,input-precharge-resistor-ohms:
>      default: 4000
>      multipleOf: 2000
> @@ -165,6 +174,7 @@ examples:
>          semtech,ph01-proxraw-strength = <2>;
>          semtech,ph23-proxraw-strength = <2>;
>          semtech,avg-pos-strength = <64>;
> +        semtech,int-comp-resistor = "lowest";
>          semtech,input-precharge-resistor-ohms = <2000>;
>        };
>      };


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain
  2022-05-10  5:48     ` Gwendal Grignou
@ 2022-06-04 16:23       ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:23 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Mon, 9 May 2022 22:48:26 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> On Sun, May 1, 2022 at 10:09 AM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Fri, 29 Apr 2022 15:01:41 -0700
> > Gwendal Grignou <gwendal@chromium.org> wrote:
> >  
> > > Allow setting the configure the input analog gain.
> > >
> > > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>  
> >
> > Hi Gwendal.
> >
> > So, my immediate thought on this is whether it make sense as a
> > dt controlled thing or not. It's the sort of thing hardwaregain
> > is for in the userspace ABI. However, I see that's already
> > in use for the digital gain. This one also unhelpfully applies
> > to all changes whereas the digital gain is pair wise. Hence
> > there is basically no way we can map the two controls to a
> > single ABI element.
> >
> > So, how would we expect a board designer to set this value?
> >
> > If the answer is we basically have no idea but some boards do
> > want it set then I'm fine with this basically being a somewhat magic
> > value that is in some vague way associated with the antenna setup...  
> More or less :-). All these parameters are set with the help of
> Semtech application engineers. The input analog gain is directly
> linked to the antenna design, as it is used by the AFE (Analog Front
> End). The hardwaregain (aka digital gain) comes second during the
> digital processing. We could have put all the settings in the device
> tree, as we don't expect changes once the values are satisfactory to
> pass regulatory testings, but the hybrid approach still allows some
> tinkering: I've use to get a sense of the data amplitude when
> collecting data with /dev/iio:devoceX.

Fair enough. Applied,

Thanks,

Jonathan

> >
> > Jonathan
> >  
> > > ---
> > > New in v5.
> > >
> > >  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > > index 0be87ac05b97a..d265eb5258c84 100644
> > > --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > > +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> > > @@ -143,6 +143,17 @@ properties:
> > >      description:
> > >        Pre-charge input resistance in Ohm.
> > >
> > > +  semtech,input-analog-gain:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    minimum: 0
> > > +    maximum: 3
> > > +    description: |
> > > +      Defines the input antenna analog gain
> > > +      0: x1.247
> > > +      1: x1 (default)
> > > +      2: x0.768
> > > +      3: x0.552
> > > +
> > >  required:
> > >    - compatible
> > >    - reg  
> >  


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 08/10] iio: sx9324: Add Setting for internal analog gain
  2022-05-03 19:12   ` Stephen Boyd
@ 2022-06-04 16:25     ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:25 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Gwendal Grignou, robh+dt, linux-iio, devicetree

On Tue, 3 May 2022 12:12:09 -0700
Stephen Boyd <swboyd@chromium.org> wrote:

> Quoting Gwendal Grignou (2022-04-29 15:01:42)
> > Based on device tree setting, set the internal analog gain.
> >
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> > ---  
> 
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>

Applied,

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting
  2022-05-03 18:03   ` Rob Herring
@ 2022-06-04 16:25     ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:25 UTC (permalink / raw)
  To: Rob Herring; +Cc: Gwendal Grignou, swboyd, devicetree, linux-iio, robh+dt

On Tue, 3 May 2022 13:03:01 -0500
Rob Herring <robh@kernel.org> wrote:

> On Fri, 29 Apr 2022 15:01:43 -0700, Gwendal Grignou wrote:
> > Allow configure the resistance used during precharge.
> > 
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> > Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> > ---
> > Changes since v4:
> > - Add multipleOf propery
> > - Move description at the end, to match convension.
> > 
> > Changes since v3:
> > - Fix maximum field. Check make dt_binding_check passes.
> > 
> > Changes since v2:
> > - Change kOhms into ohms.
> > 
> > Changes since v1:
> > - Suffix property with kOhms.
> > 
> >  .../bindings/iio/proximity/semtech,sx9360.yaml           | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >   
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied,

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v5 10/10] iio: sx9360: Add pre-charge resistor setting
  2022-04-29 22:01 ` [PATCH v5 10/10] iio: sx9360: Add pre-charge " Gwendal Grignou
@ 2022-06-04 16:26   ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:26 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: robh+dt, swboyd, linux-iio, devicetree

On Fri, 29 Apr 2022 15:01:44 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Add ability to set the precharge internal resistance from the device
> tree.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>

Applied.  Thanks,

Jonathan

> ---
> Changes since v4:
> - Added missing tests when property is not found.
> 
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - Change kOhms into ohms.
> 
> Changes since v1:
> - Suffix field with kOhms unit.
> 
>  drivers/iio/proximity/sx9360.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
> index 3ebb30c8a4f61..d9a12e6be6ca6 100644
> --- a/drivers/iio/proximity/sx9360.c
> +++ b/drivers/iio/proximity/sx9360.c
> @@ -51,6 +51,8 @@
>  #define SX9360_REG_GNRL_REG_2_FREQ(_r)  (SX9360_FOSC_HZ / ((_r) * 8192))
>  
>  #define SX9360_REG_AFE_CTRL1		0x21
> +#define SX9360_REG_AFE_CTRL1_RESFILTIN_MASK GENMASK(3, 0)
> +#define SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS 0
>  #define SX9360_REG_AFE_PARAM0_PHR	0x22
>  #define SX9360_REG_AFE_PARAM1_PHR	0x23
>  #define SX9360_REG_AFE_PARAM0_PHM	0x24
> @@ -671,7 +673,7 @@ static const struct sx_common_reg_default sx9360_default_regs[] = {
>  	{ SX9360_REG_GNRL_CTRL1, 0x00 },
>  	{ SX9360_REG_GNRL_CTRL2, SX9360_REG_GNRL_CTRL2_PERIOD_102MS },
>  
> -	{ SX9360_REG_AFE_CTRL1, 0x00 },
> +	{ SX9360_REG_AFE_CTRL1, SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS },
>  	{ SX9360_REG_AFE_PARAM0_PHR, SX9360_REG_AFE_PARAM0_RSVD |
>  		SX9360_REG_AFE_PARAM0_RESOLUTION_128 },
>  	{ SX9360_REG_AFE_PARAM1_PHR, SX9360_REG_AFE_PARAM1_AGAIN_PHM_6PF |
> @@ -722,6 +724,17 @@ sx9360_get_default_reg(struct device *dev, int idx,
>  
>  	memcpy(reg_def, &sx9360_default_regs[idx], sizeof(*reg_def));
>  	switch (reg_def->reg) {
> +	case SX9360_REG_AFE_CTRL1:
> +		ret = device_property_read_u32(dev,
> +				"semtech,input-precharge-resistor-ohms",
> +				&raw);
> +		if (ret)
> +			break;
> +
> +		reg_def->def &= ~SX9360_REG_AFE_CTRL1_RESFILTIN_MASK;
> +		reg_def->def |= FIELD_PREP(SX9360_REG_AFE_CTRL1_RESFILTIN_MASK,
> +					   raw / 2000);
> +		break;
>  	case SX9360_REG_AFE_PARAM0_PHR:
>  	case SX9360_REG_AFE_PARAM0_PHM:
>  		ret = device_property_read_u32(dev, "semtech,resolution", &raw);


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2022-06-04 16:17 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 22:01 [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Gwendal Grignou
2022-04-29 22:01 ` [PATCH v5 01/10] iio: sx9324: Fix default precharge internal resistance register Gwendal Grignou
2022-04-29 22:01 ` [PATCH v5 02/10] iio: sx9324: Fix register field spelling Gwendal Grignou
2022-06-04 16:19   ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 03/10] dt-bindings: iio: sx9324: Add precharge resistor setting Gwendal Grignou
2022-06-04 16:20   ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 04/10] iio: sx9324: Add precharge internal resistance setting Gwendal Grignou
2022-06-04 16:21   ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 05/10] dt-bindings: iio: sx9324: Add internal compensation resistor setting Gwendal Grignou
2022-06-04 16:22   ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 06/10] iio: sx9324: Add Setting for internal compensation resistor Gwendal Grignou
2022-04-29 22:01 ` [PATCH v5 07/10] dt-bindings: iio: sx9324: Add input analog gain Gwendal Grignou
2022-05-01 17:17   ` Jonathan Cameron
2022-05-10  5:48     ` Gwendal Grignou
2022-06-04 16:23       ` Jonathan Cameron
2022-05-03 18:02   ` Rob Herring
2022-05-03 19:10   ` Stephen Boyd
2022-04-29 22:01 ` [PATCH v5 08/10] iio: sx9324: Add Setting for internal " Gwendal Grignou
2022-05-03 19:12   ` Stephen Boyd
2022-06-04 16:25     ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 09/10] dt-bindings: iio: sx9360: Add precharge resistor setting Gwendal Grignou
2022-05-03 18:03   ` Rob Herring
2022-06-04 16:25     ` Jonathan Cameron
2022-04-29 22:01 ` [PATCH v5 10/10] iio: sx9360: Add pre-charge " Gwendal Grignou
2022-06-04 16:26   ` Jonathan Cameron
2022-05-01 17:20 ` [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.