blob: 004fb76974aae645096c4c9e7c809373a108c878 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __SP804_H__
8#define __SP804_H__
9
Antonio Nino Diaz09a00ef2019-01-11 13:12:58 +000010#include <stdint.h>
11
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020012#define SP804_LOAD_OFFSET 0x0
13#define SP804_CURRENT_VALUE_OFFSET 0x4
14#define SP804_CTRL_OFFSET 0x8
15#define SP804_INT_CLR_OFFSET 0xC
16#define SP804_INT_STATUS_OFFSET 0x10
17#define SP804_MASKED_INT_STATUS_OFFSET 0x14
18#define SP804_BG_LOAD_OFFSET 0x18
19
20/* SP804 Timer control register bit-fields */
21#define ONESHOT_MODE (0x1 << 0) /* Bit [0] */
22#define TIMER_SIZE (0x1 << 1) /* Bit [1] */
23#define TIMER_PRE_DIV1 (0x00 << 2) /* Bits [2:3] */
24#define INT_ENABLE (0x01 << 5) /* Bit [5] */
25#define TIMER_MODE_FREE_RUN (0x0 << 6) /* Bit [6] */
26#define TIMER_EN (0x01 << 7) /* Bit [7] */
27
28/*
29 * Program sp804 timer to fire an interrupt after `time_out_ms` milliseconds.
30 *
31 * Always return 0
32 */
33int sp804_timer_program(unsigned long time_out_ms);
34
35/*
36 * Cancel the currently programmed sp804 timer interrupt
37 *
38 * Always return 0
39 */
40int sp804_timer_cancel(void);
41
42/*
43 * Initializes the sp804 timer so that it can be used for programming
44 * timer interrupt.
45 * Must be called by the primary CPU only.
46 *
47 * Always return 0
48 */
49int sp804_timer_init(uintptr_t base_addr, unsigned int timer_freq);
50
51/*
52 * Handler to acknowledge and de-activate the sp804 timer interrupt
53 *
54 * Always return 0
55 */
56int sp804_timer_handler(void);
57
58#endif /* __SP804_H__ */