i.MX: rename i.MX CCM get_clock() function and CLK ID enum names
This is to prepare for CCM code refactoring. This is just a bit of function and enum values renaming. We also remove some useless intermediate variables. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Message-id: 53c4d9b9611988a5f56f178f285e04490747925e.1449528242.git.jcd@tribudubois.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
9de46a0aa3
commit
aaa9ec3b4d
@ -49,18 +49,18 @@ static const VMStateDescription vmstate_imx_ccm = {
|
|||||||
.post_load = imx_ccm_post_load,
|
.post_load = imx_ccm_post_load,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t imx_clock_frequency(DeviceState *dev, IMXClk clock)
|
uint32_t imx_ccm_get_clock_frequency(DeviceState *dev, IMXClk clock)
|
||||||
{
|
{
|
||||||
IMXCCMState *s = IMX_CCM(dev);
|
IMXCCMState *s = IMX_CCM(dev);
|
||||||
|
|
||||||
switch (clock) {
|
switch (clock) {
|
||||||
case NOCLK:
|
case NOCLK:
|
||||||
return 0;
|
return 0;
|
||||||
case MCU:
|
case CLK_MCU:
|
||||||
return s->mcu_clk_freq;
|
return s->mcu_clk_freq;
|
||||||
case HSP:
|
case CLK_HSP:
|
||||||
return s->hsp_clk_freq;
|
return s->hsp_clk_freq;
|
||||||
case IPG:
|
case CLK_IPG:
|
||||||
return s->ipg_clk_freq;
|
return s->ipg_clk_freq;
|
||||||
case CLK_32k:
|
case CLK_32k:
|
||||||
return CKIL_FREQ;
|
return CKIL_FREQ;
|
||||||
|
@ -51,9 +51,9 @@ static char const *imx_epit_reg_name(uint32_t reg)
|
|||||||
* These are typical.
|
* These are typical.
|
||||||
*/
|
*/
|
||||||
static const IMXClk imx_epit_clocks[] = {
|
static const IMXClk imx_epit_clocks[] = {
|
||||||
0, /* 00 disabled */
|
NOCLK, /* 00 disabled */
|
||||||
IPG, /* 01 ipg_clk, ~532MHz */
|
CLK_IPG, /* 01 ipg_clk, ~532MHz */
|
||||||
IPG, /* 10 ipg_clk_highfreq */
|
CLK_IPG, /* 10 ipg_clk_highfreq */
|
||||||
CLK_32k, /* 11 ipg_clk_32k -- ~32kHz */
|
CLK_32k, /* 11 ipg_clk_32k -- ~32kHz */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,20 +73,18 @@ static void imx_epit_set_freq(IMXEPITState *s)
|
|||||||
{
|
{
|
||||||
uint32_t clksrc;
|
uint32_t clksrc;
|
||||||
uint32_t prescaler;
|
uint32_t prescaler;
|
||||||
uint32_t freq;
|
|
||||||
|
|
||||||
clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, 2);
|
clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, 2);
|
||||||
prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, 12);
|
prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, 12);
|
||||||
|
|
||||||
freq = imx_clock_frequency(s->ccm, imx_epit_clocks[clksrc]) / prescaler;
|
s->freq = imx_ccm_get_clock_frequency(s->ccm,
|
||||||
|
imx_epit_clocks[clksrc]) / prescaler;
|
||||||
|
|
||||||
s->freq = freq;
|
DPRINTF("Setting ptimer frequency to %u\n", s->freq);
|
||||||
|
|
||||||
DPRINTF("Setting ptimer frequency to %u\n", freq);
|
if (s->freq) {
|
||||||
|
ptimer_set_freq(s->timer_reload, s->freq);
|
||||||
if (freq) {
|
ptimer_set_freq(s->timer_cmp, s->freq);
|
||||||
ptimer_set_freq(s->timer_reload, freq);
|
|
||||||
ptimer_set_freq(s->timer_cmp, freq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ static const VMStateDescription vmstate_imx_timer_gpt = {
|
|||||||
|
|
||||||
static const IMXClk imx_gpt_clocks[] = {
|
static const IMXClk imx_gpt_clocks[] = {
|
||||||
NOCLK, /* 000 No clock source */
|
NOCLK, /* 000 No clock source */
|
||||||
IPG, /* 001 ipg_clk, 532MHz*/
|
CLK_IPG, /* 001 ipg_clk, 532MHz*/
|
||||||
IPG, /* 010 ipg_clk_highfreq */
|
CLK_IPG, /* 010 ipg_clk_highfreq */
|
||||||
NOCLK, /* 011 not defined */
|
NOCLK, /* 011 not defined */
|
||||||
CLK_32k, /* 100 ipg_clk_32k */
|
CLK_32k, /* 100 ipg_clk_32k */
|
||||||
NOCLK, /* 101 not defined */
|
NOCLK, /* 101 not defined */
|
||||||
@ -93,14 +93,14 @@ static const IMXClk imx_gpt_clocks[] = {
|
|||||||
static void imx_gpt_set_freq(IMXGPTState *s)
|
static void imx_gpt_set_freq(IMXGPTState *s)
|
||||||
{
|
{
|
||||||
uint32_t clksrc = extract32(s->cr, GPT_CR_CLKSRC_SHIFT, 3);
|
uint32_t clksrc = extract32(s->cr, GPT_CR_CLKSRC_SHIFT, 3);
|
||||||
uint32_t freq = imx_clock_frequency(s->ccm, imx_gpt_clocks[clksrc])
|
|
||||||
/ (1 + s->pr);
|
|
||||||
s->freq = freq;
|
|
||||||
|
|
||||||
DPRINTF("Setting clksrc %d to frequency %d\n", clksrc, freq);
|
s->freq = imx_ccm_get_clock_frequency(s->ccm,
|
||||||
|
imx_gpt_clocks[clksrc]) / (1 + s->pr);
|
||||||
|
|
||||||
if (freq) {
|
DPRINTF("Setting clksrc %d to frequency %d\n", clksrc, s->freq);
|
||||||
ptimer_set_freq(s->timer, freq);
|
|
||||||
|
if (s->freq) {
|
||||||
|
ptimer_set_freq(s->timer, s->freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ typedef struct IMXCCMState {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NOCLK,
|
NOCLK,
|
||||||
MCU,
|
CLK_MCU,
|
||||||
HSP,
|
CLK_HSP,
|
||||||
IPG,
|
CLK_IPG,
|
||||||
CLK_32k
|
CLK_32k
|
||||||
} IMXClk;
|
} IMXClk;
|
||||||
|
|
||||||
uint32_t imx_clock_frequency(DeviceState *s, IMXClk clock);
|
uint32_t imx_ccm_get_clock_frequency(DeviceState *s, IMXClk clock);
|
||||||
|
|
||||||
#endif /* IMX_CCM_H */
|
#endif /* IMX_CCM_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user