forked from u-boot/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysreset: implement MAX77663 sysreset functions
MAX77663 PMIC has embedded poweroff function used by some device to initiane device power off. Implement it as sysreset driver. Signed-off-by: Svyatoslav Ryhel <[email protected]>
- Loading branch information
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> | ||
*/ | ||
|
||
#include <common.h> | ||
#include <dm.h> | ||
#include <i2c.h> | ||
#include <errno.h> | ||
#include <sysreset.h> | ||
#include <power/pmic.h> | ||
#include <power/max77663.h> | ||
|
||
static int max77663_sysreset_request(struct udevice *dev, | ||
enum sysreset_t type) | ||
{ | ||
int val; | ||
|
||
val = pmic_reg_read(dev->parent, MAX77663_REG_ONOFF_CFG1); | ||
if (val < 0) | ||
return val; | ||
|
||
/* clear both bits */ | ||
val &= ~ONOFF_SFT_RST; | ||
val &= ~ONOFF_PWR_OFF; | ||
|
||
switch (type) { | ||
case SYSRESET_POWER: | ||
/* MAX77663: SFT_RST > ONOFF_CFG1 */ | ||
pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1, | ||
val | ONOFF_SFT_RST); | ||
break; | ||
case SYSRESET_POWER_OFF: | ||
/* MAX77663: PWR_OFF > ONOFF_CFG1 */ | ||
pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1, | ||
val | ONOFF_PWR_OFF); | ||
break; | ||
default: | ||
return -EPROTONOSUPPORT; | ||
} | ||
|
||
return -EINPROGRESS; | ||
} | ||
|
||
static struct sysreset_ops max77663_sysreset = { | ||
.request = max77663_sysreset_request, | ||
}; | ||
|
||
U_BOOT_DRIVER(sysreset_max77663) = { | ||
.id = UCLASS_SYSRESET, | ||
.name = MAX77663_RST_DRIVER, | ||
.ops = &max77663_sysreset, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters