blob: 929cf8d3ba6c5e2fccce88982f871bbfa55868f4 [file] [log] [blame]
Bryan O'Donoghue07cb7a42018-05-25 16:48:39 +01001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <arch.h>
7#include <mmio.h>
8#include <stdint.h>
9#include <stdbool.h>
10#include <imx_regs.h>
11#include <imx_clock.h>
12
13void imx_clock_target_set(unsigned int id, uint32_t val)
14{
15 struct ccm *ccm = ((struct ccm *)CCM_BASE);
16 uintptr_t addr;
17
18 if (id > CCM_ROOT_CTRL_NUM)
19 return;
20
21 addr = (uintptr_t)&ccm->ccm_root_ctrl[id].ccm_target_root;
22 mmio_write_32(addr, val);
23}
24
25void imx_clock_target_clr(unsigned int id, uint32_t val)
26{
27 struct ccm *ccm = ((struct ccm *)CCM_BASE);
28 uintptr_t addr;
29
30 if (id > CCM_ROOT_CTRL_NUM)
31 return;
32
33 addr = (uintptr_t)&ccm->ccm_root_ctrl[id].ccm_target_root_clr;
34 mmio_write_32(addr, val);
35}
36
37void imx_clock_gate_enable(unsigned int id, bool enable)
38{
39 struct ccm *ccm = ((struct ccm *)CCM_BASE);
40 uintptr_t addr;
41
42 if (id > CCM_CLK_GATE_CTRL_NUM)
43 return;
44
45 /* TODO: add support for more than DOMAIN0 clocks */
46 if (enable)
47 addr = (uintptr_t)&ccm->ccm_clk_gate_ctrl[id].ccm_ccgr_set;
48 else
49 addr = (uintptr_t)&ccm->ccm_clk_gate_ctrl[id].ccm_ccgr_clr;
50
51 mmio_write_32(addr, CCM_CCGR_SETTING0_DOM_CLK_ALWAYS);
52}