public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] sunxi: Fix PLL1 running at half speed on sun8i
@ 2014-12-27 17:02 Hans de Goede
  2014-12-28  8:56 ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2014-12-27 17:02 UTC (permalink / raw)
  To: u-boot

PLL1 on sun6i / sun8i also has a p factor which divides the clock by
2^p (to the power p). On sun6i the p factor is ignored, but on sun8i it is
used and we were setting it to 1, resulting in the CPU running at 504 MHz
instead of 1008 MHz, this commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/cpu/armv7/sunxi/clock_sun6i.c        | 8 ++++++--
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
index 8ef19df..36e502f 100644
--- a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
+++ b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
@@ -97,6 +97,7 @@ void clock_set_pll1(unsigned int clk)
 {
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	const int p = 0;
 	int k = 1;
 	int m = 1;
 
@@ -113,8 +114,11 @@ void clock_set_pll1(unsigned int clk)
 	       CPU_CLK_SRC_OSC24M << CPU_CLK_SRC_SHIFT,
 	       &ccm->cpu_axi_cfg);
 
-	/* PLL1 rate = 24000000 * n * k / m */
-	writel(CCM_PLL1_CTRL_EN | CCM_PLL1_CTRL_MAGIC |
+	/*
+	 * sun6i: PLL1 rate = ((24000000 * n * k) >> 0) / m   (p is ignored)
+	 * sun8i: PLL1 rate = ((24000000 * n * k) >> p) / m
+	 */
+	writel(CCM_PLL1_CTRL_EN | CCM_PLL1_CTRL_P(p) |
 	       CCM_PLL1_CTRL_N(clk / (24000000 * k / m)) |
 	       CCM_PLL1_CTRL_K(k) | CCM_PLL1_CTRL_M(m), &ccm->pll1_cfg);
 	sdelay(200);
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index f2f1a9b..0e57abe 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -173,7 +173,7 @@ struct sunxi_ccm_reg {
 #define CCM_PLL1_CTRL_M(n)		((((n) - 1) & 0x3) << 0)
 #define CCM_PLL1_CTRL_K(n)		((((n) - 1) & 0x3) << 4)
 #define CCM_PLL1_CTRL_N(n)		((((n) - 1) & 0x1f) << 8)
-#define CCM_PLL1_CTRL_MAGIC		(0x1 << 16)
+#define CCM_PLL1_CTRL_P(n)		(((n) & 0x3) << 16)
 #define CCM_PLL1_CTRL_EN		(0x1 << 31)
 
 #define CCM_PLL3_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] sunxi: Fix PLL1 running at half speed on sun8i
  2014-12-27 17:02 [U-Boot] [PATCH] sunxi: Fix PLL1 running at half speed on sun8i Hans de Goede
@ 2014-12-28  8:56 ` Ian Campbell
  2014-12-28  9:02   ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Campbell @ 2014-12-28  8:56 UTC (permalink / raw)
  To: u-boot

On Sat, 2014-12-27 at 18:02 +0100, Hans de Goede wrote:
> PLL1 on sun6i / sun8i also has a p factor which divides the clock by
> 2^p (to the power p). On sun6i the p factor is ignored, but on sun8i it is
> used and we were setting it to 1, resulting in the CPU running at 504 MHz
> instead of 1008 MHz, this commit fixes this.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Ian Campbell <ijc@hellion.org.uk>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] sunxi: Fix PLL1 running at half speed on sun8i
  2014-12-28  8:56 ` Ian Campbell
@ 2014-12-28  9:02   ` Hans de Goede
  0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2014-12-28  9:02 UTC (permalink / raw)
  To: u-boot

Hi,

On 28-12-14 09:56, Ian Campbell wrote:
> On Sat, 2014-12-27 at 18:02 +0100, Hans de Goede wrote:
>> PLL1 on sun6i / sun8i also has a p factor which divides the clock by
>> 2^p (to the power p). On sun6i the p factor is ignored, but on sun8i it is
>> used and we were setting it to 1, resulting in the CPU running at 504 MHz
>> instead of 1008 MHz, this commit fixes this.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> Acked-by: Ian Campbell <ijc@hellion.org.uk>

Thanks, queued up in u-boot-sunxi/next .

Regards,

Hans

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-28  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-27 17:02 [U-Boot] [PATCH] sunxi: Fix PLL1 running at half speed on sun8i Hans de Goede
2014-12-28  8:56 ` Ian Campbell
2014-12-28  9:02   ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox