drivers: hwinfo: Add reset cause support

Add `hwinfo_get_reset_cause` and `hwinfo_clear_reset_cause` to retrieve
and to clear cause of system reset on supported platforms.

Different platforms can provide different causes of reset, however
there is a great deal of overlap. `enum reset_cause` can be expanded in
the future to support additional reasons, as additional platforms are
supported.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
This commit is contained in:
Arvin Farahmand 2020-04-30 22:32:52 -04:00 committed by Carles Cufí
commit 98a0ccd5c5
9 changed files with 409 additions and 35 deletions

View file

@ -14,3 +14,34 @@ ssize_t z_vrfy_hwinfo_get_device_id(uint8_t *buffer, size_t length)
return z_impl_hwinfo_get_device_id((uint8_t *)buffer, (size_t)length);
}
#include <syscalls/hwinfo_get_device_id_mrsh.c>
int z_vrfy_hwinfo_get_reset_cause(uint32_t *cause)
{
int ret;
uint32_t cause_copy;
ret = z_impl_hwinfo_get_reset_cause(&cause_copy);
Z_OOPS(z_user_to_copy(cause, &cause_copy, sizeof(uint32_t)));
return ret;
}
#include <syscalls/hwinfo_get_reset_cause_mrsh.c>
int z_vrfy_hwinfo_clear_reset_cause(void)
{
return z_impl_hwinfo_clear_reset_cause();
}
#include <syscalls/hwinfo_clear_reset_cause_mrsh.c>
int z_vrfy_hwinfo_get_supported_reset_cause(uint32_t *supported)
{
int ret;
uint32_t supported_copy;
ret = z_impl_hwinfo_get_supported_reset_cause(&supported_copy);
Z_OOPS(z_user_to_copy(supported, &supported_copy, sizeof(uint32_t)));
return ret;
}
#include <syscalls/hwinfo_get_supported_reset_cause_mrsh.c>