All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: jic23@kernel.org, robh+dt@kernel.org, swboyd@chromium.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	Gwendal Grignou <gwendal@chromium.org>
Subject: [PATCH v5 10/10] iio: sx9360: Add pre-charge resistor setting
Date: Fri, 29 Apr 2022 15:01:44 -0700	[thread overview]
Message-ID: <20220429220144.1476049-11-gwendal@chromium.org> (raw)
In-Reply-To: <20220429220144.1476049-1-gwendal@chromium.org>

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


  parent reply	other threads:[~2022-04-29 22:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Gwendal Grignou [this message]
2022-06-04 16:26   ` [PATCH v5 10/10] iio: sx9360: Add pre-charge " Jonathan Cameron
2022-05-01 17:20 ` [PATCH v4 00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429220144.1476049-11-gwendal@chromium.org \
    --to=gwendal@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.