diff options
author | Benoît Thébaudeau <benoit@wsystem.com> | 2017-05-03 11:59:05 +0200 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2017-05-31 10:14:30 +0200 |
commit | 3e3aab3379d99f4c955ecca4992ad33ae70e71e4 (patch) | |
tree | 4b491f68b06de4be844d56c859aec2ab27f78b98 /arch/arm/cpu/arm926ejs/mx25 | |
parent | f7c13e6a791b997e5b73f073db5f81864b882b61 (diff) |
mx25: Add function to set PER clocks
Introduce the imx_set_perclk() function to make it possible to set the
PER clocks.
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Diffstat (limited to 'arch/arm/cpu/arm926ejs/mx25')
-rw-r--r-- | arch/arm/cpu/arm926ejs/mx25/generic.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/arm/cpu/arm926ejs/mx25/generic.c b/arch/arm/cpu/arm926ejs/mx25/generic.c index f02cffb95e..5d9bc6c0f1 100644 --- a/arch/arm/cpu/arm926ejs/mx25/generic.c +++ b/arch/arm/cpu/arm926ejs/mx25/generic.c @@ -113,6 +113,25 @@ static ulong imx_get_perclk(int clk) return fref / div; } +int imx_set_perclk(enum mxc_clock clk, bool from_upll, unsigned int freq) +{ + struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE; + ulong fref = from_upll ? imx_get_upllclk() : imx_get_ahbclk(); + ulong div = (fref + freq - 1) / freq; + + if (clk > MXC_UART_CLK || !div || --div > CCM_PERCLK_MASK) + return -EINVAL; + + clrsetbits_le32(&ccm->pcdr[CCM_PERCLK_REG(clk)], + CCM_PERCLK_MASK << CCM_PERCLK_SHIFT(clk), + div << CCM_PERCLK_SHIFT(clk)); + if (from_upll) + setbits_le32(&ccm->mcr, 1 << clk); + else + clrbits_le32(&ccm->mcr, 1 << clk); + return 0; +} + unsigned int mxc_get_clock(enum mxc_clock clk) { if (clk >= MXC_CLK_NUM) |