Skip to content

Commit ffeaa7e

Browse files
committed
hwmon: add driver for max31875
MAX31875 Low-Power I2C Temperature Sensor Signed-off-by: John Erasmus Mari Geronimo <johnerasmusmari.geronimo@analog.com>
1 parent 49786f9 commit ffeaa7e

File tree

6 files changed

+671
-0
lines changed

6 files changed

+671
-0
lines changed

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Hardware Monitoring Kernel Drivers
138138
max31785
139139
max31790
140140
max31827
141+
max31875
141142
max34440
142143
max6620
143144
max6639

Documentation/hwmon/max31875.rst

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Kernel driver max31875
4+
======================
5+
6+
Supported chips:
7+
8+
* Maxim MAX31875
9+
10+
Prefix: 'max31875'
11+
12+
Addresses scanned: I2C 0x48 - 0x4f
13+
14+
Datasheet: Publicly available at the Analog Devices website
15+
16+
17+
Authors:
18+
- John Erasmus Mari Geronimo <johnerasmusmari.geronimo@analog.com>
19+
20+
Description
21+
-----------
22+
23+
MAX31875 implements a temperature sensor with a 4 WLP packaging scheme. This
24+
sensor measures the temperature of the chip itself.
25+
26+
MAX31875 has an over temperature alarm with an effective value and a hysteresis
27+
value: +80 and +75 degrees.
28+
29+
The alarm can be configured in comparator and interrupt mode from the
30+
devicetree. In Comparator mode, the OT status bit have a value of 1 when the
31+
temperature rises above the T_OS value, which is also subject to the Fault Queue
32+
selection. OT status returns to 0 when the temperature drops below the T_HYST
33+
value or when shutdown mode is entered.
34+
35+
In interrupt mode exceeding T_OS also sets OT status to 1, which remains set
36+
until a read operation is performed on any of the registers; at this point, it
37+
returns to 0. Once OT status is set to 1 from exceeding T_OS and reset, it is
38+
set to 1 again only when the temperature drops below T_HYST. The output remains
39+
asserted until it is reset by a read. It is set again if the temperature rises
40+
above T_OS, and so on.
41+
42+
Putting the MAX31875 into shutdown mode also resets the OT status. Note that if
43+
the mode is changed while OT status is set, an OT status reset may be required
44+
before it begins to behave normally. To prevent this, it is recommended to
45+
perform a read of the configuration/status register to clear the status bits
46+
before changing the operating mode.
47+
48+
The conversions can be manual with the one-shot functionality and automatic with
49+
a set frequency. When powered on, the chip measures temperatures with 0.25
50+
conv/s. The conversion rate can be modified with update_interval attribute of
51+
the chip. Conversion/second = 1/update_interval. Thus, the available options
52+
according to the data sheet are:
53+
54+
- 4000 (ms) = 0.25 conv/sec (default)
55+
- 1000 (ms) = 1 conv/sec
56+
- 250 (ms) = 4 conv/sec
57+
- 125 (ms) = 8 conv/sec
58+
59+
Enabling the device when it is already enabled has the side effect of setting
60+
the conversion frequency to 0.25 conv/s. The conversion time varies depending on
61+
the resolution.
62+
63+
The conversion time doubles with every bit of increased resolution. The
64+
available resolutions are:
65+
66+
- 8 bit -> 8.75 ms conversion time
67+
- 9 bit -> 17.5 ms conversion time
68+
- 10 bit (default) -> 35 ms conversion time
69+
- 12 bit -> 140 ms conversion time
70+
- 13 bit (extended) -> 280 ms conversion time
71+
72+
There is a temp1_resolution attribute which indicates the unit change in the
73+
input temperature in milli-degrees C. In extended format, the MSB is given a
74+
value of 128 degrees C (compared to normal format: 64 degrees C), which allows
75+
temperatures as high as 150 degrees C to be measured.
76+
77+
- 1000 mC -> 8 bit
78+
- 500 mC -> 9 bit
79+
- 250 mC -> 10 bit (default)
80+
- 62 mC -> 12 bit - actually this is 62.5, but the file returns 62
81+
- 62 mC -> 13 bit (extended) - actually this is 62.5, but the file returns 62
82+
83+
When chip is in shutdown mode and a read operation is requested, one-shot is
84+
triggered, the device waits for <conversion time> ms, and only after that is
85+
the temperature value register read. Note that the conversion times are rounded
86+
up to the nearest possible integer.
87+
88+
The LSB of the temperature values is 0.0625 degrees Celsius, but the values of
89+
the temperatures are displayed in milli-degrees. This means, that some data is
90+
lost. The step between 2 consecutive values is 62 or 63. This effect can be seen
91+
in the writing of alarm values too. For positive numbers the user-input value
92+
will always be rounded down to the nearest possible value, for negative numbers
93+
the user-input will always be rounded up to the nearest possible value.
94+
95+
Bus timeout resets the I2C-compatible interface when SCL is low for more than
96+
30ms (nominal).
97+
98+
The Fault Queue bits select how many consecutive temperature faults must occur
99+
before overtemperature fault is indicated in the OT status bit.

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12602,6 +12602,8 @@ L: linux-hwmon@vger.kernel.org
1260212602
S: Supported
1260312603
W: http://ez.analog.com/community/linux-device-drivers
1260412604
F: Documentation/devicetree/bindings/hwmon/adi,max31875.yaml
12605+
F: Documentation/hwmon/max31875.rst
12606+
F: drivers/hwmon/max31875.c
1260512607

1260612608
MAX31335 RTC DRIVER
1260712609
M: Antoniu Miclaus <antoniu.miclaus@analog.com>

drivers/hwmon/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,15 @@ config MAX31827
11021102
This driver can also be built as a module. If so, the module
11031103
will be called max31827.
11041104

1105+
config SENSORS_MAX31875
1106+
tristate "MAX31875 low-power I2C temperature sensor"
1107+
depends on I2C
1108+
help
1109+
If you say yes here you get support for MAX31875 temperature sensor.
1110+
1111+
This driver can also be built as a module. If so, the module
1112+
will be called max31875.
1113+
11051114
config SENSORS_MAX6620
11061115
tristate "Maxim MAX6620 fan controller"
11071116
depends on I2C

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
150150
obj-$(CONFIG_SENSORS_MAX6697) += max6697.o
151151
obj-$(CONFIG_SENSORS_MAX31790) += max31790.o
152152
obj-$(CONFIG_MAX31827) += max31827.o
153+
obj-$(CONFIG_SENSORS_MAX31875) += max31875.o
153154
obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
154155
obj-$(CONFIG_SENSORS_MCP3021) += mcp3021.o
155156
obj-$(CONFIG_SENSORS_TC654) += tc654.o

0 commit comments

Comments
 (0)