System reset

enum sysreset_t

system reset types

Constants

SYSRESET_WARM

reset CPU, keep GPIOs active

SYSRESET_COLD

reset CPU and GPIOs

SYSRESET_POWER

reset PMIC (remove and restore power)

SYSRESET_POWER_OFF

turn off power

SYSRESET_COUNT

number of available reset types

struct sysreset_ops

operations of system reset drivers

Definition

struct sysreset_ops {
  int (*request)(struct udevice *dev, enum sysreset_t type);
  int (*get_status)(struct udevice *dev, char *buf, int size);
  int (*get_last)(struct udevice *dev);
};

Members

request

request a sysreset of the given type

Note that this function may return before the reset takes effect.

dev: Device to be used for system reset type: Reset type to request Return: -EINPROGRESS if the reset has been started and will complete soon, -EPROTONOSUPPORT if not supported by this device, 0 if the reset has already happened (in which case this method will not actually return)

get_status

get printable reset status information

dev: Device to check buf: Buffer to receive the textual reset information size: Size of the passed buffer Return: 0 if OK, -ve on error

get_last

get information on the last reset

dev: Device to check Return: last reset state (enum sysreset_t) or -ve error

int sysreset_request(struct udevice *dev, enum sysreset_t type)

request a sysreset

Parameters

struct udevice *dev

Device to be used for system reset

enum sysreset_t type

Reset type to request

Return

0 if OK, -EPROTONOSUPPORT if not supported by this device

int sysreset_get_status(struct udevice *dev, char *buf, int size)

get printable reset status information

Parameters

struct udevice *dev

Device to check

char *buf

Buffer to receive the textual reset information

int size

Size of the passed buffer

Return

0 if OK, -ve on error

int sysreset_get_last(struct udevice *dev)

get information on the last reset

Parameters

struct udevice *dev

Device to check

Return

last reset state (enum sysreset_t) or -ve error

int sysreset_walk(enum sysreset_t type)

cause a system reset

Parameters

enum sysreset_t type

Reset type to request

Description

This works through the available sysreset devices until it finds one that can perform a reset. If the provided sysreset type is not available, the next one will be tried.

If this function fails to reset, it will display a message and halt

Return

-EINPROGRESS if a reset is in progress, -ENOSYS if not available

int sysreset_get_last_walk(void)

get information on the last reset

Parameters

void

no arguments

Description

This works through the available sysreset devices until it finds one that can perform a reset. If the provided sysreset type is not available, the next one will be tried.

If no device prives the information, this function returns -ENOENT

Return

last reset state (enum sysreset_t) or -ve error

void sysreset_walk_halt(enum sysreset_t type)

try to reset, otherwise halt

Parameters

enum sysreset_t type

Reset type to request

Description

This calls sysreset_walk(). If it returns, indicating that reset is not supported, it prints a message and halts.

void reset_cpu(void)

calls sysreset_walk(SYSRESET_WARM)

Parameters

void

no arguments

int sysreset_register_wdt(struct udevice *dev)

register a watchdog for use with sysreset

Parameters

struct udevice *dev

WDT device

Description

This registers the given watchdog timer to be used to reset the system.

Return

0 if OK, -errno if error