Svyatoslav Ryhel | b72803f | 2023-10-24 10:49:06 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright(C) 2023 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/tps80031.h> |
| 12 | |
| 13 | static int tps80031_sysreset_request(struct udevice *dev, |
| 14 | enum sysreset_t type) |
| 15 | { |
| 16 | switch (type) { |
| 17 | case SYSRESET_POWER: |
| 18 | /* TPS80031: SW_RESET > PHOENIX_DEV_ON */ |
| 19 | pmic_reg_write(dev->parent, TPS80031_PHOENIX_DEV_ON, SW_RESET); |
| 20 | break; |
| 21 | case SYSRESET_POWER_OFF: |
| 22 | /* TPS80031: DEVOFF > PHOENIX_DEV_ON */ |
| 23 | pmic_reg_write(dev->parent, TPS80031_PHOENIX_DEV_ON, DEVOFF); |
| 24 | break; |
| 25 | default: |
| 26 | return -EPROTONOSUPPORT; |
| 27 | } |
| 28 | |
| 29 | return -EINPROGRESS; |
| 30 | } |
| 31 | |
| 32 | static struct sysreset_ops tps80031_sysreset = { |
| 33 | .request = tps80031_sysreset_request, |
| 34 | }; |
| 35 | |
| 36 | U_BOOT_DRIVER(sysreset_tps80031) = { |
| 37 | .id = UCLASS_SYSRESET, |
| 38 | .name = TPS80031_RST_DRIVER, |
| 39 | .ops = &tps80031_sysreset, |
| 40 | }; |