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 v4 6/8] iio: sx9324: Add Setting for internal compensation resistor
Date: Wed, 6 Apr 2022 09:50:09 -0700 [thread overview]
Message-ID: <20220406165011.10202-7-gwendal@chromium.org> (raw)
In-Reply-To: <20220406165011.10202-1-gwendal@chromium.org>
Based on device tree setting, set the internal compensation resistor.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
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 691700de0b9d4..2dcfac09644bd 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.35.1.1094.g7c7d902a7c-goog
next prev parent reply other threads:[~2022-04-06 18:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 16:50 [PATCH v4 0/8] Add settings for precharge and internal resistor Gwendal Grignou
2022-04-06 16:50 ` [PATCH v4 1/8] iio: sx9324: Fix default precharge internal resistance register Gwendal Grignou
2022-04-06 17:14 ` Stephen Boyd
2022-04-10 16:49 ` Jonathan Cameron
2022-04-10 16:55 ` Jonathan Cameron
2022-04-06 16:50 ` [PATCH v4 2/8] iio: sx9324: Fix register field spelling Gwendal Grignou
2022-04-06 16:50 ` [PATCH v4 3/8] dt-bindings: iio: sx9324: Add precharge resistor setting Gwendal Grignou
2022-04-06 16:50 ` [PATCH v4 4/8] iio: sx9324: Add precharge internal resistance setting Gwendal Grignou
2022-04-06 16:50 ` [PATCH v4 5/8] dt-bindings: iio: sx9324: Add internal compensation resistor setting Gwendal Grignou
2022-04-06 16:50 ` Gwendal Grignou [this message]
2022-04-06 17:15 ` [PATCH v4 6/8] iio: sx9324: Add Setting for internal compensation resistor Stephen Boyd
2022-04-06 16:50 ` [PATCH v4 7/8] dt-bindings: iio: sx9360: Add precharge resistor setting Gwendal Grignou
2022-04-06 17:15 ` Stephen Boyd
2022-04-13 18:38 ` Rob Herring
2022-04-06 16:50 ` [PATCH v4 8/8] iio: sx9360: Add pre-charge " Gwendal Grignou
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=20220406165011.10202-7-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox