blob: 6f62af9bffe5550bf55ac85073441f799f9f4ae5 [file] [log] [blame]
Svyatoslav Ryhel9f8ea822024-10-06 16:51:21 +03001// 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
13static 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
29static struct sysreset_ops max8907_sysreset = {
30 .request = max8907_sysreset_request,
31};
32
33U_BOOT_DRIVER(sysreset_max8907) = {
34 .id = UCLASS_SYSRESET,
35 .name = MAX8907_RST_DRIVER,
36 .ops = &max8907_sysreset,
37};