2022-09-09 07:35:23

by Tilki, Ibrahim

[permalink] [raw]
Subject: [PATCH v7 0/4] hwmon: Add max31760 fan speed controller

changes in v7:
- make max31760_read_string static

changes in v6:
- update description of hwmon documentation
- add hwmon documentation to index.rst

changes in v5:
- add dt-bindings documentation
- add maintainer

changes in v4:
- use sysfs_emit instead of sprintf
- use kstrtou8 for pwm
- use closest match for pwm1_auto_point_temp_hyst

changes in v3:
- add regmap cache
- remove pwm1_auto_point[1-48]_{temp,temp_hyst} attributes
- add pwm1_auto_point_temp_hyst attribute

changes in v2:
- remove pulse_per_rev variable in tach_to_rpm
- remove temperature max_hyst and crit_hyst
- strict value checking for fan_enable and pwm_enable
- do not clamp pwm value for Look-up table
- add sysfs_attr_init call
- add documentation


Ibrahim Tilki (4):
drivers: hwmon: Add max31760 fan speed controller driver
docs: hwmon: add max31760 documentation
dt-bindings: hwmon: Add bindings for max31760
MAINTAINERS: Add maintainer for hwmon/max31760

.../bindings/hwmon/adi,max31760.yaml | 44 ++
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/max31760.rst | 77 +++
MAINTAINERS | 9 +
drivers/hwmon/Kconfig | 12 +
drivers/hwmon/Makefile | 1 +
drivers/hwmon/max31760.c | 595 ++++++++++++++++++
7 files changed, 739 insertions(+)
create mode 100644 Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
create mode 100644 Documentation/hwmon/max31760.rst
create mode 100644 drivers/hwmon/max31760.c

--
2.36.1


2022-09-09 07:52:54

by Tilki, Ibrahim

[permalink] [raw]
Subject: [PATCH v7 4/4] MAINTAINERS: Add maintainer for hwmon/max31760

Add maintainer for hwmon/max31760 driver

Signed-off-by: Ibrahim Tilki <[email protected]>
---
MAINTAINERS | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d30f26e07..76c7d6606 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1334,6 +1334,15 @@ F: drivers/iio/amplifiers/hmc425a.c
F: drivers/staging/iio/*/ad*
X: drivers/iio/*/adjd*

+ANALOG DEVICES INC MAX31760 DRIVER
+M: Ibrahim Tilki <[email protected]>
+S: Maintained
+W: http://wiki.analog.com/
+W: https://ez.analog.com/linux-software-drivers
+F: Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
+F: Documentation/hwmon/max31760.rst
+F: drivers/hwmon/max31760.c
+
ANALOGBITS PLL LIBRARIES
M: Paul Walmsley <[email protected]>
S: Supported
--
2.36.1

2022-09-09 07:57:32

by Tilki, Ibrahim

[permalink] [raw]
Subject: [PATCH v7 2/4] docs: hwmon: add max31760 documentation

Adding documentation for max31760 fan speed controller

Signed-off-by: Ibrahim Tilki <[email protected]>
---
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/max31760.rst | 77 ++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 Documentation/hwmon/max31760.rst

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index f7113b0f8..dba260013 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -133,6 +133,7 @@ Hardware Monitoring Kernel Drivers
max20751
max31722
max31730
+ max31760
max31785
max31790
max34440
diff --git a/Documentation/hwmon/max31760.rst b/Documentation/hwmon/max31760.rst
new file mode 100644
index 000000000..b1b55fb84
--- /dev/null
+++ b/Documentation/hwmon/max31760.rst
@@ -0,0 +1,77 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver max31760
+======================
+
+Supported chips:
+ * Analog Devices MAX31760
+
+ Prefix: 'max31760'
+
+ Addresses scanned: none
+
+ Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX31760.pdf
+
+
+Author: Ibrahim Tilki <[email protected]>
+
+Description
+-----------
+
+The MAX31760 integrates temperature sensing along with precision PWM fan
+control. It accurately measures its local die temperature and the remote
+temperature of a discrete diode-connected transistor, such as a 2N3906,
+or a thermal diode commonly found on CPUs, graphics processor units (GPUs),
+and other ASICs. Multiple temperature thresholds, such as local
+high/overtemperature (OT) and remote high/overtemperature, can be set by an
+I2C-compatible interface. Fan speed is controlled based on the temperature
+reading as an index to a 48-byte lookup table (LUT) containing
+user-programmed PWM values. The flexible LUT-based architecture enables
+the user to program a smooth nonlinear fan speed vs. temperature transfer
+function to minimize acoustic fan noise. Two tachometer inputs allow
+measuring the speeds of two fans independently. When the local or remote
+OT threshold is exceeded, the SHDN pin is asserted low and can be used to
+shut down the system. A dedicated ALERT pin reports that either a local or
+remote high-temperature threshold has been exceeded.
+
+Temperature measurement range: from -55°C to 125°C
+
+Temperature Resolution: 11 Bits, ±0.125°C
+
+Please refer how to instantiate this driver: Documentation/i2c/instantiating-devices.rst
+
+Lookup table for auto fan control
+---------------------------------
+
+========= =================================
+LUT Index Name
+========= =================================
+1 PWM value for T < +18°C
+2 PWM value for +18°C ≤ T < +20°C
+3 PWM value for +20°C ≤ T < +22°C
+... ...
+47 PWM value for +108°C ≤ T < +110°C
+48 PWM value for T ≥ +110°C
+========= =================================
+
+Sysfs entries
+-------------
+
+=============================== =================================================================================
+fan[1-2]_input Fan speed (in RPM)
+fan[1-2]_enable Enable fan readings and fan fault alarms
+fan[1-2]_fault Fan fault status
+temp[1-2]_label "Remote" and "Local" temperature channel labels
+temp[1-2]_input Temperature sensor readings (in millidegrees Celsius)
+temp1_fault Remote temperature sensor fault status
+temp[1-2]_max Temperature max value. Asserts "ALERT" pin when exceeded
+temp[1-2]_max_alarm Temperature max alarm status
+temp[1-2]_crit Temperature critical value. Asserts "SHDN" pin when exceeded
+temp[1-2]_crit_alarm Temperature critical alarm status
+pwm1 PWM value for direct fan control
+pwm1_enable 1: direct fan control, 2: temperature based auto fan control
+pwm1_freq PWM frequency in hertz
+pwm1_auto_channels_temp Temperature source for auto fan control. 1: temp1, 2: temp2, 3: max(temp1, temp2)
+pwm1_auto_point[1-48]_pwm PWM value for LUT point
+pwm1_auto_point_temp_hyst Temperature hysteresis for auto fan control. Can be either 2000mC or 4000mC
+=============================== =================================================================================
--
2.36.1

2022-09-09 08:00:02

by Tilki, Ibrahim

[permalink] [raw]
Subject: [PATCH v7 3/4] dt-bindings: hwmon: Add bindings for max31760

Adding bindings for Analog Devices MAX31760 Fan-Speed Controller

Signed-off-by: Ibrahim Tilki <[email protected]>
---
.../bindings/hwmon/adi,max31760.yaml | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 Documentation/devicetree/bindings/hwmon/adi,max31760.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml b/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
new file mode 100644
index 000000000..003ec1317
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/adi,max31760.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices MAX31760 Fan-Speed Controller
+
+maintainers:
+ - Ibrahim Tilki <[email protected]>
+
+description: |
+ Analog Devices MAX31760 Fan-Speed Controller
+ https://datasheets.maximintegrated.com/en/ds/MAX31760.pdf
+
+properties:
+ compatible:
+ enum:
+ - adi,max31760
+
+ reg:
+ description: |
+ I2C address of slave device.
+ items:
+ minimum: 0x50
+ maximum: 0x57
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ max31760@50 {
+ reg = <0x50>;
+ compatible = "adi,max31760";
+ };
+ };
--
2.36.1

2022-09-09 08:53:49

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v7 3/4] dt-bindings: hwmon: Add bindings for max31760

On 09/09/2022 09:16, Ibrahim Tilki wrote:
> Adding bindings for Analog Devices MAX31760 Fan-Speed Controller
>
> Signed-off-by: Ibrahim Tilki <[email protected]>
> ---
> .../bindings/hwmon/adi,max31760.yaml | 44 +++++++++++++++++++
> 1 file changed, 44 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
>
> diff --git a/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml b/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
> new file mode 100644
> index 000000000..003ec1317
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/adi,max31760.yaml
> @@ -0,0 +1,44 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/adi,max31760.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices MAX31760 Fan-Speed Controller
> +
> +maintainers:
> + - Ibrahim Tilki <[email protected]>
> +
> +description: |
> + Analog Devices MAX31760 Fan-Speed Controller
> + https://datasheets.maximintegrated.com/en/ds/MAX31760.pdf
> +
> +properties:
> + compatible:
> + enum:
> + - adi,max31760
> +
> + reg:
> + description: |

No need for |

> + I2C address of slave device.

maxItems: 1

> + items:
> + minimum: 0x50
> + maximum: 0x57
> +
> +required:
> + - compatible
> + - reg
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + i2c0 {

Just i2c.

> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + max31760@50 {

Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

> + reg = <0x50>;
> + compatible = "adi,max31760";

Messed up indentation. 4 spaces for DTS example.

> + };
> + };


Best regards,
Krzysztof