From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"René Rebe" <rene@exactcode.de>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Armin Wolf" <W_Armin@gmx.de>,
"Stephen Horvath" <s.horvath@outlook.com.au>,
"Paul Menzel" <pmenzel@molgen.mpg.de>,
"Sasha Kozachuk" <skozachuk@google.com>,
"John Hamrick" <johnham@google.com>,
"Chris Sarra" <chrissarra@google.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: [RFT PATCH v2 2/3] hwmon: (spd5118) Use spd5118 specific read/write operations
Date: Tue, 18 Jun 2024 12:53:47 -0700 [thread overview]
Message-ID: <20240618195348.1670547-3-linux@roeck-us.net> (raw)
In-Reply-To: <20240618195348.1670547-1-linux@roeck-us.net>
regmap write operations on i801 controllers were observed to fail with
-ENXIO errors. It appears that the i801 controller and/or at least some
spd5118 compatible chips do not support the I2C_FUNC_SMBUS_I2C_BLOCK
operation used by the regmap-i2c core if I2C_FUNC_SMBUS_I2C_BLOCK is
supported by the I2C/SMBus controller.
Stop using the regmap-i2c core and always use basic SMBus operations
instead.
Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Closes: https://lore.kernel.org/linux-hwmon/33f369c1-1098-458e-9398-30037bd8c5aa@molgen.mpg.de/
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Added patch
drivers/hwmon/Kconfig | 2 +-
drivers/hwmon/spd5118.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index d5eced417fc3..fdfa778a965d 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2184,7 +2184,7 @@ config SENSORS_INA3221
config SENSORS_SPD5118
tristate "SPD5118 Compliant Temperature Sensors"
depends on I2C
- select REGMAP_I2C
+ select REGMAP
help
If you say yes here you get support for SPD5118 (JEDEC JESD300)
compliant temperature sensors. Such sensors are found on DDR5 memory
diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index d405c5ef755d..995c45e2a997 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -489,6 +489,31 @@ static bool spd5118_volatile_reg(struct device *dev, unsigned int reg)
}
}
+static int spd5118_regmap_reg_read(void *context, unsigned int reg,
+ unsigned int *val)
+{
+ int ret;
+
+ ret = i2c_smbus_read_byte_data(context, reg);
+ if (ret < 0)
+ return ret;
+
+ *val = ret;
+
+ return 0;
+}
+
+static int spd5118_regmap_reg_write(void *context, unsigned int reg,
+ unsigned int val)
+{
+ return i2c_smbus_write_byte_data(context, reg, val);
+}
+
+static const struct regmap_bus spd5118_regmap_bus = {
+ .reg_write = spd5118_regmap_reg_write,
+ .reg_read = spd5118_regmap_reg_read,
+};
+
static const struct regmap_range_cfg spd5118_regmap_range_cfg[] = {
{
.selector_reg = SPD5118_REG_I2C_LEGACY_MODE,
@@ -526,7 +551,8 @@ static int spd5118_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
- regmap = devm_regmap_init_i2c(client, &spd5118_regmap_config);
+ regmap = devm_regmap_init(dev, &spd5118_regmap_bus, client,
+ &spd5118_regmap_config);
if (IS_ERR(regmap))
return dev_err_probe(dev, PTR_ERR(regmap), "regmap init failed\n");
--
2.39.2
next prev parent reply other threads:[~2024-06-18 19:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 19:53 [RFT PATCH v2 0/3] hwmon: (spd5118) Various improvements Guenter Roeck
2024-06-18 19:53 ` [RFT PATCH v2 1/3] hwmon: (spd5118) Use regmap to implement paging Guenter Roeck
2024-06-18 19:53 ` Guenter Roeck [this message]
2024-06-18 20:37 ` [RFT PATCH v2 2/3] hwmon: (spd5118) Use spd5118 specific read/write operations Paul Menzel
2024-06-18 21:08 ` Guenter Roeck
2024-06-18 21:45 ` Paul Menzel
2024-06-18 22:37 ` Guenter Roeck
2024-06-18 22:59 ` Paul Menzel
2024-06-18 22:28 ` Wolfram Sang
2024-06-18 23:28 ` Armin Wolf
2024-06-18 23:39 ` Paul Menzel
2024-06-19 0:23 ` Guenter Roeck
2024-06-19 0:50 ` Thomas Weißschuh
2024-06-19 1:02 ` Guenter Roeck
2024-06-19 9:13 ` Thomas Weißschuh
2024-06-19 14:18 ` Guenter Roeck
2024-06-18 19:53 ` [RFT PATCH v2 3/3] hwmon: (spd5118) Add support for Renesas/ITD SPD5118 hub controllers Guenter Roeck
2024-06-18 20:59 ` [RFT PATCH v2 0/3] hwmon: (spd5118) Various improvements Armin Wolf
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=20240618195348.1670547-3-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=W_Armin@gmx.de \
--cc=chrissarra@google.com \
--cc=johnham@google.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=pmenzel@molgen.mpg.de \
--cc=rene@exactcode.de \
--cc=s.horvath@outlook.com.au \
--cc=skozachuk@google.com \
--cc=wsa+renesas@sang-engineering.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