diff --git a/target/linux/realtek/dts/rtl9301_d-link_dgs-1250-28x.dts b/target/linux/realtek/dts/rtl9301_d-link_dgs-1250-28x.dts index 2c1b7f81262..bd6896c2663 100644 --- a/target/linux/realtek/dts/rtl9301_d-link_dgs-1250-28x.dts +++ b/target/linux/realtek/dts/rtl9301_d-link_dgs-1250-28x.dts @@ -79,7 +79,7 @@ compatible = "microchip,tcn75"; reg = <0x48>; #thermal-sensor-cells = <0>; - alert-polarity-active-high; + ti,alert-polarity-active-high; }; eeprom@50 { diff --git a/target/linux/realtek/patches-6.18/028-v7.1-hwmon-lm75-fix-configuration-register-writes.patch b/target/linux/realtek/patches-6.18/028-v7.1-hwmon-lm75-fix-configuration-register-writes.patch new file mode 100644 index 00000000000..e5b86c7e2b5 --- /dev/null +++ b/target/linux/realtek/patches-6.18/028-v7.1-hwmon-lm75-fix-configuration-register-writes.patch @@ -0,0 +1,40 @@ +From ccef20232ded30ca6e73865458ebe89c0fe48dfe Mon Sep 17 00:00:00 2001 +From: Markus Stockhausen +Date: Sat, 2 May 2026 19:32:07 +0200 +Subject: hwmon: (lm75) Fix configuration register writes. + +Sensors configurations are defined by set and clear masks. These +do not follow a consistent "clear mask is a superset of set mask" +rule. This relaxed definition breaks lm75_write_config() + +static inline int lm75_write_config(struct lm75_data *data, u16 set_mask, + u16 clr_mask) +{ + return regmap_update_bits(data->regmap, LM75_REG_CONF, + clr_mask | LM75_SHUTDOWN, set_mask); +} + +Basically all bits from set_mask that are not defined in clr_mask are +dropped. Fix that by enhancing the helper to always combine clr_mask +and set_mask into the mask bits of regmap_update_bits(). + +Fixes: 6da24a25f766 ("hwmon: (lm75) Hide register size differences in regmap access functions") +Suggested-by: Guenter Roeck +Signed-off-by: Markus Stockhausen +Link: https://lore.kernel.org/r/20260502173207.3567876-3-markus.stockhausen@gmx.de +Signed-off-by: Guenter Roeck +--- + drivers/hwmon/lm75.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/hwmon/lm75.c ++++ b/drivers/hwmon/lm75.c +@@ -352,7 +352,7 @@ static inline int lm75_write_config(stru + u16 clr_mask) + { + return regmap_update_bits(data->regmap, LM75_REG_CONF, +- clr_mask | LM75_SHUTDOWN, set_mask); ++ clr_mask | set_mask | LM75_SHUTDOWN, set_mask); + } + + static irqreturn_t lm75_alarm_handler(int irq, void *private) diff --git a/target/linux/realtek/patches-6.18/029-v7.2-hwmon-lm75-support-active-high-alert-polarity.patch b/target/linux/realtek/patches-6.18/029-v7.2-hwmon-lm75-support-active-high-alert-polarity.patch new file mode 100644 index 00000000000..7ca6d068c64 --- /dev/null +++ b/target/linux/realtek/patches-6.18/029-v7.2-hwmon-lm75-support-active-high-alert-polarity.patch @@ -0,0 +1,63 @@ +From da96d42a568b98508729abf5c8f05d6e7770443d Mon Sep 17 00:00:00 2001 +From: Markus Stockhausen +Date: Mon, 4 May 2026 17:10:20 +0200 +Subject: hwmon: (lm75) Support active-high alert polarity + +LM75 devices supported by this driver support configurable active-high +alert polarity. This is already documented in the devicetree description. +Add support for it to the driver. + +Follow documentation and defensively enforce active-low if property is +not set. This avoids possible inconsistencies for future devices with +wrong parametrization. No API breakage as all current devices have +their parameters set to active-low. + +Signed-off-by: Markus Stockhausen +Link: https://lore.kernel.org/r/20260504151020.462342-3-markus.stockhausen@gmx.de +Signed-off-by: Guenter Roeck +--- + drivers/hwmon/lm75.c | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +--- a/drivers/hwmon/lm75.c ++++ b/drivers/hwmon/lm75.c +@@ -122,7 +122,9 @@ struct lm75_data { + + static const u8 lm75_sample_set_masks[] = { 0 << 5, 1 << 5, 2 << 5, 3 << 5 }; + +-#define LM75_SAMPLE_CLEAR_MASK (3 << 5) ++#define LM75_ALERT_POLARITY_HIGH_8_BIT (BIT(2)) ++#define LM75_ALERT_POLARITY_HIGH_16_BIT (BIT(2) << 8) ++#define LM75_SAMPLE_CLEAR_MASK (3 << 5) + + /* The structure below stores the configuration values of the supported devices. + * In case of being supported multiple configurations, the default one must +@@ -710,6 +712,7 @@ static void lm75_remove(void *data) + static int lm75_generic_probe(struct device *dev, const char *name, + enum lm75_type kind, int irq, struct regmap *regmap) + { ++ u16 clr_mask, pol_mask, set_mask; + struct device *hwmon_dev; + struct lm75_data *data; + int status, err; +@@ -744,8 +747,18 @@ static int lm75_generic_probe(struct dev + return err; + data->orig_conf = status; + +- err = lm75_write_config(data, data->params->set_mask, +- data->params->clr_mask); ++ /* Enforce polarity active-low (default) or active-high (devicetree) */ ++ if (!data->params->config_reg_16bits) ++ pol_mask = LM75_ALERT_POLARITY_HIGH_8_BIT; ++ else ++ pol_mask = LM75_ALERT_POLARITY_HIGH_16_BIT; ++ ++ clr_mask = data->params->clr_mask | pol_mask; ++ set_mask = data->params->set_mask & ~pol_mask; ++ if (device_property_read_bool(dev, "ti,alert-polarity-active-high")) ++ set_mask |= pol_mask; ++ ++ err = lm75_write_config(data, set_mask, clr_mask); + if (err) + return err; + diff --git a/target/linux/realtek/patches-6.18/810-lm75-alert-polarity-swap.patch b/target/linux/realtek/patches-6.18/810-lm75-alert-polarity-swap.patch deleted file mode 100644 index 87835f3965b..00000000000 --- a/target/linux/realtek/patches-6.18/810-lm75-alert-polarity-swap.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 92ea53e058d40ebda7326016494e3c21dc536c53 Mon Sep 17 00:00:00 2001 -From: Markus Stockhausen -Date: Mon, 23 Mar 2026 22:12:01 +0200 -Subject: [PATCH] hwmon: lm75 alert polarity swap - -The LM75 can steer the alert polarity. In default mode the alert -output pin is active-low. This can not be configured with the -existing LM75 driver. - -There are hardware designs that use this alert output for an automatic -fan speed control. E.g. the D-Link DGS-1250. This works as follows - -- temperature below Tmax threshold -> alert pin low -> fan slow speed -- temperature above Tmax threshold -> alert pin high -> fan high speed - -As one can see the hardware design requires the alert pin to be -configured in mode active-high to work as described. Add a LM75 DTS -property "alert-polarity-active-high" that allows to swap the alert -pin behaviour during initialization to active-high. - -Signed-off-by: Markus Stockhausen - ---- a/drivers/hwmon/lm75.c -+++ b/drivers/hwmon/lm75.c -@@ -122,7 +122,8 @@ struct lm75_data { - - static const u8 lm75_sample_set_masks[] = { 0 << 5, 1 << 5, 2 << 5, 3 << 5 }; - --#define LM75_SAMPLE_CLEAR_MASK (3 << 5) -+#define LM75_SAMPLE_CLEAR_MASK (3 << 5) -+#define LM75_ALERT_POLARITY_HIGH BIT(2) - - /* The structure below stores the configuration values of the supported devices. - * In case of being supported multiple configurations, the default one must -@@ -713,6 +714,7 @@ static int lm75_generic_probe(struct dev - struct device *hwmon_dev; - struct lm75_data *data; - int status, err; -+ u16 set_mask; - - data = devm_kzalloc(dev, sizeof(struct lm75_data), GFP_KERNEL); - if (!data) -@@ -744,8 +746,13 @@ static int lm75_generic_probe(struct dev - return err; - data->orig_conf = status; - -- err = lm75_write_config(data, data->params->set_mask, -- data->params->clr_mask); -+ set_mask = data->params->set_mask; -+ if (of_property_read_bool(dev->of_node, "alert-polarity-active-high")) { -+ pr_info("set lm75 alert to active high\n"); -+ set_mask |= LM75_ALERT_POLARITY_HIGH; -+ } -+ -+ err = lm75_write_config(data, set_mask, data->params->clr_mask); - if (err) - return err; -