From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH v2 1/9] ARM: clps711x: Rework lowlevel initialization code
Date: Wed, 13 Feb 2013 15:41:36 +0400 [thread overview]
Message-ID: <1360755704-24105-1-git-send-email-shc_work@mail.ru> (raw)
This is a rework of CLPS711X low level initialization code which includes:
- Prepare for changing CPU PLL multiplier from board lowlevel code.
- Decrease initial memory size to 8MB. It is minimal known size.
- Fix SDRAM initialization comment about size.
- Turn off all peripherals on startup.
- Skip PLL initialization if CPU is running from external 13 MHz clock.
- Use correct CPU speed for older CPUs without PLL.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
arch/arm/boards/clep7212/lowlevel.c | 53 +++++++++++++++++++++--------------
1 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/arch/arm/boards/clep7212/lowlevel.c b/arch/arm/boards/clep7212/lowlevel.c
index b4d1bf1..fcee5bf 100644
--- a/arch/arm/boards/clep7212/lowlevel.c
+++ b/arch/arm/boards/clep7212/lowlevel.c
@@ -17,41 +17,52 @@
#include <mach/clps711x.h>
-#define MAIN_CLOCK 3686400
-#define CPU_SPEED 92160000
-#define BUS_SPEED (CPU_SPEED / 2)
-
-#define PLL_VALUE (((CPU_SPEED * 2) / MAIN_CLOCK) << 24)
-#define SDRAM_REFRESH_RATE (64 * (BUS_SPEED / (8192 * 1000)))
-
void __naked __bare_init barebox_arm_reset_vector(void)
{
- u32 tmp;
+ const u32 pllmult = 50;
+ u32 cpu, bus;
arm_cpu_lowlevel_init();
- /* Setup base clock */
+ /* Setup base clocking, Enable SDQM pins */
writel(SYSCON3_CLKCTL0 | SYSCON3_CLKCTL1, SYSCON3);
asm("nop");
- /* Setup PLL */
- writel(PLL_VALUE, PLLW);
- asm("nop");
+ /* Check if we running from external 13 MHz clock */
+ if (!(readl(SYSFLG2) & SYSFLG2_CKMODE)) {
+ /* Setup PLL */
+ writel(pllmult << 24, PLLW);
+ asm("nop");
+
+ /* Check for old CPUs without PLL */
+ if ((readl(PLLR) >> 24) != pllmult)
+ cpu = 73728000;
+ else
+ cpu = pllmult * 3686400;
+
+ if (cpu >= 36864000)
+ bus = cpu /2;
+ else
+ bus = 36864000 / 2;
+ } else
+ bus = 13000000;
/* CLKEN select, SDRAM width=32 */
writel(SYSCON2_CLKENSL, SYSCON2);
- /* Enable SDQM pins */
- tmp = readl(SYSCON3);
- tmp &= ~SYSCON3_ENPD67;
- writel(tmp, SYSCON3);
+ /* Setup SDRAM params (64MB, 16Bit*2, CAS=3) */
+ writel(SDCONF_CASLAT_3 | SDCONF_SIZE_256 | SDCONF_WIDTH_16 |
+ SDCONF_CLKCTL | SDCONF_ACTIVE, SDCONF);
/* Setup Refresh Rate (64ms 8K Blocks) */
- writel(SDRAM_REFRESH_RATE, SDRFPR);
+ writel((64 * bus) / (8192 * 1000), SDRFPR);
- /* Setup SDRAM (32MB, 16Bit*2, CAS=3) */
- writel(SDCONF_CASLAT_3 | SDCONF_SIZE_256 | SDCONF_WIDTH_16 |
- SDCONF_CLKCTL | SDCONF_ACTIVE, SDCONF);
+ /* Disable UART, IrDa, LCD */
+ writel(0, SYSCON1);
+ /* Disable PWM */
+ writew(0, PMPCON);
+ /* Disable LED flasher */
+ writew(0, LEDFLSH);
- barebox_arm_entry(SDRAM0_BASE, SZ_32M, 0);
+ barebox_arm_entry(SDRAM0_BASE, SZ_8M, 0);
}
--
1.7.3.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2013-02-13 11:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-13 11:41 Alexander Shiyan [this message]
2013-02-13 11:41 ` [PATCH v2 2/9] ARM: clps711x: Move basic lowlevel initialization in common CLPS711X location Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 3/9] ARM: clps711x: Adds config option for CPU PLL multiplier Alexander Shiyan
2013-02-13 12:02 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 12:23 ` Re[2]: " Alexander Shiyan
2013-02-13 13:36 ` [SPAM] " Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 17:06 ` Sascha Hauer
2013-02-13 17:20 ` Re[2]: " Alexander Shiyan
2013-02-13 17:40 ` Sascha Hauer
2013-02-13 18:01 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 18:06 ` Re[2]: " Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 4/9] ARM: clps711x: Remove unused "start" declaration from reset.c Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 5/9] ARM: clps711x: Mark private functions that not will be used outside as static Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 6/9] ARM: clep7212: Fix NULL pointer exception if MMU is enabled Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 7/9] ARM: clps711x: Move memory initialization in common CLPS711X location Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 8/9] ARM: clep7212: Update default environment Alexander Shiyan
2013-02-13 11:41 ` [PATCH v2 9/9] ARM: clps711x: Update defconfig Alexander Shiyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360755704-24105-1-git-send-email-shc_work@mail.ru \
--to=shc_work@mail.ru \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox