* [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support
@ 2026-06-19 10:31 Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-06-19 10:31 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Svyatoslav Ryhel
Cc: linux-hwmon, devicetree, linux-kernel
Document, add OF and regulator support to EMC14XX thermal sensor family.
Schema file was separated from LM90 since according to Guenter Roeck[1]
these sensors are incompatible with LM90. Proposed schema has basic
hardware description. All registers Guenter Roeck mentioned may be added
later on, when/if driver would need to work with them. As for now driver
successfully works as is.
[1] https://lore.kernel.org/lkml/a0c5c1e8-9a36-4835-a5d9-7bafda79c36f@roeck-us.net/
---
Changes in v2:
- schema separated into a dedicated file
- dropped chip id check
- fixed match data casting
- adjusted regulator name
---
Jonas Schwöbel (1):
hwmon: (emc1403) Convert to use OF bindings
Svyatoslav Ryhel (2):
dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428
hwmon: (emc1403) Add regulator support
.../bindings/hwmon/smsc,emc1403.yaml | 191 ++++++++++++++++++
drivers/hwmon/emc1403.c | 23 ++-
2 files changed, 212 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428
2026-06-19 10:31 [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support Svyatoslav Ryhel
@ 2026-06-19 10:31 ` Svyatoslav Ryhel
2026-06-19 10:40 ` sashiko-bot
2026-06-19 10:31 ` [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 3/3] hwmon: (emc1403) Add regulator support Svyatoslav Ryhel
2 siblings, 1 reply; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-06-19 10:31 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Svyatoslav Ryhel
Cc: linux-hwmon, devicetree, linux-kernel
Document the basic hardware layout of SMSC (now Microchip)
EMC1402/1403/1404/1428 thermal sensors.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
.../bindings/hwmon/smsc,emc1403.yaml | 191 ++++++++++++++++++
1 file changed, 191 insertions(+)
create mode 100644 Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml
diff --git a/Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml b/Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml
new file mode 100644
index 000000000000..bef07b599720
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml
@@ -0,0 +1,191 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/smsc,emc1403.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SMSC EMC1402/1403/1404/1428 thermal sensors
+
+maintainers:
+ - Svyatoslav Ryhel <clamor95@gmail.com>
+
+properties:
+ compatible:
+ oneOf:
+ - enum:
+ - smsc,emc1402
+ - smsc,emc1403
+ - smsc,emc1404
+ - smsc,emc1428
+
+ - items:
+ - enum:
+ - smsc,emc1412
+ - smsc,emc1422
+ - smsc,emc1442
+ - const: smsc,emc1402
+
+ - items:
+ - enum:
+ - smsc,emc1413
+ - smsc,emc1423
+ - const: smsc,emc1403
+
+ - items:
+ - enum:
+ - smsc,emc1414
+ - smsc,emc1424
+ - const: smsc,emc1404
+
+ - items:
+ - enum:
+ - smsc,emc1438
+ - const: smsc,emc1428
+
+ interrupts:
+ items:
+ - description: Sensors "ALERT" pin output.
+
+ reg:
+ maxItems: 1
+
+ "#thermal-sensor-cells":
+ const: 1
+
+ '#address-cells':
+ const: 1
+
+ '#size-cells':
+ const: 0
+
+ vdd-supply: true
+
+required:
+ - compatible
+ - reg
+
+patternProperties:
+ "^channel@([0-7])$":
+ type: object
+ description: Represents channels of the device and their specific configuration.
+
+ properties:
+ reg:
+ description: The channel number. 0 is local channel, 1-7 are remote channels.
+ items:
+ minimum: 0
+ maximum: 7
+
+ label:
+ description: A descriptive name for this channel, like "ambient" or "psu".
+
+ required:
+ - reg
+
+ additionalProperties: false
+
+allOf:
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - smsc,emc1404
+ - smsc,emc1428
+ then:
+ patternProperties:
+ "^channel@([0-7])$":
+ properties:
+ reg:
+ items:
+ maximum: 2
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - smsc,emc1404
+ then:
+ patternProperties:
+ "^channel@([0-7])$":
+ properties:
+ reg:
+ items:
+ maximum: 3
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ sensor@4c {
+ compatible = "smsc,emc1412", "smsc,emc1402";
+ reg = <0x4c>;
+
+ interrupt-parent = <&gpio>;
+ interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
+
+ vdd-supply = <&vdd_3v3_sys>;
+ #thermal-sensor-cells = <1>;
+ };
+ };
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ sensor@29 {
+ compatible = "smsc,emc1428";
+ reg = <0x29>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ channel@0 {
+ reg = <0x0>;
+ label = "local";
+ };
+
+ channel@1 {
+ reg = <0x1>;
+ label = "chan1";
+ };
+
+ channel@2 {
+ reg = <0x2>;
+ label = "chan2";
+ };
+
+ channel@3 {
+ reg = <0x3>;
+ label = "chan3";
+ };
+
+ channel@4 {
+ reg = <0x4>;
+ label = "chan4";
+ };
+
+ channel@5 {
+ reg = <0x5>;
+ label = "chan5";
+ };
+
+ channel@6 {
+ reg = <0x6>;
+ label = "chan6";
+ };
+
+ channel@7 {
+ reg = <0x7>;
+ label = "chan7";
+ };
+ };
+ };
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings
2026-06-19 10:31 [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
@ 2026-06-19 10:31 ` Svyatoslav Ryhel
2026-06-19 10:45 ` sashiko-bot
2026-06-19 10:31 ` [PATCH v2 3/3] hwmon: (emc1403) Add regulator support Svyatoslav Ryhel
2 siblings, 1 reply; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-06-19 10:31 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Svyatoslav Ryhel
Cc: linux-hwmon, devicetree, linux-kernel
From: Jonas Schwöbel <jonasschwoebel@yahoo.de>
Add OF match compatible table to be able to use this driver with Device
Trees.
Signed-off-by: Jonas Schwöbel <jonasschwoebel@yahoo.de>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/hwmon/emc1403.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 964a8cb278f1..ef1ccb40ed6c 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -16,6 +16,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mod_devicetable.h>
#include <linux/sysfs.h>
#include <linux/regmap.h>
#include <linux/util_macros.h>
@@ -659,14 +660,14 @@ static int emc1403_probe(struct i2c_client *client)
{
struct thermal_data *data;
struct device *hwmon_dev;
- const struct i2c_device_id *id = i2c_match_id(emc1403_idtable, client);
data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
- data->chip = id->driver_data;
+ data->chip = (uintptr_t)i2c_get_match_data(client);
+
data->regmap = devm_regmap_init_i2c(client, &emc1403_regmap_config);
if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap);
@@ -682,10 +683,21 @@ static const unsigned short emc1403_address_list[] = {
0x18, 0x1c, 0x29, 0x3c, 0x4c, 0x4d, 0x5c, I2C_CLIENT_END
};
+static const struct of_device_id emc1403_of_match[] = {
+ { .compatible = "smsc,emc1402", .data = (void *)emc1402 },
+ { .compatible = "smsc,emc1403", .data = (void *)emc1403 },
+ { .compatible = "smsc,emc1404", .data = (void *)emc1404 },
+ { .compatible = "smsc,emc1428", .data = (void *)emc1428 },
+ { }
+
+};
+MODULE_DEVICE_TABLE(of, emc1403_of_match);
+
static struct i2c_driver sensor_emc1403 = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "emc1403",
+ .of_match_table = emc1403_of_match,
},
.detect = emc1403_detect,
.probe = emc1403_probe,
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] hwmon: (emc1403) Add regulator support
2026-06-19 10:31 [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings Svyatoslav Ryhel
@ 2026-06-19 10:31 ` Svyatoslav Ryhel
2026-06-19 10:41 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-06-19 10:31 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Svyatoslav Ryhel
Cc: linux-hwmon, devicetree, linux-kernel
Add support for VDD power supply for this sensor. It is required on some
devices for the sensor to start up and work properly.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/hwmon/emc1403.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index ef1ccb40ed6c..d14bd90ce424 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -19,6 +19,7 @@
#include <linux/mod_devicetable.h>
#include <linux/sysfs.h>
#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
#include <linux/util_macros.h>
#define THERMAL_PID_REG 0xfd
@@ -660,6 +661,12 @@ static int emc1403_probe(struct i2c_client *client)
{
struct thermal_data *data;
struct device *hwmon_dev;
+ int ret;
+
+ ret = devm_regulator_get_enable(&client->dev, "vdd");
+ if (ret)
+ return dev_err_probe(&client->dev, ret,
+ "Failed to enable regulator\n");
data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
GFP_KERNEL);
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
@ 2026-06-19 10:40 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-19 10:40 UTC (permalink / raw)
To: Svyatoslav Ryhel; +Cc: devicetree, linux-hwmon, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The device tree binding schema fails to correctly restrict the maximum number of channels for the `smsc,emc1402` and its variants (emc1412, emc1422, emc1442). By grouping it alongside `emc1403` under the `not` condition for `emc1404`/`emc1428`, it inadvertently sets the channel `reg` maximum to 2 instead of 1.
--
commit 5a834c50ed998e304e4c00fb64e4e434cbd93896
Author: Svyatoslav Ryhel <clamor95@gmail.com>
dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428
This commit documents the basic hardware layout of SMSC (now Microchip)
EMC1402/1403/1404/1428 thermal sensors.
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/smsc,emc1403.yaml
[ ... ]
> +allOf:
> + - if:
> + not:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - smsc,emc1404
> + - smsc,emc1428
> + then:
> + patternProperties:
> + "^channel@([0-7])$":
> + properties:
> + reg:
> + items:
> + maximum: 2
[Severity: Low]
Does this conditional block correctly restrict the channel limits for the
smsc,emc1402 device and its variants (emc1412, emc1422, emc1442)?
By grouping the emc1402 variants with the emc1403 under the fallback
condition (not containing emc1404/emc1428), it applies a maximum reg value
of 2. This appears to allow up to 3 channels (0, 1, 2) to pass schema
validation.
Since the emc1402 hardware only supports 2 channels (local and 1 remote),
should there be a separate conditional for the emc1402 family setting the
maximum to 1?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619103153.216444-1-clamor95@gmail.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] hwmon: (emc1403) Add regulator support
2026-06-19 10:31 ` [PATCH v2 3/3] hwmon: (emc1403) Add regulator support Svyatoslav Ryhel
@ 2026-06-19 10:41 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-19 10:41 UTC (permalink / raw)
To: Svyatoslav Ryhel; +Cc: robh, devicetree, linux-hwmon, conor+dt
> Add support for VDD power supply for this sensor. It is required on some
> devices for the sensor to start up and work properly.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619103153.216444-1-clamor95@gmail.com?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings
2026-06-19 10:31 ` [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings Svyatoslav Ryhel
@ 2026-06-19 10:45 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-19 10:45 UTC (permalink / raw)
To: Svyatoslav Ryhel; +Cc: conor+dt, robh, linux-hwmon, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Ambiguous OF match data value (0) prevents error handling for unsupported devices.
--
commit 7ef40c1ea161b005037b0b33a8e16b1f9bf6d41a
Author: Jonas Schwöbel <jonasschwoebel@yahoo.de>
hwmon: (emc1403) Convert to use OF bindings
This commit adds an OF match compatible table to the emc1403 driver
to enable device tree support.
> --- a/drivers/hwmon/emc1403.c
> +++ b/drivers/hwmon/emc1403.c
[ ... ]
> @@ -659,14 +660,14 @@ static int emc1403_probe(struct i2c_client *client)
[ ... ]
> - data->chip = id->driver_data;
> + data->chip = (uintptr_t)i2c_get_match_data(client);
> +
[Severity: Medium]
Will this cast silently hide error conditions?
If an unsupported device is manually bound via sysfs, i2c_get_match_data()
will return NULL (no match found). Since emc1402 evaluates to 0 in the
emc1403_chip enum, casting NULL to uintptr_t assigns 0 to data->chip. This
causes the driver to proceed as if an emc1402 device was found, rather than
safely aborting and returning -ENODEV.
[ ... ]
> @@ -682,10 +683,21 @@ static const unsigned short emc1403_address_list[] = {
[ ... ]
> +static const struct of_device_id emc1403_of_match[] = {
> + { .compatible = "smsc,emc1402", .data = (void *)emc1402 },
> + { .compatible = "smsc,emc1403", .data = (void *)emc1403 },
[Severity: Medium]
Does assigning 0 as the match data here cause ambiguity during device matching?
Because emc1402 is 0, when device_get_match_data() matches "smsc,emc1402",
it returns NULL. This forces i2c_get_match_data() to fall back to
i2c_match_id().
While this happens to succeed for valid DT nodes because the I2C core strips
the vendor prefix (allowing the id_table to match), it removes the ability
to distinguish between a successful emc1402 match and an error where no
match was found at all.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619103153.216444-1-clamor95@gmail.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-06-19 10:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-19 10:31 [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
2026-06-19 10:40 ` sashiko-bot
2026-06-19 10:31 ` [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings Svyatoslav Ryhel
2026-06-19 10:45 ` sashiko-bot
2026-06-19 10:31 ` [PATCH v2 3/3] hwmon: (emc1403) Add regulator support Svyatoslav Ryhel
2026-06-19 10:41 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.