2011-05-01 13:02:46 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright © 2011 by Amaury Pouly
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "clkctrl-imx233.h"
|
|
|
|
|
|
|
|
#define __CLK_CLKGATE (1 << 31)
|
|
|
|
#define __CLK_BUSY (1 << 29)
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_enable_xtal(enum imx233_xtal_clk_t xtal_clk, bool enable)
|
2011-05-01 13:02:46 +00:00
|
|
|
{
|
|
|
|
if(enable)
|
2011-10-18 22:00:50 +00:00
|
|
|
__REG_CLR(HW_CLKCTRL_XTAL) = xtal_clk;
|
2011-05-01 13:02:46 +00:00
|
|
|
else
|
2011-10-18 22:00:50 +00:00
|
|
|
__REG_SET(HW_CLKCTRL_XTAL) = xtal_clk;
|
2011-05-01 13:02:46 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_is_xtal_enable(enum imx233_xtal_clk_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
return HW_CLKCTRL_XTAL & clk;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_enable_clock(enum imx233_clock_t clk, bool enable)
|
2011-05-01 13:02:46 +00:00
|
|
|
{
|
|
|
|
volatile uint32_t *REG;
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PIX: REG = &HW_CLKCTRL_PIX; break;
|
2011-06-17 22:30:58 +00:00
|
|
|
case CLK_SSP: REG = &HW_CLKCTRL_SSP; break;
|
2012-05-21 14:28:12 +00:00
|
|
|
case CLK_PLL:
|
|
|
|
{
|
|
|
|
if(enable)
|
|
|
|
{
|
|
|
|
__REG_SET(HW_CLKCTRL_PLLCTRL0) = HW_CLKCTRL_PLLCTRL0__POWER;
|
|
|
|
while(!(HW_CLKCTRL_PLLCTRL1 & HW_CLKCTRL_PLLCTRL1__LOCK));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__REG_CLR(HW_CLKCTRL_PLLCTRL0) = HW_CLKCTRL_PLLCTRL0__POWER;
|
|
|
|
return;
|
|
|
|
}
|
2011-05-01 13:02:46 +00:00
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* warning: some registers like HW_CLKCTRL_PIX don't have a CLR/SET variant ! */
|
|
|
|
if(enable)
|
|
|
|
{
|
|
|
|
*REG = (*REG) & ~__CLK_CLKGATE;
|
|
|
|
while((*REG) & __CLK_CLKGATE);
|
|
|
|
while((*REG) & __CLK_BUSY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*REG |= __CLK_CLKGATE;
|
|
|
|
while(!((*REG) & __CLK_CLKGATE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_is_clock_enabled(enum imx233_clock_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
volatile uint32_t *REG;
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PLL: return HW_CLKCTRL_PLLCTRL0 & HW_CLKCTRL_PLLCTRL0__POWER;
|
|
|
|
case CLK_PIX: REG = &HW_CLKCTRL_PIX; break;
|
|
|
|
case CLK_SSP: REG = &HW_CLKCTRL_SSP; break;
|
|
|
|
default: return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !((*REG) & __CLK_CLKGATE);
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_set_clock_divisor(enum imx233_clock_t clk, int div)
|
2011-05-01 13:02:46 +00:00
|
|
|
{
|
2012-01-21 19:14:27 +00:00
|
|
|
/* warning: some registers like HW_CLKCTRL_PIX don't have a CLR/SET variant ! */
|
2011-05-01 13:02:46 +00:00
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PIX:
|
2012-02-28 21:45:45 +00:00
|
|
|
__FIELD_SET(HW_CLKCTRL_PIX, DIV, div);
|
2011-05-01 13:02:46 +00:00
|
|
|
break;
|
2011-06-17 22:30:58 +00:00
|
|
|
case CLK_SSP:
|
2012-02-28 21:45:45 +00:00
|
|
|
__FIELD_SET(HW_CLKCTRL_SSP, DIV, div);
|
2011-06-17 22:30:58 +00:00
|
|
|
break;
|
2011-06-30 17:31:40 +00:00
|
|
|
case CLK_CPU:
|
2012-02-28 21:45:45 +00:00
|
|
|
__FIELD_SET(HW_CLKCTRL_CPU, DIV_CPU, div);
|
2011-06-30 17:31:40 +00:00
|
|
|
break;
|
2011-12-03 15:34:40 +00:00
|
|
|
case CLK_EMI:
|
2012-02-28 21:45:45 +00:00
|
|
|
__FIELD_SET(HW_CLKCTRL_EMI, DIV_EMI, div);
|
2011-12-03 15:34:40 +00:00
|
|
|
break;
|
|
|
|
case CLK_HBUS:
|
2012-12-26 00:06:04 +00:00
|
|
|
/* disable frac enable at the same time */
|
|
|
|
HW_CLKCTRL_HBUS = div << HW_CLKCTRL_HBUS__DIV_BP |
|
|
|
|
(HW_CLKCTRL_HBUS & ~(HW_CLKCTRL_HBUS__DIV_FRAC_EN | HW_CLKCTRL_HBUS__DIV_BM));
|
2011-06-30 17:31:40 +00:00
|
|
|
break;
|
2011-12-03 15:34:40 +00:00
|
|
|
case CLK_XBUS:
|
2012-02-28 21:45:45 +00:00
|
|
|
__FIELD_SET(HW_CLKCTRL_XBUS, DIV, div);
|
2011-12-03 15:34:40 +00:00
|
|
|
break;
|
2011-06-17 22:30:58 +00:00
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
int imx233_clkctrl_get_clock_divisor(enum imx233_clock_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PIX: return __XTRACT(HW_CLKCTRL_PIX, DIV);
|
|
|
|
case CLK_SSP: return __XTRACT(HW_CLKCTRL_SSP, DIV);
|
|
|
|
case CLK_CPU: return __XTRACT(HW_CLKCTRL_CPU, DIV_CPU);
|
|
|
|
case CLK_EMI: return __XTRACT(HW_CLKCTRL_EMI, DIV_EMI);
|
|
|
|
case CLK_HBUS:
|
|
|
|
if(HW_CLKCTRL_HBUS & HW_CLKCTRL_HBUS__DIV_FRAC_EN)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return __XTRACT(HW_CLKCTRL_HBUS, DIV);
|
|
|
|
case CLK_XBUS: return __XTRACT(HW_CLKCTRL_XBUS, DIV);
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_set_fractional_divisor(enum imx233_clock_t clk, int fracdiv)
|
2011-06-17 22:30:58 +00:00
|
|
|
{
|
|
|
|
/* NOTE: HW_CLKCTRL_FRAC only support byte access ! */
|
|
|
|
volatile uint8_t *REG;
|
|
|
|
switch(clk)
|
|
|
|
{
|
2011-12-03 15:34:40 +00:00
|
|
|
case CLK_HBUS:
|
2012-12-26 00:06:04 +00:00
|
|
|
/* set frac enable at the same time */
|
|
|
|
HW_CLKCTRL_HBUS = fracdiv << HW_CLKCTRL_HBUS__DIV_BP | HW_CLKCTRL_HBUS__DIV_FRAC_EN |
|
|
|
|
(HW_CLKCTRL_HBUS & ~HW_CLKCTRL_HBUS__DIV_BM);
|
2011-12-03 15:34:40 +00:00
|
|
|
return;
|
2011-06-17 22:30:58 +00:00
|
|
|
case CLK_PIX: REG = &HW_CLKCTRL_FRAC_PIX; break;
|
|
|
|
case CLK_IO: REG = &HW_CLKCTRL_FRAC_IO; break;
|
2011-06-30 17:31:40 +00:00
|
|
|
case CLK_CPU: REG = &HW_CLKCTRL_FRAC_CPU; break;
|
2011-12-03 15:34:40 +00:00
|
|
|
case CLK_EMI: REG = &HW_CLKCTRL_FRAC_EMI; break;
|
2011-05-01 13:02:46 +00:00
|
|
|
default: return;
|
|
|
|
}
|
2011-06-17 22:30:58 +00:00
|
|
|
|
|
|
|
if(fracdiv != 0)
|
|
|
|
*REG = fracdiv;
|
|
|
|
else
|
2012-08-29 14:30:49 +00:00
|
|
|
*REG = HW_CLKCTRL_FRAC_XX__CLKGATEXX;
|
2011-05-01 13:02:46 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
int imx233_clkctrl_get_fractional_divisor(enum imx233_clock_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
/* NOTE: HW_CLKCTRL_FRAC only support byte access ! */
|
|
|
|
volatile uint8_t *REG;
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_HBUS:
|
|
|
|
if(HW_CLKCTRL_HBUS & HW_CLKCTRL_HBUS__DIV_FRAC_EN)
|
|
|
|
return __XTRACT(HW_CLKCTRL_HBUS, DIV);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
case CLK_PIX: REG = &HW_CLKCTRL_FRAC_PIX; break;
|
|
|
|
case CLK_IO: REG = &HW_CLKCTRL_FRAC_IO; break;
|
|
|
|
case CLK_CPU: REG = &HW_CLKCTRL_FRAC_CPU; break;
|
|
|
|
case CLK_EMI: REG = &HW_CLKCTRL_FRAC_EMI; break;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((*REG) & HW_CLKCTRL_FRAC_XX__CLKGATEXX)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return *REG & ~HW_CLKCTRL_FRAC_XX__XX_STABLE;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_set_bypass_pll(enum imx233_clock_t clk, bool bypass)
|
2011-05-01 13:02:46 +00:00
|
|
|
{
|
|
|
|
uint32_t msk;
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PIX: msk = HW_CLKCTRL_CLKSEQ__BYPASS_PIX; break;
|
2011-06-17 22:30:58 +00:00
|
|
|
case CLK_SSP: msk = HW_CLKCTRL_CLKSEQ__BYPASS_SSP; break;
|
2011-06-30 17:31:40 +00:00
|
|
|
case CLK_CPU: msk = HW_CLKCTRL_CLKSEQ__BYPASS_CPU; break;
|
2011-12-03 15:34:40 +00:00
|
|
|
case CLK_EMI: msk = HW_CLKCTRL_CLKSEQ__BYPASS_EMI; break;
|
2011-05-01 13:02:46 +00:00
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bypass)
|
|
|
|
__REG_SET(HW_CLKCTRL_CLKSEQ) = msk;
|
|
|
|
else
|
|
|
|
__REG_CLR(HW_CLKCTRL_CLKSEQ) = msk;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_get_bypass_pll(enum imx233_clock_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
uint32_t msk;
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PIX: msk = HW_CLKCTRL_CLKSEQ__BYPASS_PIX; break;
|
|
|
|
case CLK_SSP: msk = HW_CLKCTRL_CLKSEQ__BYPASS_SSP; break;
|
|
|
|
case CLK_CPU: msk = HW_CLKCTRL_CLKSEQ__BYPASS_CPU; break;
|
|
|
|
case CLK_EMI: msk = HW_CLKCTRL_CLKSEQ__BYPASS_EMI; break;
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HW_CLKCTRL_CLKSEQ & msk;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_enable_usb_pll(bool enable)
|
2011-09-14 11:50:06 +00:00
|
|
|
{
|
|
|
|
if(enable)
|
|
|
|
__REG_SET(HW_CLKCTRL_PLLCTRL0) = HW_CLKCTRL_PLLCTRL0__EN_USB_CLKS;
|
|
|
|
else
|
|
|
|
__REG_CLR(HW_CLKCTRL_PLLCTRL0) = HW_CLKCTRL_PLLCTRL0__EN_USB_CLKS;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_is_usb_pll_enabled(void)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
return HW_CLKCTRL_PLLCTRL0 & HW_CLKCTRL_PLLCTRL0__EN_USB_CLKS;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_set_auto_slow_divisor(enum imx233_as_div_t div)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
2012-08-30 23:24:51 +00:00
|
|
|
/* the SLOW_DIV must only be set when auto-slow is disabled */
|
|
|
|
bool old_status = imx233_clkctrl_is_auto_slow_enabled();
|
|
|
|
imx233_clkctrl_enable_auto_slow(false);
|
|
|
|
__FIELD_SET(HW_CLKCTRL_HBUS, SLOW_DIV, div);
|
|
|
|
imx233_clkctrl_enable_auto_slow(old_status);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
enum imx233_as_div_t imx233_clkctrl_get_auto_slow_divisor(void)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
return __XTRACT(HW_CLKCTRL_HBUS, SLOW_DIV);
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_enable_auto_slow(bool enable)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
if(enable)
|
|
|
|
__REG_SET(HW_CLKCTRL_HBUS) = HW_CLKCTRL_HBUS__AUTO_SLOW_MODE;
|
2012-08-30 18:57:42 +00:00
|
|
|
else
|
|
|
|
__REG_CLR(HW_CLKCTRL_HBUS) = HW_CLKCTRL_HBUS__AUTO_SLOW_MODE;
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_is_auto_slow_enabled(void)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
return HW_CLKCTRL_HBUS & HW_CLKCTRL_HBUS__AUTO_SLOW_MODE;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
void imx233_clkctrl_enable_auto_slow_monitor(enum imx233_as_monitor_t monitor, bool enable)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
if(enable)
|
|
|
|
__REG_SET(HW_CLKCTRL_HBUS) = monitor;
|
|
|
|
else
|
|
|
|
__REG_CLR(HW_CLKCTRL_HBUS) = monitor;
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
bool imx233_clkctrl_is_auto_slow_monitor_enabled(enum imx233_as_monitor_t monitor)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
return HW_CLKCTRL_HBUS & monitor;
|
|
|
|
}
|
|
|
|
|
2012-08-29 14:30:49 +00:00
|
|
|
bool imx233_clkctrl_is_emi_sync_enabled(void)
|
|
|
|
{
|
|
|
|
return !!(HW_CLKCTRL_EMI & HW_CLKCTRL_EMI__SYNC_MODE_EN);
|
|
|
|
}
|
|
|
|
|
2012-05-19 11:16:17 +00:00
|
|
|
unsigned imx233_clkctrl_get_clock_freq(enum imx233_clock_t clk)
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
|
|
|
switch(clk)
|
|
|
|
{
|
|
|
|
case CLK_PLL: /* PLL: 480MHz when enable */
|
2012-05-19 11:16:17 +00:00
|
|
|
return imx233_clkctrl_is_clock_enabled(CLK_PLL) ? 480000 : 0;
|
2011-12-15 17:07:15 +00:00
|
|
|
case CLK_XTAL: /* crystal: 24MHz */
|
2011-12-03 15:34:40 +00:00
|
|
|
return 24000;
|
|
|
|
case CLK_CPU:
|
|
|
|
{
|
|
|
|
unsigned ref;
|
|
|
|
/* In bypass mode: clk_p derived from clk_xtal via int/binfrac divider
|
|
|
|
* otherwise, clk_p derived from clk_cpu via int div and clk_cpu
|
|
|
|
* derived from clk_pll fracdiv */
|
2012-05-19 11:16:17 +00:00
|
|
|
if(imx233_clkctrl_get_bypass_pll(CLK_CPU))
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_XTAL);
|
2011-12-03 15:34:40 +00:00
|
|
|
/* Integer divide mode vs fractional divide mode */
|
|
|
|
if(HW_CLKCTRL_CPU & HW_CLKCTRL_CPU__DIV_XTAL_FRAC_EN)
|
|
|
|
|
|
|
|
return (ref * __XTRACT(HW_CLKCTRL_CPU, DIV_XTAL)) / 32;
|
|
|
|
else
|
2012-05-19 11:16:17 +00:00
|
|
|
return ref / imx233_clkctrl_get_clock_divisor(CLK_CPU);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_PLL);
|
2011-12-03 15:34:40 +00:00
|
|
|
/* fractional divider enable ? */
|
2012-05-19 11:16:17 +00:00
|
|
|
if(imx233_clkctrl_get_fractional_divisor(CLK_CPU) != 0)
|
|
|
|
ref = (ref * 18) / imx233_clkctrl_get_fractional_divisor(CLK_CPU);
|
|
|
|
return ref / imx233_clkctrl_get_clock_divisor(CLK_CPU);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case CLK_HBUS:
|
|
|
|
{
|
|
|
|
/* Derived from clk_p via integer/fractional div */
|
2012-05-19 11:16:17 +00:00
|
|
|
unsigned ref = imx233_clkctrl_get_clock_freq(CLK_CPU);
|
|
|
|
if(imx233_clkctrl_get_fractional_divisor(CLK_HBUS) != 0)
|
|
|
|
ref = (ref * imx233_clkctrl_get_fractional_divisor(CLK_HBUS)) / 32;
|
|
|
|
if(imx233_clkctrl_get_clock_divisor(CLK_HBUS) != 0)
|
|
|
|
ref /= imx233_clkctrl_get_clock_divisor(CLK_HBUS);
|
2011-12-03 15:34:40 +00:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
case CLK_IO:
|
|
|
|
{
|
|
|
|
/* Derived from clk_pll via fracdiv */
|
2012-05-19 11:16:17 +00:00
|
|
|
unsigned ref = imx233_clkctrl_get_clock_freq(CLK_PLL);
|
|
|
|
if(imx233_clkctrl_get_fractional_divisor(CLK_IO) != 0)
|
|
|
|
ref = (ref * 18) / imx233_clkctrl_get_fractional_divisor(CLK_IO);
|
2011-12-03 15:34:40 +00:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
case CLK_PIX:
|
|
|
|
{
|
|
|
|
unsigned ref;
|
|
|
|
/* Derived from clk_pll or clk_xtal */
|
2012-05-19 11:16:17 +00:00
|
|
|
if(!imx233_clkctrl_is_clock_enabled(CLK_PIX))
|
2011-12-03 15:34:40 +00:00
|
|
|
ref = 0;
|
2012-05-19 11:16:17 +00:00
|
|
|
else if(imx233_clkctrl_get_bypass_pll(CLK_PIX))
|
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_XTAL);
|
2011-12-03 15:34:40 +00:00
|
|
|
else
|
|
|
|
{
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_PLL);
|
|
|
|
if(imx233_clkctrl_get_fractional_divisor(CLK_PIX) != 0)
|
|
|
|
ref = (ref * 18) / imx233_clkctrl_get_fractional_divisor(CLK_PIX);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
2012-05-19 11:16:17 +00:00
|
|
|
return ref / imx233_clkctrl_get_clock_divisor(CLK_PIX);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
case CLK_SSP:
|
|
|
|
{
|
|
|
|
unsigned ref;
|
|
|
|
/* Derived from clk_pll or clk_xtal */
|
2012-05-19 11:16:17 +00:00
|
|
|
if(!imx233_clkctrl_is_clock_enabled(CLK_SSP))
|
2011-12-03 15:34:40 +00:00
|
|
|
ref = 0;
|
2012-05-19 11:16:17 +00:00
|
|
|
else if(imx233_clkctrl_get_bypass_pll(CLK_SSP))
|
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_XTAL);
|
2011-12-03 15:34:40 +00:00
|
|
|
else
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_IO);
|
|
|
|
return ref / imx233_clkctrl_get_clock_divisor(CLK_SSP);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
case CLK_EMI:
|
|
|
|
{
|
|
|
|
unsigned ref;
|
|
|
|
/* Derived from clk_pll or clk_xtal */
|
2012-05-19 11:16:17 +00:00
|
|
|
if(imx233_clkctrl_get_bypass_pll(CLK_EMI))
|
2011-12-03 15:34:40 +00:00
|
|
|
{
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_XTAL);
|
2011-12-03 15:34:40 +00:00
|
|
|
if(HW_CLKCTRL_EMI & HW_CLKCTRL_EMI__CLKGATE)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return ref / __XTRACT(HW_CLKCTRL_EMI, DIV_XTAL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-19 11:16:17 +00:00
|
|
|
ref = imx233_clkctrl_get_clock_freq(CLK_PLL);
|
|
|
|
if(imx233_clkctrl_get_fractional_divisor(CLK_EMI) != 0)
|
|
|
|
ref = (ref * 18) / imx233_clkctrl_get_fractional_divisor(CLK_EMI);
|
|
|
|
return ref / imx233_clkctrl_get_clock_divisor(CLK_EMI);
|
2011-12-03 15:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case CLK_XBUS:
|
2012-05-19 11:16:17 +00:00
|
|
|
return imx233_clkctrl_get_clock_freq(CLK_XTAL) /
|
|
|
|
imx233_clkctrl_get_clock_divisor(CLK_XBUS);
|
2011-12-03 15:34:40 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|