Stefan Roese | 4df2d0d | 2020-06-30 12:08:55 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2020 Stefan Roese <sr@denx.de> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <errno.h> |
| 9 | #include <sysreset.h> |
| 10 | #include <asm/io.h> |
| 11 | |
| 12 | #define RST_SOFT_RST 0x0080 |
| 13 | |
| 14 | struct octeon_sysreset_data { |
| 15 | void __iomem *base; |
| 16 | }; |
| 17 | |
| 18 | static int octeon_sysreset_request(struct udevice *dev, enum sysreset_t type) |
| 19 | { |
| 20 | struct octeon_sysreset_data *data = dev_get_priv(dev); |
| 21 | |
| 22 | writeq(1, data->base + RST_SOFT_RST); |
| 23 | |
| 24 | return -EINPROGRESS; |
| 25 | } |
| 26 | |
| 27 | static int octeon_sysreset_probe(struct udevice *dev) |
| 28 | { |
| 29 | struct octeon_sysreset_data *data = dev_get_priv(dev); |
| 30 | |
| 31 | data->base = dev_remap_addr(dev); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | static struct sysreset_ops octeon_sysreset = { |
| 37 | .request = octeon_sysreset_request, |
| 38 | }; |
| 39 | |
| 40 | static const struct udevice_id octeon_sysreset_ids[] = { |
| 41 | { .compatible = "mrvl,cn7xxx-rst" }, |
| 42 | { } |
| 43 | }; |
| 44 | |
| 45 | U_BOOT_DRIVER(sysreset_octeon) = { |
| 46 | .id = UCLASS_SYSRESET, |
| 47 | .name = "octeon_sysreset", |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 48 | .priv_auto = sizeof(struct octeon_sysreset_data), |
Stefan Roese | 4df2d0d | 2020-06-30 12:08:55 +0200 | [diff] [blame] | 49 | .ops = &octeon_sysreset, |
| 50 | .probe = octeon_sysreset_probe, |
| 51 | .of_match = octeon_sysreset_ids, |
| 52 | }; |