summaryrefslogtreecommitdiff
path: root/drivers/sysreset/sysreset_max8907.c
blob: 6f62af9bffe5550bf55ac85073441f799f9f4ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-2.0+
/*
 *  Copyright(C) 2024 Svyatoslav Ryhel <clamor95@gmail.com>
 */

#include <dm.h>
#include <i2c.h>
#include <errno.h>
#include <sysreset.h>
#include <power/pmic.h>
#include <power/max8907.h>

static int max8907_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
	switch (type) {
	case SYSRESET_POWER:
	case SYSRESET_POWER_OFF:
		/* MAX8907: PWR_OFF > RESET_CNFG */
		pmic_clrsetbits(dev->parent, MAX8907_REG_RESET_CNFG,
				MASK_POWER_OFF, MASK_POWER_OFF);
		break;
	default:
		return -EPROTONOSUPPORT;
	}

	return -EINPROGRESS;
}

static struct sysreset_ops max8907_sysreset = {
	.request = max8907_sysreset_request,
};

U_BOOT_DRIVER(sysreset_max8907) = {
	.id	= UCLASS_SYSRESET,
	.name	= MAX8907_RST_DRIVER,
	.ops	= &max8907_sysreset,
};