1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 SYSRESET_WARM, /* Reset CPU, keep GPIOs active */
12 SYSRESET_COLD, /* Reset CPU and GPIOs */
13 SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
14 SYSRESET_POWER_OFF, /* Turn off power */
21 * request() - request a sysreset of the given type
23 * Note that this function may return before the reset takes effect.
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)
31 int (*request)(struct udevice *dev, enum sysreset_t type);
33 * get_status() - get printable reset status information
35 * @dev: Device to check
36 * @buf: Buffer to receive the textual reset information
37 * @size: Size of the passed buffer
38 * @return 0 if OK, -ve on error
40 int (*get_status)(struct udevice *dev, char *buf, int size);
43 * get_last() - get information on the last reset
45 * @dev: Device to check
46 * @return last reset state (enum sysreset_t) or -ve error
48 int (*get_last)(struct udevice *dev);
51 #define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops)
54 * sysreset_request() - request a sysreset
56 * @type: Reset type to request
57 * @return 0 if OK, -EPROTONOSUPPORT if not supported by this device
59 int sysreset_request(struct udevice *dev, enum sysreset_t type);
62 * sysreset_get_status() - get printable reset status information
64 * @dev: Device to check
65 * @buf: Buffer to receive the textual reset information
66 * @size: Size of the passed buffer
67 * @return 0 if OK, -ve on error
69 int sysreset_get_status(struct udevice *dev, char *buf, int size);
72 * sysreset_get_last() - get information on the last reset
74 * @dev: Device to check
75 * @return last reset state (enum sysreset_t) or -ve error
77 int sysreset_get_last(struct udevice *dev);
80 * sysreset_walk() - cause a system reset
82 * This works through the available sysreset devices until it finds one that can
83 * perform a reset. If the provided sysreset type is not available, the next one
86 * If this function fails to reset, it will display a message and halt
88 * @type: Reset type to request
89 * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
91 int sysreset_walk(enum sysreset_t type);
94 * sysreset_get_last_walk() - get information on the last reset
96 * This works through the available sysreset devices until it finds one that can
97 * perform a reset. If the provided sysreset type is not available, the next one
100 * If no device prives the information, this function returns -ENOENT
102 * @return last reset state (enum sysreset_t) or -ve error
104 int sysreset_get_last_walk(void);
107 * sysreset_walk_halt() - try to reset, otherwise halt
109 * This calls sysreset_walk(). If it returns, indicating that reset is not
110 * supported, it prints a message and halts.
112 void sysreset_walk_halt(enum sysreset_t type);
115 * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
117 void reset_cpu(ulong addr);