diff options
author | Tom Rini <trini@konsulko.com> | 2021-10-07 09:00:45 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-10-07 09:00:45 -0400 |
commit | 11a69a9ef3f5eaccdca4dd89c7d8d91bd5b3b904 (patch) | |
tree | 75ea296bb71b6f5ab86b82979304576f04caaa66 /drivers/sysreset/sysreset_sbi.c | |
parent | ea67f467a43e4c8852bd1ce1bb75f5dc6c3788d1 (diff) | |
parent | 1b2b52f29402b5aaccccadfe4ba11bd3f29bd414 (diff) |
Merge https://source.denx.de/u-boot/custodians/u-boot-riscv
- Reset improvements, enable coherence manager on ae350, k210 clk
improvements, other fixes
Diffstat (limited to 'drivers/sysreset/sysreset_sbi.c')
-rw-r--r-- | drivers/sysreset/sysreset_sbi.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/sysreset/sysreset_sbi.c b/drivers/sysreset/sysreset_sbi.c new file mode 100644 index 0000000000..5e8090d62b --- /dev/null +++ b/drivers/sysreset/sysreset_sbi.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> + */ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <log.h> +#include <sysreset.h> +#include <asm/sbi.h> + +static enum sbi_srst_reset_type reset_type_map[SYSRESET_COUNT] = { + [SYSRESET_WARM] = SBI_SRST_RESET_TYPE_WARM_REBOOT, + [SYSRESET_COLD] = SBI_SRST_RESET_TYPE_COLD_REBOOT, + [SYSRESET_POWER] = SBI_SRST_RESET_TYPE_COLD_REBOOT, + [SYSRESET_POWER_OFF] = SBI_SRST_RESET_TYPE_SHUTDOWN, +}; + +static int sbi_sysreset_request(struct udevice *dev, enum sysreset_t type) +{ + enum sbi_srst_reset_type reset_type; + + reset_type = reset_type_map[type]; + sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE); + + return -EINPROGRESS; +} + +static int sbi_sysreset_probe(struct udevice *dev) +{ + long have_reset; + + have_reset = sbi_probe_extension(SBI_EXT_SRST); + if (have_reset) + return 0; + + log_warning("SBI has no system reset extension\n"); + return -ENOENT; +} + +static struct sysreset_ops sbi_sysreset_ops = { + .request = sbi_sysreset_request, +}; + +U_BOOT_DRIVER(sbi_sysreset) = { + .name = "sbi-sysreset", + .id = UCLASS_SYSRESET, + .ops = &sbi_sysreset_ops, + .probe = sbi_sysreset_probe, +}; |