xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_bl2_setup.c (revision 32cd95f094eaa17631a08dca214ea61b06937f6c)
13fc4124cSDan Handley /*
23fc4124cSDan Handley  * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
33fc4124cSDan Handley  *
43fc4124cSDan Handley  * Redistribution and use in source and binary forms, with or without
53fc4124cSDan Handley  * modification, are permitted provided that the following conditions are met:
63fc4124cSDan Handley  *
73fc4124cSDan Handley  * Redistributions of source code must retain the above copyright notice, this
83fc4124cSDan Handley  * list of conditions and the following disclaimer.
93fc4124cSDan Handley  *
103fc4124cSDan Handley  * Redistributions in binary form must reproduce the above copyright notice,
113fc4124cSDan Handley  * this list of conditions and the following disclaimer in the documentation
123fc4124cSDan Handley  * and/or other materials provided with the distribution.
133fc4124cSDan Handley  *
143fc4124cSDan Handley  * Neither the name of ARM nor the names of its contributors may be used
153fc4124cSDan Handley  * to endorse or promote products derived from this software without specific
163fc4124cSDan Handley  * prior written permission.
173fc4124cSDan Handley  *
183fc4124cSDan Handley  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
193fc4124cSDan Handley  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
203fc4124cSDan Handley  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
213fc4124cSDan Handley  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
223fc4124cSDan Handley  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
233fc4124cSDan Handley  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
243fc4124cSDan Handley  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
253fc4124cSDan Handley  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
263fc4124cSDan Handley  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
273fc4124cSDan Handley  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
283fc4124cSDan Handley  * POSSIBILITY OF SUCH DAMAGE.
293fc4124cSDan Handley  */
303fc4124cSDan Handley 
31*32cd95f0SAntonio Nino Diaz #include <generic_delay_timer.h>
32540a5ba8SJuan Castillo #include <mmio.h>
333fc4124cSDan Handley #include <plat_arm.h>
34b49b3221SRyan Harkin #include <sp804_delay_timer.h>
35b49b3221SRyan Harkin #include <v2m_def.h>
36b49b3221SRyan Harkin #include "fvp_def.h"
373fc4124cSDan Handley #include "fvp_private.h"
383fc4124cSDan Handley 
393fc4124cSDan Handley 
403fc4124cSDan Handley void bl2_early_platform_setup(meminfo_t *mem_layout)
413fc4124cSDan Handley {
423fc4124cSDan Handley 	arm_bl2_early_platform_setup(mem_layout);
433fc4124cSDan Handley 
443fc4124cSDan Handley 	/* Initialize the platform config for future decision making */
453fc4124cSDan Handley 	fvp_config_setup();
463fc4124cSDan Handley }
47b49b3221SRyan Harkin 
48b49b3221SRyan Harkin void bl2_platform_setup(void)
49b49b3221SRyan Harkin {
50b49b3221SRyan Harkin 	arm_bl2_platform_setup();
51b49b3221SRyan Harkin 
52*32cd95f0SAntonio Nino Diaz #if FVP_USE_SP804_TIMER
53540a5ba8SJuan Castillo 	/* Enable the clock override for SP804 timer 0, which means that no
54540a5ba8SJuan Castillo 	 * clock dividers are applied and the raw (35 MHz) clock will be used */
55540a5ba8SJuan Castillo 	mmio_write_32(V2M_SP810_BASE, FVP_SP810_CTRL_TIM0_OV);
56540a5ba8SJuan Castillo 
57b49b3221SRyan Harkin 	/* Initialize delay timer driver using SP804 dual timer 0 */
58b49b3221SRyan Harkin 	sp804_timer_init(V2M_SP804_TIMER0_BASE,
59b49b3221SRyan Harkin 			SP804_TIMER_CLKMULT, SP804_TIMER_CLKDIV);
60*32cd95f0SAntonio Nino Diaz #else
61*32cd95f0SAntonio Nino Diaz 	generic_delay_timer_init();
62*32cd95f0SAntonio Nino Diaz #endif /* FVP_USE_SP804_TIMER */
63b49b3221SRyan Harkin }
64