]> Git Repo - u-boot.git/blob - drivers/sysreset/sysreset_max77663.c
Subtree merge tag 'v6.9-dts' of devicetree-rebasing repo [1] into dts/upstream
[u-boot.git] / drivers / sysreset / sysreset_max77663.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *  Copyright(C) 2023 Svyatoslav Ryhel <[email protected]>
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/max77663.h>
12
13 static int max77663_sysreset_request(struct udevice *dev,
14                                      enum sysreset_t type)
15 {
16         int val;
17
18         val = pmic_reg_read(dev->parent, MAX77663_REG_ONOFF_CFG1);
19         if (val < 0)
20                 return val;
21
22         /* clear both bits */
23         val &= ~ONOFF_SFT_RST;
24         val &= ~ONOFF_PWR_OFF;
25
26         switch (type) {
27         case SYSRESET_POWER:
28                 /* MAX77663: SFT_RST > ONOFF_CFG1 */
29                 pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1,
30                                val | ONOFF_SFT_RST);
31                 break;
32         case SYSRESET_POWER_OFF:
33                 /* MAX77663: PWR_OFF > ONOFF_CFG1 */
34                 pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1,
35                                val | ONOFF_PWR_OFF);
36                 break;
37         default:
38                 return -EPROTONOSUPPORT;
39         }
40
41         return -EINPROGRESS;
42 }
43
44 static struct sysreset_ops max77663_sysreset = {
45         .request = max77663_sysreset_request,
46 };
47
48 U_BOOT_DRIVER(sysreset_max77663) = {
49         .id     = UCLASS_SYSRESET,
50         .name   = MAX77663_RST_DRIVER,
51         .ops    = &max77663_sysreset,
52 };
This page took 0.028873 seconds and 4 git commands to generate.