Skip to content

Commit bdfccc7

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 7ebc26e commit bdfccc7

File tree

4 files changed

+247
-0
lines changed

4 files changed

+247
-0
lines changed

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

include/linux/mfd/max42500.h

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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+
#include <linux/bitfield.h>
12+
#include <linux/bitops.h>
13+
14+
/* Command registers */
15+
#define MAX42500_REG_ID 0x00
16+
#define MAX42500_REG_CONFIG1 0x01
17+
#define MAX42500_REG_CONFIG2 0x02
18+
#define MAX42500_REG_VMON 0x03
19+
#define MAX42500_REG_RSTMAP 0x04
20+
#define MAX42500_REG_STATOV 0x05
21+
#define MAX42500_REG_STATUV 0x06
22+
#define MAX42500_REG_STATOFF 0x07
23+
#define MAX42500_REG_VIN1 0x08
24+
#define MAX42500_REG_VIN2 0x09
25+
#define MAX42500_REG_VIN3 0x0A
26+
#define MAX42500_REG_VIN4 0x0B
27+
#define MAX42500_REG_VIN5 0x0C
28+
#define MAX42500_REG_VINO6 0x0D
29+
#define MAX42500_REG_VINU6 0x0E
30+
#define MAX42500_REG_VINO7 0x0F
31+
#define MAX42500_REG_VINU7 0x10
32+
#define MAX42500_REG_OVUV1 0x11
33+
#define MAX42500_REG_OVUV2 0x12
34+
#define MAX42500_REG_OVUV3 0x13
35+
#define MAX42500_REG_OVUV4 0x14
36+
#define MAX42500_REG_OVUV5 0x15
37+
#define MAX42500_REG_FPSTAT1 0x16
38+
#define MAX42500_REG_FPSCFG1 0x17
39+
#define MAX42500_REG_UTIME1 0x18
40+
#define MAX42500_REG_UTIME2 0x19
41+
#define MAX42500_REG_UTIME3 0x1A
42+
#define MAX42500_REG_UTIME4 0x1B
43+
#define MAX42500_REG_UTIME5 0x1C
44+
#define MAX42500_REG_UTIME6 0x1D
45+
#define MAX42500_REG_UTIME7 0x1E
46+
#define MAX42500_REG_DTIME1 0x1F
47+
#define MAX42500_REG_DTIME2 0x20
48+
#define MAX42500_REG_DTIME3 0x21
49+
#define MAX42500_REG_DTIME4 0x22
50+
#define MAX42500_REG_DTIME5 0x23
51+
#define MAX42500_REG_DTIME6 0x24
52+
#define MAX42500_REG_DTIME7 0x25
53+
#define MAX42500_REG_WDSTAT 0x26
54+
#define MAX42500_REG_WDCDIV 0x27
55+
#define MAX42500_REG_WDCFG1 0x28
56+
#define MAX42500_REG_WDCFG2 0x29
57+
#define MAX42500_REG_WDKEY 0x2A
58+
#define MAX42500_REG_WDLOCK 0x2B
59+
#define MAX42500_REG_RSTCTRL 0x2C
60+
#define MAX42500_REG_CID 0x2D
61+
62+
/* Status error */
63+
#define MAX42500_STS_ERROR 0xFF
64+
65+
/* Device chip registers */
66+
#define MAX42500_CHIP_ID_MASK GENMASK(7, 0)
67+
#define MAX42500_CHIP_ID(x) FIELD_GET(MAX42500_CHIP_ID_MASK, x)
68+
#define MAX42500_CHIP_CID_MASK GENMASK(7, 0)
69+
#define MAX42500_CHIP_CID(x) FIELD_GET(MAX42500_CHIP_CID_MASK, x)
70+
#define MAX42500_CHIP_CFG2_MASK GENMASK(7, 0)
71+
#define MAX42500_CHIP_CFG2(x) FIELD_GET(MAX42500_CHIP_PECE_MASK, x)
72+
#define MAX42500_CHIP_PECE_MASK BIT(0)
73+
#define MAX42500_CHIP_PECE(x) FIELD_GET(MAX42500_CHIP_PECE_MASK, x)
74+
#define MAX42500_CHIP_MBST_MASK BIT(1)
75+
#define MAX42500_CHIP_MBST(x) FIELD_GET(MAX42500_CHIP_MBST_MASK, x)
76+
#define MAX42500_CHIP_RR_MASK BIT(2)
77+
#define MAX42500_CHIP_RR(x) FIELD_GET(MAX42500_CHIP_RR_MASK, x)
78+
79+
/* Voltage Monitor registers */
80+
#define MAX42500_VMON_VM1_MASK BIT(0)
81+
#define MAX42500_VMON_VM1(x) FIELD_GET(MAX42500_VMON_VM1_MASK, x)
82+
#define MAX42500_VMON_VM2_MASK BIT(1)
83+
#define MAX42500_VMON_VM2(x) FIELD_GET(MAX42500_VMON_VM2_MASK, x)
84+
#define MAX42500_VMON_VM3_MASK BIT(2)
85+
#define MAX42500_VMON_VM3(x) FIELD_GET(MAX42500_VMON_VM3_MASK, x)
86+
#define MAX42500_VMON_VM4_MASK BIT(3)
87+
#define MAX42500_VMON_VM4(x) FIELD_GET(MAX42500_VMON_VM4_MASK, x)
88+
#define MAX42500_VMON_VM5_MASK BIT(4)
89+
#define MAX42500_VMON_VM5(x) FIELD_GET(MAX42500_VMON_VM5_MASK, x)
90+
#define MAX42500_VMON_VM6_MASK BIT(5)
91+
#define MAX42500_VMON_VM6(x) FIELD_GET(MAX42500_VMON_VM6_MASK, x)
92+
#define MAX42500_VMON_VM7_MASK BIT(6)
93+
#define MAX42500_VMON_VM7(x) FIELD_GET(MAX42500_VMON_VM7_MASK, x)
94+
#define MAX42500_VMON_VMPD_MASK BIT(7)
95+
#define MAX42500_VMON_VMPD(x) FIELD_GET(MAX42500_VMON_VMPD_MASK, x)
96+
#define MAX42500_VMON_RST1_MASK BIT(0)
97+
#define MAX42500_VMON_RST1(x) FIELD_GET(MAX42500_VMON_RST1_MASK, x)
98+
#define MAX42500_VMON_RST2_MASK BIT(1)
99+
#define MAX42500_VMON_RST2(x) FIELD_GET(MAX42500_VMON_RST2_MASK, x)
100+
#define MAX42500_VMON_RST3_MASK BIT(2)
101+
#define MAX42500_VMON_RST3(x) FIELD_GET(MAX42500_VMON_RST3_MASK, x)
102+
#define MAX42500_VMON_RST4_MASK BIT(3)
103+
#define MAX42500_VMON_RST4(x) FIELD_GET(MAX42500_VMON_RST4_MASK, x)
104+
#define MAX42500_VMON_RST5_MASK BIT(4)
105+
#define MAX42500_VMON_RST5(x) FIELD_GET(MAX42500_VMON_RST5_MASK, x)
106+
#define MAX42500_VMON_RST6_MASK BIT(5)
107+
#define MAX42500_VMON_RST6(x) FIELD_GET(MAX42500_VMON_RST6_MASK, x)
108+
#define MAX42500_VMON_RST7_MASK BIT(6)
109+
#define MAX42500_VMON_RST7(x) FIELD_GET(MAX42500_VMON_RST7_MASK, x)
110+
#define MAX42500_VMON_PARM_MASK BIT(7)
111+
#define MAX42500_VMON_PARM(x) FIELD_GET(MAX42500_VMON_PARM_MASK, x)
112+
#define MAX42500_VMON_1VIN5_MASK GENMASK(7, 0)
113+
#define MAX42500_VMON_1VIN5(x) FIELD_GET(MAX42500_VMON_1VIN5_MASK, x)
114+
#define MAX42500_VMON_1VINU5_MASK GENMASK(3, 0)
115+
#define MAX42500_VMON_1VINU5(x) FIELD_GET(MAX42500_VMON_1VINU5_MASK, x)
116+
#define MAX42500_VMON_6VINU7_MASK GENMASK(7, 0)
117+
#define MAX42500_VMON_6VINU7(x) FIELD_GET(MAX42500_VMON_6VINU7_MASK, x)
118+
#define MAX42500_VMON_1VINO5_MASK GENMASK(7, 4)
119+
#define MAX42500_VMON_1VINO5(x) FIELD_GET(MAX42500_VMON_1VINO5_MASK, x)
120+
#define MAX42500_VMON_6VINO7_MASK GENMASK(7, 0)
121+
#define MAX42500_VMON_6VINO7(x) FIELD_GET(MAX42500_VMON_6VINO7_MASK, x)
122+
#define MAX42500_VMON_STATOFF_MASK GENMASK(7, 0)
123+
#define MAX42500_VMON_STATOFF(x) FIELD_GET(MAX42500_VMON_STATOFF_MASK, x)
124+
#define MAX42500_VMON_STATUV_MASK GENMASK(7, 0)
125+
#define MAX42500_VMON_STATUV(x) FIELD_GET(MAX42500_VMON_STATUV_MASK, x)
126+
#define MAX42500_VMON_STATOV_MASK GENMASK(7, 0)
127+
#define MAX42500_VMON_STATOV(x) FIELD_GET(MAX42500_VMON_STATOV_MASK, x)
128+
129+
/* Sequence recorder registers */
130+
#define MAX42500_FPSR_FPSTAT1_MASK GENMASK(7, 0)
131+
#define MAX42500_FPSR_FPSTAT1(x) FIELD_GET(MAX42500_FPSR_FPSTAT1_MASK, x)
132+
#define MAX42500_FPSR_FDIV_MASK GENMASK(2, 0)
133+
#define MAX42500_FPSR_FDIV(x) FIELD_GET(MAX42500_FPSR_FDIV_MASK, x)
134+
#define MAX42500_FPSR_FPSEN1_MASK BIT(3)
135+
#define MAX42500_FPSR_FPSEN1(x) FIELD_GET(MAX42500_FPSR_FPSEN1_MASK, x)
136+
#define MAX42500_FPSR_DVALM_MASK BIT(4)
137+
#define MAX42500_FPSR_DVALM(x) FIELD_GET(MAX42500_FPSR_DVALM_MASK, x)
138+
#define MAX42500_FPSR_UVALM_MASK BIT(5)
139+
#define MAX42500_FPSR_UVALM(x) FIELD_GET(MAX42500_FPSR_UVALM_MASK, x)
140+
#define MAX42500_FPSR_DVAL_MASK BIT(6)
141+
#define MAX42500_FPSR_DVAL(x) FIELD_GET(MAX42500_FPSR_DVAL_MASK, x)
142+
#define MAX42500_FPSR_UVAL_MASK BIT(7)
143+
#define MAX42500_FPSR_UVAL(x) FIELD_GET(MAX42500_FPSR_UVAL_MASK, x)
144+
#define MAX42500_FPSR_1UTIM7_MASK GENMASK(7, 0)
145+
#define MAX42500_FPSR_1UTIM7(x) FIELD_GET(MAX42500_FPSR_1UTIM7_MASK, x)
146+
#define MAX42500_FPSR_1DTIM7_MASK GENMASK(7, 0)
147+
#define MAX42500_FPSR_1DTIM7(x) FIELD_GET(MAX42500_FPSR_1DTIM7_MASK, x)
148+
149+
/* Windowed watchdog register*/
150+
#define MAX42500_WDOG_WDSTAT_MASK GENMASK(7, 0)
151+
#define MAX42500_WDOG_WDSTAT(x) FIELD_GET(MAX42500_WDOG_WDSTAT_MASK, x)
152+
#define MAX42500_WDOG_WDIV_MASK GENMASK(5, 0)
153+
#define MAX42500_WDOG_WDIV(x) FIELD_GET(MAX42500_WDOG_WDIV_MASK, x)
154+
#define MAX42500_WDOG_SWW_MASK BIT(6)
155+
#define MAX42500_WDOG_SWW(x) FIELD_GET(MAX42500_WDOG_SWW_MASK, x)
156+
#define MAX42500_WDOG_WDOPEN_MASK GENMASK(3, 0)
157+
#define MAX42500_WDOG_WDOPEN(x) FIELD_GET(MAX42500_WDOG_WDOPEN_MASK, x)
158+
#define MAX42500_WDOG_WDCLOSE_MASK GENMASK(7, 4)
159+
#define MAX42500_WDOG_WDCLOSE(x) FIELD_GET(MAX42500_WDOG_WDCLOSE_MASK, x)
160+
#define MAX42500_WDOG_1UD_MASK GENMASK(2, 0)
161+
#define MAX42500_WDOG_1UD(x) FIELD_GET(MAX42500_WDOG_1UD_MASK, x)
162+
#define MAX42500_WDOG_WDEN_MASK BIT(3)
163+
#define MAX42500_WDOG_WDEN(x) FIELD_GET(MAX42500_WDOG_WDEN_MASK, x)
164+
#define MAX42500_WDOG_WDKEY_MASK GENMASK(7, 0)
165+
#define MAX42500_WDOG_WDKEY(x) FIELD_GET(MAX42500_WDOG_WDKEY_MASK, x)
166+
#define MAX42500_WDOG_WDLOCK_MASK BIT(0)
167+
#define MAX42500_WDOG_WDLOCK(x) FIELD_GET(MAX42500_WDOG_WDLOCK_MASK, x)
168+
#define MAX42500_WDOG_RHLD_MASK GENMASK(1, 0)
169+
#define MAX42500_WDOG_RHLD(x) FIELD_GET(MAX42500_WDOG_RHLD_MASK, x)
170+
#define MAX42500_WDOG_MR1_MASK BIT(2)
171+
#define MAX42500_WDOG_MR1(x) FIELD_GET(MAX42500_WDOG_MR1_MASK, x)
172+
173+
#endif /* __MFD_MAX42500_H */

0 commit comments

Comments
 (0)