From: Michael Walle <mwalle@kernel.org>
To: Nishanth Menon <nm@ti.com>, Vignesh Raghavendra <vigneshr@ti.com>,
Tero Kristo <kristo@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michael Walle <mwalle@kernel.org>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>, Lee Jones <lee@kernel.org>,
Srinivas Kandagatla <srini@kernel.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-watchdog@vger.kernel.org
Subject: [PATCH v1 6/7] hwmon: sl28cpld: add SMARC-sAM67 support
Date: Fri, 22 Aug 2025 15:15:30 +0200 [thread overview]
Message-ID: <20250822131531.1366437-7-mwalle@kernel.org> (raw)
In-Reply-To: <20250822131531.1366437-1-mwalle@kernel.org>
The on-board uC on the SMARC-sAM67 board is compatible with the older
CPLD implementation on the SMARC-sAL28 board, but has different sensors,
namely two voltage sensors and one temperature sensor. Add support for it.
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/hwmon/sl28cpld-hwmon.c | 76 ++++++++++++++++++++++++++++++++--
1 file changed, 73 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/sl28cpld-hwmon.c b/drivers/hwmon/sl28cpld-hwmon.c
index 454cc844fb9d..670308d9b72f 100644
--- a/drivers/hwmon/sl28cpld-hwmon.c
+++ b/drivers/hwmon/sl28cpld-hwmon.c
@@ -18,6 +18,9 @@
#define FAN_SCALE_X8 BIT(7)
#define FAN_VALUE_MASK GENMASK(6, 0)
+#define SA67MCU_VOLTAGE(n) (0x00 + ((n) * 2))
+#define SA67MCU_TEMP(n) (0x04 + ((n) * 2))
+
struct sl28cpld_hwmon {
struct regmap *regmap;
u32 offset;
@@ -75,8 +78,71 @@ static const struct hwmon_chip_info sl28cpld_hwmon_chip_info = {
.info = sl28cpld_hwmon_info,
};
+static int sa67mcu_hwmon_read(struct device *dev,
+ enum hwmon_sensor_types type, u32 attr,
+ int channel, long *input)
+{
+ struct sl28cpld_hwmon *hwmon = dev_get_drvdata(dev);
+ unsigned int offset;
+ u8 reg[2];
+ int ret;
+
+ switch (type) {
+ case hwmon_in:
+ switch (attr) {
+ case hwmon_in_input:
+ offset = hwmon->offset + SA67MCU_VOLTAGE(channel);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ break;
+ case hwmon_temp:
+ switch (attr) {
+ case hwmon_temp_input:
+ offset = hwmon->offset + SA67MCU_TEMP(channel);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ /* Reading the low byte will capture the value */
+ ret = regmap_bulk_read(hwmon->regmap, offset, reg, ARRAY_SIZE(reg));
+ if (ret)
+ return ret;
+
+ *input = reg[1] << 8 | reg[0];
+
+ /* Temperatures are s16 and in 0.1degC steps. */
+ if (type == hwmon_temp)
+ *input = sign_extend32(*input, 15) * 100;
+
+ return 0;
+}
+
+static const struct hwmon_channel_info * const sa67mcu_hwmon_info[] = {
+ HWMON_CHANNEL_INFO(in, HWMON_I_INPUT, HWMON_I_INPUT),
+ HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
+ NULL
+};
+
+static const struct hwmon_ops sa67mcu_hwmon_ops = {
+ .visible = 0444,
+ .read = sa67mcu_hwmon_read,
+};
+
+static const struct hwmon_chip_info sa67mcu_hwmon_chip_info = {
+ .ops = &sa67mcu_hwmon_ops,
+ .info = sa67mcu_hwmon_info,
+};
+
static int sl28cpld_hwmon_probe(struct platform_device *pdev)
{
+ const struct hwmon_chip_info *chip_info;
struct sl28cpld_hwmon *hwmon;
struct device *hwmon_dev;
int ret;
@@ -84,6 +150,10 @@ static int sl28cpld_hwmon_probe(struct platform_device *pdev)
if (!pdev->dev.parent)
return -ENODEV;
+ chip_info = device_get_match_data(&pdev->dev);
+ if (!chip_info)
+ return -EINVAL;
+
hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
if (!hwmon)
return -ENOMEM;
@@ -97,8 +167,7 @@ static int sl28cpld_hwmon_probe(struct platform_device *pdev)
return -EINVAL;
hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
- "sl28cpld_hwmon", hwmon,
- &sl28cpld_hwmon_chip_info, NULL);
+ "sl28cpld_hwmon", hwmon, chip_info, NULL);
if (IS_ERR(hwmon_dev))
dev_err(&pdev->dev, "failed to register as hwmon device");
@@ -106,7 +175,8 @@ static int sl28cpld_hwmon_probe(struct platform_device *pdev)
}
static const struct of_device_id sl28cpld_hwmon_of_match[] = {
- { .compatible = "kontron,sl28cpld-fan" },
+ { .compatible = "kontron,sl28cpld-fan", .data = &sl28cpld_hwmon_chip_info },
+ { .compatible = "kontron,sa67mcu-hwmon", .data = &sa67mcu_hwmon_chip_info },
{}
};
MODULE_DEVICE_TABLE(of, sl28cpld_hwmon_of_match);
--
2.39.5
next prev parent reply other threads:[~2025-08-22 13:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 13:15 [PATCH v1 0/7] Initial Kontron " Michael Walle
2025-08-22 13:15 ` [PATCH v1 1/7] dt-bindings: arm: ti: Add bindings for Kontron SMARC-sAM67 module Michael Walle
2025-08-25 7:43 ` Krzysztof Kozlowski
2025-08-22 13:15 ` [PATCH v1 2/7] dt-bindings: mfd: sl28cpld: add sa67mcu compatible Michael Walle
2025-08-27 12:56 ` Krzysztof Kozlowski
2025-09-03 12:05 ` (subset) " Lee Jones
2025-08-22 13:15 ` [PATCH v1 3/7] dt-bindings: hwmon: " Michael Walle
2025-08-27 12:56 ` Krzysztof Kozlowski
2025-08-22 13:15 ` [PATCH v1 4/7] dt-bindings: watchdog: add SMARC-sAM67 support Michael Walle
2025-08-27 13:03 ` Krzysztof Kozlowski
2025-08-22 13:15 ` [PATCH v1 5/7] dt-bindings: nvmem: sl28cpld: add sa67mcu compatible Michael Walle
2025-08-27 12:57 ` Krzysztof Kozlowski
2025-08-22 13:15 ` Michael Walle [this message]
2025-09-07 15:28 ` [PATCH v1 6/7] hwmon: sl28cpld: add SMARC-sAM67 support Guenter Roeck
2025-09-08 7:04 ` Michael Walle
2025-09-08 13:27 ` Guenter Roeck
2025-08-22 13:15 ` [PATCH v1 7/7] arm64: dts: ti: Add support for Kontron SMARC-sAM67 Michael Walle
2025-08-27 13:31 ` Andrew Davis
2025-08-22 15:23 ` [PATCH v1 0/7] Initial Kontron SMARC-sAM67 support Nishanth Menon
2025-08-25 7:28 ` Michael Walle
2025-08-27 12:18 ` Michael Walle
2025-08-22 21:27 ` Rob Herring (Arm)
2025-08-25 7:53 ` Michael Walle
2025-09-08 7:18 ` (subset) " Srinivas Kandagatla
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=20250822131531.1366437-7-mwalle@kernel.org \
--to=mwalle@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=kristo@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nm@ti.com \
--cc=robh@kernel.org \
--cc=srini@kernel.org \
--cc=vigneshr@ti.com \
--cc=wim@linux-watchdog.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
all inboxes | Powered by JetHome®