xref: /rk3399_ARM-atf/include/drivers/arm/sp804_delay_timer.h (revision cc58b2d0f5698560d9f8c26e136fd0afc1d5d71b)
1*cc58b2d0SRyan Harkin /*
2*cc58b2d0SRyan Harkin  * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3*cc58b2d0SRyan Harkin  *
4*cc58b2d0SRyan Harkin  * Redistribution and use in source and binary forms, with or without
5*cc58b2d0SRyan Harkin  * modification, are permitted provided that the following conditions are met:
6*cc58b2d0SRyan Harkin  *
7*cc58b2d0SRyan Harkin  * Redistributions of source code must retain the above copyright notice, this
8*cc58b2d0SRyan Harkin  * list of conditions and the following disclaimer.
9*cc58b2d0SRyan Harkin  *
10*cc58b2d0SRyan Harkin  * Redistributions in binary form must reproduce the above copyright notice,
11*cc58b2d0SRyan Harkin  * this list of conditions and the following disclaimer in the documentation
12*cc58b2d0SRyan Harkin  * and/or other materials provided with the distribution.
13*cc58b2d0SRyan Harkin  *
14*cc58b2d0SRyan Harkin  * Neither the name of ARM nor the names of its contributors may be used
15*cc58b2d0SRyan Harkin  * to endorse or promote products derived from this software without specific
16*cc58b2d0SRyan Harkin  * prior written permission.
17*cc58b2d0SRyan Harkin  *
18*cc58b2d0SRyan Harkin  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*cc58b2d0SRyan Harkin  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*cc58b2d0SRyan Harkin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*cc58b2d0SRyan Harkin  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*cc58b2d0SRyan Harkin  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*cc58b2d0SRyan Harkin  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*cc58b2d0SRyan Harkin  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*cc58b2d0SRyan Harkin  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*cc58b2d0SRyan Harkin  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*cc58b2d0SRyan Harkin  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*cc58b2d0SRyan Harkin  * POSSIBILITY OF SUCH DAMAGE.
29*cc58b2d0SRyan Harkin  */
30*cc58b2d0SRyan Harkin 
31*cc58b2d0SRyan Harkin #ifndef __SP804_DELAY_TIMER_H__
32*cc58b2d0SRyan Harkin #define __SP804_DELAY_TIMER_H__
33*cc58b2d0SRyan Harkin 
34*cc58b2d0SRyan Harkin #include <delay_timer.h>
35*cc58b2d0SRyan Harkin #include <stdint.h>
36*cc58b2d0SRyan Harkin 
37*cc58b2d0SRyan Harkin 
38*cc58b2d0SRyan Harkin uint32_t sp804_get_timer_value(void);
39*cc58b2d0SRyan Harkin 
40*cc58b2d0SRyan Harkin void sp804_timer_ops_init(uintptr_t base_addr, const timer_ops_t *ops);
41*cc58b2d0SRyan Harkin 
42*cc58b2d0SRyan Harkin #define sp804_timer_init(base_addr, clk_mult, clk_div)			\
43*cc58b2d0SRyan Harkin 	sp804_timer_ops_init((base_addr), &(const timer_ops_t)		\
44*cc58b2d0SRyan Harkin 			{ sp804_get_timer_value, (clk_mult), (clk_div) })
45*cc58b2d0SRyan Harkin 
46*cc58b2d0SRyan Harkin 
47*cc58b2d0SRyan Harkin #endif /* __SP804_DELAY_TIMER_H__ */
48