Skip to content

Add driver for MAX42500 #2659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Documentation/devicetree/bindings/mfd/adi,max42500.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/hwmon/adi,max42500.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices MAX42500 Industrial Power System Monitor

maintainers:
- Kent Libetario <Kent.Libetario@analog.com>

description: |
Analog Devices MAX42500 Industrial Power System Monitor Family
https://www.analog.com/media/en/technical-documentation/data-sheets/max42500.pdf

properties:
compatible:
enum:
- adi,max42500
reg:
maxItems: 1

poweroff-gpios:
description:
This property sets the GPIO as output. Then used to control the power and
mode state of the device. This can be enabled optionally to control the
state of comparators in the voltage monitoring and/or trigger timestamp
recording in the flexible power sequence recording functions. Check the
state transition conditions in datasheet for more information.
maxItems: 1

sleepoff-gpios:
description:
This property sets the GPIO as output. Then used to control the power and
mode state of the device. This can be enabled and masked optionally to
control the state of comparators in the voltage monitoring and/or trigger
timestamp recording in the flexible power sequence recording functions.
Check the state transition conditions in datasheet for more information.
maxItems: 1

required:
- compatible
- reg

additionalProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;

hwmon@28 {
compatible = "adi,max42500";
reg = <0x28>;
};
};
135 changes: 135 additions & 0 deletions Documentation/hwmon/max42500-hwmon.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
.. SPDX-License-Identifier: GPL-2.0-or-later

Kernel driver max42500
======================

Supported chips:
* Analog Devices MAX42500

Prefix: 'max42500'

Addresses scanned: I2C 0x28 to 0x2B

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max42500.pdf

Author: Kent Libetario <Kent.Libetario@analog.com>

Description
-----------

This driver supports hardware monitoring of MAX42500 power system with up
to seven voltage monitor inputs. Each input has programmable overvoltage
(OV) and undervoltage (UV) thresholds where two of the inputs support
dynamic voltage scaling (DVS). Additionally, the MAX42500 features a
programmable flexible power sequence recorder that stores timestamps
separately. And also, the MAX42500 has a programmable challenge and
response watchdog with a configurable RESET output.


Usage Notes
-----------

This driver does not auto-detect devices. You will have to instantiate the
devices explicitly. Please see Documentation/i2c/instantiating-devices.rst
for details.

Due to its multi-functionality, the MAX42500 is split into three drivers:
the mfd driver as the main device, and the hwmon and watchdog drivers as
the sub-devices. The mfd driver is a client to the core driver and
consumed by both the hwmon and watchdog drivers.

Optionally, two power management GPIOs are provided by the mfd driver and
consumed only by the hwmon sub-device driver. The pins are fixed-outputs
to control the voltage monitor comparators and trigger the power sequence
timestamp recording of the device. Please see the datasheet for details.

For the two GPIO output pins to be consumed, the device tree will look
like this:

.. code-block::

i2c {
#address-cells = <1>;
#size-cells = <0>;
poweroff-gpios
sleepoff-gpios

hwmon@28 {
compatible = "adi,max42500";
reg = <0x28>;
};
};

Otherwise, the two pins maybe omitted in the device tree if unused.


Platform data support
---------------------

The Hwmon driver supports standard Hwmon ABI driver and sysfs platform
data. While the watchdog driver supports the standard watchdog ABI driver
and sysfs platform data.


Hwmon Sysfs entries
-------------------

The following attributes are supported. Limits are read-write; all other
attributes are read-only.


Chip
~~~~

======================= =======================================================
chip_pec Enable or disable PEC: PECE bit in CONFIG1 register
======================= =======================================================

In
~~

======================= ======================================================
in[1-7]_label "VMON[1-7]"
in[1-7]_enable Enable or disable voltage monitors: VM1 to VM7 bits of
VMON register
in[1-5]_min Nominal Voltage set point: VIN1 to VIN5 registers
in[1-5]_lcrit IN1-IN5 UV threshold: UV1 to UV5 nibbles of OVUV1 to
OVUV5 registers
in[6-7]_lcrit IN6-IN7 UV threshold: VINU6 to VINU7 registers
in[1-5]_crit IN1-IN5 OV threshold: OV1 to OV5 nibbles of OVUV1 to
OVUV5 registers
in[6-7]_crit IN6-IN7 OV threshold: VINO6 to VINO7 registers
in[1-7]_reset_history Enable or disable reset mapping: IN1 to IN7 bits of
RSTMAP register
======================= ======================================================

Power
~~~~~

=============================== ===============================================
power[1-7]_label "STATUS[1-7]"
power_enable OFF comparator status: STATOFF register
power_lcrit_alarm UV comparator status: STATUV register
power_crit_alarm OV comparator status: STATOV register
power[1-7]_average_interval_min Power-Down sequence time-stamp: DTIME1 to
DTIME7 registers
power[1-7]_average_interval_max Power-Up sequence time-stamp: UTIME1 to
UTIME7 registers
=============================== ===============================================


Watchdog Sysfs entries
----------------------

======================= =======================================================
start Enable the watchdog: WDEN bit of WDCFG2 register
stop Disable the watchdog: WDEN bit of WDCFG2 register
ping Set the watchdog key to the device: WDKEY register
status Watchdog status: WDSTAT register
set_timeout Watchdog Clock Divider: WDIV bits of WDCDIV register
set_pretimeout First Update Extension: 1UD bit of WDCFG2 register
restart Reset Hold or Active Timeout: RHLD bits of RSTCTRL
register
======================= =======================================================

..
2 changes: 2 additions & 0 deletions Kconfig.adi
Original file line number Diff line number Diff line change
@@ -96,6 +96,8 @@ config KERNEL_ALL_ADI_DRIVERS
imply REGULATOR_MAX77857
imply REGULATOR_MAX77541
imply MFD_MAX77541
imply MAX42500_WDT
imply MFD_MAX42500

source "drivers/clk/Kconfig.adi"
source "drivers/hwmon/Kconfig.adi"
12 changes: 12 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
@@ -1131,6 +1131,18 @@ config MAX31827
This driver can also be built as a module. If so, the module
will be called max31827.

config SENSORS_MAX42500
tristate "MAX42500 Industrial Power System Monitor"
depends on MFD_MAX42500
help
If you say yes here you get support for MAX42500 SoC power-system
monitor with up to seven voltage monitor. The driver also contains a
programmable challenge/response watchdog, which is accessible through
the I2C interface, along with a configurable RESET output.

This driver can also be built as a module. If so, the module
will be called max42500-hwmon.

config SENSORS_MAX6620
tristate "Maxim MAX6620 fan controller"
depends on I2C
1 change: 1 addition & 0 deletions drivers/hwmon/Kconfig.adi
Original file line number Diff line number Diff line change
@@ -44,4 +44,5 @@ config HWMON_ALL_ADI_DRIVERS
imply MAX31827
imply SENSORS_MAX31760
imply SENSORS_LT7182S
imply SENSORS_MAX42500

1 change: 1 addition & 0 deletions drivers/hwmon/Makefile
Original file line number Diff line number Diff line change
@@ -145,6 +145,7 @@ obj-$(CONFIG_SENSORS_MAX197) += max197.o
obj-$(CONFIG_SENSORS_MAX31722) += max31722.o
obj-$(CONFIG_SENSORS_MAX31730) += max31730.o
obj-$(CONFIG_SENSORS_MAX31760) += max31760.o
obj-$(CONFIG_SENSORS_MAX42500) += max42500-hwmon.o
obj-$(CONFIG_SENSORS_MAX6620) += max6620.o
obj-$(CONFIG_SENSORS_MAX6621) += max6621.o
obj-$(CONFIG_SENSORS_MAX6639) += max6639.o
Loading