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