public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (spd5118) Explicitly enable temperature sensor in probe function
@ 2026-01-31 15:20 Guenter Roeck
  2026-01-31 19:20 ` TINSAE TADESSE
  2026-02-03 19:23 ` Kurt Borja
  0 siblings, 2 replies; 5+ messages in thread
From: Guenter Roeck @ 2026-01-31 15:20 UTC (permalink / raw)
  To: Hardware Monitoring; +Cc: Guenter Roeck, Armin Wolf, Kurt Borja, Tinsae Tadesse

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


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

end of thread, other threads:[~2026-02-04  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 15:20 [PATCH] hwmon: (spd5118) Explicitly enable temperature sensor in probe function Guenter Roeck
2026-01-31 19:20 ` TINSAE TADESSE
2026-02-03 19:23 ` Kurt Borja
2026-02-03 19:49   ` Guenter Roeck
2026-02-04  6:22     ` Kurt Borja

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox