1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12#pragma once 13 14#include <platsupport/timer.h> 15 16#define RTC0_PADDR 0xF8003000 17#define RTC1_PADDR 0xF8004000 18 19#define RTC0_INTERRUPT 44 20#define RTC1_INTERRUPT 40 21 22typedef enum rtc_id { 23 RTC0, 24 RTC1, 25 NUM_RTCS = 2, 26} rtc_id_t; 27 28static inline void *rtc_get_paddr(rtc_id_t id) { 29 switch (id) { 30 case RTC0: 31 return (void *) RTC0_PADDR; 32 case RTC1: 33 return (void *) RTC1_PADDR; 34 default: 35 return NULL; 36 } 37} 38 39static inline long rtc_get_irq(rtc_id_t id) { 40 switch (id) { 41 case RTC0: 42 return RTC0_INTERRUPT; 43 case RTC1: 44 return RTC1_INTERRUPT; 45 default: 46 return 0; 47 } 48} 49 50typedef struct { 51 int timer_id; 52 void *vaddr; 53 uint32_t irq; 54} rtc_t; 55 56typedef struct { 57 void *vaddr; 58 rtc_id_t id; 59} rtc_config_t; 60 61static UNUSED timer_properties_t rtc_props = { 62 .upcounter = true, 63 .timeouts = false, 64 .bit_width = 32, 65 .irqs = 0 66}; 67 68int rtc_stop(rtc_t *rtc); 69int rtc_start(rtc_t *rtc); 70uint32_t rtc_get_time(rtc_t *rtc); 71int rtc_init(rtc_t *rtc, rtc_config_t config); 72