2018-02-17 18:50:39 -08:00
|
|
|
#ifndef EXOSPHERE_TIMERS_H
|
|
|
|
#define EXOSPHERE_TIMERS_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-02-24 17:13:42 +01:00
|
|
|
#include "memory_map.h"
|
2018-02-17 18:50:39 -08:00
|
|
|
|
|
|
|
/* Exosphere driver for the Tegra X1 Timers. */
|
|
|
|
|
2018-02-26 22:09:35 +01:00
|
|
|
static inline uintptr_t get_timers_base(void) {
|
|
|
|
return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_TMRs_WDTs);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TIMERS_BASE (get_timers_base())
|
2018-02-17 18:50:39 -08:00
|
|
|
|
2018-03-03 20:23:13 +01:00
|
|
|
#define MAKE_TIMERS_REG(n) MAKE_REG32(TIMERS_BASE + n)
|
2018-03-02 12:45:37 -08:00
|
|
|
|
2018-03-03 20:23:13 +01:00
|
|
|
#define TIMERUS_CNTR_1US_0 MAKE_REG32(TIMERS_BASE + 0x10)
|
2018-02-17 18:50:39 -08:00
|
|
|
|
2018-02-27 19:43:07 -08:00
|
|
|
typedef struct {
|
|
|
|
uint32_t CONFIG;
|
|
|
|
uint32_t STATUS;
|
|
|
|
uint32_t COMMAND;
|
|
|
|
uint32_t PATTERN;
|
|
|
|
} watchdog_timers_t;
|
|
|
|
|
|
|
|
#define GET_WDT(n) ((volatile watchdog_timers_t *)(TIMERS_BASE + 0x100 + 0x20 * n))
|
|
|
|
#define WDT_REBOOT_PATTERN 0xC45A
|
2018-03-03 20:23:13 +01:00
|
|
|
#define GET_WDT_REBOOT_CFG_REG(n) MAKE_REG32(TIMERS_BASE + 0x60 + 0x8*n)
|
2018-02-27 19:43:07 -08:00
|
|
|
|
2018-02-17 18:50:39 -08:00
|
|
|
void wait(uint32_t microseconds);
|
|
|
|
|
2018-02-26 02:00:02 -08:00
|
|
|
static inline uint32_t get_time(void) {
|
|
|
|
return TIMERUS_CNTR_1US_0;
|
|
|
|
}
|
|
|
|
|
2018-02-27 19:43:07 -08:00
|
|
|
__attribute__ ((noreturn)) void watchdog_reboot(void);
|
|
|
|
|
2018-02-24 17:13:42 +01:00
|
|
|
#endif
|