2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-04-04 17:16:53 +00:00
|
|
|
/*
|
|
|
|
* Keystone2: pll initialization
|
|
|
|
*
|
|
|
|
* (C) Copyright 2012-2014
|
|
|
|
* Texas Instruments Incorporated, <www.ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/clock_defs.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:44 +00:00
|
|
|
/* DEV and ARM speed definitions as specified in DEVSPEED register */
|
|
|
|
int __weak speeds[DEVSPEED_NUMSPDS] = {
|
|
|
|
SPD1000,
|
|
|
|
SPD1200,
|
|
|
|
SPD1350,
|
|
|
|
SPD1400,
|
|
|
|
SPD1500,
|
|
|
|
SPD1400,
|
|
|
|
SPD1350,
|
|
|
|
SPD1200,
|
|
|
|
SPD1000,
|
|
|
|
SPD800,
|
|
|
|
};
|
2014-07-25 19:23:19 +00:00
|
|
|
|
2015-07-28 08:46:45 +00:00
|
|
|
const struct keystone_pll_regs keystone_pll_regs[] = {
|
|
|
|
[CORE_PLL] = {KS2_MAINPLLCTL0, KS2_MAINPLLCTL1},
|
|
|
|
[PASS_PLL] = {KS2_PASSPLLCTL0, KS2_PASSPLLCTL1},
|
|
|
|
[TETRIS_PLL] = {KS2_ARMPLLCTL0, KS2_ARMPLLCTL1},
|
|
|
|
[DDR3A_PLL] = {KS2_DDR3APLLCTL0, KS2_DDR3APLLCTL1},
|
|
|
|
[DDR3B_PLL] = {KS2_DDR3BPLLCTL0, KS2_DDR3BPLLCTL1},
|
2015-09-19 10:56:40 +00:00
|
|
|
[UART_PLL] = {KS2_UARTPLLCTL0, KS2_UARTPLLCTL1},
|
2015-07-28 08:46:45 +00:00
|
|
|
};
|
|
|
|
|
2015-10-08 06:01:47 +00:00
|
|
|
inline void pll_pa_clk_sel(void)
|
|
|
|
{
|
|
|
|
setbits_le32(keystone_pll_regs[PASS_PLL].reg1, CFG_PLLCTL1_PAPLL_MASK);
|
|
|
|
}
|
|
|
|
|
2014-04-04 17:16:53 +00:00
|
|
|
static void wait_for_completion(const struct pll_init_data *data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
sdelay(450);
|
2015-07-28 08:46:43 +00:00
|
|
|
if (!(pllctl_reg_read(data->pll, stat) & PLLSTAT_GOSTAT_MASK))
|
2014-04-04 17:16:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
static inline void bypass_main_pll(const struct pll_init_data *data)
|
2014-04-04 17:16:53 +00:00
|
|
|
{
|
2015-07-28 08:46:43 +00:00
|
|
|
pllctl_reg_clrbits(data->pll, ctl, PLLCTL_PLLENSRC_MASK |
|
|
|
|
PLLCTL_PLLEN_MASK);
|
|
|
|
|
|
|
|
/* 4 cycles of reference clock CLKIN*/
|
|
|
|
sdelay(340);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void configure_mult_div(const struct pll_init_data *data)
|
|
|
|
{
|
|
|
|
u32 pllm, plld, bwadj;
|
2014-04-04 17:16:53 +00:00
|
|
|
|
|
|
|
pllm = data->pll_m - 1;
|
2015-07-28 08:46:43 +00:00
|
|
|
plld = (data->pll_d - 1) & CFG_PLLCTL0_PLLD_MASK;
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Program Multiplier */
|
|
|
|
if (data->pll == MAIN_PLL)
|
|
|
|
pllctl_reg_write(data->pll, mult, pllm & PLLM_MULT_LO_MASK);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
clrsetbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_PLLM_MASK,
|
|
|
|
pllm << CFG_PLLCTL0_PLLM_SHIFT);
|
|
|
|
|
|
|
|
/* Program BWADJ */
|
|
|
|
bwadj = (data->pll_m - 1) >> 1; /* Divide pllm by 2 */
|
|
|
|
clrsetbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_BWADJ_MASK,
|
|
|
|
(bwadj << CFG_PLLCTL0_BWADJ_SHIFT) &
|
|
|
|
CFG_PLLCTL0_BWADJ_MASK);
|
|
|
|
bwadj = bwadj >> CFG_PLLCTL0_BWADJ_BITS;
|
|
|
|
clrsetbits_le32(keystone_pll_regs[data->pll].reg1,
|
|
|
|
CFG_PLLCTL1_BWADJ_MASK, bwadj);
|
|
|
|
|
|
|
|
/* Program Divider */
|
|
|
|
clrsetbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_PLLD_MASK, plld);
|
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
void configure_main_pll(const struct pll_init_data *data)
|
|
|
|
{
|
|
|
|
u32 tmp, pllod, i, alnctl_val = 0;
|
|
|
|
u32 *offset;
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
pllod = data->pll_od - 1;
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* 100 micro sec for stabilization */
|
|
|
|
sdelay(210000);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
tmp = pllctl_reg_read(data->pll, secctl);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Check for Bypass */
|
|
|
|
if (tmp & SECCTL_BYPASS_MASK) {
|
|
|
|
setbits_le32(keystone_pll_regs[data->pll].reg1,
|
|
|
|
CFG_PLLCTL1_ENSAT_MASK);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
bypass_main_pll(data);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Powerdown and powerup Main Pll */
|
|
|
|
pllctl_reg_setbits(data->pll, secctl, SECCTL_BYPASS_MASK);
|
|
|
|
pllctl_reg_setbits(data->pll, ctl, PLLCTL_PLLPWRDN_MASK);
|
|
|
|
/* 5 micro sec */
|
|
|
|
sdelay(21000);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
pllctl_reg_clrbits(data->pll, ctl, PLLCTL_PLLPWRDN_MASK);
|
|
|
|
} else {
|
|
|
|
bypass_main_pll(data);
|
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
configure_mult_div(data);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Program Output Divider */
|
|
|
|
pllctl_reg_rmw(data->pll, secctl, SECCTL_OP_DIV_MASK,
|
|
|
|
((pllod << SECCTL_OP_DIV_SHIFT) & SECCTL_OP_DIV_MASK));
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Program PLLDIVn */
|
|
|
|
wait_for_completion(data);
|
|
|
|
for (i = 0; i < PLLDIV_MAX; i++) {
|
|
|
|
if (i < 3)
|
|
|
|
offset = pllctl_reg(data->pll, div1) + i;
|
|
|
|
else
|
|
|
|
offset = pllctl_reg(data->pll, div4) + (i - 3);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
if (divn_val[i] != -1) {
|
|
|
|
__raw_writel(divn_val[i] | PLLDIV_ENABLE_MASK, offset);
|
|
|
|
alnctl_val |= BIT(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alnctl_val) {
|
|
|
|
pllctl_reg_setbits(data->pll, alnctl, alnctl_val);
|
2014-04-04 17:16:53 +00:00
|
|
|
/*
|
|
|
|
* Set GOSET bit in PLLCMD to initiate the GO operation
|
|
|
|
* to change the divide
|
|
|
|
*/
|
2015-07-28 08:46:43 +00:00
|
|
|
pllctl_reg_setbits(data->pll, cmd, PLLSTAT_GOSTAT_MASK);
|
2014-04-04 17:16:53 +00:00
|
|
|
wait_for_completion(data);
|
2015-07-28 08:46:43 +00:00
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Reset PLL */
|
|
|
|
pllctl_reg_setbits(data->pll, ctl, PLLCTL_PLLRST_MASK);
|
|
|
|
sdelay(21000); /* Wait for a minimum of 7 us*/
|
|
|
|
pllctl_reg_clrbits(data->pll, ctl, PLLCTL_PLLRST_MASK);
|
|
|
|
sdelay(105000); /* Wait for PLL Lock time (min 50 us) */
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Enable PLL */
|
|
|
|
pllctl_reg_clrbits(data->pll, secctl, SECCTL_BYPASS_MASK);
|
|
|
|
pllctl_reg_setbits(data->pll, ctl, PLLCTL_PLLEN_MASK);
|
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
void configure_secondary_pll(const struct pll_init_data *data)
|
|
|
|
{
|
|
|
|
int pllod = data->pll_od - 1;
|
|
|
|
|
2016-11-03 10:02:51 +00:00
|
|
|
/* Enable Glitch free bypass for ARM PLL */
|
|
|
|
if (cpu_is_k2hk() && data->pll == TETRIS_PLL)
|
|
|
|
clrbits_le32(KS2_MISC_CTRL, MISC_CTL1_ARM_PLL_EN);
|
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
/* Enable Bypass mode */
|
|
|
|
setbits_le32(keystone_pll_regs[data->pll].reg1, CFG_PLLCTL1_ENSAT_MASK);
|
|
|
|
setbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_BYPASS_MASK);
|
|
|
|
|
|
|
|
configure_mult_div(data);
|
|
|
|
|
|
|
|
/* Program Output Divider */
|
|
|
|
clrsetbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_CLKOD_MASK,
|
|
|
|
(pllod << CFG_PLLCTL0_CLKOD_SHIFT) &
|
|
|
|
CFG_PLLCTL0_CLKOD_MASK);
|
|
|
|
|
|
|
|
/* Reset PLL */
|
|
|
|
setbits_le32(keystone_pll_regs[data->pll].reg1, CFG_PLLCTL1_RST_MASK);
|
|
|
|
/* Wait for 5 micro seconds */
|
|
|
|
sdelay(21000);
|
|
|
|
|
|
|
|
/* Select the Output of PASS PLL as input to PASS */
|
2015-10-08 06:01:47 +00:00
|
|
|
if (data->pll == PASS_PLL && cpu_is_k2hk())
|
|
|
|
pll_pa_clk_sel();
|
2015-07-28 08:46:43 +00:00
|
|
|
|
|
|
|
clrbits_le32(keystone_pll_regs[data->pll].reg1, CFG_PLLCTL1_RST_MASK);
|
|
|
|
/* Wait for 500 * REFCLK cucles * (PLLD + 1) */
|
|
|
|
sdelay(105000);
|
|
|
|
|
|
|
|
/* Switch to PLL mode */
|
|
|
|
clrbits_le32(keystone_pll_regs[data->pll].reg0,
|
|
|
|
CFG_PLLCTL0_BYPASS_MASK);
|
2016-11-03 10:02:51 +00:00
|
|
|
|
|
|
|
/* Select the Output of ARM PLL as input to ARM */
|
|
|
|
if (cpu_is_k2hk() && data->pll == TETRIS_PLL)
|
|
|
|
setbits_le32(KS2_MISC_CTRL, MISC_CTL1_ARM_PLL_EN);
|
2015-07-28 08:46:43 +00:00
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:43 +00:00
|
|
|
void init_pll(const struct pll_init_data *data)
|
|
|
|
{
|
|
|
|
if (data->pll == MAIN_PLL)
|
|
|
|
configure_main_pll(data);
|
|
|
|
else
|
|
|
|
configure_secondary_pll(data);
|
2014-04-04 17:16:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is required to provide a delay between multiple
|
|
|
|
* consequent PPL configurations
|
|
|
|
*/
|
|
|
|
sdelay(210000);
|
|
|
|
}
|
|
|
|
|
2015-07-28 08:46:46 +00:00
|
|
|
void init_plls(void)
|
2014-04-04 17:16:53 +00:00
|
|
|
{
|
2015-07-28 08:46:46 +00:00
|
|
|
struct pll_init_data *data;
|
|
|
|
int pll;
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2015-07-28 08:46:46 +00:00
|
|
|
for (pll = MAIN_PLL; pll < MAX_PLL_COUNT; pll++) {
|
|
|
|
data = get_pll_init_data(pll);
|
|
|
|
if (data)
|
|
|
|
init_pll(data);
|
|
|
|
}
|
2014-04-04 17:16:53 +00:00
|
|
|
}
|
2014-07-25 19:23:19 +00:00
|
|
|
|
2016-03-04 16:36:40 +00:00
|
|
|
static int get_max_speed(u32 val, u32 speed_supported, int *spds)
|
2014-07-25 19:23:19 +00:00
|
|
|
{
|
2015-07-28 08:46:44 +00:00
|
|
|
int speed;
|
2014-07-25 19:23:19 +00:00
|
|
|
|
2015-07-28 08:46:44 +00:00
|
|
|
/* Left most setbit gives the speed */
|
|
|
|
for (speed = DEVSPEED_NUMSPDS; speed >= 0; speed--) {
|
|
|
|
if ((val & BIT(speed)) & speed_supported)
|
2016-03-04 16:36:40 +00:00
|
|
|
return spds[speed];
|
2014-07-25 19:23:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 16:36:41 +00:00
|
|
|
/* If no bit is set, return minimum speed */
|
|
|
|
if (cpu_is_k2g())
|
|
|
|
return SPD200;
|
|
|
|
else
|
|
|
|
return SPD800;
|
2014-07-25 19:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 read_efuse_bootrom(void)
|
|
|
|
{
|
2015-07-28 08:46:44 +00:00
|
|
|
if (cpu_is_k2hk() && (cpu_revision() <= 1))
|
|
|
|
return __raw_readl(KS2_REV1_DEVSPEED);
|
|
|
|
else
|
|
|
|
return __raw_readl(KS2_EFUSE_BOOTROM);
|
2014-07-25 19:23:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 16:36:40 +00:00
|
|
|
int get_max_arm_speed(int *spds)
|
2014-07-25 19:23:19 +00:00
|
|
|
{
|
2015-07-28 08:46:44 +00:00
|
|
|
u32 armspeed = read_efuse_bootrom();
|
|
|
|
|
|
|
|
armspeed = (armspeed & DEVSPEED_ARMSPEED_MASK) >>
|
|
|
|
DEVSPEED_ARMSPEED_SHIFT;
|
|
|
|
|
2016-03-04 16:36:40 +00:00
|
|
|
return get_max_speed(armspeed, ARM_SUPPORTED_SPEEDS, spds);
|
2014-07-25 19:23:19 +00:00
|
|
|
}
|
2014-10-17 18:01:16 +00:00
|
|
|
|
2016-03-04 16:36:40 +00:00
|
|
|
int get_max_dev_speed(int *spds)
|
2015-06-15 12:54:15 +00:00
|
|
|
{
|
2015-07-28 08:46:44 +00:00
|
|
|
u32 devspeed = read_efuse_bootrom();
|
|
|
|
|
|
|
|
devspeed = (devspeed & DEVSPEED_DEVSPEED_MASK) >>
|
|
|
|
DEVSPEED_DEVSPEED_SHIFT;
|
|
|
|
|
2016-03-04 16:36:40 +00:00
|
|
|
return get_max_speed(devspeed, DEV_SUPPORTED_SPEEDS, spds);
|
2015-06-15 12:54:15 +00:00
|
|
|
}
|
2015-07-28 08:46:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* pll_freq_get - get pll frequency
|
|
|
|
* @pll: pll identifier
|
|
|
|
*/
|
|
|
|
static unsigned long pll_freq_get(int pll)
|
|
|
|
{
|
|
|
|
unsigned long mult = 1, prediv = 1, output_div = 2;
|
|
|
|
unsigned long ret;
|
|
|
|
u32 tmp, reg;
|
|
|
|
|
|
|
|
if (pll == MAIN_PLL) {
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(sys_clk);
|
2015-07-28 08:46:48 +00:00
|
|
|
if (pllctl_reg_read(pll, ctl) & PLLCTL_PLLEN_MASK) {
|
|
|
|
/* PLL mode */
|
|
|
|
tmp = __raw_readl(KS2_MAINPLLCTL0);
|
|
|
|
prediv = (tmp & CFG_PLLCTL0_PLLD_MASK) + 1;
|
|
|
|
mult = ((tmp & CFG_PLLCTL0_PLLM_HI_MASK) >>
|
|
|
|
CFG_PLLCTL0_PLLM_SHIFT |
|
|
|
|
(pllctl_reg_read(pll, mult) &
|
|
|
|
PLLM_MULT_LO_MASK)) + 1;
|
|
|
|
output_div = ((pllctl_reg_read(pll, secctl) &
|
|
|
|
SECCTL_OP_DIV_MASK) >>
|
|
|
|
SECCTL_OP_DIV_SHIFT) + 1;
|
|
|
|
|
|
|
|
ret = ret / prediv / output_div * mult;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (pll) {
|
|
|
|
case PASS_PLL:
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(pa_clk);
|
2015-07-28 08:46:48 +00:00
|
|
|
reg = KS2_PASSPLLCTL0;
|
|
|
|
break;
|
|
|
|
case TETRIS_PLL:
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(tetris_clk);
|
2015-07-28 08:46:48 +00:00
|
|
|
reg = KS2_ARMPLLCTL0;
|
|
|
|
break;
|
|
|
|
case DDR3A_PLL:
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(ddr3a_clk);
|
2015-07-28 08:46:48 +00:00
|
|
|
reg = KS2_DDR3APLLCTL0;
|
|
|
|
break;
|
|
|
|
case DDR3B_PLL:
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(ddr3b_clk);
|
2015-07-28 08:46:48 +00:00
|
|
|
reg = KS2_DDR3BPLLCTL0;
|
|
|
|
break;
|
2015-09-19 10:56:40 +00:00
|
|
|
case UART_PLL:
|
2017-05-03 11:28:26 +00:00
|
|
|
ret = get_external_clk(uart_clk);
|
2015-09-19 10:56:40 +00:00
|
|
|
reg = KS2_UARTPLLCTL0;
|
|
|
|
break;
|
2015-07-28 08:46:48 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = __raw_readl(reg);
|
|
|
|
|
|
|
|
if (!(tmp & CFG_PLLCTL0_BYPASS_MASK)) {
|
|
|
|
/* Bypass disabled */
|
|
|
|
prediv = (tmp & CFG_PLLCTL0_PLLD_MASK) + 1;
|
|
|
|
mult = ((tmp & CFG_PLLCTL0_PLLM_MASK) >>
|
|
|
|
CFG_PLLCTL0_PLLM_SHIFT) + 1;
|
|
|
|
output_div = ((tmp & CFG_PLLCTL0_CLKOD_MASK) >>
|
|
|
|
CFG_PLLCTL0_CLKOD_SHIFT) + 1;
|
|
|
|
ret = ((ret / prediv) * mult) / output_div;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-09-26 11:45:26 +00:00
|
|
|
unsigned long ks_clk_get_rate(unsigned int clk)
|
2015-07-28 08:46:48 +00:00
|
|
|
{
|
|
|
|
unsigned long freq = 0;
|
|
|
|
|
|
|
|
switch (clk) {
|
|
|
|
case core_pll_clk:
|
|
|
|
freq = pll_freq_get(CORE_PLL);
|
|
|
|
break;
|
|
|
|
case pass_pll_clk:
|
|
|
|
freq = pll_freq_get(PASS_PLL);
|
|
|
|
break;
|
|
|
|
case tetris_pll_clk:
|
|
|
|
if (!cpu_is_k2e())
|
|
|
|
freq = pll_freq_get(TETRIS_PLL);
|
|
|
|
break;
|
|
|
|
case ddr3a_pll_clk:
|
|
|
|
freq = pll_freq_get(DDR3A_PLL);
|
|
|
|
break;
|
|
|
|
case ddr3b_pll_clk:
|
|
|
|
if (cpu_is_k2hk())
|
|
|
|
freq = pll_freq_get(DDR3B_PLL);
|
|
|
|
break;
|
2015-09-19 10:56:41 +00:00
|
|
|
case uart_pll_clk:
|
|
|
|
if (cpu_is_k2g())
|
|
|
|
freq = pll_freq_get(UART_PLL);
|
|
|
|
break;
|
2015-07-28 08:46:48 +00:00
|
|
|
case sys_clk0_1_clk:
|
|
|
|
case sys_clk0_clk:
|
|
|
|
freq = pll_freq_get(CORE_PLL) / pll0div_read(1);
|
|
|
|
break;
|
|
|
|
case sys_clk1_clk:
|
|
|
|
return pll_freq_get(CORE_PLL) / pll0div_read(2);
|
|
|
|
break;
|
|
|
|
case sys_clk2_clk:
|
|
|
|
freq = pll_freq_get(CORE_PLL) / pll0div_read(3);
|
|
|
|
break;
|
|
|
|
case sys_clk3_clk:
|
|
|
|
freq = pll_freq_get(CORE_PLL) / pll0div_read(4);
|
|
|
|
break;
|
|
|
|
case sys_clk0_2_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 2;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_3_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 3;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_4_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 4;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_6_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 6;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_8_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 8;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_12_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 12;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk0_24_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk0_clk) / 24;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk1_3_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk1_clk) / 3;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk1_4_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk1_clk) / 4;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk1_6_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk1_clk) / 6;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
case sys_clk1_12_clk:
|
2016-09-26 11:45:26 +00:00
|
|
|
freq = ks_clk_get_rate(sys_clk1_clk) / 12;
|
2015-07-28 08:46:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return freq;
|
|
|
|
}
|