blob: 7ca556762de9fea9371882106301c686d00fc838 [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
10#define SP804_LOAD_OFFSET 0x0
11#define SP804_CURRENT_VALUE_OFFSET 0x4
12#define SP804_CTRL_OFFSET 0x8
13#define SP804_INT_CLR_OFFSET 0xC
14#define SP804_INT_STATUS_OFFSET 0x10
15#define SP804_MASKED_INT_STATUS_OFFSET 0x14
16#define SP804_BG_LOAD_OFFSET 0x18
17
18/* SP804 Timer control register bit-fields */
19#define ONESHOT_MODE (0x1 << 0) /* Bit [0] */
20#define TIMER_SIZE (0x1 << 1) /* Bit [1] */
21#define TIMER_PRE_DIV1 (0x00 << 2) /* Bits [2:3] */
22#define INT_ENABLE (0x01 << 5) /* Bit [5] */
23#define TIMER_MODE_FREE_RUN (0x0 << 6) /* Bit [6] */
24#define TIMER_EN (0x01 << 7) /* Bit [7] */
25
26/*
27 * Program sp804 timer to fire an interrupt after `time_out_ms` milliseconds.
28 *
29 * Always return 0
30 */
31int sp804_timer_program(unsigned long time_out_ms);
32
33/*
34 * Cancel the currently programmed sp804 timer interrupt
35 *
36 * Always return 0
37 */
38int sp804_timer_cancel(void);
39
40/*
41 * Initializes the sp804 timer so that it can be used for programming
42 * timer interrupt.
43 * Must be called by the primary CPU only.
44 *
45 * Always return 0
46 */
47int sp804_timer_init(uintptr_t base_addr, unsigned int timer_freq);
48
49/*
50 * Handler to acknowledge and de-activate the sp804 timer interrupt
51 *
52 * Always return 0
53 */
54int sp804_timer_handler(void);
55
56#endif /* __SP804_H__ */