Skip to content

Commit edb40d7

Browse files
Eugeniy Paltsevvineetgarc
authored andcommitted
ARC: [plat-hsdk]: Temporary fix to set CPU frequency to 1GHz
Add temporary fix to HSDK platform code to setup CPU frequency to 1GHz on early boot. We can remove this fix when smart hsdk pll driver will be introduced, see discussion: https://www.mail-archive.com/linux-snps-arc@lists.infradead.org/msg02689.html Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent 5464d03 commit edb40d7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

arch/arc/plat-hsdk/platform.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@ static void __init hsdk_init_per_cpu(unsigned int cpu)
3838
#define CREG_PAE (CREG_BASE + 0x180)
3939
#define CREG_PAE_UPDATE (CREG_BASE + 0x194)
4040

41+
#define CREG_CORE_IF_CLK_DIV (CREG_BASE + 0x4B8)
42+
#define CREG_CORE_IF_CLK_DIV_2 0x1
43+
#define CGU_BASE ARC_PERIPHERAL_BASE
44+
#define CGU_PLL_STATUS (ARC_PERIPHERAL_BASE + 0x4)
45+
#define CGU_PLL_CTRL (ARC_PERIPHERAL_BASE + 0x0)
46+
#define CGU_PLL_STATUS_LOCK BIT(0)
47+
#define CGU_PLL_STATUS_ERR BIT(1)
48+
#define CGU_PLL_CTRL_1GHZ 0x3A10
49+
#define HSDK_PLL_LOCK_TIMEOUT 500
50+
51+
#define HSDK_PLL_LOCKED() \
52+
!!(ioread32((void __iomem *) CGU_PLL_STATUS) & CGU_PLL_STATUS_LOCK)
53+
54+
#define HSDK_PLL_ERR() \
55+
!!(ioread32((void __iomem *) CGU_PLL_STATUS) & CGU_PLL_STATUS_ERR)
56+
57+
static void __init hsdk_set_cpu_freq_1ghz(void)
58+
{
59+
u32 timeout = HSDK_PLL_LOCK_TIMEOUT;
60+
61+
/*
62+
* As we set cpu clock which exceeds 500MHz, the divider for the interface
63+
* clock must be programmed to div-by-2.
64+
*/
65+
iowrite32(CREG_CORE_IF_CLK_DIV_2, (void __iomem *) CREG_CORE_IF_CLK_DIV);
66+
67+
/* Set cpu clock to 1GHz */
68+
iowrite32(CGU_PLL_CTRL_1GHZ, (void __iomem *) CGU_PLL_CTRL);
69+
70+
while (!HSDK_PLL_LOCKED() && timeout--)
71+
cpu_relax();
72+
73+
if (!HSDK_PLL_LOCKED() || HSDK_PLL_ERR())
74+
pr_err("Failed to setup CPU frequency to 1GHz!");
75+
}
76+
4177
static void __init hsdk_init_early(void)
4278
{
4379
/*
@@ -52,6 +88,12 @@ static void __init hsdk_init_early(void)
5288

5389
/* Really apply settings made above */
5490
writel(1, (void __iomem *) CREG_PAE_UPDATE);
91+
92+
/*
93+
* Setup CPU frequency to 1GHz.
94+
* TODO: remove it after smart hsdk pll driver will be introduced.
95+
*/
96+
hsdk_set_cpu_freq_1ghz();
5597
}
5698

5799
static const char *hsdk_compat[] __initconst = {

0 commit comments

Comments
 (0)