From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: "Hristo Venev" <hristo@venev.name>,
"René Rebe" <rene@exactcode.de>, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
"Radu Sabau" <radu.sabau@analog.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: [RFT PATCH 3/3] hwmon: (spd5118) Add PEC support
Date: Wed, 29 May 2024 13:52:04 -0700 [thread overview]
Message-ID: <20240529205204.81208-4-linux@roeck-us.net> (raw)
In-Reply-To: <20240529205204.81208-1-linux@roeck-us.net>
Add support for configuring PEC (Packet Error Checking).
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
This patch depends on the patch series at
https://patchwork.kernel.org/project/linux-hwmon/list/?series=857097
drivers/hwmon/spd5118.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 440503d09d13..eb21bf3dffd7 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -33,6 +33,7 @@ static const unsigned short normal_i2c[] = {
#define SPD5118_REG_VENDOR 0x03 /* MR3:MR4 */
#define SPD5118_REG_CAPABILITY 0x05 /* MR5 */
#define SPD5118_REG_I2C_LEGACY_MODE 0x0B /* MR11 */
+#define SPD5118_REG_DEV_CONFIG 0x12 /* MR18 */
#define SPD5118_REG_TEMP_CLR 0x13 /* MR19 */
#define SPD5118_REG_ERROR_CLR 0x14 /* MR20 */
#define SPD5118_REG_TEMP_CONFIG 0x1A /* MR26 */
@@ -50,6 +51,8 @@ static const unsigned short normal_i2c[] = {
#define SPD5118_CAP_TS_SUPPORT BIT(1) /* temperature sensor support */
+#define SPD5118_PEC_ENABLE BIT(7) /* PEC enable */
+
#define SPD5118_TS_DISABLE BIT(0) /* temperature sensor disable */
/* Temperature unit in millicelsius */
@@ -217,6 +220,18 @@ static int spd5118_write_enable(struct regmap *regmap, u32 attr, long val)
val ? 0 : SPD5118_TS_DISABLE);
}
+static int spd5118_chip_write(struct regmap *regmap, u32 attr, long val)
+{
+ switch (attr) {
+ case hwmon_chip_pec:
+ return regmap_update_bits(regmap, SPD5118_REG_DEV_CONFIG,
+ SPD5118_PEC_ENABLE,
+ val ? SPD5118_PEC_ENABLE : 0);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static int spd5118_temp_write(struct regmap *regmap, u32 attr, long val)
{
switch (attr) {
@@ -238,6 +253,8 @@ static int spd5118_write(struct device *dev, enum hwmon_sensor_types type,
struct regmap *regmap = dev_get_drvdata(dev);
switch (type) {
+ case hwmon_chip:
+ return spd5118_chip_write(regmap, attr, val);
case hwmon_temp:
return spd5118_temp_write(regmap, attr, val);
default:
@@ -338,7 +355,7 @@ static int spd5118_detect(struct i2c_client *client, struct i2c_board_info *info
static const struct hwmon_channel_info *spd5118_info[] = {
HWMON_CHANNEL_INFO(chip,
- HWMON_C_REGISTER_TZ),
+ HWMON_C_REGISTER_TZ | HWMON_C_PEC),
HWMON_CHANNEL_INFO(temp,
HWMON_T_INPUT |
HWMON_T_LCRIT | HWMON_T_LCRIT_ALARM |
--
2.39.2
prev parent reply other threads:[~2024-05-29 20:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 20:52 [PATCH 0/3] hwmon: Add support for SPD5118 compliant temperature sensors Guenter Roeck
2024-05-29 20:52 ` [PATCH 1/3] dt-bindings: hwmon: jedec,spd5118: Add bindings Guenter Roeck
2024-05-29 20:52 ` [PATCH 2/3] hwmon: Add support for SPD5118 compliant temperature sensors Guenter Roeck
2024-05-30 8:08 ` Armin Wolf
2024-05-30 13:23 ` Guenter Roeck
2024-05-30 13:39 ` Guenter Roeck
2024-05-30 16:45 ` Armin Wolf
2024-05-30 16:51 ` Guenter Roeck
2024-05-30 17:06 ` Armin Wolf
2024-05-30 9:08 ` Thomas Weißschuh
2024-05-30 13:27 ` Guenter Roeck
2024-05-30 10:51 ` Thomas Weißschuh
2024-05-30 13:47 ` Guenter Roeck
2024-05-30 13:57 ` Thomas Weißschuh
2024-05-30 14:07 ` Guenter Roeck
2024-05-30 17:03 ` Armin Wolf
2024-05-30 17:33 ` Guenter Roeck
2024-05-30 17:41 ` Armin Wolf
2024-05-30 17:36 ` Guenter Roeck
2024-05-30 20:20 ` Thomas Weißschuh
2024-05-30 20:46 ` Guenter Roeck
2024-05-30 21:02 ` Thomas Weißschuh
2024-05-30 22:33 ` Guenter Roeck
2024-05-31 9:31 ` Wolfram Sang
2024-05-31 10:01 ` René Rebe
2024-05-31 10:37 ` Thomas Weißschuh
2024-05-31 13:14 ` Guenter Roeck
2024-05-31 13:20 ` René Rebe
2024-05-31 13:55 ` Guenter Roeck
2024-05-29 20:52 ` Guenter Roeck [this message]
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=20240529205204.81208-4-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hristo@venev.name \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=radu.sabau@analog.com \
--cc=rene@exactcode.de \
--cc=robh@kernel.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;
as well as URLs for NNTP newsgroup(s).