blob: 393c7be3d8111692d35a2d8de108731b6a3c83ab [file] [log] [blame]
Stephen Warren11636252016-05-12 12:03:35 -06001/*
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef __SYSRESET_H
9#define __SYSRESET_H
10
11enum sysreset_t {
12 SYSRESET_WARM, /* Reset CPU, keep GPIOs active */
13 SYSRESET_COLD, /* Reset CPU and GPIOs */
14 SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
15
16 SYSRESET_COUNT,
17};
18
19struct sysreset_ops {
20 /**
21 * request() - request a sysreset of the given type
22 *
23 * Note that this function may return before the reset takes effect.
24 *
25 * @type: Reset type to request
26 * @return -EINPROGRESS if the reset has been started and
27 * will complete soon, -EPROTONOSUPPORT if not supported
28 * by this device, 0 if the reset has already happened
29 * (in which case this method will not actually return)
30 */
31 int (*request)(struct udevice *dev, enum sysreset_t type);
32};
33
34#define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops)
35
36/**
37 * sysreset_request() - request a sysreset
38 *
39 * @type: Reset type to request
40 * @return 0 if OK, -EPROTONOSUPPORT if not supported by this device
41 */
42int sysreset_request(struct udevice *dev, enum sysreset_t type);
43
44/**
45 * sysreset_walk() - cause a system reset
46 *
47 * This works through the available sysreset devices until it finds one that can
48 * perform a reset. If the provided sysreset type is not available, the next one
49 * will be tried.
50 *
51 * If this function fails to reset, it will display a message and halt
52 *
53 * @type: Reset type to request
54 * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
55 */
56int sysreset_walk(enum sysreset_t type);
57
58/**
59 * sysreset_walk_halt() - try to reset, otherwise halt
60 *
61 * This calls sysreset_walk(). If it returns, indicating that reset is not
62 * supported, it prints a message and halts.
63 */
64void sysreset_walk_halt(enum sysreset_t type);
65
66/**
67 * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
68 */
69void reset_cpu(ulong addr);
70
71#endif