Skip to content

Commit 82d1b0e

Browse files
committed
mfd: add driver for max42500
The MAX42500 is a multiple function device for power-system monitoring, timestamp recordings and watchdog controls all-together in one SoC package. These features can be used independently or at the same time in a wide range of applications. Signed-off-by: Kent Libetario <Kent.Libetario@analog.com>
1 parent 541bf87 commit 82d1b0e

File tree

5 files changed

+135
-0
lines changed

5 files changed

+135
-0
lines changed

Kconfig.adi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ config KERNEL_ALL_ADI_DRIVERS
9595
imply REGULATOR_MAX77857
9696
imply REGULATOR_MAX77541
9797
imply MFD_MAX77541
98+
imply MAX42500_WDT
99+
imply MFD_MAX42500
98100

99101
source "drivers/clk/Kconfig.adi"
100102
source "drivers/hwmon/Kconfig.adi"

drivers/mfd/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,19 @@ config MFD_MAX14577
808808
additional drivers must be enabled in order to use the functionality
809809
of the device.
810810

811+
config MFD_MAX42500
812+
bool "Analog Devices MAX42500 Industrial Power System Monitor"
813+
depends on I2C
814+
select MFD_CORE
815+
select REGMAP_I2C
816+
help
817+
Say yes here to add support for MAX42500 SoC power-system monitor
818+
with up to seven voltage monitor. The driver also contains a
819+
programmable challenge/response watchdog, which is accessible through
820+
the I2C interface, along with a configurable RESET output. Additional
821+
drivers can be enabled in order to use the following functionalities
822+
of the device: GPIO.
823+
811824
config MFD_MAX77541
812825
tristate "Analog Devices MAX77541/77540 PMIC Support"
813826
depends on I2C=y

drivers/mfd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ obj-$(CONFIG_MFD_DA9063) += da9063.o
157157
obj-$(CONFIG_MFD_DA9150) += da9150-core.o
158158

159159
obj-$(CONFIG_MFD_MAX14577) += max14577.o
160+
obj-$(CONFIG_MFD_MAX42500) += max42500.o
160161
obj-$(CONFIG_MFD_MAX77541) += max77541.o
161162
obj-$(CONFIG_MFD_MAX77620) += max77620.o
162163
obj-$(CONFIG_MFD_MAX77650) += max77650.o

drivers/mfd/max42500.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* MAX42500 - MFD Power System Monitor
4+
*
5+
* Copyright 2025 Analog Devices Inc.
6+
*/
7+
8+
#include <linux/err.h>
9+
#include <linux/i2c.h>
10+
#include <linux/kernel.h>
11+
#include <linux/mfd/core.h>
12+
#include <linux/mfd/max42500.h>
13+
#include <linux/mod_devicetable.h>
14+
#include <linux/module.h>
15+
#include <linux/regmap.h>
16+
17+
static const struct mfd_cell max42500_subdev[] = {
18+
MFD_CELL_NAME("max42500-hwmon"),
19+
MFD_CELL_NAME("max42500-wdt"),
20+
};
21+
22+
static const struct regmap_config max42500_regmap_config = {
23+
.reg_bits = 8,
24+
.val_bits = 8,
25+
.max_register = MAX42500_REG_CID,
26+
};
27+
28+
static int max42500_probe(struct i2c_client *i2c)
29+
{
30+
struct regmap *map;
31+
int ret;
32+
33+
map = devm_regmap_init_i2c(i2c, &max42500_regmap_config);
34+
if (IS_ERR(map))
35+
return PTR_ERR(map);
36+
37+
ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO,
38+
max42500_subdev, ARRAY_SIZE(max42500_subdev),
39+
NULL, 0, NULL);
40+
41+
return ret;
42+
}
43+
44+
static const struct of_device_id max42500_of_match[] = {
45+
{ .compatible = "adi,max42500" },
46+
{ }
47+
};
48+
MODULE_DEVICE_TABLE(of, max42500_of_match);
49+
50+
static struct i2c_driver max42500_driver = {
51+
.driver = {
52+
.name = "max42500",
53+
.of_match_table = max42500_of_match,
54+
},
55+
.probe = max42500_probe,
56+
};
57+
module_i2c_driver(max42500_driver);
58+
59+
MODULE_AUTHOR("Kent Libetario <kent.libetario@analog.com>");
60+
MODULE_DESCRIPTION("MFD driver for MAX42500");
61+
MODULE_LICENSE("GPL");

include/linux/mfd/max42500.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* MAX42500 - Industrial Power System Monitor
4+
*
5+
* Copyright 2025 Analog Devices Inc.
6+
*/
7+
8+
#ifndef __MFD_MAX42500_H
9+
#define __MFD_MAX42500_H
10+
11+
#define MAX42500_REG_ID 0x00
12+
#define MAX42500_REG_CONFIG1 0x01
13+
#define MAX42500_REG_CONFIG2 0x02
14+
#define MAX42500_REG_VMON 0x03
15+
#define MAX42500_REG_RSTMAP 0x04
16+
#define MAX42500_REG_STATOV 0x05
17+
#define MAX42500_REG_STATUV 0x06
18+
#define MAX42500_REG_STATOFF 0x07
19+
#define MAX42500_REG_VIN1 0x08
20+
#define MAX42500_REG_VIN2 0x09
21+
#define MAX42500_REG_VIN3 0x0A
22+
#define MAX42500_REG_VIN4 0x0B
23+
#define MAX42500_REG_VIN5 0x0C
24+
#define MAX42500_REG_VINO6 0x0D
25+
#define MAX42500_REG_VINU6 0x0E
26+
#define MAX42500_REG_VINO7 0x0F
27+
#define MAX42500_REG_VINU7 0x10
28+
#define MAX42500_REG_OVUV1 0x11
29+
#define MAX42500_REG_OVUV2 0x12
30+
#define MAX42500_REG_OVUV3 0x13
31+
#define MAX42500_REG_OVUV4 0x14
32+
#define MAX42500_REG_OVUV5 0x15
33+
#define MAX42500_REG_FPSSTAT1 0x16
34+
#define MAX42500_REG_FPSCFG1 0x17
35+
#define MAX42500_REG_UTIME1 0x18
36+
#define MAX42500_REG_UTIME2 0x19
37+
#define MAX42500_REG_UTIME3 0x1A
38+
#define MAX42500_REG_UTIME4 0x1B
39+
#define MAX42500_REG_UTIME5 0x1C
40+
#define MAX42500_REG_UTIME6 0x1D
41+
#define MAX42500_REG_UTIME7 0x1E
42+
#define MAX42500_REG_DTIME1 0x1F
43+
#define MAX42500_REG_DTIME2 0x20
44+
#define MAX42500_REG_DTIME3 0x21
45+
#define MAX42500_REG_DTIME4 0x22
46+
#define MAX42500_REG_DTIME5 0x23
47+
#define MAX42500_REG_DTIME6 0x24
48+
#define MAX42500_REG_DTIME7 0x25
49+
#define MAX42500_REG_WDSTAT 0x26
50+
#define MAX42500_REG_WDCDIV 0x27
51+
#define MAX42500_REG_WDCFG1 0x28
52+
#define MAX42500_REG_WDCFG2 0x29
53+
#define MAX42500_REG_WDKEY 0x2A
54+
#define MAX42500_REG_WDLOCK 0x2B
55+
#define MAX42500_REG_RSTCTRL 0x2C
56+
#define MAX42500_REG_CID 0x2D
57+
58+
#endif /* __MFD_MAX42500_H */

0 commit comments

Comments
 (0)