xref: /rk3399_ARM-atf/include/drivers/delay_timer.h (revision 540a5ba8d955b6f369322b099f70bb5dc6787a06)
19055c7d1SRyan Harkin /*
29055c7d1SRyan Harkin  * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
39055c7d1SRyan Harkin  *
49055c7d1SRyan Harkin  * Redistribution and use in source and binary forms, with or without
59055c7d1SRyan Harkin  * modification, are permitted provided that the following conditions are met:
69055c7d1SRyan Harkin  *
79055c7d1SRyan Harkin  * Redistributions of source code must retain the above copyright notice, this
89055c7d1SRyan Harkin  * list of conditions and the following disclaimer.
99055c7d1SRyan Harkin  *
109055c7d1SRyan Harkin  * Redistributions in binary form must reproduce the above copyright notice,
119055c7d1SRyan Harkin  * this list of conditions and the following disclaimer in the documentation
129055c7d1SRyan Harkin  * and/or other materials provided with the distribution.
139055c7d1SRyan Harkin  *
149055c7d1SRyan Harkin  * Neither the name of ARM nor the names of its contributors may be used
159055c7d1SRyan Harkin  * to endorse or promote products derived from this software without specific
169055c7d1SRyan Harkin  * prior written permission.
179055c7d1SRyan Harkin  *
189055c7d1SRyan Harkin  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
199055c7d1SRyan Harkin  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
209055c7d1SRyan Harkin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
219055c7d1SRyan Harkin  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
229055c7d1SRyan Harkin  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239055c7d1SRyan Harkin  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
249055c7d1SRyan Harkin  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
259055c7d1SRyan Harkin  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
269055c7d1SRyan Harkin  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
279055c7d1SRyan Harkin  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
289055c7d1SRyan Harkin  * POSSIBILITY OF SUCH DAMAGE.
299055c7d1SRyan Harkin  */
309055c7d1SRyan Harkin 
319055c7d1SRyan Harkin #ifndef __DELAY_TIMER_H__
329055c7d1SRyan Harkin #define __DELAY_TIMER_H__
339055c7d1SRyan Harkin 
349055c7d1SRyan Harkin #include <stdint.h>
359055c7d1SRyan Harkin 
369055c7d1SRyan Harkin /********************************************************************
379055c7d1SRyan Harkin  * A simple timer driver providing synchronous delay functionality.
389055c7d1SRyan Harkin  * The driver must be initialized with a structure that provides a
399055c7d1SRyan Harkin  * function pointer to return the timer value and a clock
409055c7d1SRyan Harkin  * multiplier/divider. The ratio of the multiplier and the divider is
41*540a5ba8SJuan Castillo  * the clock period in microseconds.
429055c7d1SRyan Harkin  ********************************************************************/
439055c7d1SRyan Harkin 
449055c7d1SRyan Harkin typedef struct timer_ops {
459055c7d1SRyan Harkin 	uint32_t (*get_timer_value)(void);
469055c7d1SRyan Harkin 	uint32_t clk_mult;
479055c7d1SRyan Harkin 	uint32_t clk_div;
489055c7d1SRyan Harkin } timer_ops_t;
499055c7d1SRyan Harkin 
509055c7d1SRyan Harkin void mdelay(uint32_t msec);
519055c7d1SRyan Harkin void udelay(uint32_t usec);
529055c7d1SRyan Harkin void timer_init(const timer_ops_t *ops);
539055c7d1SRyan Harkin 
549055c7d1SRyan Harkin 
559055c7d1SRyan Harkin #endif /* __DELAY_TIMER_H__ */
56