xref: /arm-trusted-firmware/plat/imx/common/imx7_clock.c (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu #include <imx_regs.h>
7*91f16700Schasinglulu #include <imx_clock.h>
8*91f16700Schasinglulu 
9*91f16700Schasinglulu static void imx7_clock_uart_init(void)
10*91f16700Schasinglulu {
11*91f16700Schasinglulu 	unsigned int i;
12*91f16700Schasinglulu 
13*91f16700Schasinglulu 	for (i = 0; i < MXC_MAX_UART_NUM; i++)
14*91f16700Schasinglulu 		imx_clock_disable_uart(i);
15*91f16700Schasinglulu }
16*91f16700Schasinglulu 
17*91f16700Schasinglulu static void imx7_clock_wdog_init(void)
18*91f16700Schasinglulu {
19*91f16700Schasinglulu 	unsigned int i;
20*91f16700Schasinglulu 
21*91f16700Schasinglulu 	for (i = 0; i < MXC_MAX_WDOG_NUM; i++)
22*91f16700Schasinglulu 		imx_clock_disable_wdog(i);
23*91f16700Schasinglulu }
24*91f16700Schasinglulu 
25*91f16700Schasinglulu static void imx7_clock_usb_init(void)
26*91f16700Schasinglulu {
27*91f16700Schasinglulu 	/* Disable the clock root */
28*91f16700Schasinglulu 	imx_clock_target_clr(CCM_TRT_ID_USB_HSIC_CLK_ROOT, 0xFFFFFFFF);
29*91f16700Schasinglulu }
30*91f16700Schasinglulu 
31*91f16700Schasinglulu void imx_clock_init(void)
32*91f16700Schasinglulu {
33*91f16700Schasinglulu 	/*
34*91f16700Schasinglulu 	 * The BootROM hands off to the next stage with the internal 24 MHz XTAL
35*91f16700Schasinglulu 	 * crystal already clocking the main PLL, which is very handy.
36*91f16700Schasinglulu 	 * Here we should enable whichever peripherals are required for ATF and
37*91f16700Schasinglulu 	 * OPTEE.
38*91f16700Schasinglulu 	 *
39*91f16700Schasinglulu 	 * Subsequent stages in the boot process such as u-boot and Linux
40*91f16700Schasinglulu 	 * already have a significant and mature code-base around clocks, so our
41*91f16700Schasinglulu 	 * objective should be to enable what we need for ATF/OPTEE without
42*91f16700Schasinglulu 	 * breaking any existing upstream code in Linux and u-boot.
43*91f16700Schasinglulu 	 */
44*91f16700Schasinglulu 
45*91f16700Schasinglulu 	/* Initialize UART clocks */
46*91f16700Schasinglulu 	imx7_clock_uart_init();
47*91f16700Schasinglulu 
48*91f16700Schasinglulu 	/* Watchdog clocks */
49*91f16700Schasinglulu 
50*91f16700Schasinglulu 	imx7_clock_wdog_init();
51*91f16700Schasinglulu 
52*91f16700Schasinglulu 	/* USB clocks */
53*91f16700Schasinglulu 	imx7_clock_usb_init();
54*91f16700Schasinglulu 
55*91f16700Schasinglulu }
56