From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>, Armin Wolf <W_Armin@gmx.de>,
Kurt Borja <kuurtb@gmail.com>,
Tinsae Tadesse <tinsaetadesse2015@gmail.com>
Subject: [PATCH] hwmon: (spd5118) Explicitly enable temperature sensor in probe function
Date: Sat, 31 Jan 2026 07:20:48 -0800 [thread overview]
Message-ID: <20260131152048.2299403-1-linux@roeck-us.net> (raw)
Instantiating the driver does not make sense if the temperature sensor
is disabled, so enable it unconditionally in the probe function.
If that fails, write operations to the chip are likely disabled
by the I2C controller. Bail out with an error message if that happens.
Cc: Armin Wolf <W_Armin@gmx.de>
Cc: Kurt Borja <kuurtb@gmail.com>
Cc: Tinsae Tadesse <tinsaetadesse2015@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/spd5118.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 5da44571b6a0..d8834d4d980b 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -552,6 +552,20 @@ static int spd5118_common_probe(struct device *dev, struct regmap *regmap,
if (!spd5118_vendor_valid(bank, vendor))
return -ENODEV;
+ /*
+ * Some I2C controllers write protect the address range used by SPD5118
+ * compliant chips. This makes the chips effectively unaccessible since
+ * the driver needs to be able to set the page in the legacy mode
+ * register, and it needs to be able to disable the temperature sensor
+ * during suspend. Check if writes to the chip are possible by
+ * explicitly enabling the temperature sensor. Bail out if that fails.
+ */
+ err = regmap_write_bits(regmap, SPD5118_REG_TEMP_CONFIG,
+ SPD5118_TS_DISABLE, 0);
+ if (err)
+ return dev_err_probe(dev, err,
+ "Failed to enable temperature sensor (write protected ?)\n");
+
data->regmap = regmap;
mutex_init(&data->nvmem_lock);
dev_set_drvdata(dev, data);
--
2.45.2
next reply other threads:[~2026-01-31 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 15:20 Guenter Roeck [this message]
2026-01-31 19:20 ` [PATCH] hwmon: (spd5118) Explicitly enable temperature sensor in probe function TINSAE TADESSE
2026-02-03 19:23 ` Kurt Borja
2026-02-03 19:49 ` Guenter Roeck
2026-02-04 6:22 ` Kurt Borja
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=20260131152048.2299403-1-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=W_Armin@gmx.de \
--cc=kuurtb@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=tinsaetadesse2015@gmail.com \
/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