blob: ebdea6ab66edfafc4492b62ebc3c8807f87f99a0 [file] [log] [blame]
Stefan Roese59aea372020-06-30 12:08:55 +02001// 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
14struct octeon_sysreset_data {
15 void __iomem *base;
16};
17
18static 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
27static 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
36static struct sysreset_ops octeon_sysreset = {
37 .request = octeon_sysreset_request,
38};
39
40static const struct udevice_id octeon_sysreset_ids[] = {
41 { .compatible = "mrvl,cn7xxx-rst" },
42 { }
43};
44
45U_BOOT_DRIVER(sysreset_octeon) = {
46 .id = UCLASS_SYSRESET,
47 .name = "octeon_sysreset",
Simon Glass41575d82020-12-03 16:55:17 -070048 .priv_auto = sizeof(struct octeon_sysreset_data),
Stefan Roese59aea372020-06-30 12:08:55 +020049 .ops = &octeon_sysreset,
50 .probe = octeon_sysreset_probe,
51 .of_match = octeon_sysreset_ids,
52};