blob: c16223720e5abfd04122a8ed71b3bf062a125ab8 [file] [log] [blame]
Stefan Roese4df2d0d2020-06-30 12:08:55 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2020 Stefan Roese <sr@denx.de>
4 */
5
Stefan Roese4df2d0d2020-06-30 12:08:55 +02006#include <dm.h>
7#include <errno.h>
8#include <sysreset.h>
9#include <asm/io.h>
10
11#define RST_SOFT_RST 0x0080
12
13struct octeon_sysreset_data {
14 void __iomem *base;
15};
16
17static 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
26static 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
35static struct sysreset_ops octeon_sysreset = {
36 .request = octeon_sysreset_request,
37};
38
39static const struct udevice_id octeon_sysreset_ids[] = {
40 { .compatible = "mrvl,cn7xxx-rst" },
41 { }
42};
43
44U_BOOT_DRIVER(sysreset_octeon) = {
45 .id = UCLASS_SYSRESET,
46 .name = "octeon_sysreset",
Simon Glass8a2b47f2020-12-03 16:55:17 -070047 .priv_auto = sizeof(struct octeon_sysreset_data),
Stefan Roese4df2d0d2020-06-30 12:08:55 +020048 .ops = &octeon_sysreset,
49 .probe = octeon_sysreset_probe,
50 .of_match = octeon_sysreset_ids,
51};