1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *  Copyright(C) 2024 Svyatoslav Ryhel <clamor95@gmail.com>
4  */
5 
6 #include <dm.h>
7 #include <i2c.h>
8 #include <errno.h>
9 #include <sysreset.h>
10 #include <power/pmic.h>
11 #include <power/max8907.h>
12 
max8907_sysreset_request(struct udevice * dev,enum sysreset_t type)13 static int max8907_sysreset_request(struct udevice *dev, enum sysreset_t type)
14 {
15 	switch (type) {
16 	case SYSRESET_POWER:
17 	case SYSRESET_POWER_OFF:
18 		/* MAX8907: PWR_OFF > RESET_CNFG */
19 		pmic_clrsetbits(dev->parent, MAX8907_REG_RESET_CNFG,
20 				MASK_POWER_OFF, MASK_POWER_OFF);
21 		break;
22 	default:
23 		return -EPROTONOSUPPORT;
24 	}
25 
26 	return -EINPROGRESS;
27 }
28 
29 static struct sysreset_ops max8907_sysreset = {
30 	.request = max8907_sysreset_request,
31 };
32 
33 U_BOOT_DRIVER(sysreset_max8907) = {
34 	.id	= UCLASS_SYSRESET,
35 	.name	= MAX8907_RST_DRIVER,
36 	.ops	= &max8907_sysreset,
37 };
38