U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
September 2013
- 180 participants
- 592 discussions

20 Sep '13
The Linux kernel cannot unpack a ramdisk that's stored in high memory.
Unless the initrd_high environment variable is explicitly set, abide by
that restriction using the getenv_bootm_low() and getenv_bootm_mapsize()
helpers.
Signed-off-by: Thierry Reding <treding(a)nvidia.com>
---
Changes in v2:
- update function header comment
common/image.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/common/image.c b/common/image.c
index 2c88091..47336f2 100644
--- a/common/image.c
+++ b/common/image.c
@@ -966,7 +966,8 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
* end address (after possible relocation)
*
* boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
- * variable and if requested ramdisk data is moved to a specified location.
+ * variable and if requested ramdisk data is moved to a specified location. If
+ * no such hint is given, the default is to relocate the initrd to low memory.
*
* Initrd_start and initrd_end are set to final (after relocation) ramdisk
* start/end addresses if ramdisk image start and len were provided,
@@ -991,8 +992,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
if (initrd_high == ~0)
initrd_copy_to_ram = 0;
} else {
- /* not set, no restrictions to load high */
- initrd_high = ~0;
+ /* make sure to put ramdisk in low memory */
+ initrd_high = getenv_bootm_low() + getenv_bootm_mapsize();
}
--
1.8.4
1
1

[U-Boot] [PATCH] arm: ep9315: Return back Cirrus Logic EDB9315A board support
by Sergey Kostanbaev 20 Sep '13
by Sergey Kostanbaev 20 Sep '13
20 Sep '13
From: Sergey Kostanbaev <sergey.kostanbaev(a)fairwaves.ru>
This patch return back support of old EDB9315A board based on Cirrus Logic EP9315 processor.
Signed-off-by: Sergey Kostanbaev <sergey.kostanbaev(a)fairwaves.ru>
---
arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S | 568 +++++++++++++++++++++++++--
arch/arm/include/asm/arch-ep93xx/ep93xx.h | 62 +++
board/cirrus/edb93xx/Makefile | 37 ++
board/cirrus/edb93xx/edb93xx.c | 340 ++++++++++++++++
board/cirrus/edb93xx/u-boot.lds | 106 +++++
boards.cfg | 1 +
drivers/spi/Makefile | 1 +
drivers/spi/ep93xx_spi.c | 274 +++++++++++++
drivers/usb/host/Makefile | 1 +
drivers/usb/host/ohci-ep93xx.c | 38 ++
include/configs/edb93xx.h | 291 ++++++++++++++
11 files changed, 1690 insertions(+), 29 deletions(-)
create mode 100644 board/cirrus/edb93xx/Makefile
create mode 100644 board/cirrus/edb93xx/edb93xx.c
create mode 100644 board/cirrus/edb93xx/u-boot.lds
create mode 100644 drivers/spi/ep93xx_spi.c
create mode 100644 drivers/usb/host/ohci-ep93xx.c
create mode 100644 include/configs/edb93xx.h
diff --git a/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S b/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
index bf2fa2a..96fc43c 100644
--- a/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
+++ b/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
@@ -1,49 +1,559 @@
/*
* Low-level initialization for EP93xx
*
- * Copyright (C) 2009 Matthias Kaehlcke <matthias(a)kaehlcke.net>
+ * Copyright (C) 2013
+ * Sergey Kostanabev <sergey.kostanbaev <at> fairwaves.ru>
*
- * Copyright (C) 2006 Dominic Rath <Dominic.Rath(a)gmx.de>
+ * Copyright (C) 2006 Cirrus Logic Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
*
* SPDX-License-Identifier: GPL-2.0+
*/
-#include <version.h>
-#include <asm/arch/ep93xx.h>
+#include <config.h>
+#include <asm/arch-ep93xx/ep93xx.h>
+
+/*
+/* Configure the SDRAM based on the supplied settings.
+ */
+ep93xx_sdram_config:
+ /* Program the SDRAM device configuration register. */
+ ldr r3, =EP93XX_SDRAMCTRL
+#ifdef CONFIG_EDB93XX_SDCS0
+ str r0, [r3, #0x0010]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ str r0, [r3, #0x0014]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ str r0, [r3, #0x0018]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ str r0, [r3, #0x001c]
+#endif
+
+ /* Set the Initialize and MRS bits (issue continuous NOP commands
+ * (INIT & MRS set))
+ */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_MRS | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_CKE)
+ str r4, [r3, #0x0004]
+
+ /* Delay for 200us. */
+ mov r4, #0x3000
+delay1:
+ subs r4, r4, #1
+ bne delay1
+
+ /* Clear the MRS bit to issue a precharge all. */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_CKE)
+ str r4, [r3, #0x0004]
+
+ /* Temporarily set the refresh timer to 0x10. Make it really low so
+ * that refresh cycles are generated.
+ */
+ ldr r4, =0x10
+ str r4, [r3, #0x0008]
+
+ /* Delay for at least 80 SDRAM clock cycles. */
+ mov r4, #80
+delay2:
+ subs r4, r4, #1
+ bne delay2
+
+ /* Set the refresh timer to the fastest required for any device
+ * that might be used.
+ */
+ ldr r4, =0x01e0
+ str r4, [r3, #0x0008]
+
+ /* Select mode register update mode. */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_CKE | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_MRS)
+ str r4, [r3, #0x0004]
+
+ /* Program the mode register on the SDRAM. */
+ ldr r4, [r2]
+
+ /* Select normal operating mode. */
+ ldr r4, =EP93XX_SDRAMCTRL_GLOBALCFG_CKE
+ str r4, [r3, #0x0004]
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Test to see if the SDRAM has been configured in a usable mode.
+ */
+ep93xx_sdram_test:
+ /* Load the test patterns to be written to SDRAM. */
+ ldr r1, =0xf00dface
+ ldr r2, =0xdeadbeef
+ ldr r3, =0x08675309
+ ldr r4, =0xdeafc0ed
+
+ /* Store the test patterns to SDRAM. */
+ stmia r0, {r1-r4}
+
+ /* Load the test patterns from SDRAM one at a time and compare them
+ * to the actual pattern.
+ */
+ ldr r5, [r0]
+ cmp r5, r1
+ ldreq r5, [r0, #0x0004]
+ cmpeq r5, r2
+ ldreq r5, [r0, #0x0008]
+ cmpeq r5, r3
+ ldreq r5, [r0, #0x000c]
+ cmpeq r5, r4
+
+ /* Return -1 if a mismatch was encountered, 0 otherwise. */
+ mvnne r0, #0xffffffff
+ moveq r0, #0x00000000
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Determine the size of the SDRAM. Use data=address for the scan.
+ *
+ * Input: r0 - Start SDRAM address
+ *
+ * Return: r0 - Single block size
+ * r1 - Valid block mask
+ * r2 - Total block count
+ */
+ep93xx_sdram_size:
+ /* Store zero at offset zero. */
+ str r0, [r0]
+
+ /* Start checking for an alias at 1MB into SDRAM. */
+ ldr r1, =0x00100000
+
+ /* Store the offset at the current offset. */
+check_block_size:
+ str r1, [r0, r1]
+
+ /* Read back from zero. */
+ ldr r2, [r0]
+
+ /* Stop searching of an alias was found. */
+ cmp r1, r2
+ beq found_block_size
+
+ /* Advance to the next power of two boundary. */
+ mov r1, r1, lsl #1
+
+ /* Loop back if the size has not reached 256MB. */
+ cmp r1, #0x10000000
+ bne check_block_size
+
+ /* A full 256MB of memory was found, so return it now. */
+ ldr r0, =0x10000000
+ ldr r1, =0x00000000
+ ldr r2, =0x00000001
+ mov pc, lr
+
+ /* An alias was found. See if the first block is 128MB in size. */
+found_block_size:
+ cmp r1, #0x08000000
+
+ /* The first block is 128MB, so there is no further memory. Return it
+ * now.
+ */
+ ldreq r0, =0x08000000
+ ldreq r1, =0x00000000
+ ldreq r2, =0x00000001
+ moveq pc, lr
+
+ /* Save the block size, set the block address bits to zero, and
+ * initialize the block count to one.
+ */
+ mov r3, r1
+ ldr r4, =0x00000000
+ ldr r5, =0x00000001
+
+ /* Look for additional blocks of memory by searching for non-aliases. */
+find_blocks:
+ /* Store zero back to address zero. It may be overwritten. */
+ str r0, [r0]
+
+ /* Advance to the next power of two boundary. */
+ mov r1, r1, lsl #1
+
+ /* Store the offset at the current offset. */
+ str r1, [r0, r1]
+
+ /* Read back from zero. */
+ ldr r2, [r0]
+
+ /* See if a non-alias was found. */
+ cmp r1, r2
+
+ /* If a non-alias was found, then or in the block address bit and
+ * multiply the block count by two (since there are two unique
+ * blocks, one with this bit zero and one with it one).
+ */
+ orrne r4, r4, r1
+ movne r5, r5, lsl #1
+
+ /* Continue searching if there are more address bits to check. */
+ cmp r1, #0x08000000
+ bne find_blocks
+
+ /* Return the block size, address mask, and count. */
+ mov r0, r3
+ mov r1, r4
+ mov r2, r5
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Compute the starting address of the SDRAM memory blocks.
+ */
+ep93xx_sdram_find_bank:
+ /* Get a pointer to the SDRAM address map. */
+ orr r0, r11, #0x00002100
+
+ /* If there is only one bank, then there is no need to look for it. */
+ cmp r10, #1
+ moveq r1, #0x00000000
+ streq r1, [r0]
+ moveq pc, lr
+
+ /* Create a table mapping the individual address bits used to access the
+ * various banks.
+ */
+ add r1, r0, #0x00000080
+ mov r2, r10, lsr #1
+ mov r3, #0x00100000
+find_bit:
+ tst r9, r3
+ moveq r3, r3, lsl #1
+ beq find_bit
+ str r3, [r1], #4
+ mov r3, r3, lsl #1
+ movs r2, r2, lsr #1
+ bne find_bit
+
+ /* Using the individual address bits, compute the address of each
+ * bank of SDRAM.
+ */
+ add r1, r0, #0x00000080
+ mov r2, r10
+ mov r3, #0x00000000
+find_bank:
+ mov r4, #0x00000000
+ tst r3, #0x00000001
+ ldrne r5, [r1]
+ orrne r4, r4, r5
+ tst r3, #0x00000002
+ ldrne r5, [r1, #4]
+ orrne r4, r4, r5
+ tst r3, #0x00000004
+ ldrne r5, [r1, #8]
+ orrne r4, r4, r5
+ tst r3, #0x00000008
+ ldrne r5, [r1, #12]
+ orrne r4, r4, r5
+ tst r3, #0x00000010
+ ldrne r5, [r1, #16]
+ orrne r4, r4, r5
+ tst r3, #0x00000020
+ ldrne r5, [r1, #20]
+ orrne r4, r4, r5
+ tst r3, #0x00000040
+ ldrne r5, [r1, #24]
+ orrne r4, r4, r5
+ tst r3, #0x00000080
+ ldrne r5, [r1, #28]
+ orrne r4, r4, r5
+ str r4, [r0], #4
+ add r3, r3, #1
+ subs r2, r2, #1
+ bne find_bank
+
+ /* Return to the caller. */
+ mov pc, lr
.globl lowlevel_init
lowlevel_init:
- /* backup return address */
- ldr r1, =SYSCON_SCRATCH0
- str lr, [r1]
- /* Turn on both LEDs */
- bl red_led_on
- bl green_led_on
+ mov r6, lr
+
+ /* Make sure caches are off and invalidated. */
+ ldr r0, =0x00000000
+ mcr p15, 0, r0, c1, c0, 0
+ nop
+ nop
+ nop
+ nop
+ nop
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ bl SetBaud
+ mov r0, #0x42 /* 'B' */
+ bl SendChar
+#endif
+
+ /* Turn off the green LED and turn on the red LED. If the red LED
+ * is left on for too long, the external reset circuit described
+ * by application note AN258 will cause the system to reset.
+ */
+ ldr r1, =EP93XX_LED_DATA
+ ldr r0, [r1]
+ bic r0, r0, #EP93XX_LED_GREEN_ON
+ orr r0, r0, #EP93XX_LED_RED_ON
+ str r0, [r1]
+
+ /* Undo the silly static memory controller programming performed
+ * by the boot rom.
+ */
+ ldr r0, =0x80080000
+ ldr r1, =0x0000fbe0
+ ldr r2, [r0]
+ orr r2, r2, r1
+ str r2, [r0]
+ ldr r2, [r0, #0x04]
+ orr r2, r2, r1
+ str r2, [r0, #0x04]
+ ldr r2, [r0, #0x08]
+ orr r2, r2, r1
+ str r2, [r0, #0x08]
+ ldr r2, [r0, #0x0c]
+ orr r2, r2, r1
+ str r2, [r0, #0x0c]
+ ldr r2, [r0, #0x18]
+ orr r2, r2, r1
+ str r2, [r0, #0x18]
+ ldr r2, [r0, #0x1c]
+ orr r2, r2, r1
+ str r2, [r0, #0x1c]
+
+ /* Set the PLL1 and processor clock. */
+ ldr r0, =SYSCON_BASE
+#ifdef CONFIG_EDB9301
+ /* 332MHz, giving a 166MHz processor clock. */
+ ldr r1, = 0x02b49907
+#else
+
+ /* 400MHz, giving a 200MHz processor clock. */
+ ldr r1, =0x02a4e39e
+
+
+ /* If you are using an Industrial Rated EP93XX then you need to
+ * comment the above ldr line and uncomment this one below here
+ * to enable correct CLKSET1 values of 192Mhz Core and 96Mhz SDRAM
+ */
+
+ /* ldr r1, =0x02a4bb38 This is for Industrial rated Chips */
+
+
+#endif
+ str r1, [r0, #0x0020]
+
+ nop
+ nop
+ nop
+ nop
+ nop
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ mov r0, #0x43 /* 'C' */
+ bl SendChar
+#endif
+
+
+ /* Need to make sure that SDRAM is configured correctly before
+ * coping the code into it.
+ */
+
+#ifdef CONFIG_EDB93XX_SDCS0
+ mov r11, #0xc0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ mov r11, #0xd0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ mov r11, #0xe0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ ldr r0, =EP93XX_SYSCON
+ ldr r0, [r0, #0x009c]
+ ands r0, r0, #0x00000020
+ moveq r11, #0xf0000000
+ movne r11, #0x00000000
+#endif
+ /* Try a 32-bit wide configuration of SDRAM. */
+ ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \
+ EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \
+ EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2)
+
+ ldr r1, =0x00400000
+ orr r2, r11, #0x00008800
+ bl ep93xx_sdram_config
+
+ /* Test the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_test
+ cmp r0, #0x00000000
+ beq ep93xx_sdram_done
+
+ /* Try a 16-bit wide configuration of SDRAM. */
+ ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \
+ EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \
+ EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH)
+ ldr r1, =0x00200000
+ orr r2, r11, #0x00004600
+ bl ep93xx_sdram_config
+
+ /* Test the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_test
+ cmp r0, #0x00000000
+ beq ep93xx_sdram_done
+
+ /* Turn off the red LED. */
+ ldr r0, =EP93XX_LED_DATA
+ ldr r1, [r0]
+ bic r1, r1, #EP93XX_LED_RED_ON
+ str r1, [r0]
+
+ /* There is no SDRAM so flash the green LED. */
+flash_green:
+ orr r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_1:
+ subs r2, r2, #1
+ bne flash_green_delay_1
+ bic r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_2:
+ subs r2, r2, #1
+ bne flash_green_delay_2
+ orr r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_3:
+ subs r2, r2, #1
+ bne flash_green_delay_3
+ bic r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00050000
+flash_green_delay_4:
+ subs r2, r2, #1
+ bne flash_green_delay_4
+ b flash_green
+
+
+ep93xx_sdram_done:
+
+ ldr r1, =EP93XX_LED_DATA
+ ldr r0, [r1]
+ bic r0, r0, #EP93XX_LED_RED_ON
+ str r0, [r1]
+
+ /* Determine the size of the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_size
+
+ /* Save the SDRAM characteristics. */
+ mov r8, r0
+ mov r9, r1
+ mov r10, r2
+ ldr r3, =EP93XX_SDRAMCTRL
+ mul r1, r8, r10
+#ifdef CONFIG_EDB93XX_SDCS0
+ ldr r2, [r0, #0x0010]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ ldr r2, [r0, #0x0014]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ ldr r2, [r0, #0x0018]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ ldr r2, [r0, #0x001c]
+#endif
+ tst r2, #EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH
+ moveq r1, r1, lsr #1
+ cmp r1, #0x02000000
+#if defined(CONFIG_EDB9301)
+ movlt r1, #0x03f0
+ movge r1, #0x01e0
+#else
+ movlt r1, #0x0600
+ movge r1, #0x2f0
+#endif
+ str r1, [r0, #0x0008]
+
+ /* Find the location of each block of SDRAM. */
+ bl ep93xx_sdram_find_bank
+
+ /* Save the memory configuration information. */
+ orr r0, r11, #0x00002000
+ stmia r0, {r8-r11}
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ mov r0, #0x44 /* 'D' */
+ bl SendChar
+#endif
+ mov lr, r6
+ mov pc,lr
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+SetBaud:
+ /* DEVICECFG */
+ ldr r1, =0x80930080
+ ldr r0, [r1]
+ orr r0, r0, #0x040000
+ str r0, [r1]
+
+ ldr r3, =0x808c0000
+
+ /* Clear the status */
+ mov r1, #0
+ str r1, [r3, #0x4]
+
+ /* Set 115200 Baud. */
+ mov r1, #0x03
+ str r1, [r3, #0x10]
+
+ /* Clear the upper baud divisor register */
+ mov r1, #0
+ str r1, [r3, #0xc]
- /* Configure flash wait states before we switch to the PLL */
- bl flash_cfg
+ /* Set the mode to N-8-1 */
+ mov r1, #0x70
+ str r1, [r3, #0x8]
- /* Set up PLL */
- bl pll_cfg
+ /* Enable uart 1 */
+ mov r1, #1
+ str r1, [r3, #0x14]
- /* Turn off the Green LED and leave the Red LED on */
- bl green_led_off
+ /* Return to the caller. */
+ mov pc, lr
- /* Setup SDRAM */
- bl sdram_cfg
- /* Turn on Green LED, Turn off the Red LED */
- bl green_led_on
- bl red_led_off
+.globl SendChar
+SendChar:
+ /* Load the base address to the UART 1 registers. 0x808c0000 */
+ ldr r1, =0x808c0000
- /* FIXME: we use async mode for now */
- mrc p15, 0, r0, c1, c0, 0
- orr r0, r0, #0xc0000000
- mcr p15, 0, r0, c1, c0, 0
+ /* Write the character to UART1. */
+ str r0, [r1]
- /* restore return address */
- ldr r1, =SYSCON_SCRATCH0
- ldr lr, [r1]
+ /* Return to the caller. */
+ mov pc, lr
- mov pc, lr
+#endif
diff --git a/arch/arm/include/asm/arch-ep93xx/ep93xx.h b/arch/arm/include/asm/arch-ep93xx/ep93xx.h
index 9e7f2f3..deef473 100644
--- a/arch/arm/include/asm/arch-ep93xx/ep93xx.h
+++ b/arch/arm/include/asm/arch-ep93xx/ep93xx.h
@@ -1,6 +1,9 @@
/*
* Cirrus Logic EP93xx register definitions.
*
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
* Copyright (C) 2009
* Matthias Kaehlcke <matthias(a)kaehlcke.net>
*
@@ -295,6 +298,53 @@ struct sdram_regs {
#define GLCONFIG_CLKSHUTDOWN (1 << 30)
#define GLCONFIG_CKE (1 << 31)
+#define EP93XX_SDRAMCTRL 0x80060000
+
+#define EP93XX_SDRAMCTRL_GLCONFIG 0x0004
+#define EP93XX_SDRAMCTRL_REFTIMER 0x0008
+#define EP93XX_SDRAMCTRL_BOOTSTS 0x000c
+#define EP93XX_SDRAMCTRL_DEVCFG_0 0x0010
+#define EP93XX_SDRAMCTRL_DEVCFG_1 0x0014
+#define EP93XX_SDRAMCTRL_DEVCFG_2 0x0018
+#define EP93XX_SDRAMCTRL_DEVCFG_3 0x001c
+#define EP93XX_SDRAMCTRL_DEVCFG_AUTOPRE 0x01000000
+
+#define EP93XX_SDRAMCTRL_GLOBALCFG_INIT 0x00000001
+#define EP93XX_SDRAMCTRL_GLOBALCFG_MRS 0x00000002
+#define EP93XX_SDRAMCTRL_GLOBALCFG_SMEMBUSY 0x00000020
+#define EP93XX_SDRAMCTRL_GLOBALCFG_LCR 0x00000040
+#define EP93XX_SDRAMCTRL_GLOBALCFG_REARBEN 0x00000080
+#define EP93XX_SDRAMCTRL_GLOBALCFG_CLKSHUTDOWN 0x40000000
+#define EP93XX_SDRAMCTRL_GLOBALCFG_CKE 0x80000000
+
+#define EP93XX_SDRAMCTRL_REFRESH_MASK 0x0000FFFF
+
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_32 0x00000002
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_16 0x00000001
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_8 0x00000000
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_MASK 0x00000003
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_MEDIA 0x00000004
+
+#define EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH 0x00000004
+#define EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT 0x00000008
+#define EP93XX_SDRAMCTRL_DEVCFG_SROM512 0x00000010
+#define EP93XX_SDRAMCTRL_DEVCFG_SROMLL 0x00000020
+#define EP93XX_SDRAMCTRL_DEVCFG_2KPAGE 0x00000040
+#define EP93XX_SDRAMCTRL_DEVCFG_SFCONFIGADDR 0x00000080
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_MASK 0x00070000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 0x00010000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_3 0x00020000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_4 0x00030000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_5 0x00040000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_6 0x00050000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_7 0x00060000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_8 0x00070000
+#define EP93XX_SDRAMCTRL_DEVCFG_WBL 0x00080000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_MASK 0x00300000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2 0x00200000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_3 0x00300000
+#define EP93XX_SDRAMCTRL_DEVCFG_AUTOPRECHARGE 0x01000000
+
/*
* 0x80070000 - 0x8007FFFF: Reserved
*/
@@ -445,6 +495,14 @@ struct gpio_regs {
};
#endif
+#define EP93XX_LED_DATA 0x80840020
+#define EP93XX_LED_GREEN_ON 0x0001
+#define EP93XX_LED_RED_ON 0x0002
+
+#define EP93XX_LED_DDR 0x80840024
+#define EP93XX_LED_GREEN_ENABLE 0x0001
+#define EP93XX_LED_RED_ENABLE 0x00020000
+
/*
* 0x80850000 - 0x8087FFFF: Reserved
*/
@@ -519,6 +577,9 @@ struct gpio_regs {
#define SYSCON_OFFSET 0x930000
#define SYSCON_BASE (EP93XX_APB_BASE | SYSCON_OFFSET)
+/* Security */
+#define SECURITY_EXTENSIONID 0x80832714
+
#ifndef __ASSEMBLY__
struct syscon_regs {
uint32_t pwrsts;
@@ -554,6 +615,7 @@ struct syscon_regs {
#endif
#define SYSCON_PWRCNT_UART_BAUD (1 << 29)
+#define SYSCON_PWRCNT_USH_EN (1 << 28)
#define SYSCON_CLKSET_PLL_X2IPD_SHIFT 0
#define SYSCON_CLKSET_PLL_X2FBD2_SHIFT 5
diff --git a/board/cirrus/edb93xx/Makefile b/board/cirrus/edb93xx/Makefile
new file mode 100644
index 0000000..fb8d3e0
--- /dev/null
+++ b/board/cirrus/edb93xx/Makefile
@@ -0,0 +1,37 @@
+#
+# (C) Copyright 2013
+# Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+#
+# (C) Copyright 2003-2006
+# Wolfgang Denk, DENX Software Engineering, wd <at> denx.de.
+#
+# * SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).o
+
+COBJS-y := edb93xx.o
+
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS-y))
+SOBJS := $(addprefix $(obj),$(SOBJS-y))
+
+$(LIB): $(obj).depend $(OBJS) $(SOBJS)
+ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+clean:
+ rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+ rm -f $(LIB) core *.bak .depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/cirrus/edb93xx/edb93xx.c b/board/cirrus/edb93xx/edb93xx.c
new file mode 100644
index 0000000..2e0165c
--- /dev/null
+++ b/board/cirrus/edb93xx/edb93xx.c
@@ -0,0 +1,340 @@
+/*
+ * Board initialization for EP93xx
+ *
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Copyright (C) 2009
+ * Matthias Kaehlcke <matthias <at> kaehlcke.net>
+ *
+ * (C) Copyright 2002 2003
+ * Network Audio Technologies, Inc. <www.netaudiotech.com>
+ * Adam Bezanson <bezanson <at> netaudiotech.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm/arch/ep93xx.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * usb_div: 4, nbyp2: 1, pll2_en: 1
+ * pll2_x1: 368640000.000000, pll2_x2ip: 15360000.000000,
+ * pll2_x2: 384000000.000000, pll2_out: 192000000.000000
+ */
+#define CLKSET2_VAL (23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+ 24 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+ 24 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+ 1 << SYSCON_CLKSET_PLL_PS_SHIFT | \
+ SYSCON_CLKSET2_PLL2_EN | \
+ SYSCON_CLKSET2_NBYP2 | \
+ 3 << SYSCON_CLKSET2_USB_DIV_SHIFT)
+
+#define SMC_BCR6_VALUE (2 << SMC_BCR_IDCY_SHIFT | 5 << SMC_BCR_WST1_SHIFT | \
+ SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \
+ 1 << SMC_BCR_MW_SHIFT)
+
+/* delay execution before timers are initialized */
+static inline void early_udelay(uint32_t usecs)
+{
+ /* loop takes 4 cycles at 5.0ns (fastest case, running at 200MHz) */
+ register uint32_t loops = (usecs * 1000) / 20;
+
+ __asm__ volatile ("1:\n"
+ "subs %0, %1, #1\n"
+ "bne 1b" : "=r" (loops) : "0" (loops));
+}
+
+#ifndef CONFIG_EP93XX_NO_FLASH_CFG
+static void flash_cfg(void)
+{
+ struct smc_regs *smc = (struct smc_regs *)SMC_BASE;
+
+ writel(SMC_BCR6_VALUE, &smc->bcr6);
+}
+#else
+#define flash_cfg()
+#endif
+
+int board_init(void)
+{
+ /*
+ * Setup PLL2, PPL1 has been set during lowlevel init
+ */
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ writel(CLKSET2_VAL, &syscon->clkset2);
+
+ /*
+ * the user's guide recommends to wait at least 1 ms for PLL2 to
+ * stabilize
+ */
+ early_udelay(1000);
+
+ /* Go to Async mode */
+ __asm__ volatile ("mrc p15, 0, r0, c1, c0, 0");
+ __asm__ volatile ("orr r0, r0, #0xc0000000");
+ __asm__ volatile ("mcr p15, 0, r0, c1, c0, 0");
+
+ icache_enable();
+
+#ifdef USE_920T_MMU
+ dcache_enable();
+#endif
+
+ /* Machine number, as defined in linux/arch/arm/tools/mach-types */
+ gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
+
+ /* adress of boot parameters */
+ gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
+
+ /* We have a console */
+ gd->have_console = 1;
+
+ enable_interrupts();
+
+ flash_cfg();
+
+ green_led_on();
+ red_led_off();
+
+ return 0;
+}
+
+int board_early_init_f(void)
+{
+ /*
+ * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
+ * 14.7456/2 MHz
+ */
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ writel(SYSCON_PWRCNT_UART_BAUD, &syscon->pwrcnt);
+ return 0;
+}
+
+int board_eth_init(bd_t *bd)
+{
+ return ep93xx_eth_initialize(0, MAC_BASE);
+}
+
+/* called in board_init_f (before relocation) */
+static unsigned dram_init_banksize_int(int print)
+{
+ /*
+ * Collect information of banks has been filled during lowlevel
+ * initialization
+ */
+
+ unsigned i;
+ unsigned dram_bank_base[8];
+ unsigned dram_total = 0;
+ unsigned dram_base_addr = PHYS_SDRAM_1;
+ unsigned dram_bank_size = *(unsigned *)(dram_base_addr | 0x2000);
+ /* unsigned dram_addr_mask = *(unsigned *)(dram_base_addr | 0x2004); */
+ unsigned dram_bank_cnt = *(unsigned *)(dram_base_addr | 0x2008);
+
+ for (i = 0; i < dram_bank_cnt; i++)
+ dram_bank_base[i] = dram_base_addr |
+ *(unsigned *)(dram_base_addr | (0x2100 + i*4));
+
+ for (i = 0; i < dram_bank_cnt; i++) {
+ gd->bd->bi_dram[i].start = dram_bank_base[i];
+ gd->bd->bi_dram[i].size = dram_bank_size;
+ dram_total += dram_bank_size;
+ }
+ for (; i < CONFIG_NR_DRAM_BANKS; i++) {
+ gd->bd->bi_dram[i].start = 0;
+ gd->bd->bi_dram[i].size = 0;
+ }
+
+ if (print) {
+ printf("DRAM total %u banks:\n", dram_bank_cnt);
+ printf("bank base-address size\n");
+
+ if (dram_bank_cnt > CONFIG_NR_DRAM_BANKS) {
+ printf("WARNING! UBoot was configured for %u banks,\n"
+ "but %u has been found. Supressing extra memory banks\n",
+ CONFIG_NR_DRAM_BANKS, dram_bank_cnt);
+ dram_bank_cnt = CONFIG_NR_DRAM_BANKS;
+ }
+
+ for (i = 0; i < dram_bank_cnt; i++) {
+ printf(" %u %08x %08x\n",
+ i, dram_bank_base[i], dram_bank_size);
+ }
+ printf(" ------------------------------------------\n"
+ "Total %9d\n\n",
+ dram_total);
+ }
+
+ return dram_total;
+}
+
+void dram_init_banksize(void)
+{
+ dram_init_banksize_int(0);
+}
+
+/* called in board_init_f (before relocation) */
+int dram_init(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned sec_id = readl(SECURITY_EXTENSIONID);
+ unsigned chip_id = readl(&syscon->chipid);
+
+ printf("CPU: Cirrus Logic ");
+ switch (sec_id & 0x000001FE) {
+ case 0x00000008:
+ printf("EP9301");
+ break;
+ case 0x00000004:
+ printf("EP9307");
+ break;
+ case 0x00000002:
+ printf("EP931x");
+ break;
+ case 0x00000000:
+ printf("EP9315");
+ break;
+ default:
+ printf("<unknown>");
+ break;
+ }
+
+ printf(" - Rev. ");
+ switch (chip_id & 0xF0000000) {
+ case 0x00000000:
+ printf("A");
+ break;
+ case 0x10000000:
+ printf("B");
+ break;
+ case 0x20000000:
+ printf("C");
+ break;
+ case 0x30000000:
+ printf("D0");
+ break;
+ case 0x40000000:
+ printf("D1");
+ break;
+ case 0x50000000:
+ printf("E0");
+ break;
+ case 0x60000000:
+ printf("E1");
+ break;
+ case 0x70000000:
+ printf("E2");
+ break;
+ default:
+ printf("?");
+ break;
+ }
+ printf(" (SecExtID=%.8x/ChipID=%.8x)\n", sec_id, chip_id);
+
+ gd->ram_size = dram_init_banksize_int(1);
+ return 0;
+}
+
+
+#ifdef CONFIG_EP93XX_SPI
+#include <spi.h>
+
+/*
+ * EGIO0-EGIPO7 -> port A
+ * EGIO8-EGIP15 -> port B
+ */
+
+static void ep93xx_set_epgio(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->padr) | (1<<num), ®s->padr);
+ else
+ writel(readl(®s->pbdr) | (1<<(num-8)), ®s->pbdr);
+}
+
+static void ep93xx_clear_epgio(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->padr) & (~(1<<num)), ®s->padr);
+ else
+ writel(readl(®s->pbdr) & (~(1<<(num-8))), ®s->pbdr);
+}
+
+static void ep93xx_dir_epgio_out(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->paddr) | (1<<num), ®s->paddr);
+ else
+ writel(readl(®s->pbddr) | (1<<(num-8)), ®s->pbddr);
+}
+
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+ if (bus == 0 && cs < 16)
+ return 1;
+
+ return 0;
+}
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+ ep93xx_clear_epgio(slave->cs);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+ ep93xx_set_epgio(slave->cs);
+}
+
+#ifdef CONFIG_MMC_SPI
+#include <mmc.h>
+
+#ifndef CONFIG_MMC_SPI_CS_EPGIO
+# define CONFIG_MMC_SPI_CS_EPGIO 4
+#endif
+
+#ifndef CONFIG_MMC_SPI_SPEED
+# define CONFIG_MMC_SPI_SPEED 25000000
+#endif
+
+#ifndef CONFIG_MMC_SPI_MODE
+# define CONFIG_MMC_SPI_MODE SPI_MODE_0
+#endif
+
+int board_mmc_init(bd_t *bis)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+
+ ep93xx_set_epgio(CONFIG_MMC_SPI_CS_EPGIO);
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_CS_EPGIO);
+
+#ifdef CONFIG_MMC_SPI_POWER_EGPIO
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_POWER_EGPIO);
+ ep93xx_set_epgio(CONFIG_MMC_SPI_POWER_EGPIO);
+#elif defined(CONFIG_MMC_SPI_NPOWER_EGPIO)
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_NPOWER_EGPIO);
+ ep93xx_clear_epgio(CONFIG_MMC_SPI_NPOWER_EGPIO);
+#endif
+ struct mmc *mmc = mmc_spi_init(0, CONFIG_MMC_SPI_CS_EPGIO,
+ CONFIG_MMC_SPI_SPEED, CONFIG_MMC_SPI_MODE);
+
+ if (!mmc) {
+ printf("Failed to create MMC Device\n");
+ return 1;
+ }
+ mmc_init(mmc);
+ return 0;
+}
+
+
+#endif /* CONFIG_MMC_SPI */
+#endif /* CONFIG_EP93XX_SPI */
diff --git a/board/cirrus/edb93xx/u-boot.lds b/board/cirrus/edb93xx/u-boot.lds
new file mode 100644
index 0000000..e61aa36
--- /dev/null
+++ b/board/cirrus/edb93xx/u-boot.lds
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Copyright (c) 2004-2008 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <garyj(a)denx.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text : {
+ *(.__image_copy_start)
+ arch/arm/cpu/arm920t/start.o (.text*)
+ . = 0x1000;
+
+ LONG(0x53555243)
+ *(.text*)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+ . = ALIGN(4);
+ .data : {
+ *(.data*)
+ }
+
+ . = ALIGN(4);
+
+ . = .;
+
+ . = ALIGN(4);
+ .u_boot_list : {
+ KEEP(*(SORT(.u_boot_list*)));
+ }
+
+ . = ALIGN(4);
+
+ .image_copy_end :
+ {
+ *(.__image_copy_end)
+ }
+
+ .rel_dyn_start :
+ {
+ *(.__rel_dyn_start)
+ }
+
+ .rel.dyn : {
+ *(.rel*)
+ }
+
+ .rel_dyn_end :
+ {
+ *(.__rel_dyn_end)
+ }
+
+ _end = .;
+
+ /*
+ * Deprecated: this MMU section is used by pxa at present but
+ * should not be used by new boards/CPUs.
+ */
+ . = ALIGN(4096);
+ .mmutable : {
+ *(.mmutable)
+ }
+
+/*
+ * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c
+ * __bss_base and __bss_limit are for linker only (overlay ordering)
+ */
+
+ .bss_start __rel_dyn_start (OVERLAY) : {
+ KEEP(*(.__bss_start));
+ __bss_base = .;
+ }
+
+ .bss __bss_base (OVERLAY) : {
+ *(.bss*)
+ . = ALIGN(4);
+ __bss_limit = .;
+ }
+
+ .bss_end __bss_limit (OVERLAY) : {
+ KEEP(*(.__bss_end));
+ }
+
+ /DISCARD/ : { *(.dynsym) }
+ /DISCARD/ : { *(.dynstr*) }
+ /DISCARD/ : { *(.dynamic*) }
+ /DISCARD/ : { *(.plt*) }
+ /DISCARD/ : { *(.interp*) }
+ /DISCARD/ : { *(.gnu*) }
+}
diff --git a/boards.cfg b/boards.cfg
index dbd8479..ae4bf6d 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -72,6 +72,7 @@ Active arm arm920t ks8695 - -
Active arm arm920t s3c24x0 friendlyarm mini2440 mini2440 - Gabriel Huau <contact(a)huau-gabriel.fr>
Active arm arm920t s3c24x0 mpl vcma9 VCMA9 - David Müller <d.mueller(a)elsoft.ch>
Active arm arm920t s3c24x0 samsung - smdk2410 - David Müller <d.mueller(a)elsoft.ch>
+Active arm arm920t ep93xx cirrus edb93xx edb9315a edb93xx:MK_edb9315a Sergey Kostanbaev <sergey.kostanbaev(a)fairwaves.ru>
Active arm arm926ejs - armltd integrator integratorap_cm926ejs integratorap:CM926EJ_S Linus Walleij <linus.walleij(a)linaro.org>
Active arm arm926ejs - armltd integrator integratorcp_cm926ejs integratorcp:CM924EJ_S Linus Walleij <linus.walleij(a)linaro.org>
Active arm arm926ejs armada100 Marvell - aspenite - Prafulla Wadaskar <prafulla(a)marvell.com>
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 91d24ce..51becae 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -12,6 +12,7 @@ LIB := $(obj)libspi.o
# There are many options which enable SPI, so make this library available
COBJS-y += spi.o
+COBJS-$(CONFIG_EP93XX_SPI) += ep93xx_spi.o
COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o
COBJS-$(CONFIG_ANDES_SPI) += andes_spi.o
COBJS-$(CONFIG_ARMADA100_SPI) += armada100_spi.o
diff --git a/drivers/spi/ep93xx_spi.c b/drivers/spi/ep93xx_spi.c
new file mode 100644
index 0000000..235557e
--- /dev/null
+++ b/drivers/spi/ep93xx_spi.c
@@ -0,0 +1,274 @@
+/*
+ * SPI Driver for EP93xx
+ *
+ * Copyright (C) 2013 Sergey Kostanabev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Inspired form linux kernel driver and atmel uboot driver
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <spi.h>
+#include <malloc.h>
+
+#include <asm/io.h>
+
+#include <asm/arch/ep93xx.h>
+
+
+#define BIT(x) (1<<(x))
+#define SSPBASE SPI_BASE
+
+#define SSPCR0 0x0000
+#define SSPCR0_MODE_SHIFT 6
+#define SSPCR0_SCR_SHIFT 8
+#define SSPCR0_SPH BIT(7)
+#define SSPCR0_SPO BIT(6)
+#define SSPCR0_FRF_SPI 0
+#define SSPCR0_DSS_8BIT 7
+
+#define SSPCR1 0x0004
+#define SSPCR1_RIE BIT(0)
+#define SSPCR1_TIE BIT(1)
+#define SSPCR1_RORIE BIT(2)
+#define SSPCR1_LBM BIT(3)
+#define SSPCR1_SSE BIT(4)
+#define SSPCR1_MS BIT(5)
+#define SSPCR1_SOD BIT(6)
+
+#define SSPDR 0x0008
+
+#define SSPSR 0x000c
+#define SSPSR_TFE BIT(0)
+#define SSPSR_TNF BIT(1)
+#define SSPSR_RNE BIT(2)
+#define SSPSR_RFF BIT(3)
+#define SSPSR_BSY BIT(4)
+#define SSPCPSR 0x0010
+
+#define SSPIIR 0x0014
+#define SSPIIR_RIS BIT(0)
+#define SSPIIR_TIS BIT(1)
+#define SSPIIR_RORIS BIT(2)
+#define SSPICR SSPIIR
+
+#define SSPCLOCK 14745600
+#define SSP_MAX_RATE (SSPCLOCK / 2)
+#define SSP_MIN_RATE (SSPCLOCK / (254 * 256))
+
+/* timeout in milliseconds */
+#define SPI_TIMEOUT 5
+/* maximum depth of RX/TX FIFO */
+#define SPI_FIFO_SIZE 8
+
+struct ep93xx_spi_slave {
+ struct spi_slave slave;
+
+ unsigned sspcr0;
+ unsigned sspcpsr;
+};
+
+static inline struct ep93xx_spi_slave *to_ep93xx_spi(struct spi_slave *slave)
+{
+ return container_of(slave, struct ep93xx_spi_slave, slave);
+}
+
+void spi_init()
+{
+}
+
+static inline void ep93xx_spi_write_u8(u16 reg, u8 value)
+{
+ writel(value, (unsigned int *)(SSPBASE + reg));
+}
+
+static inline u8 ep93xx_spi_read_u8(u16 reg)
+{
+ return readl((unsigned int *)(SSPBASE + reg));
+}
+
+static inline void ep93xx_spi_write_u16(u16 reg, u16 value)
+{
+ writel(value, (unsigned int *)(SSPBASE + reg));
+}
+
+static inline u16 ep93xx_spi_read_u16(u16 reg)
+{
+ return (u16)readl((unsigned int *)(SSPBASE + reg));
+}
+
+static int ep93xx_spi_init_hw(unsigned int rate, unsigned int mode,
+ struct ep93xx_spi_slave *slave)
+{
+ unsigned cpsr, scr;
+
+ if (rate > SSP_MAX_RATE)
+ rate = SSP_MAX_RATE;
+
+ if (rate < SSP_MIN_RATE)
+ return -1;
+
+ /* Calculate divisors so that we can get speed according the
+ * following formula:
+ * rate = spi_clock_rate / (cpsr * (1 + scr))
+ *
+ * cpsr must be even number and starts from 2, scr can be any number
+ * between 0 and 255.
+ */
+ for (cpsr = 2; cpsr <= 254; cpsr += 2) {
+ for (scr = 0; scr <= 255; scr++) {
+ if ((SSPCLOCK / (cpsr * (scr + 1))) <= rate) {
+ /* Set CHPA and CPOL, SPI format and 8bit */
+ unsigned sspcr0 = (scr << SSPCR0_SCR_SHIFT) |
+ SSPCR0_FRF_SPI | SSPCR0_DSS_8BIT;
+ if (mode & SPI_CPHA)
+ sspcr0 |= SSPCR0_SPH;
+ if (mode & SPI_CPOL)
+ sspcr0 |= SSPCR0_SPO;
+
+ slave->sspcr0 = sspcr0;
+ slave->sspcpsr = cpsr;
+ return 0;
+ }
+ }
+ }
+
+ return -1;
+}
+
+void spi_set_speed(struct spi_slave *slave, unsigned int hz)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ unsigned int mode = 0;
+ if (as->sspcr0 & SSPCR0_SPH)
+ mode |= SPI_CPHA;
+ if (as->sspcr0 & SSPCR0_SPO)
+ mode |= SPI_CPOL;
+
+ ep93xx_spi_init_hw(hz, mode, as);
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int mode)
+{
+ struct ep93xx_spi_slave *as;
+
+ if (!spi_cs_is_valid(bus, cs))
+ return NULL;
+
+ as = spi_alloc_slave(struct ep93xx_spi_slave, bus, cs);
+ if (!as)
+ return NULL;
+
+ if (ep93xx_spi_init_hw(max_hz, mode, as)) {
+ free(as);
+ return NULL;
+ }
+
+ return &as->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ free(as);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ /* Enable the SPI hardware */
+ ep93xx_spi_write_u8(SSPCR1, SSPCR1_SSE);
+
+
+ ep93xx_spi_write_u8(SSPCPSR, as->sspcpsr);
+ ep93xx_spi_write_u16(SSPCR0, as->sspcr0);
+
+ debug("Select CS:%d SSPCPSR=%02x SSPCR0=%04x\n",
+ slave->cs, as->sspcpsr, as->sspcr0);
+ return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+ /* Disable the SPI hardware */
+ ep93xx_spi_write_u8(SSPCR1, 0);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+ const void *dout, void *din, unsigned long flags)
+{
+ unsigned int len_tx;
+ unsigned int len_rx;
+ unsigned int len;
+ u32 status;
+ const u8 *txp = dout;
+ u8 *rxp = din;
+ u8 value;
+
+ debug("spi_xfer: slave %u:%u dout %p din %p bitlen %u\n",
+ slave->bus, slave->cs, (uint *)dout, (uint *)din, bitlen);
+
+
+ if (bitlen == 0)
+ /* Finish any previously submitted transfers */
+ goto out;
+
+ if (bitlen % 8) {
+ /* Errors always terminate an ongoing transfer */
+ flags |= SPI_XFER_END;
+ goto out;
+ }
+
+ len = bitlen / 8;
+
+
+ if (flags & SPI_XFER_BEGIN) {
+ /* Empty RX FIFO */
+ while ((ep93xx_spi_read_u8(SSPSR) & SSPSR_RNE))
+ ep93xx_spi_read_u8(SSPDR);
+
+ spi_cs_activate(slave);
+ }
+
+ for (len_tx = 0, len_rx = 0; len_rx < len; ) {
+ status = ep93xx_spi_read_u8(SSPSR);
+
+ if ((len_tx < len) && (status & SSPSR_TNF)) {
+ if (txp)
+ value = *txp++;
+ else
+ value = 0xff;
+
+ ep93xx_spi_write_u8(SSPDR, value);
+ len_tx++;
+ }
+
+ if (status & SSPSR_RNE) {
+ value = ep93xx_spi_read_u8(SSPDR);
+
+ if (rxp)
+ *rxp++ = value;
+ len_rx++;
+ }
+ }
+
+out:
+ if (flags & SPI_XFER_END) {
+ /*
+ * Wait until the transfer is completely done before
+ * we deactivate CS.
+ */
+ do {
+ status = ep93xx_spi_read_u8(SSPSR);
+ } while (status & SSPSR_BSY);
+
+ spi_cs_deactivate(slave);
+ }
+
+ return 0;
+}
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index ff6c80e..d1209ee 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -12,6 +12,7 @@ LIB := $(obj)libusb_host.o
# ohci
COBJS-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o
COBJS-$(CONFIG_USB_ATMEL) += ohci-at91.o
+COBJS-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
COBJS-$(CONFIG_USB_OHCI_DA8XX) += ohci-da8xx.o
COBJS-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
COBJS-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
new file mode 100644
index 0000000..8fb4aba
--- /dev/null
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2013
+ * Sergey Kostanbaev < sergey.kostanbaev <at> fairwaves.ru >
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+
+#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
+#include <asm/io.h>
+#include <asm/arch/ep93xx.h>
+
+int usb_cpu_init(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned long pwr = readl(&syscon->pwrcnt);
+ writel(pwr | SYSCON_PWRCNT_USH_EN, &syscon->pwrcnt);
+
+ return 0;
+}
+
+int usb_cpu_stop(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned long pwr = readl(&syscon->pwrcnt);
+ writel(pwr & ~SYSCON_PWRCNT_USH_EN, &syscon->pwrcnt);
+
+ return 0;
+}
+
+int usb_cpu_init_fail(void)
+{
+ return usb_cpu_stop();
+}
+
+#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
diff --git a/include/configs/edb93xx.h b/include/configs/edb93xx.h
new file mode 100644
index 0000000..c122c22
--- /dev/null
+++ b/include/configs/edb93xx.h
@@ -0,0 +1,291 @@
+/*
+ * U-boot - Configuration file for Cirrus Logic EDB93xx boards
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#ifdef CONFIG_MK_edb9301
+#define CONFIG_EDB9301
+#elif defined(CONFIG_MK_edb9302)
+#define CONFIG_EDB9302
+#elif defined(CONFIG_MK_edb9302a)
+#define CONFIG_EDB9302A
+#elif defined(CONFIG_MK_edb9307)
+#define CONFIG_EDB9307
+#elif defined(CONFIG_MK_edb9307a)
+#define CONFIG_EDB9307A
+#elif defined(CONFIG_MK_edb9312)
+#define CONFIG_EDB9312
+#elif defined(CONFIG_MK_edb9315)
+#define CONFIG_EDB9315
+#elif defined(CONFIG_MK_edb9315a)
+#define CONFIG_EDB9315A
+#else
+#error "no board defined"
+#endif
+
+/* Initial environment and monitor configuration options. */
+#define CONFIG_BOOTDELAY 2
+#define CONFIG_CMDLINE_TAG 1
+#define CONFIG_INITRD_TAG 1
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_BOOTARGS "root=/dev/nfs console=ttyAM0,115200 ip=dhcp"
+#define CONFIG_BOOTFILE "edb93xx.img"
+
+#define CONFIG_SYS_HUSH_PARSER 1
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+
+#define CONFIG_SYS_LDSCRIPT "board/cirrus/edb93xx/u-boot.lds"
+
+
+#ifdef CONFIG_EDB9301
+#define CONFIG_EP9301
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9301
+#define CONFIG_SYS_PROMPT "EDB9301> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9302)
+#define CONFIG_EP9302
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9302
+#define CONFIG_SYS_PROMPT "EDB9302> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9302A)
+#define CONFIG_EP9302
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9302A
+#define CONFIG_SYS_PROMPT "EDB9302A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9307)
+#define CONFIG_EP9307
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9307
+#define CONFIG_SYS_PROMPT "EDB9307> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9307A)
+#define CONFIG_EP9307
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9307A
+#define CONFIG_SYS_PROMPT "EDB9307A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9312)
+#define CONFIG_EP9312
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9312
+#define CONFIG_SYS_PROMPT "EDB9312> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9315)
+#define CONFIG_EP9315
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9315
+#define CONFIG_SYS_PROMPT "EDB9315> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9315A)
+#define CONFIG_EP9315
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9315A
+#define CONFIG_SYS_PROMPT "EDB9315A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#else
+#error "no board defined"
+#endif
+
+/* High-level configuration options */
+#define CONFIG_ARM920T 1 /* This is an ARM920T core... */
+#define CONFIG_EP93XX 1 /* in a Cirrus Logic 93xx SoC */
+
+#define CONFIG_SYS_CLK_FREQ 14745600 /* EP93xx has a 14.7456 clock */
+#define CONFIG_SYS_HZ 1000 /* decr freq: 1 ms ticks */
+#undef CONFIG_USE_IRQ /* Don't need IRQ/FIQ */
+
+/* Monitor configuration */
+#include <config_cmd_default.h>
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_SETGETDCR
+#undef CONFIG_CMD_XIMG
+
+#undef CONFIG_CMD_DATE
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_JFFS2
+
+#define CONFIG_SYS_LONGHELP /* Enable "long" help in mon */
+#define CONFIG_SYS_CBSIZE 1024 /* Console I/O buffer size */
+/* Print buffer size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
+/* Boot argument buffer size */
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
+#define CONFIG_SYS_MAXARGS 16 /* Max number of command args */
+
+/* Serial port hardware configuration */
+#define CONFIG_PL010_SERIAL
+#define CONFIG_CONS_INDEX 0
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {9600, 19200, 38400, 57600, \
+ 115200, 230400}
+#define CONFIG_SYS_SERIAL0 0x808C0000
+#define CONFIG_SYS_SERIAL1 0x808D0000
+/*#define CONFIG_PL01x_PORTS {(void *)CONFIG_SYS_SERIAL0, \
+ (void *)CONFIG_SYS_SERIAL1} */
+
+#define CONFIG_PL01x_PORTS {(void *)CONFIG_SYS_SERIAL0}
+
+/* Status LED */
+#define CONFIG_STATUS_LED 1 /* Status LED enabled */
+#define CONFIG_BOARD_SPECIFIC_LED 1
+#define STATUS_LED_GREEN 0
+#define STATUS_LED_RED 1
+/* Green */
+#define STATUS_LED_BIT STATUS_LED_GREEN
+#define STATUS_LED_STATE STATUS_LED_ON
+#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
+/* Red */
+#define STATUS_LED_BIT1 STATUS_LED_RED
+#define STATUS_LED_STATE1 STATUS_LED_OFF
+#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2)
+/* Optional value */
+#define STATUS_LED_BOOT STATUS_LED_BIT
+
+/* Network hardware configuration */
+#define CONFIG_DRIVER_EP93XX_MAC
+#define CONFIG_MII_SUPPRESS_PREAMBLE
+#define CONFIG_MII
+#define CONFIG_PHY_ADDR 1
+#define CONFIG_NET_MULTI
+#undef CONFIG_NETCONSOLE
+
+/* SDRAM configuration */
+#if defined(CONFIG_EDB9301) || defined(CONFIG_EDB9302) || \
+ defined(CONFIG_EDB9307) || defined CONFIG_EDB9312 || \
+ defined(CONFIG_EDB9315)
+/*
+ * EDB9301/2 has 4 banks of SDRAM consisting of 1x Samsung K4S561632E-TC75
+ * 256 Mbit SDRAM on a 16-bit data bus, for a total of 32MB of SDRAM. We set
+ * the SROMLL bit on the processor, resulting in this non-contiguous memory map.
+ *
+ * The EDB9307, EDB9312, and EDB9315 have 2 banks of SDRAM consisting of
+ * 2x Samsung K4S561632E-TC75 256 Mbit on a 32-bit data bus, for a total of
+ * 64 MB of SDRAM.
+ */
+
+#define CONFIG_EDB93XX_SDCS3
+
+#elif defined(CONFIG_EDB9302A) || \
+ defined(CONFIG_EDB9307A) || defined(CONFIG_EDB9315A)
+/*
+ * EDB9302a has 4 banks of SDRAM consisting of 1x Samsung K4S561632E-TC75
+ * 256 Mbit SDRAM on a 16-bit data bus, for a total of 32MB of SDRAM. We set
+ * the SROMLL bit on the processor, resulting in this non-contiguous memory map.
+ *
+ * The EDB9307A and EDB9315A have 2 banks of SDRAM consisting of 2x Samsung
+ * K4S561632E-TC75 256 Mbit on a 32-bit data bus, for a total of 64 MB of SDRAM.
+ */
+#define CONFIG_EDB93XX_SDCS0
+
+#else
+#error "no SDCS configuration for this board"
+#endif
+
+
+#if defined(CONFIG_EDB93XX_SDCS3)
+#define CONFIG_SYS_LOAD_ADDR 0x01000000 /* Default load address */
+#define PHYS_SDRAM_1 0x00000000
+#elif defined(CONFIG_EDB93XX_SDCS0)
+#define CONFIG_SYS_LOAD_ADDR 0xc1000000 /* Default load address */
+#define PHYS_SDRAM_1 0xc0000000
+#endif
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_NR_DRAM_BANKS 8
+
+#define CONFIG_SYS_INIT_SP_ADDR \
+ (CONFIG_SYS_SDRAM_BASE + 32*1024 - GENERATED_GBL_DATA_SIZE)
+
+
+/* Must match kernel config */
+#define LINUX_BOOT_PARAM_ADDR (PHYS_SDRAM_1 + 0x100)
+
+/* Run-time memory allocatons */
+#define CONFIG_SYS_GBL_DATA_SIZE 128
+#define CONFIG_STACKSIZE (128 * 1024)
+
+#if defined(CONFIG_USE_IRQ)
+#define CONFIG_STACKSIZE_IRQ (4 * 1024)
+#define CONFIG_STACKSIZE_FIQ (4 * 1024)
+#endif
+
+#define CONFIG_SYS_MALLOC_LEN (512 * 1024)
+
+/* -----------------------------------------------------------------------------
+ * FLASH and environment organization
+ *
+ * The EDB9301, EDB9302(a), EDB9307a, EDB9315a have 1 bank of flash memory at
+ * 0x60000000 consisting of 1x Intel TE28F128J3C-150 128 Mbit flash on a 16-bit
+ * data bus, for a total of 16 MB of CFI-compatible flash.
+ *
+ * The EDB9307, EDB9312, and EDB9315 have 1 bank of flash memory at
+ * 0x60000000 consisting of 2x Micron MT28F128J3-12 128 Mbit flash on a 32-bit
+ * data bus, for a total of 32 MB of CFI-compatible flash.
+ *
+ *
+ * EDB9301/02(a)7a/15a EDB9307/12/15
+ * 0x60000000 - 0x0003FFFF u-boot u-boot
+ * 0x60040000 - 0x0005FFFF environment #1 environment #1
+ * 0x60060000 - 0x0007FFFF environment #2 environment #1 (continued)
+ * 0x60080000 - 0x0009FFFF unused environment #2
+ * 0x600A0000 - 0x000BFFFF unused environment #2 (continued)
+ * 0x600C0000 - 0x00FFFFFF unused unused
+ * 0x61000000 - 0x01FFFFFF not present unused
+ */
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
+
+
+#define CONFIG_SYS_FLASH_PROTECTION
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT (256+8)
+
+#define CONFIG_SYS_TEXT_BASE 0x60000000
+#define PHYS_FLASH_1 CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_FLASH_BASE CONFIG_SYS_TEXT_BASE
+
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
+#define CONFIG_SYS_MONITOR_LEN (256 * 1024)
+
+#define CONFIG_ENV_OVERWRITE /* Vendor params unprotected */
+#define CONFIG_ENV_IS_IN_FLASH
+
+#define CONFIG_ENV_ADDR 0x60040000
+#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE)
+
+#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
+#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
+
+/* Define to enable MMC on SPI support */
+/* #define CONFIG_EP93XX_SPI_MMC */
+
+#ifdef CONFIG_EP93XX_SPI_MMC
+#define CONFIG_EP93XX_SPI
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC_SPI
+#define CONFIG_CMD_MMC
+#define CONFIG_MMC_SPI_NPOWER_EGPIO 9
+#endif
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_USB_OHCI_EP93XX
+#define CONFIG_SYS_USB_OHCI_CPU_INIT
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 3
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME "ep93xx-ohci"
+#define CONFIG_SYS_USB_OHCI_REGS_BASE 0x80020000
+
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
+
+#define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_CMD_BOOTZ
+
+/* Define to disable flash configuration*/
+/* #define CONFIG_EP93XX_NO_FLASH_CFG */
+
+/* #define CONFIG_LOWLEVEL_DEBUG */
+
+#endif /* !defined (__CONFIG_H) */
--
1.7.3.4
1
0

[U-Boot] [PATCH] arm: ep9315: Return back Cirrus Logic EDB9315A board support
by Sergey Kostanbaev 20 Sep '13
by Sergey Kostanbaev 20 Sep '13
20 Sep '13
This patch return back support of old EDB9315A board based on Cirrus Logic EP9315 processor.
Signed-off-by: Sergey Kostanbaev <sergey.kostanbaev(a)fairwaves.ru>
Cc: albert.u.boot(a)aribaud.net
---
arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S | 568 +++++++++++++++++++++++++--
arch/arm/include/asm/arch-ep93xx/ep93xx.h | 62 +++
board/cirrus/edb93xx/Makefile | 37 ++
board/cirrus/edb93xx/edb93xx.c | 340 ++++++++++++++++
board/cirrus/edb93xx/u-boot.lds | 106 +++++
boards.cfg | 1 +
drivers/spi/Makefile | 1 +
drivers/spi/ep93xx_spi.c | 274 +++++++++++++
drivers/usb/host/Makefile | 1 +
drivers/usb/host/ohci-ep93xx.c | 38 ++
include/configs/edb93xx.h | 291 ++++++++++++++
11 files changed, 1690 insertions(+), 29 deletions(-)
create mode 100644 board/cirrus/edb93xx/Makefile
create mode 100644 board/cirrus/edb93xx/edb93xx.c
create mode 100644 board/cirrus/edb93xx/u-boot.lds
create mode 100644 drivers/spi/ep93xx_spi.c
create mode 100644 drivers/usb/host/ohci-ep93xx.c
create mode 100644 include/configs/edb93xx.h
diff --git a/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S b/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
index bf2fa2a..96fc43c 100644
--- a/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
+++ b/arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S
@@ -1,49 +1,559 @@
/*
* Low-level initialization for EP93xx
*
- * Copyright (C) 2009 Matthias Kaehlcke <matthias(a)kaehlcke.net>
+ * Copyright (C) 2013
+ * Sergey Kostanabev <sergey.kostanbaev <at> fairwaves.ru>
*
- * Copyright (C) 2006 Dominic Rath <Dominic.Rath(a)gmx.de>
+ * Copyright (C) 2006 Cirrus Logic Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
*
* SPDX-License-Identifier: GPL-2.0+
*/
-#include <version.h>
-#include <asm/arch/ep93xx.h>
+#include <config.h>
+#include <asm/arch-ep93xx/ep93xx.h>
+
+/*
+/* Configure the SDRAM based on the supplied settings.
+ */
+ep93xx_sdram_config:
+ /* Program the SDRAM device configuration register. */
+ ldr r3, =EP93XX_SDRAMCTRL
+#ifdef CONFIG_EDB93XX_SDCS0
+ str r0, [r3, #0x0010]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ str r0, [r3, #0x0014]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ str r0, [r3, #0x0018]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ str r0, [r3, #0x001c]
+#endif
+
+ /* Set the Initialize and MRS bits (issue continuous NOP commands
+ * (INIT & MRS set))
+ */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_MRS | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_CKE)
+ str r4, [r3, #0x0004]
+
+ /* Delay for 200us. */
+ mov r4, #0x3000
+delay1:
+ subs r4, r4, #1
+ bne delay1
+
+ /* Clear the MRS bit to issue a precharge all. */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_CKE)
+ str r4, [r3, #0x0004]
+
+ /* Temporarily set the refresh timer to 0x10. Make it really low so
+ * that refresh cycles are generated.
+ */
+ ldr r4, =0x10
+ str r4, [r3, #0x0008]
+
+ /* Delay for at least 80 SDRAM clock cycles. */
+ mov r4, #80
+delay2:
+ subs r4, r4, #1
+ bne delay2
+
+ /* Set the refresh timer to the fastest required for any device
+ * that might be used.
+ */
+ ldr r4, =0x01e0
+ str r4, [r3, #0x0008]
+
+ /* Select mode register update mode. */
+ ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_CKE | \
+ EP93XX_SDRAMCTRL_GLOBALCFG_MRS)
+ str r4, [r3, #0x0004]
+
+ /* Program the mode register on the SDRAM. */
+ ldr r4, [r2]
+
+ /* Select normal operating mode. */
+ ldr r4, =EP93XX_SDRAMCTRL_GLOBALCFG_CKE
+ str r4, [r3, #0x0004]
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Test to see if the SDRAM has been configured in a usable mode.
+ */
+ep93xx_sdram_test:
+ /* Load the test patterns to be written to SDRAM. */
+ ldr r1, =0xf00dface
+ ldr r2, =0xdeadbeef
+ ldr r3, =0x08675309
+ ldr r4, =0xdeafc0ed
+
+ /* Store the test patterns to SDRAM. */
+ stmia r0, {r1-r4}
+
+ /* Load the test patterns from SDRAM one at a time and compare them
+ * to the actual pattern.
+ */
+ ldr r5, [r0]
+ cmp r5, r1
+ ldreq r5, [r0, #0x0004]
+ cmpeq r5, r2
+ ldreq r5, [r0, #0x0008]
+ cmpeq r5, r3
+ ldreq r5, [r0, #0x000c]
+ cmpeq r5, r4
+
+ /* Return -1 if a mismatch was encountered, 0 otherwise. */
+ mvnne r0, #0xffffffff
+ moveq r0, #0x00000000
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Determine the size of the SDRAM. Use data=address for the scan.
+ *
+ * Input: r0 - Start SDRAM address
+ *
+ * Return: r0 - Single block size
+ * r1 - Valid block mask
+ * r2 - Total block count
+ */
+ep93xx_sdram_size:
+ /* Store zero at offset zero. */
+ str r0, [r0]
+
+ /* Start checking for an alias at 1MB into SDRAM. */
+ ldr r1, =0x00100000
+
+ /* Store the offset at the current offset. */
+check_block_size:
+ str r1, [r0, r1]
+
+ /* Read back from zero. */
+ ldr r2, [r0]
+
+ /* Stop searching of an alias was found. */
+ cmp r1, r2
+ beq found_block_size
+
+ /* Advance to the next power of two boundary. */
+ mov r1, r1, lsl #1
+
+ /* Loop back if the size has not reached 256MB. */
+ cmp r1, #0x10000000
+ bne check_block_size
+
+ /* A full 256MB of memory was found, so return it now. */
+ ldr r0, =0x10000000
+ ldr r1, =0x00000000
+ ldr r2, =0x00000001
+ mov pc, lr
+
+ /* An alias was found. See if the first block is 128MB in size. */
+found_block_size:
+ cmp r1, #0x08000000
+
+ /* The first block is 128MB, so there is no further memory. Return it
+ * now.
+ */
+ ldreq r0, =0x08000000
+ ldreq r1, =0x00000000
+ ldreq r2, =0x00000001
+ moveq pc, lr
+
+ /* Save the block size, set the block address bits to zero, and
+ * initialize the block count to one.
+ */
+ mov r3, r1
+ ldr r4, =0x00000000
+ ldr r5, =0x00000001
+
+ /* Look for additional blocks of memory by searching for non-aliases. */
+find_blocks:
+ /* Store zero back to address zero. It may be overwritten. */
+ str r0, [r0]
+
+ /* Advance to the next power of two boundary. */
+ mov r1, r1, lsl #1
+
+ /* Store the offset at the current offset. */
+ str r1, [r0, r1]
+
+ /* Read back from zero. */
+ ldr r2, [r0]
+
+ /* See if a non-alias was found. */
+ cmp r1, r2
+
+ /* If a non-alias was found, then or in the block address bit and
+ * multiply the block count by two (since there are two unique
+ * blocks, one with this bit zero and one with it one).
+ */
+ orrne r4, r4, r1
+ movne r5, r5, lsl #1
+
+ /* Continue searching if there are more address bits to check. */
+ cmp r1, #0x08000000
+ bne find_blocks
+
+ /* Return the block size, address mask, and count. */
+ mov r0, r3
+ mov r1, r4
+ mov r2, r5
+
+ /* Return to the caller. */
+ mov pc, lr
+
+/*
+ * Compute the starting address of the SDRAM memory blocks.
+ */
+ep93xx_sdram_find_bank:
+ /* Get a pointer to the SDRAM address map. */
+ orr r0, r11, #0x00002100
+
+ /* If there is only one bank, then there is no need to look for it. */
+ cmp r10, #1
+ moveq r1, #0x00000000
+ streq r1, [r0]
+ moveq pc, lr
+
+ /* Create a table mapping the individual address bits used to access the
+ * various banks.
+ */
+ add r1, r0, #0x00000080
+ mov r2, r10, lsr #1
+ mov r3, #0x00100000
+find_bit:
+ tst r9, r3
+ moveq r3, r3, lsl #1
+ beq find_bit
+ str r3, [r1], #4
+ mov r3, r3, lsl #1
+ movs r2, r2, lsr #1
+ bne find_bit
+
+ /* Using the individual address bits, compute the address of each
+ * bank of SDRAM.
+ */
+ add r1, r0, #0x00000080
+ mov r2, r10
+ mov r3, #0x00000000
+find_bank:
+ mov r4, #0x00000000
+ tst r3, #0x00000001
+ ldrne r5, [r1]
+ orrne r4, r4, r5
+ tst r3, #0x00000002
+ ldrne r5, [r1, #4]
+ orrne r4, r4, r5
+ tst r3, #0x00000004
+ ldrne r5, [r1, #8]
+ orrne r4, r4, r5
+ tst r3, #0x00000008
+ ldrne r5, [r1, #12]
+ orrne r4, r4, r5
+ tst r3, #0x00000010
+ ldrne r5, [r1, #16]
+ orrne r4, r4, r5
+ tst r3, #0x00000020
+ ldrne r5, [r1, #20]
+ orrne r4, r4, r5
+ tst r3, #0x00000040
+ ldrne r5, [r1, #24]
+ orrne r4, r4, r5
+ tst r3, #0x00000080
+ ldrne r5, [r1, #28]
+ orrne r4, r4, r5
+ str r4, [r0], #4
+ add r3, r3, #1
+ subs r2, r2, #1
+ bne find_bank
+
+ /* Return to the caller. */
+ mov pc, lr
.globl lowlevel_init
lowlevel_init:
- /* backup return address */
- ldr r1, =SYSCON_SCRATCH0
- str lr, [r1]
- /* Turn on both LEDs */
- bl red_led_on
- bl green_led_on
+ mov r6, lr
+
+ /* Make sure caches are off and invalidated. */
+ ldr r0, =0x00000000
+ mcr p15, 0, r0, c1, c0, 0
+ nop
+ nop
+ nop
+ nop
+ nop
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ bl SetBaud
+ mov r0, #0x42 /* 'B' */
+ bl SendChar
+#endif
+
+ /* Turn off the green LED and turn on the red LED. If the red LED
+ * is left on for too long, the external reset circuit described
+ * by application note AN258 will cause the system to reset.
+ */
+ ldr r1, =EP93XX_LED_DATA
+ ldr r0, [r1]
+ bic r0, r0, #EP93XX_LED_GREEN_ON
+ orr r0, r0, #EP93XX_LED_RED_ON
+ str r0, [r1]
+
+ /* Undo the silly static memory controller programming performed
+ * by the boot rom.
+ */
+ ldr r0, =0x80080000
+ ldr r1, =0x0000fbe0
+ ldr r2, [r0]
+ orr r2, r2, r1
+ str r2, [r0]
+ ldr r2, [r0, #0x04]
+ orr r2, r2, r1
+ str r2, [r0, #0x04]
+ ldr r2, [r0, #0x08]
+ orr r2, r2, r1
+ str r2, [r0, #0x08]
+ ldr r2, [r0, #0x0c]
+ orr r2, r2, r1
+ str r2, [r0, #0x0c]
+ ldr r2, [r0, #0x18]
+ orr r2, r2, r1
+ str r2, [r0, #0x18]
+ ldr r2, [r0, #0x1c]
+ orr r2, r2, r1
+ str r2, [r0, #0x1c]
+
+ /* Set the PLL1 and processor clock. */
+ ldr r0, =SYSCON_BASE
+#ifdef CONFIG_EDB9301
+ /* 332MHz, giving a 166MHz processor clock. */
+ ldr r1, = 0x02b49907
+#else
+
+ /* 400MHz, giving a 200MHz processor clock. */
+ ldr r1, =0x02a4e39e
+
+
+ /* If you are using an Industrial Rated EP93XX then you need to
+ * comment the above ldr line and uncomment this one below here
+ * to enable correct CLKSET1 values of 192Mhz Core and 96Mhz SDRAM
+ */
+
+ /* ldr r1, =0x02a4bb38 This is for Industrial rated Chips */
+
+
+#endif
+ str r1, [r0, #0x0020]
+
+ nop
+ nop
+ nop
+ nop
+ nop
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ mov r0, #0x43 /* 'C' */
+ bl SendChar
+#endif
+
+
+ /* Need to make sure that SDRAM is configured correctly before
+ * coping the code into it.
+ */
+
+#ifdef CONFIG_EDB93XX_SDCS0
+ mov r11, #0xc0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ mov r11, #0xd0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ mov r11, #0xe0000000
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ ldr r0, =EP93XX_SYSCON
+ ldr r0, [r0, #0x009c]
+ ands r0, r0, #0x00000020
+ moveq r11, #0xf0000000
+ movne r11, #0x00000000
+#endif
+ /* Try a 32-bit wide configuration of SDRAM. */
+ ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \
+ EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \
+ EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2)
+
+ ldr r1, =0x00400000
+ orr r2, r11, #0x00008800
+ bl ep93xx_sdram_config
+
+ /* Test the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_test
+ cmp r0, #0x00000000
+ beq ep93xx_sdram_done
+
+ /* Try a 16-bit wide configuration of SDRAM. */
+ ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \
+ EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \
+ EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2 | \
+ EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH)
+ ldr r1, =0x00200000
+ orr r2, r11, #0x00004600
+ bl ep93xx_sdram_config
+
+ /* Test the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_test
+ cmp r0, #0x00000000
+ beq ep93xx_sdram_done
+
+ /* Turn off the red LED. */
+ ldr r0, =EP93XX_LED_DATA
+ ldr r1, [r0]
+ bic r1, r1, #EP93XX_LED_RED_ON
+ str r1, [r0]
+
+ /* There is no SDRAM so flash the green LED. */
+flash_green:
+ orr r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_1:
+ subs r2, r2, #1
+ bne flash_green_delay_1
+ bic r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_2:
+ subs r2, r2, #1
+ bne flash_green_delay_2
+ orr r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00010000
+flash_green_delay_3:
+ subs r2, r2, #1
+ bne flash_green_delay_3
+ bic r1, r1, #EP93XX_LED_GREEN_ON
+ str r1, [r0]
+ ldr r2, =0x00050000
+flash_green_delay_4:
+ subs r2, r2, #1
+ bne flash_green_delay_4
+ b flash_green
+
+
+ep93xx_sdram_done:
+
+ ldr r1, =EP93XX_LED_DATA
+ ldr r0, [r1]
+ bic r0, r0, #EP93XX_LED_RED_ON
+ str r0, [r1]
+
+ /* Determine the size of the SDRAM. */
+ mov r0, r11
+ bl ep93xx_sdram_size
+
+ /* Save the SDRAM characteristics. */
+ mov r8, r0
+ mov r9, r1
+ mov r10, r2
+ ldr r3, =EP93XX_SDRAMCTRL
+ mul r1, r8, r10
+#ifdef CONFIG_EDB93XX_SDCS0
+ ldr r2, [r0, #0x0010]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS1
+ ldr r2, [r0, #0x0014]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS2
+ ldr r2, [r0, #0x0018]
+#endif
+#ifdef CONFIG_EDB93XX_SDCS3
+ ldr r2, [r0, #0x001c]
+#endif
+ tst r2, #EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH
+ moveq r1, r1, lsr #1
+ cmp r1, #0x02000000
+#if defined(CONFIG_EDB9301)
+ movlt r1, #0x03f0
+ movge r1, #0x01e0
+#else
+ movlt r1, #0x0600
+ movge r1, #0x2f0
+#endif
+ str r1, [r0, #0x0008]
+
+ /* Find the location of each block of SDRAM. */
+ bl ep93xx_sdram_find_bank
+
+ /* Save the memory configuration information. */
+ orr r0, r11, #0x00002000
+ stmia r0, {r8-r11}
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+ mov r0, #0x44 /* 'D' */
+ bl SendChar
+#endif
+ mov lr, r6
+ mov pc,lr
+
+#ifdef CONFIG_LOWLEVEL_DEBUG
+SetBaud:
+ /* DEVICECFG */
+ ldr r1, =0x80930080
+ ldr r0, [r1]
+ orr r0, r0, #0x040000
+ str r0, [r1]
+
+ ldr r3, =0x808c0000
+
+ /* Clear the status */
+ mov r1, #0
+ str r1, [r3, #0x4]
+
+ /* Set 115200 Baud. */
+ mov r1, #0x03
+ str r1, [r3, #0x10]
+
+ /* Clear the upper baud divisor register */
+ mov r1, #0
+ str r1, [r3, #0xc]
- /* Configure flash wait states before we switch to the PLL */
- bl flash_cfg
+ /* Set the mode to N-8-1 */
+ mov r1, #0x70
+ str r1, [r3, #0x8]
- /* Set up PLL */
- bl pll_cfg
+ /* Enable uart 1 */
+ mov r1, #1
+ str r1, [r3, #0x14]
- /* Turn off the Green LED and leave the Red LED on */
- bl green_led_off
+ /* Return to the caller. */
+ mov pc, lr
- /* Setup SDRAM */
- bl sdram_cfg
- /* Turn on Green LED, Turn off the Red LED */
- bl green_led_on
- bl red_led_off
+.globl SendChar
+SendChar:
+ /* Load the base address to the UART 1 registers. 0x808c0000 */
+ ldr r1, =0x808c0000
- /* FIXME: we use async mode for now */
- mrc p15, 0, r0, c1, c0, 0
- orr r0, r0, #0xc0000000
- mcr p15, 0, r0, c1, c0, 0
+ /* Write the character to UART1. */
+ str r0, [r1]
- /* restore return address */
- ldr r1, =SYSCON_SCRATCH0
- ldr lr, [r1]
+ /* Return to the caller. */
+ mov pc, lr
- mov pc, lr
+#endif
diff --git a/arch/arm/include/asm/arch-ep93xx/ep93xx.h b/arch/arm/include/asm/arch-ep93xx/ep93xx.h
index 9e7f2f3..deef473 100644
--- a/arch/arm/include/asm/arch-ep93xx/ep93xx.h
+++ b/arch/arm/include/asm/arch-ep93xx/ep93xx.h
@@ -1,6 +1,9 @@
/*
* Cirrus Logic EP93xx register definitions.
*
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
* Copyright (C) 2009
* Matthias Kaehlcke <matthias(a)kaehlcke.net>
*
@@ -295,6 +298,53 @@ struct sdram_regs {
#define GLCONFIG_CLKSHUTDOWN (1 << 30)
#define GLCONFIG_CKE (1 << 31)
+#define EP93XX_SDRAMCTRL 0x80060000
+
+#define EP93XX_SDRAMCTRL_GLCONFIG 0x0004
+#define EP93XX_SDRAMCTRL_REFTIMER 0x0008
+#define EP93XX_SDRAMCTRL_BOOTSTS 0x000c
+#define EP93XX_SDRAMCTRL_DEVCFG_0 0x0010
+#define EP93XX_SDRAMCTRL_DEVCFG_1 0x0014
+#define EP93XX_SDRAMCTRL_DEVCFG_2 0x0018
+#define EP93XX_SDRAMCTRL_DEVCFG_3 0x001c
+#define EP93XX_SDRAMCTRL_DEVCFG_AUTOPRE 0x01000000
+
+#define EP93XX_SDRAMCTRL_GLOBALCFG_INIT 0x00000001
+#define EP93XX_SDRAMCTRL_GLOBALCFG_MRS 0x00000002
+#define EP93XX_SDRAMCTRL_GLOBALCFG_SMEMBUSY 0x00000020
+#define EP93XX_SDRAMCTRL_GLOBALCFG_LCR 0x00000040
+#define EP93XX_SDRAMCTRL_GLOBALCFG_REARBEN 0x00000080
+#define EP93XX_SDRAMCTRL_GLOBALCFG_CLKSHUTDOWN 0x40000000
+#define EP93XX_SDRAMCTRL_GLOBALCFG_CKE 0x80000000
+
+#define EP93XX_SDRAMCTRL_REFRESH_MASK 0x0000FFFF
+
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_32 0x00000002
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_16 0x00000001
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_8 0x00000000
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_WIDTH_MASK 0x00000003
+#define EP93XX_SDRAMCTRL_BOOTSTATUS_MEDIA 0x00000004
+
+#define EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH 0x00000004
+#define EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT 0x00000008
+#define EP93XX_SDRAMCTRL_DEVCFG_SROM512 0x00000010
+#define EP93XX_SDRAMCTRL_DEVCFG_SROMLL 0x00000020
+#define EP93XX_SDRAMCTRL_DEVCFG_2KPAGE 0x00000040
+#define EP93XX_SDRAMCTRL_DEVCFG_SFCONFIGADDR 0x00000080
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_MASK 0x00070000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 0x00010000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_3 0x00020000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_4 0x00030000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_5 0x00040000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_6 0x00050000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_7 0x00060000
+#define EP93XX_SDRAMCTRL_DEVCFG_CASLAT_8 0x00070000
+#define EP93XX_SDRAMCTRL_DEVCFG_WBL 0x00080000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_MASK 0x00300000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2 0x00200000
+#define EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_3 0x00300000
+#define EP93XX_SDRAMCTRL_DEVCFG_AUTOPRECHARGE 0x01000000
+
/*
* 0x80070000 - 0x8007FFFF: Reserved
*/
@@ -445,6 +495,14 @@ struct gpio_regs {
};
#endif
+#define EP93XX_LED_DATA 0x80840020
+#define EP93XX_LED_GREEN_ON 0x0001
+#define EP93XX_LED_RED_ON 0x0002
+
+#define EP93XX_LED_DDR 0x80840024
+#define EP93XX_LED_GREEN_ENABLE 0x0001
+#define EP93XX_LED_RED_ENABLE 0x00020000
+
/*
* 0x80850000 - 0x8087FFFF: Reserved
*/
@@ -519,6 +577,9 @@ struct gpio_regs {
#define SYSCON_OFFSET 0x930000
#define SYSCON_BASE (EP93XX_APB_BASE | SYSCON_OFFSET)
+/* Security */
+#define SECURITY_EXTENSIONID 0x80832714
+
#ifndef __ASSEMBLY__
struct syscon_regs {
uint32_t pwrsts;
@@ -554,6 +615,7 @@ struct syscon_regs {
#endif
#define SYSCON_PWRCNT_UART_BAUD (1 << 29)
+#define SYSCON_PWRCNT_USH_EN (1 << 28)
#define SYSCON_CLKSET_PLL_X2IPD_SHIFT 0
#define SYSCON_CLKSET_PLL_X2FBD2_SHIFT 5
diff --git a/board/cirrus/edb93xx/Makefile b/board/cirrus/edb93xx/Makefile
new file mode 100644
index 0000000..fb8d3e0
--- /dev/null
+++ b/board/cirrus/edb93xx/Makefile
@@ -0,0 +1,37 @@
+#
+# (C) Copyright 2013
+# Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+#
+# (C) Copyright 2003-2006
+# Wolfgang Denk, DENX Software Engineering, wd <at> denx.de.
+#
+# * SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).o
+
+COBJS-y := edb93xx.o
+
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS-y))
+SOBJS := $(addprefix $(obj),$(SOBJS-y))
+
+$(LIB): $(obj).depend $(OBJS) $(SOBJS)
+ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+clean:
+ rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+ rm -f $(LIB) core *.bak .depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/cirrus/edb93xx/edb93xx.c b/board/cirrus/edb93xx/edb93xx.c
new file mode 100644
index 0000000..2e0165c
--- /dev/null
+++ b/board/cirrus/edb93xx/edb93xx.c
@@ -0,0 +1,340 @@
+/*
+ * Board initialization for EP93xx
+ *
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Copyright (C) 2009
+ * Matthias Kaehlcke <matthias <at> kaehlcke.net>
+ *
+ * (C) Copyright 2002 2003
+ * Network Audio Technologies, Inc. <www.netaudiotech.com>
+ * Adam Bezanson <bezanson <at> netaudiotech.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm/arch/ep93xx.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * usb_div: 4, nbyp2: 1, pll2_en: 1
+ * pll2_x1: 368640000.000000, pll2_x2ip: 15360000.000000,
+ * pll2_x2: 384000000.000000, pll2_out: 192000000.000000
+ */
+#define CLKSET2_VAL (23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+ 24 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+ 24 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+ 1 << SYSCON_CLKSET_PLL_PS_SHIFT | \
+ SYSCON_CLKSET2_PLL2_EN | \
+ SYSCON_CLKSET2_NBYP2 | \
+ 3 << SYSCON_CLKSET2_USB_DIV_SHIFT)
+
+#define SMC_BCR6_VALUE (2 << SMC_BCR_IDCY_SHIFT | 5 << SMC_BCR_WST1_SHIFT | \
+ SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \
+ 1 << SMC_BCR_MW_SHIFT)
+
+/* delay execution before timers are initialized */
+static inline void early_udelay(uint32_t usecs)
+{
+ /* loop takes 4 cycles at 5.0ns (fastest case, running at 200MHz) */
+ register uint32_t loops = (usecs * 1000) / 20;
+
+ __asm__ volatile ("1:\n"
+ "subs %0, %1, #1\n"
+ "bne 1b" : "=r" (loops) : "0" (loops));
+}
+
+#ifndef CONFIG_EP93XX_NO_FLASH_CFG
+static void flash_cfg(void)
+{
+ struct smc_regs *smc = (struct smc_regs *)SMC_BASE;
+
+ writel(SMC_BCR6_VALUE, &smc->bcr6);
+}
+#else
+#define flash_cfg()
+#endif
+
+int board_init(void)
+{
+ /*
+ * Setup PLL2, PPL1 has been set during lowlevel init
+ */
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ writel(CLKSET2_VAL, &syscon->clkset2);
+
+ /*
+ * the user's guide recommends to wait at least 1 ms for PLL2 to
+ * stabilize
+ */
+ early_udelay(1000);
+
+ /* Go to Async mode */
+ __asm__ volatile ("mrc p15, 0, r0, c1, c0, 0");
+ __asm__ volatile ("orr r0, r0, #0xc0000000");
+ __asm__ volatile ("mcr p15, 0, r0, c1, c0, 0");
+
+ icache_enable();
+
+#ifdef USE_920T_MMU
+ dcache_enable();
+#endif
+
+ /* Machine number, as defined in linux/arch/arm/tools/mach-types */
+ gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
+
+ /* adress of boot parameters */
+ gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
+
+ /* We have a console */
+ gd->have_console = 1;
+
+ enable_interrupts();
+
+ flash_cfg();
+
+ green_led_on();
+ red_led_off();
+
+ return 0;
+}
+
+int board_early_init_f(void)
+{
+ /*
+ * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
+ * 14.7456/2 MHz
+ */
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ writel(SYSCON_PWRCNT_UART_BAUD, &syscon->pwrcnt);
+ return 0;
+}
+
+int board_eth_init(bd_t *bd)
+{
+ return ep93xx_eth_initialize(0, MAC_BASE);
+}
+
+/* called in board_init_f (before relocation) */
+static unsigned dram_init_banksize_int(int print)
+{
+ /*
+ * Collect information of banks has been filled during lowlevel
+ * initialization
+ */
+
+ unsigned i;
+ unsigned dram_bank_base[8];
+ unsigned dram_total = 0;
+ unsigned dram_base_addr = PHYS_SDRAM_1;
+ unsigned dram_bank_size = *(unsigned *)(dram_base_addr | 0x2000);
+ /* unsigned dram_addr_mask = *(unsigned *)(dram_base_addr | 0x2004); */
+ unsigned dram_bank_cnt = *(unsigned *)(dram_base_addr | 0x2008);
+
+ for (i = 0; i < dram_bank_cnt; i++)
+ dram_bank_base[i] = dram_base_addr |
+ *(unsigned *)(dram_base_addr | (0x2100 + i*4));
+
+ for (i = 0; i < dram_bank_cnt; i++) {
+ gd->bd->bi_dram[i].start = dram_bank_base[i];
+ gd->bd->bi_dram[i].size = dram_bank_size;
+ dram_total += dram_bank_size;
+ }
+ for (; i < CONFIG_NR_DRAM_BANKS; i++) {
+ gd->bd->bi_dram[i].start = 0;
+ gd->bd->bi_dram[i].size = 0;
+ }
+
+ if (print) {
+ printf("DRAM total %u banks:\n", dram_bank_cnt);
+ printf("bank base-address size\n");
+
+ if (dram_bank_cnt > CONFIG_NR_DRAM_BANKS) {
+ printf("WARNING! UBoot was configured for %u banks,\n"
+ "but %u has been found. Supressing extra memory banks\n",
+ CONFIG_NR_DRAM_BANKS, dram_bank_cnt);
+ dram_bank_cnt = CONFIG_NR_DRAM_BANKS;
+ }
+
+ for (i = 0; i < dram_bank_cnt; i++) {
+ printf(" %u %08x %08x\n",
+ i, dram_bank_base[i], dram_bank_size);
+ }
+ printf(" ------------------------------------------\n"
+ "Total %9d\n\n",
+ dram_total);
+ }
+
+ return dram_total;
+}
+
+void dram_init_banksize(void)
+{
+ dram_init_banksize_int(0);
+}
+
+/* called in board_init_f (before relocation) */
+int dram_init(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned sec_id = readl(SECURITY_EXTENSIONID);
+ unsigned chip_id = readl(&syscon->chipid);
+
+ printf("CPU: Cirrus Logic ");
+ switch (sec_id & 0x000001FE) {
+ case 0x00000008:
+ printf("EP9301");
+ break;
+ case 0x00000004:
+ printf("EP9307");
+ break;
+ case 0x00000002:
+ printf("EP931x");
+ break;
+ case 0x00000000:
+ printf("EP9315");
+ break;
+ default:
+ printf("<unknown>");
+ break;
+ }
+
+ printf(" - Rev. ");
+ switch (chip_id & 0xF0000000) {
+ case 0x00000000:
+ printf("A");
+ break;
+ case 0x10000000:
+ printf("B");
+ break;
+ case 0x20000000:
+ printf("C");
+ break;
+ case 0x30000000:
+ printf("D0");
+ break;
+ case 0x40000000:
+ printf("D1");
+ break;
+ case 0x50000000:
+ printf("E0");
+ break;
+ case 0x60000000:
+ printf("E1");
+ break;
+ case 0x70000000:
+ printf("E2");
+ break;
+ default:
+ printf("?");
+ break;
+ }
+ printf(" (SecExtID=%.8x/ChipID=%.8x)\n", sec_id, chip_id);
+
+ gd->ram_size = dram_init_banksize_int(1);
+ return 0;
+}
+
+
+#ifdef CONFIG_EP93XX_SPI
+#include <spi.h>
+
+/*
+ * EGIO0-EGIPO7 -> port A
+ * EGIO8-EGIP15 -> port B
+ */
+
+static void ep93xx_set_epgio(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->padr) | (1<<num), ®s->padr);
+ else
+ writel(readl(®s->pbdr) | (1<<(num-8)), ®s->pbdr);
+}
+
+static void ep93xx_clear_epgio(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->padr) & (~(1<<num)), ®s->padr);
+ else
+ writel(readl(®s->pbdr) & (~(1<<(num-8))), ®s->pbdr);
+}
+
+static void ep93xx_dir_epgio_out(unsigned num)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+ if (num < 8)
+ writel(readl(®s->paddr) | (1<<num), ®s->paddr);
+ else
+ writel(readl(®s->pbddr) | (1<<(num-8)), ®s->pbddr);
+}
+
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+ if (bus == 0 && cs < 16)
+ return 1;
+
+ return 0;
+}
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+ ep93xx_clear_epgio(slave->cs);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+ ep93xx_set_epgio(slave->cs);
+}
+
+#ifdef CONFIG_MMC_SPI
+#include <mmc.h>
+
+#ifndef CONFIG_MMC_SPI_CS_EPGIO
+# define CONFIG_MMC_SPI_CS_EPGIO 4
+#endif
+
+#ifndef CONFIG_MMC_SPI_SPEED
+# define CONFIG_MMC_SPI_SPEED 25000000
+#endif
+
+#ifndef CONFIG_MMC_SPI_MODE
+# define CONFIG_MMC_SPI_MODE SPI_MODE_0
+#endif
+
+int board_mmc_init(bd_t *bis)
+{
+ struct gpio_regs *regs = (struct gpio_regs *)GPIO_BASE;
+
+ ep93xx_set_epgio(CONFIG_MMC_SPI_CS_EPGIO);
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_CS_EPGIO);
+
+#ifdef CONFIG_MMC_SPI_POWER_EGPIO
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_POWER_EGPIO);
+ ep93xx_set_epgio(CONFIG_MMC_SPI_POWER_EGPIO);
+#elif defined(CONFIG_MMC_SPI_NPOWER_EGPIO)
+ ep93xx_dir_epgio_out(CONFIG_MMC_SPI_NPOWER_EGPIO);
+ ep93xx_clear_epgio(CONFIG_MMC_SPI_NPOWER_EGPIO);
+#endif
+ struct mmc *mmc = mmc_spi_init(0, CONFIG_MMC_SPI_CS_EPGIO,
+ CONFIG_MMC_SPI_SPEED, CONFIG_MMC_SPI_MODE);
+
+ if (!mmc) {
+ printf("Failed to create MMC Device\n");
+ return 1;
+ }
+ mmc_init(mmc);
+ return 0;
+}
+
+
+#endif /* CONFIG_MMC_SPI */
+#endif /* CONFIG_EP93XX_SPI */
diff --git a/board/cirrus/edb93xx/u-boot.lds b/board/cirrus/edb93xx/u-boot.lds
new file mode 100644
index 0000000..e61aa36
--- /dev/null
+++ b/board/cirrus/edb93xx/u-boot.lds
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (C) 2013
+ * Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Copyright (c) 2004-2008 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <garyj(a)denx.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text : {
+ *(.__image_copy_start)
+ arch/arm/cpu/arm920t/start.o (.text*)
+ . = 0x1000;
+
+ LONG(0x53555243)
+ *(.text*)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+ . = ALIGN(4);
+ .data : {
+ *(.data*)
+ }
+
+ . = ALIGN(4);
+
+ . = .;
+
+ . = ALIGN(4);
+ .u_boot_list : {
+ KEEP(*(SORT(.u_boot_list*)));
+ }
+
+ . = ALIGN(4);
+
+ .image_copy_end :
+ {
+ *(.__image_copy_end)
+ }
+
+ .rel_dyn_start :
+ {
+ *(.__rel_dyn_start)
+ }
+
+ .rel.dyn : {
+ *(.rel*)
+ }
+
+ .rel_dyn_end :
+ {
+ *(.__rel_dyn_end)
+ }
+
+ _end = .;
+
+ /*
+ * Deprecated: this MMU section is used by pxa at present but
+ * should not be used by new boards/CPUs.
+ */
+ . = ALIGN(4096);
+ .mmutable : {
+ *(.mmutable)
+ }
+
+/*
+ * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c
+ * __bss_base and __bss_limit are for linker only (overlay ordering)
+ */
+
+ .bss_start __rel_dyn_start (OVERLAY) : {
+ KEEP(*(.__bss_start));
+ __bss_base = .;
+ }
+
+ .bss __bss_base (OVERLAY) : {
+ *(.bss*)
+ . = ALIGN(4);
+ __bss_limit = .;
+ }
+
+ .bss_end __bss_limit (OVERLAY) : {
+ KEEP(*(.__bss_end));
+ }
+
+ /DISCARD/ : { *(.dynsym) }
+ /DISCARD/ : { *(.dynstr*) }
+ /DISCARD/ : { *(.dynamic*) }
+ /DISCARD/ : { *(.plt*) }
+ /DISCARD/ : { *(.interp*) }
+ /DISCARD/ : { *(.gnu*) }
+}
diff --git a/boards.cfg b/boards.cfg
index dbd8479..ae4bf6d 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -72,6 +72,7 @@ Active arm arm920t ks8695 - -
Active arm arm920t s3c24x0 friendlyarm mini2440 mini2440 - Gabriel Huau <contact(a)huau-gabriel.fr>
Active arm arm920t s3c24x0 mpl vcma9 VCMA9 - David Müller <d.mueller(a)elsoft.ch>
Active arm arm920t s3c24x0 samsung - smdk2410 - David Müller <d.mueller(a)elsoft.ch>
+Active arm arm920t ep93xx cirrus edb93xx edb9315a edb93xx:MK_edb9315a Sergey Kostanbaev <sergey.kostanbaev(a)fairwaves.ru>
Active arm arm926ejs - armltd integrator integratorap_cm926ejs integratorap:CM926EJ_S Linus Walleij <linus.walleij(a)linaro.org>
Active arm arm926ejs - armltd integrator integratorcp_cm926ejs integratorcp:CM924EJ_S Linus Walleij <linus.walleij(a)linaro.org>
Active arm arm926ejs armada100 Marvell - aspenite - Prafulla Wadaskar <prafulla(a)marvell.com>
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 91d24ce..51becae 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -12,6 +12,7 @@ LIB := $(obj)libspi.o
# There are many options which enable SPI, so make this library available
COBJS-y += spi.o
+COBJS-$(CONFIG_EP93XX_SPI) += ep93xx_spi.o
COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o
COBJS-$(CONFIG_ANDES_SPI) += andes_spi.o
COBJS-$(CONFIG_ARMADA100_SPI) += armada100_spi.o
diff --git a/drivers/spi/ep93xx_spi.c b/drivers/spi/ep93xx_spi.c
new file mode 100644
index 0000000..235557e
--- /dev/null
+++ b/drivers/spi/ep93xx_spi.c
@@ -0,0 +1,274 @@
+/*
+ * SPI Driver for EP93xx
+ *
+ * Copyright (C) 2013 Sergey Kostanabev <sergey.kostanbaev <at> fairwaves.ru>
+ *
+ * Inspired form linux kernel driver and atmel uboot driver
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <spi.h>
+#include <malloc.h>
+
+#include <asm/io.h>
+
+#include <asm/arch/ep93xx.h>
+
+
+#define BIT(x) (1<<(x))
+#define SSPBASE SPI_BASE
+
+#define SSPCR0 0x0000
+#define SSPCR0_MODE_SHIFT 6
+#define SSPCR0_SCR_SHIFT 8
+#define SSPCR0_SPH BIT(7)
+#define SSPCR0_SPO BIT(6)
+#define SSPCR0_FRF_SPI 0
+#define SSPCR0_DSS_8BIT 7
+
+#define SSPCR1 0x0004
+#define SSPCR1_RIE BIT(0)
+#define SSPCR1_TIE BIT(1)
+#define SSPCR1_RORIE BIT(2)
+#define SSPCR1_LBM BIT(3)
+#define SSPCR1_SSE BIT(4)
+#define SSPCR1_MS BIT(5)
+#define SSPCR1_SOD BIT(6)
+
+#define SSPDR 0x0008
+
+#define SSPSR 0x000c
+#define SSPSR_TFE BIT(0)
+#define SSPSR_TNF BIT(1)
+#define SSPSR_RNE BIT(2)
+#define SSPSR_RFF BIT(3)
+#define SSPSR_BSY BIT(4)
+#define SSPCPSR 0x0010
+
+#define SSPIIR 0x0014
+#define SSPIIR_RIS BIT(0)
+#define SSPIIR_TIS BIT(1)
+#define SSPIIR_RORIS BIT(2)
+#define SSPICR SSPIIR
+
+#define SSPCLOCK 14745600
+#define SSP_MAX_RATE (SSPCLOCK / 2)
+#define SSP_MIN_RATE (SSPCLOCK / (254 * 256))
+
+/* timeout in milliseconds */
+#define SPI_TIMEOUT 5
+/* maximum depth of RX/TX FIFO */
+#define SPI_FIFO_SIZE 8
+
+struct ep93xx_spi_slave {
+ struct spi_slave slave;
+
+ unsigned sspcr0;
+ unsigned sspcpsr;
+};
+
+static inline struct ep93xx_spi_slave *to_ep93xx_spi(struct spi_slave *slave)
+{
+ return container_of(slave, struct ep93xx_spi_slave, slave);
+}
+
+void spi_init()
+{
+}
+
+static inline void ep93xx_spi_write_u8(u16 reg, u8 value)
+{
+ writel(value, (unsigned int *)(SSPBASE + reg));
+}
+
+static inline u8 ep93xx_spi_read_u8(u16 reg)
+{
+ return readl((unsigned int *)(SSPBASE + reg));
+}
+
+static inline void ep93xx_spi_write_u16(u16 reg, u16 value)
+{
+ writel(value, (unsigned int *)(SSPBASE + reg));
+}
+
+static inline u16 ep93xx_spi_read_u16(u16 reg)
+{
+ return (u16)readl((unsigned int *)(SSPBASE + reg));
+}
+
+static int ep93xx_spi_init_hw(unsigned int rate, unsigned int mode,
+ struct ep93xx_spi_slave *slave)
+{
+ unsigned cpsr, scr;
+
+ if (rate > SSP_MAX_RATE)
+ rate = SSP_MAX_RATE;
+
+ if (rate < SSP_MIN_RATE)
+ return -1;
+
+ /* Calculate divisors so that we can get speed according the
+ * following formula:
+ * rate = spi_clock_rate / (cpsr * (1 + scr))
+ *
+ * cpsr must be even number and starts from 2, scr can be any number
+ * between 0 and 255.
+ */
+ for (cpsr = 2; cpsr <= 254; cpsr += 2) {
+ for (scr = 0; scr <= 255; scr++) {
+ if ((SSPCLOCK / (cpsr * (scr + 1))) <= rate) {
+ /* Set CHPA and CPOL, SPI format and 8bit */
+ unsigned sspcr0 = (scr << SSPCR0_SCR_SHIFT) |
+ SSPCR0_FRF_SPI | SSPCR0_DSS_8BIT;
+ if (mode & SPI_CPHA)
+ sspcr0 |= SSPCR0_SPH;
+ if (mode & SPI_CPOL)
+ sspcr0 |= SSPCR0_SPO;
+
+ slave->sspcr0 = sspcr0;
+ slave->sspcpsr = cpsr;
+ return 0;
+ }
+ }
+ }
+
+ return -1;
+}
+
+void spi_set_speed(struct spi_slave *slave, unsigned int hz)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ unsigned int mode = 0;
+ if (as->sspcr0 & SSPCR0_SPH)
+ mode |= SPI_CPHA;
+ if (as->sspcr0 & SSPCR0_SPO)
+ mode |= SPI_CPOL;
+
+ ep93xx_spi_init_hw(hz, mode, as);
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int mode)
+{
+ struct ep93xx_spi_slave *as;
+
+ if (!spi_cs_is_valid(bus, cs))
+ return NULL;
+
+ as = spi_alloc_slave(struct ep93xx_spi_slave, bus, cs);
+ if (!as)
+ return NULL;
+
+ if (ep93xx_spi_init_hw(max_hz, mode, as)) {
+ free(as);
+ return NULL;
+ }
+
+ return &as->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ free(as);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+ struct ep93xx_spi_slave *as = to_ep93xx_spi(slave);
+
+ /* Enable the SPI hardware */
+ ep93xx_spi_write_u8(SSPCR1, SSPCR1_SSE);
+
+
+ ep93xx_spi_write_u8(SSPCPSR, as->sspcpsr);
+ ep93xx_spi_write_u16(SSPCR0, as->sspcr0);
+
+ debug("Select CS:%d SSPCPSR=%02x SSPCR0=%04x\n",
+ slave->cs, as->sspcpsr, as->sspcr0);
+ return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+ /* Disable the SPI hardware */
+ ep93xx_spi_write_u8(SSPCR1, 0);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+ const void *dout, void *din, unsigned long flags)
+{
+ unsigned int len_tx;
+ unsigned int len_rx;
+ unsigned int len;
+ u32 status;
+ const u8 *txp = dout;
+ u8 *rxp = din;
+ u8 value;
+
+ debug("spi_xfer: slave %u:%u dout %p din %p bitlen %u\n",
+ slave->bus, slave->cs, (uint *)dout, (uint *)din, bitlen);
+
+
+ if (bitlen == 0)
+ /* Finish any previously submitted transfers */
+ goto out;
+
+ if (bitlen % 8) {
+ /* Errors always terminate an ongoing transfer */
+ flags |= SPI_XFER_END;
+ goto out;
+ }
+
+ len = bitlen / 8;
+
+
+ if (flags & SPI_XFER_BEGIN) {
+ /* Empty RX FIFO */
+ while ((ep93xx_spi_read_u8(SSPSR) & SSPSR_RNE))
+ ep93xx_spi_read_u8(SSPDR);
+
+ spi_cs_activate(slave);
+ }
+
+ for (len_tx = 0, len_rx = 0; len_rx < len; ) {
+ status = ep93xx_spi_read_u8(SSPSR);
+
+ if ((len_tx < len) && (status & SSPSR_TNF)) {
+ if (txp)
+ value = *txp++;
+ else
+ value = 0xff;
+
+ ep93xx_spi_write_u8(SSPDR, value);
+ len_tx++;
+ }
+
+ if (status & SSPSR_RNE) {
+ value = ep93xx_spi_read_u8(SSPDR);
+
+ if (rxp)
+ *rxp++ = value;
+ len_rx++;
+ }
+ }
+
+out:
+ if (flags & SPI_XFER_END) {
+ /*
+ * Wait until the transfer is completely done before
+ * we deactivate CS.
+ */
+ do {
+ status = ep93xx_spi_read_u8(SSPSR);
+ } while (status & SSPSR_BSY);
+
+ spi_cs_deactivate(slave);
+ }
+
+ return 0;
+}
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index ff6c80e..d1209ee 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -12,6 +12,7 @@ LIB := $(obj)libusb_host.o
# ohci
COBJS-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o
COBJS-$(CONFIG_USB_ATMEL) += ohci-at91.o
+COBJS-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
COBJS-$(CONFIG_USB_OHCI_DA8XX) += ohci-da8xx.o
COBJS-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
COBJS-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
new file mode 100644
index 0000000..8fb4aba
--- /dev/null
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2013
+ * Sergey Kostanbaev < sergey.kostanbaev <at> fairwaves.ru >
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+
+#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
+#include <asm/io.h>
+#include <asm/arch/ep93xx.h>
+
+int usb_cpu_init(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned long pwr = readl(&syscon->pwrcnt);
+ writel(pwr | SYSCON_PWRCNT_USH_EN, &syscon->pwrcnt);
+
+ return 0;
+}
+
+int usb_cpu_stop(void)
+{
+ struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+ unsigned long pwr = readl(&syscon->pwrcnt);
+ writel(pwr & ~SYSCON_PWRCNT_USH_EN, &syscon->pwrcnt);
+
+ return 0;
+}
+
+int usb_cpu_init_fail(void)
+{
+ return usb_cpu_stop();
+}
+
+#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
diff --git a/include/configs/edb93xx.h b/include/configs/edb93xx.h
new file mode 100644
index 0000000..c122c22
--- /dev/null
+++ b/include/configs/edb93xx.h
@@ -0,0 +1,291 @@
+/*
+ * U-boot - Configuration file for Cirrus Logic EDB93xx boards
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#ifdef CONFIG_MK_edb9301
+#define CONFIG_EDB9301
+#elif defined(CONFIG_MK_edb9302)
+#define CONFIG_EDB9302
+#elif defined(CONFIG_MK_edb9302a)
+#define CONFIG_EDB9302A
+#elif defined(CONFIG_MK_edb9307)
+#define CONFIG_EDB9307
+#elif defined(CONFIG_MK_edb9307a)
+#define CONFIG_EDB9307A
+#elif defined(CONFIG_MK_edb9312)
+#define CONFIG_EDB9312
+#elif defined(CONFIG_MK_edb9315)
+#define CONFIG_EDB9315
+#elif defined(CONFIG_MK_edb9315a)
+#define CONFIG_EDB9315A
+#else
+#error "no board defined"
+#endif
+
+/* Initial environment and monitor configuration options. */
+#define CONFIG_BOOTDELAY 2
+#define CONFIG_CMDLINE_TAG 1
+#define CONFIG_INITRD_TAG 1
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_BOOTARGS "root=/dev/nfs console=ttyAM0,115200 ip=dhcp"
+#define CONFIG_BOOTFILE "edb93xx.img"
+
+#define CONFIG_SYS_HUSH_PARSER 1
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+
+#define CONFIG_SYS_LDSCRIPT "board/cirrus/edb93xx/u-boot.lds"
+
+
+#ifdef CONFIG_EDB9301
+#define CONFIG_EP9301
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9301
+#define CONFIG_SYS_PROMPT "EDB9301> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9302)
+#define CONFIG_EP9302
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9302
+#define CONFIG_SYS_PROMPT "EDB9302> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9302A)
+#define CONFIG_EP9302
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9302A
+#define CONFIG_SYS_PROMPT "EDB9302A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9307)
+#define CONFIG_EP9307
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9307
+#define CONFIG_SYS_PROMPT "EDB9307> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9307A)
+#define CONFIG_EP9307
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9307A
+#define CONFIG_SYS_PROMPT "EDB9307A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#elif defined(CONFIG_EDB9312)
+#define CONFIG_EP9312
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9312
+#define CONFIG_SYS_PROMPT "EDB9312> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9315)
+#define CONFIG_EP9315
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9315
+#define CONFIG_SYS_PROMPT "EDB9315> "
+#define CONFIG_ENV_SECT_SIZE 0x00040000
+#elif defined(CONFIG_EDB9315A)
+#define CONFIG_EP9315
+#define CONFIG_MACH_TYPE MACH_TYPE_EDB9315A
+#define CONFIG_SYS_PROMPT "EDB9315A> "
+#define CONFIG_ENV_SECT_SIZE 0x00020000
+#else
+#error "no board defined"
+#endif
+
+/* High-level configuration options */
+#define CONFIG_ARM920T 1 /* This is an ARM920T core... */
+#define CONFIG_EP93XX 1 /* in a Cirrus Logic 93xx SoC */
+
+#define CONFIG_SYS_CLK_FREQ 14745600 /* EP93xx has a 14.7456 clock */
+#define CONFIG_SYS_HZ 1000 /* decr freq: 1 ms ticks */
+#undef CONFIG_USE_IRQ /* Don't need IRQ/FIQ */
+
+/* Monitor configuration */
+#include <config_cmd_default.h>
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_SETGETDCR
+#undef CONFIG_CMD_XIMG
+
+#undef CONFIG_CMD_DATE
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_JFFS2
+
+#define CONFIG_SYS_LONGHELP /* Enable "long" help in mon */
+#define CONFIG_SYS_CBSIZE 1024 /* Console I/O buffer size */
+/* Print buffer size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
+/* Boot argument buffer size */
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
+#define CONFIG_SYS_MAXARGS 16 /* Max number of command args */
+
+/* Serial port hardware configuration */
+#define CONFIG_PL010_SERIAL
+#define CONFIG_CONS_INDEX 0
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {9600, 19200, 38400, 57600, \
+ 115200, 230400}
+#define CONFIG_SYS_SERIAL0 0x808C0000
+#define CONFIG_SYS_SERIAL1 0x808D0000
+/*#define CONFIG_PL01x_PORTS {(void *)CONFIG_SYS_SERIAL0, \
+ (void *)CONFIG_SYS_SERIAL1} */
+
+#define CONFIG_PL01x_PORTS {(void *)CONFIG_SYS_SERIAL0}
+
+/* Status LED */
+#define CONFIG_STATUS_LED 1 /* Status LED enabled */
+#define CONFIG_BOARD_SPECIFIC_LED 1
+#define STATUS_LED_GREEN 0
+#define STATUS_LED_RED 1
+/* Green */
+#define STATUS_LED_BIT STATUS_LED_GREEN
+#define STATUS_LED_STATE STATUS_LED_ON
+#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
+/* Red */
+#define STATUS_LED_BIT1 STATUS_LED_RED
+#define STATUS_LED_STATE1 STATUS_LED_OFF
+#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2)
+/* Optional value */
+#define STATUS_LED_BOOT STATUS_LED_BIT
+
+/* Network hardware configuration */
+#define CONFIG_DRIVER_EP93XX_MAC
+#define CONFIG_MII_SUPPRESS_PREAMBLE
+#define CONFIG_MII
+#define CONFIG_PHY_ADDR 1
+#define CONFIG_NET_MULTI
+#undef CONFIG_NETCONSOLE
+
+/* SDRAM configuration */
+#if defined(CONFIG_EDB9301) || defined(CONFIG_EDB9302) || \
+ defined(CONFIG_EDB9307) || defined CONFIG_EDB9312 || \
+ defined(CONFIG_EDB9315)
+/*
+ * EDB9301/2 has 4 banks of SDRAM consisting of 1x Samsung K4S561632E-TC75
+ * 256 Mbit SDRAM on a 16-bit data bus, for a total of 32MB of SDRAM. We set
+ * the SROMLL bit on the processor, resulting in this non-contiguous memory map.
+ *
+ * The EDB9307, EDB9312, and EDB9315 have 2 banks of SDRAM consisting of
+ * 2x Samsung K4S561632E-TC75 256 Mbit on a 32-bit data bus, for a total of
+ * 64 MB of SDRAM.
+ */
+
+#define CONFIG_EDB93XX_SDCS3
+
+#elif defined(CONFIG_EDB9302A) || \
+ defined(CONFIG_EDB9307A) || defined(CONFIG_EDB9315A)
+/*
+ * EDB9302a has 4 banks of SDRAM consisting of 1x Samsung K4S561632E-TC75
+ * 256 Mbit SDRAM on a 16-bit data bus, for a total of 32MB of SDRAM. We set
+ * the SROMLL bit on the processor, resulting in this non-contiguous memory map.
+ *
+ * The EDB9307A and EDB9315A have 2 banks of SDRAM consisting of 2x Samsung
+ * K4S561632E-TC75 256 Mbit on a 32-bit data bus, for a total of 64 MB of SDRAM.
+ */
+#define CONFIG_EDB93XX_SDCS0
+
+#else
+#error "no SDCS configuration for this board"
+#endif
+
+
+#if defined(CONFIG_EDB93XX_SDCS3)
+#define CONFIG_SYS_LOAD_ADDR 0x01000000 /* Default load address */
+#define PHYS_SDRAM_1 0x00000000
+#elif defined(CONFIG_EDB93XX_SDCS0)
+#define CONFIG_SYS_LOAD_ADDR 0xc1000000 /* Default load address */
+#define PHYS_SDRAM_1 0xc0000000
+#endif
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_NR_DRAM_BANKS 8
+
+#define CONFIG_SYS_INIT_SP_ADDR \
+ (CONFIG_SYS_SDRAM_BASE + 32*1024 - GENERATED_GBL_DATA_SIZE)
+
+
+/* Must match kernel config */
+#define LINUX_BOOT_PARAM_ADDR (PHYS_SDRAM_1 + 0x100)
+
+/* Run-time memory allocatons */
+#define CONFIG_SYS_GBL_DATA_SIZE 128
+#define CONFIG_STACKSIZE (128 * 1024)
+
+#if defined(CONFIG_USE_IRQ)
+#define CONFIG_STACKSIZE_IRQ (4 * 1024)
+#define CONFIG_STACKSIZE_FIQ (4 * 1024)
+#endif
+
+#define CONFIG_SYS_MALLOC_LEN (512 * 1024)
+
+/* -----------------------------------------------------------------------------
+ * FLASH and environment organization
+ *
+ * The EDB9301, EDB9302(a), EDB9307a, EDB9315a have 1 bank of flash memory at
+ * 0x60000000 consisting of 1x Intel TE28F128J3C-150 128 Mbit flash on a 16-bit
+ * data bus, for a total of 16 MB of CFI-compatible flash.
+ *
+ * The EDB9307, EDB9312, and EDB9315 have 1 bank of flash memory at
+ * 0x60000000 consisting of 2x Micron MT28F128J3-12 128 Mbit flash on a 32-bit
+ * data bus, for a total of 32 MB of CFI-compatible flash.
+ *
+ *
+ * EDB9301/02(a)7a/15a EDB9307/12/15
+ * 0x60000000 - 0x0003FFFF u-boot u-boot
+ * 0x60040000 - 0x0005FFFF environment #1 environment #1
+ * 0x60060000 - 0x0007FFFF environment #2 environment #1 (continued)
+ * 0x60080000 - 0x0009FFFF unused environment #2
+ * 0x600A0000 - 0x000BFFFF unused environment #2 (continued)
+ * 0x600C0000 - 0x00FFFFFF unused unused
+ * 0x61000000 - 0x01FFFFFF not present unused
+ */
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
+
+
+#define CONFIG_SYS_FLASH_PROTECTION
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT (256+8)
+
+#define CONFIG_SYS_TEXT_BASE 0x60000000
+#define PHYS_FLASH_1 CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_FLASH_BASE CONFIG_SYS_TEXT_BASE
+
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
+#define CONFIG_SYS_MONITOR_LEN (256 * 1024)
+
+#define CONFIG_ENV_OVERWRITE /* Vendor params unprotected */
+#define CONFIG_ENV_IS_IN_FLASH
+
+#define CONFIG_ENV_ADDR 0x60040000
+#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE)
+
+#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
+#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
+
+/* Define to enable MMC on SPI support */
+/* #define CONFIG_EP93XX_SPI_MMC */
+
+#ifdef CONFIG_EP93XX_SPI_MMC
+#define CONFIG_EP93XX_SPI
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC_SPI
+#define CONFIG_CMD_MMC
+#define CONFIG_MMC_SPI_NPOWER_EGPIO 9
+#endif
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_USB_OHCI_EP93XX
+#define CONFIG_SYS_USB_OHCI_CPU_INIT
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 3
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME "ep93xx-ohci"
+#define CONFIG_SYS_USB_OHCI_REGS_BASE 0x80020000
+
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
+
+#define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_CMD_BOOTZ
+
+/* Define to disable flash configuration*/
+/* #define CONFIG_EP93XX_NO_FLASH_CFG */
+
+/* #define CONFIG_LOWLEVEL_DEBUG */
+
+#endif /* !defined (__CONFIG_H) */
--
1.7.3.4
1
0

20 Sep '13
Adding Freeze Controller driver. All HPS IOs need to be
in freeze state during pin mux or IO buffer configuration.
It is to avoid any glitch which might happen
during the configuration from propagating to external devices.
Signed-off-by: Chin Liang See <clsee(a)altera.com>
Cc: Wolfgang Denk <wd(a)denx.de>
CC: Pavel Machek <pavel(a)denx.de>
Cc: Dinh Nguyen <dinguyen(a)altera.com>
---
Changes for v2
- Removed FREEZE_CONTROLLER_FSM_HW
- Removed the get_timer_count_masked and convert to use delay in us
- Used shorter local variables
---
arch/arm/cpu/armv7/socfpga/Makefile | 2 +-
arch/arm/cpu/armv7/socfpga/freeze_controller.c | 249 ++++++++++++++++++++
arch/arm/cpu/armv7/socfpga/spl.c | 16 ++
.../include/asm/arch-socfpga/freeze_controller.h | 71 ++++++
4 files changed, 337 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/cpu/armv7/socfpga/freeze_controller.c
create mode 100644 arch/arm/include/asm/arch-socfpga/freeze_controller.h
diff --git a/arch/arm/cpu/armv7/socfpga/Makefile b/arch/arm/cpu/armv7/socfpga/Makefile
index 0859e44..10d20f2 100644
--- a/arch/arm/cpu/armv7/socfpga/Makefile
+++ b/arch/arm/cpu/armv7/socfpga/Makefile
@@ -14,7 +14,7 @@ LIB = $(obj)lib$(SOC).o
SOBJS := lowlevel_init.o
COBJS-y := misc.o timer.o reset_manager.o system_manager.o
-COBJS-$(CONFIG_SPL_BUILD) += spl.o
+COBJS-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
COBJS := $(COBJS-y)
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/socfpga/freeze_controller.c b/arch/arm/cpu/armv7/socfpga/freeze_controller.c
new file mode 100644
index 0000000..668c6d6
--- /dev/null
+++ b/arch/arm/cpu/armv7/socfpga/freeze_controller.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2013 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/freeze_controller.h>
+#include <asm/arch/timer.h>
+#include <asm/errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+
+
+static const struct socfpga_freeze_controller *freeze_controller_base =
+ (void *)(SOCFPGA_SYSMGR_ADDRESS + SYSMGR_FRZCTRL_ADDRESS);
+
+/*
+ * Default state from cold reset is FREEZE_ALL; the global
+ * flag is set to TRUE to indicate the IO banks are frozen
+ */
+static uint32_t frzctrl_channel_freeze[FREEZE_CHANNEL_NUM]
+ = { FREEZE_CTRL_FROZEN, FREEZE_CTRL_FROZEN,
+ FREEZE_CTRL_FROZEN, FREEZE_CTRL_FROZEN};
+
+
+/* Freeze HPS IOs */
+u32 sys_mgr_frzctrl_freeze_req(FreezeChannelSelect channel_id,
+ FreezeControllerFSMSelect fsm_select)
+{
+ u32 ioctrl_reg_offset;
+ u32 reg_value;
+ u32 reg_cfg_mask;
+
+ if (FREEZE_CONTROLLER_FSM_SW != fsm_select)
+ return -EINVAL;
+
+ /* select software FSM */
+ writel(SYSMGR_FRZCTRL_SRC_VIO1_ENUM_SW, &freeze_controller_base->src);
+
+ /* Freeze channel ID checking and base address */
+ switch (channel_id) {
+ case FREEZE_CHANNEL_0:
+ case FREEZE_CHANNEL_1:
+ case FREEZE_CHANNEL_2:
+ ioctrl_reg_offset = (u32)(
+ &freeze_controller_base->vioctrl +
+ (channel_id << SYSMGR_FRZCTRL_VIOCTRL_SHIFT));
+
+ /*
+ * Assert active low enrnsl, plniotri
+ * and niotri signals
+ */
+ reg_cfg_mask =
+ SYSMGR_FRZCTRL_VIOCTRL_SLEW_MASK
+ | SYSMGR_FRZCTRL_VIOCTRL_WKPULLUP_MASK
+ | SYSMGR_FRZCTRL_VIOCTRL_TRISTATE_MASK;
+ clrbits_le32(ioctrl_reg_offset, reg_cfg_mask);
+
+ /*
+ * Note: Delay for 20ns at min
+ * Assert active low bhniotri signal and de-assert
+ * active high csrdone
+ */
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_VIOCTRL_BUSHOLD_MASK
+ | SYSMGR_FRZCTRL_VIOCTRL_CFG_MASK;
+ clrbits_le32(ioctrl_reg_offset, reg_cfg_mask);
+
+ /* Set global flag to indicate channel is frozen */
+ frzctrl_channel_freeze[channel_id] = FREEZE_CTRL_FROZEN;
+ break;
+
+ case FREEZE_CHANNEL_3:
+ /*
+ * Assert active low enrnsl, plniotri and
+ * niotri signals
+ */
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_HIOCTRL_SLEW_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_WKPULLUP_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_TRISTATE_MASK;
+ clrbits_le32(&freeze_controller_base->hioctrl, reg_cfg_mask);
+
+ /*
+ * Note: Delay for 40ns at min
+ * assert active low bhniotri & nfrzdrv signals,
+ * de-assert active high csrdone and assert
+ * active high frzreg and nfrzdrv signals
+ */
+ reg_value = readl(&freeze_controller_base->hioctrl);
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_HIOCTRL_BUSHOLD_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_CFG_MASK;
+ reg_value
+ = (reg_value & ~reg_cfg_mask)
+ | SYSMGR_FRZCTRL_HIOCTRL_REGRST_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_OCTRST_MASK;
+ writel(reg_value, &freeze_controller_base->hioctrl);
+
+ /*
+ * Note: Delay for 40ns at min
+ * assert active high reinit signal and de-assert
+ * active high pllbiasen signals
+ */
+ reg_value = readl(&freeze_controller_base->hioctrl);
+ reg_value
+ = (reg_value &
+ ~SYSMGR_FRZCTRL_HIOCTRL_OCT_CFGEN_CALSTART_MASK)
+ | SYSMGR_FRZCTRL_HIOCTRL_DLLRST_MASK;
+ writel(reg_value, &freeze_controller_base->hioctrl);
+
+ /* Set global flag to indicate channel is frozen */
+ frzctrl_channel_freeze[channel_id] = FREEZE_CTRL_FROZEN;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/* Unfreeze/Thaw HPS IOs */
+u32 sys_mgr_frzctrl_thaw_req(FreezeChannelSelect channel_id,
+ FreezeControllerFSMSelect fsm_select)
+{
+ u32 ioctrl_reg_offset;
+ u32 reg_cfg_mask;
+ u32 reg_value;
+
+ if (FREEZE_CONTROLLER_FSM_SW != fsm_select)
+ return -EINVAL;
+
+ /* select software FSM */
+ writel(SYSMGR_FRZCTRL_SRC_VIO1_ENUM_SW, &freeze_controller_base->src);
+
+ /* Freeze channel ID checking and base address */
+ switch (channel_id) {
+ case FREEZE_CHANNEL_0:
+ case FREEZE_CHANNEL_1:
+ case FREEZE_CHANNEL_2:
+ ioctrl_reg_offset
+ = (u32)(&freeze_controller_base->vioctrl
+ + (channel_id << SYSMGR_FRZCTRL_VIOCTRL_SHIFT));
+
+ /*
+ * Assert active low bhniotri signal and
+ * de-assert active high csrdone
+ */
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_VIOCTRL_BUSHOLD_MASK
+ | SYSMGR_FRZCTRL_VIOCTRL_CFG_MASK;
+ setbits_le32(ioctrl_reg_offset, reg_cfg_mask);
+
+ /*
+ * Note: Delay for 20ns at min
+ * de-assert active low plniotri and niotri signals
+ */
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_VIOCTRL_WKPULLUP_MASK
+ | SYSMGR_FRZCTRL_VIOCTRL_TRISTATE_MASK;
+ setbits_le32(ioctrl_reg_offset, reg_cfg_mask);
+
+ /*
+ * Note: Delay for 20ns at min
+ * de-assert active low enrnsl signal
+ */
+ setbits_le32(ioctrl_reg_offset,
+ SYSMGR_FRZCTRL_VIOCTRL_SLEW_MASK);
+
+ /* Set global flag to indicate channel is thawed */
+ frzctrl_channel_freeze[channel_id] = FREEZE_CTRL_THAWED;
+
+ break;
+
+ case FREEZE_CHANNEL_3:
+ /* de-assert active high reinit signal */
+ clrbits_le32(&freeze_controller_base->hioctrl,
+ SYSMGR_FRZCTRL_HIOCTRL_DLLRST_MASK);
+
+ /*
+ * Note: Delay for 40ns at min
+ * assert active high pllbiasen signals
+ */
+ setbits_le32(&freeze_controller_base->hioctrl,
+ SYSMGR_FRZCTRL_HIOCTRL_OCT_CFGEN_CALSTART_MASK);
+
+ /*
+ * Delay 1000 intosc. intosc is based on eosc1
+ * Use worst case which is fatest eosc1=50MHz, delay required
+ * is 1/50MHz * 1000 = 20us
+ */
+ udelay(20);
+
+ /*
+ * de-assert active low bhniotri signals,
+ * assert active high csrdone and nfrzdrv signal
+ */
+ reg_value = readl(&freeze_controller_base->hioctrl);
+ reg_value = (reg_value
+ | SYSMGR_FRZCTRL_HIOCTRL_BUSHOLD_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_CFG_MASK)
+ & ~SYSMGR_FRZCTRL_HIOCTRL_OCTRST_MASK;
+ writel(reg_value, &freeze_controller_base->hioctrl);
+
+ /*
+ * Delay 33 intosc
+ * Use worst case which is fatest eosc1=50MHz, delay required
+ * is 1/50MHz * 33 = 660ns ~= 1us
+ */
+ udelay(1);
+
+ /* de-assert active low plniotri and niotri signals */
+ reg_cfg_mask
+ = SYSMGR_FRZCTRL_HIOCTRL_WKPULLUP_MASK
+ | SYSMGR_FRZCTRL_HIOCTRL_TRISTATE_MASK;
+
+ setbits_le32(&freeze_controller_base->hioctrl, reg_cfg_mask);
+
+ /*
+ * Note: Delay for 40ns at min
+ * de-assert active high frzreg signal
+ */
+ clrbits_le32(&freeze_controller_base->hioctrl,
+ SYSMGR_FRZCTRL_HIOCTRL_REGRST_MASK);
+
+ /*
+ * Note: Delay for 40ns at min
+ * de-assert active low enrnsl signal
+ */
+ setbits_le32(&freeze_controller_base->hioctrl,
+ SYSMGR_FRZCTRL_HIOCTRL_SLEW_MASK);
+
+ /* Set global flag to indicate channel is thawed */
+ frzctrl_channel_freeze[channel_id] = FREEZE_CTRL_THAWED;
+
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
diff --git a/arch/arm/cpu/armv7/socfpga/spl.c b/arch/arm/cpu/armv7/socfpga/spl.c
index 74bceab..5173c0d 100644
--- a/arch/arm/cpu/armv7/socfpga/spl.c
+++ b/arch/arm/cpu/armv7/socfpga/spl.c
@@ -13,6 +13,8 @@
#include <asm/arch/reset_manager.h>
#include <spl.h>
#include <asm/arch/system_manager.h>
+#include <asm/arch/freeze_controller.h>
+
DECLARE_GLOBAL_DATA_PTR;
@@ -27,6 +29,13 @@ u32 spl_boot_device(void)
void spl_board_init(void)
{
#ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET
+ debug("Freezing all I/O banks\n");
+ /* freeze all IO banks */
+ sys_mgr_frzctrl_freeze_req(FREEZE_CHANNEL_0, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_freeze_req(FREEZE_CHANNEL_1, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_freeze_req(FREEZE_CHANNEL_2, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_freeze_req(FREEZE_CHANNEL_3, FREEZE_CONTROLLER_FSM_SW);
+
/* configure the pin muxing through system manager */
sysmgr_pinmux_init();
#endif /* CONFIG_SOCFPGA_VIRTUAL_TARGET */
@@ -34,6 +43,13 @@ void spl_board_init(void)
/* de-assert reset for peripherals and bridges based on handoff */
reset_deassert_peripherals_handoff();
+ debug("Unfreezing/Thaw all I/O banks\n");
+ /* unfreeze / thaw all IO banks */
+ sys_mgr_frzctrl_thaw_req(FREEZE_CHANNEL_0, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_thaw_req(FREEZE_CHANNEL_1, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_thaw_req(FREEZE_CHANNEL_2, FREEZE_CONTROLLER_FSM_SW);
+ sys_mgr_frzctrl_thaw_req(FREEZE_CHANNEL_3, FREEZE_CONTROLLER_FSM_SW);
+
/* enable console uart printing */
preloader_console_init();
}
diff --git a/arch/arm/include/asm/arch-socfpga/freeze_controller.h b/arch/arm/include/asm/arch-socfpga/freeze_controller.h
new file mode 100644
index 0000000..b25ff99
--- /dev/null
+++ b/arch/arm/include/asm/arch-socfpga/freeze_controller.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _FREEZE_CONTROLLER_H_
+#define _FREEZE_CONTROLLER_H_
+
+struct socfpga_freeze_controller {
+ u32 vioctrl;
+ u32 padding[3];
+ u32 hioctrl;
+ u32 src;
+ u32 hwctrl;
+};
+
+#define SYSMGR_FRZCTRL_LOOP_PARAM (1000)
+#define SYSMGR_FRZCTRL_DELAY_LOOP_PARAM (10)
+#define SYSMGR_FRZCTRL_INTOSC_33 (33)
+#define SYSMGR_FRZCTRL_INTOSC_1000 (1000)
+#define FREEZE_CHANNEL_NUM (4)
+
+typedef enum {
+ FREEZE_CTRL_FROZEN = 0,
+ FREEZE_CTRL_THAWED = 1
+} FREEZE_CTRL_CHAN_STATE;
+
+typedef enum {
+ FREEZE_CHANNEL_0 = 0, /* EMAC_IO & MIXED2_IO */
+ FREEZE_CHANNEL_1, /* MIXED1_IO and FLASH_IO */
+ FREEZE_CHANNEL_2, /* General IO */
+ FREEZE_CHANNEL_3, /* DDR IO */
+ FREEZE_CHANNEL_UNDEFINED
+} FreezeChannelSelect;
+
+typedef enum {
+ FREEZE_CONTROLLER_FSM_SW = 0,
+ FREEZE_CONTROLLER_FSM_HW,
+ FREEZE_CONTROLLER_FSM_UNDEFINED
+} FreezeControllerFSMSelect;
+
+#define SYSMGR_FRZCTRL_ADDRESS 0x40
+#define SYSMGR_FRZCTRL_SRC_VIO1_ENUM_SW 0x0
+#define SYSMGR_FRZCTRL_SRC_VIO1_ENUM_HW 0x1
+#define SYSMGR_FRZCTRL_VIOCTRL_SLEW_MASK 0x00000010
+#define SYSMGR_FRZCTRL_VIOCTRL_WKPULLUP_MASK 0x00000008
+#define SYSMGR_FRZCTRL_VIOCTRL_TRISTATE_MASK 0x00000004
+#define SYSMGR_FRZCTRL_VIOCTRL_BUSHOLD_MASK 0x00000002
+#define SYSMGR_FRZCTRL_VIOCTRL_CFG_MASK 0x00000001
+#define SYSMGR_FRZCTRL_HIOCTRL_SLEW_MASK 0x00000010
+#define SYSMGR_FRZCTRL_HIOCTRL_WKPULLUP_MASK 0x00000008
+#define SYSMGR_FRZCTRL_HIOCTRL_TRISTATE_MASK 0x00000004
+#define SYSMGR_FRZCTRL_HIOCTRL_BUSHOLD_MASK 0x00000002
+#define SYSMGR_FRZCTRL_HIOCTRL_CFG_MASK 0x00000001
+#define SYSMGR_FRZCTRL_HIOCTRL_REGRST_MASK 0x00000080
+#define SYSMGR_FRZCTRL_HIOCTRL_OCTRST_MASK 0x00000040
+#define SYSMGR_FRZCTRL_HIOCTRL_OCT_CFGEN_CALSTART_MASK 0x00000100
+#define SYSMGR_FRZCTRL_HIOCTRL_DLLRST_MASK 0x00000020
+#define SYSMGR_FRZCTRL_HWCTRL_VIO1REQ_MASK 0x00000001
+#define SYSMGR_FRZCTRL_HWCTRL_VIO1STATE_ENUM_FROZEN 0x2
+#define SYSMGR_FRZCTRL_HWCTRL_VIO1STATE_ENUM_THAWED 0x1
+#define SYSMGR_FRZCTRL_HWCTRL_VIO1STATE_GET(x) (((x) & 0x00000006) >> 1)
+#define SYSMGR_FRZCTRL_VIOCTRL_SHIFT 0x2
+
+u32 sys_mgr_frzctrl_freeze_req(FreezeChannelSelect channel_id,
+ FreezeControllerFSMSelect fsm_select);
+u32 sys_mgr_frzctrl_thaw_req(FreezeChannelSelect channel_id,
+ FreezeControllerFSMSelect fsm_select);
+
+#endif /* _FREEZE_CONTROLLER_H_ */
--
1.7.9.5
2
2

[U-Boot] [RFC 5/5] B4860QDS: Add support of 2 stage NAND boot loader
by Prabhakar Kushwaha 20 Sep '13
by Prabhakar Kushwaha 20 Sep '13
20 Sep '13
Add support of 2 stage NAND boot loader using SPL framework.
here, PBL initialise the internal SRAM and copy SPL(96K). This further
initialise DDR using SPD and environment and copy u-boot(512 kb) from NAND to DDR.
Finally SPL transer control to u-boot.
Initialise/create followings required for SPL framework
- Add spl.c which defines board_init_f, board_init_r
- update tlb and ddr accordingly
Signed-off-by: Prabhakar Kushwaha <prabhakar(a)freescale.com>
---
This is a prototype done on B4860.It has 512K internal RAM.
We only configured SRAM as 256K and made sure only 128KB is used
throught SPL execution.
board/freescale/b4860qds/Makefile | 7 +-
board/freescale/b4860qds/ddr.c | 6 +-
board/freescale/b4860qds/spl.c | 128 +++++++++++++++++++++++++++++++++++++
board/freescale/b4860qds/tlb.c | 10 +++
boards.cfg | 2 +-
include/configs/B4860QDS.h | 58 +++++++++++++++--
6 files changed, 203 insertions(+), 8 deletions(-)
create mode 100644 board/freescale/b4860qds/spl.c
diff --git a/board/freescale/b4860qds/Makefile b/board/freescale/b4860qds/Makefile
index a864c0b..42819a6 100644
--- a/board/freescale/b4860qds/Makefile
+++ b/board/freescale/b4860qds/Makefile
@@ -8,10 +8,15 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).o
+ifdef CONFIG_SPL_BUILD
+COBJS-y += spl.o
+endif
+ifndef CONFIG_SPL_BUILD
COBJS-y += $(BOARD).o
-COBJS-y += ddr.o
COBJS-$(CONFIG_B4860QDS)+= eth_b4860qds.o
COBJS-$(CONFIG_PCI) += pci.o
+endif
+COBJS-y += ddr.o
COBJS-y += law.o
COBJS-y += tlb.o
diff --git a/board/freescale/b4860qds/ddr.c b/board/freescale/b4860qds/ddr.c
index b82b3d4..467be3c 100644
--- a/board/freescale/b4860qds/ddr.c
+++ b/board/freescale/b4860qds/ddr.c
@@ -181,12 +181,16 @@ phys_size_t initdram(int board_type)
puts("Initializing....using SPD\n");
+#ifdef CONFIG_SPL_BUILD
dram_size = fsl_ddr_sdram();
dram_size = setup_ddr_tlbs(dram_size / 0x100000);
dram_size *= 0x100000;
- puts(" DDR: ");
+#else
+ puts("DDR has been initialised by pre loader\n");
+ dram_size = 0x80000000;
+#endif
return dram_size;
}
diff --git a/board/freescale/b4860qds/spl.c b/board/freescale/b4860qds/spl.c
new file mode 100644
index 0000000..55891fc
--- /dev/null
+++ b/board/freescale/b4860qds/spl.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <asm/processor.h>
+#include <asm/mmu.h>
+#include <ns16550.h>
+#include <asm/spl.h>
+#include <asm/fsl_law.h>
+#include <asm/fsl_ddr_sdram.h>
+#include <malloc.h>
+#include <nand.h>
+#include <i2c.h>
+#include "../common/qixis.h"
+#include "b4860qds_qixis.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+ulong get_effective_memsize(void)
+{
+ return CONFIG_SYS_L3_SIZE;
+}
+
+unsigned long get_board_sys_clk(void)
+{
+ u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
+
+ switch ((sysclk_conf & 0x0C) >> 2) {
+ case QIXIS_CLK_100:
+ return 100000000;
+ case QIXIS_CLK_125:
+ return 125000000;
+ case QIXIS_CLK_133:
+ return 133333333;
+ }
+ return 66666666;
+}
+
+unsigned long get_board_ddr_clk(void)
+{
+ u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
+
+ switch (ddrclk_conf & 0x03) {
+ case QIXIS_CLK_100:
+ return 100000000;
+ case QIXIS_CLK_125:
+ return 125000000;
+ case QIXIS_CLK_133:
+ return 133333333;
+ }
+ return 66666666;
+}
+
+void board_init_f(ulong bootflag)
+{
+ u32 plat_ratio, sys_clk, uart_clk;
+ u32 stack = CONFIG_SPL_RELOC_STACK;
+ ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
+
+ console_init_f();
+
+ /* initialize selected port with appropriate baud rate */
+ sys_clk = get_board_sys_clk();
+ /* plat_ratio = 10; */
+ plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
+ uart_clk = sys_clk * plat_ratio / 2;
+
+ NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+ uart_clk / 16 / CONFIG_BAUDRATE);
+
+ /* clear BSS segment */
+ memset(__bss_start, 0, __bss_end - __bss_start);
+
+ /* Set STACK pointer */
+ asm volatile ("lwz 1, %0" : : "m"(stack));
+
+ board_init_r(NULL, 0x0);
+}
+
+void board_init_r(gd_t *gd, ulong dest_addr)
+{
+ /* Pointer is writable since we allocated a register for it */
+ gd = (gd_t *)CONFIG_SPL_GD_ADDR;
+ bd_t *bd;
+
+ memset(gd, 0, sizeof(gd_t));
+ bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
+ memset(bd, 0, sizeof(bd_t));
+ gd->bd = bd;
+ bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
+ bd->bi_memsize = CONFIG_SYS_L3_SIZE;
+
+ probecpu();
+ get_clocks();
+ mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
+ CONFIG_SPL_RELOC_MALLOC_SIZE);
+ env_init();
+
+ /* relocate environment function pointers etc. */
+ env_relocate();
+
+ i2c_init(CONFIG_SYS_FSL_I2C_SPEED, CONFIG_SYS_FSL_I2C_SLAVE);
+
+ gd->ram_size = initdram(0);
+ puts("Second program loader running in sram...\n");
+
+#ifdef CONFIG_SPL_NAND_BOOT
+ nand_boot();
+#endif
+}
diff --git a/board/freescale/b4860qds/tlb.c b/board/freescale/b4860qds/tlb.c
index f71aca4..734b1e3 100644
--- a/board/freescale/b4860qds/tlb.c
+++ b/board/freescale/b4860qds/tlb.c
@@ -62,6 +62,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
MAS3_SX|MAS3_SR, MAS2_W|MAS2_G,
0, 2, BOOKE_PAGESZ_256M, 1),
+#ifndef CONFIG_SPL_BUILD
/* *I*G* - PCI */
SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_PHYS,
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
@@ -96,6 +97,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
0, 9, BOOKE_PAGESZ_16M, 1),
#endif
+#endif
#ifdef CONFIG_SYS_DCSRBAR_PHYS
SET_TLB_ENTRY(1, CONFIG_SYS_DCSRBAR, CONFIG_SYS_DCSRBAR_PHYS,
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
@@ -118,6 +120,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
* entry 14 and 15 has been used hard coded, they will be disabled
* in cpu_init_f, so we use entry 16 for SRIO2.
*/
+#ifndef CONFIG_SPL_BUILD
#ifdef CONFIG_SYS_SRIO1_MEM_PHYS
/* *I*G* - SRIO1 */
SET_TLB_ENTRY(1, CONFIG_SYS_SRIO1_MEM_VIRT, CONFIG_SYS_SRIO1_MEM_PHYS,
@@ -140,6 +143,13 @@ struct fsl_e_tlb_entry tlb_table[] = {
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_G,
0, 17, BOOKE_PAGESZ_1M, 1),
#endif
+#endif
+
+#if defined(CONFIG_RAMBOOT_PBL) && !defined(CONFIG_SPL_BUILD)
+ SET_TLB_ENTRY(1, CONFIG_SYS_DDR_SDRAM_BASE, CONFIG_SYS_DDR_SDRAM_BASE,
+ MAS3_SX|MAS3_SW|MAS3_SR, 0,
+ 0, 17, BOOKE_PAGESZ_2G, 1)
+#endif
};
int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/boards.cfg b/boards.cfg
index b4297e5..824d77d 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -950,7 +950,7 @@ T4160QDS powerpc mpc85xx t4qds freesca
T4160QDS_SDCARD powerpc mpc85xx t4qds freescale - T4240QDS:PPC_T4160,RAMBOOT_PBL,SDCARD,SYS_TEXT_BASE=0xFFF80000
T4160QDS_SPIFLASH powerpc mpc85xx t4qds freescale - T4240QDS:PPC_T4160,RAMBOOT_PBL,SPIFLASH,SYS_TEXT_BASE=0xFFF80000
B4860QDS powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4860
-B4860QDS_NAND powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4860,RAMBOOT_PBL,NAND,SYS_TEXT_BASE=0xFFF80000
+B4860QDS_NAND powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4860,RAMBOOT_PBL,NAND
B4860QDS_SPIFLASH powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4860,RAMBOOT_PBL,SPIFLASH,SYS_TEXT_BASE=0xFFF80000
B4860QDS_SRIO_PCIE_BOOT powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4860,SRIO_PCIE_BOOT_SLAVE,SYS_TEXT_BASE=0xFFF80000
B4420QDS powerpc mpc85xx b4860qds freescale - B4860QDS:PPC_B4420
diff --git a/include/configs/B4860QDS.h b/include/configs/B4860QDS.h
index 2f0bc6b..0fef305 100644
--- a/include/configs/B4860QDS.h
+++ b/include/configs/B4860QDS.h
@@ -14,8 +14,41 @@
#define CONFIG_PHYS_64BIT
#ifdef CONFIG_RAMBOOT_PBL
+#ifndef CONFIG_NAND
#define CONFIG_RAMBOOT_TEXT_BASE CONFIG_SYS_TEXT_BASE
#define CONFIG_RESET_VECTOR_ADDRESS 0xfffffffc
+#else
+#define CONFIG_SPL
+#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
+#define CONFIG_SPL_ENV_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_FLUSH_IMAGE
+#define CONFIG_SPL_TARGET "u-boot-with-spl.bin"
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_FSL_LAW /* Use common FSL init code */
+#define CONFIG_SKIP_RELOCATE_SPL
+#define CONFIG_SYS_TEXT_BASE 0x00201000
+#define CONFIG_SPL_TEXT_BASE 0xfffe8000
+#define CONFIG_SPL_PAD_TO 0x18000
+#define CONFIG_SPL_MAX_SIZE 0x18000
+#define RESET_VECTOR_OFFSET 0x17FFC
+#define BOOT_PAGE_OFFSET 0x17000
+#define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SYS_NAND_U_BOOT_SIZE (512 << 10)
+#define CONFIG_SYS_NAND_U_BOOT_DST 0x00200000
+#define CONFIG_SYS_NAND_U_BOOT_START 0x00200000
+#define CONFIG_SYS_NAND_U_BOOT_OFFS (512 << 10)
+#define CONFIG_SYS_LDSCRIPT "arch/powerpc/cpu/mpc85xx/u-boot-nand.lds"
+#define CONFIG_SPL_NAND_BOOT
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_SPL_COMMON_INIT_DDR
+#define CONFIG_SYS_CCSR_DO_NOT_RELOCATE
+#define CONFIG_SYS_NO_FLASH
+#endif
+#define CONFIG_RAMBOOT_TEXT_BASE 0xFFF80000
+#endif
#endif
#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
@@ -112,8 +145,8 @@
#elif defined(CONFIG_NAND)
#define CONFIG_SYS_EXTRA_ENV_RELOC
#define CONFIG_ENV_IS_IN_NAND
-#define CONFIG_ENV_SIZE CONFIG_SYS_NAND_BLOCK_SIZE
-#define CONFIG_ENV_OFFSET (5 * CONFIG_SYS_NAND_BLOCK_SIZE)
+#define CONFIG_ENV_SIZE 0x1000
+#define CONFIG_ENV_OFFSET (8 * CONFIG_SYS_NAND_BLOCK_SIZE)
#elif defined(CONFIG_SRIO_PCIE_BOOT_SLAVE)
#define CONFIG_ENV_IS_IN_REMOTE
#define CONFIG_ENV_ADDR 0xffe20000
@@ -163,7 +196,14 @@ unsigned long get_board_ddr_clk(void);
/*
* Config the L3 Cache as L3 SRAM
*/
-#define CONFIG_SYS_INIT_L3_ADDR CONFIG_RAMBOOT_TEXT_BASE
+#define CONFIG_SYS_L3_SIZE 512 << 10
+#define CONFIG_SYS_INIT_L3_ADDR 0xFFFE0000
+#define CONFIG_SPL_RELOC_TEXT_BASE CONFIG_SYS_INIT_L3_ADDR
+#define CONFIG_SPL_GD_ADDR CONFIG_SYS_INIT_L3_ADDR
+#define CONFIG_SPL_RELOC_MALLOC_ADDR (CONFIG_SYS_INIT_L3_ADDR + 1 * 1024)
+#define CONFIG_SPL_RELOC_MALLOC_SIZE (26 << 10)
+#define CONFIG_SPL_RELOC_STACK (CONFIG_SYS_INIT_L3_ADDR + 32 * 1024)
+#define CONFIG_SPL_RELOC_STACK_SIZE (5 << 10)
#ifdef CONFIG_PHYS_64BIT
#define CONFIG_SYS_DCSRBAR 0xf0000000
@@ -192,7 +232,9 @@ unsigned long get_board_ddr_clk(void);
#define CONFIG_DDR_SPD
#define CONFIG_SYS_DDR_RAW_TIMING
#define CONFIG_FSL_DDR3
+#ifndef CONFIG_SPL_BUILD
#define CONFIG_FSL_DDR_INTERACTIVE
+#endif
#define CONFIG_SYS_SPD_BUS_NUM 0
#define SPD_EEPROM_ADDRESS1 0x51
@@ -378,7 +420,11 @@ unsigned long get_board_ddr_clk(void);
#define CONFIG_SYS_CS1_FTIM2 CONFIG_SYS_NOR_FTIM2
#define CONFIG_SYS_CS1_FTIM3 CONFIG_SYS_NOR_FTIM3
-#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SPL_TEXT_BASE
+#else
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE /* start of monitor */
+#endif
#if defined(CONFIG_RAMBOOT_PBL)
#define CONFIG_SYS_RAMBOOT
@@ -432,7 +478,9 @@ unsigned long get_board_ddr_clk(void);
#define CONFIG_SYS_NS16550_COM3 (CONFIG_SYS_CCSRBAR+0x11D500)
#define CONFIG_SYS_NS16550_COM4 (CONFIG_SYS_CCSRBAR+0x11D600)
#define CONFIG_SERIAL_MULTI /* Enable both serial ports */
+#ifndef CONFIG_SPL_BUILD
#define CONFIG_SYS_CONSOLE_IS_IN_ENV /* determine from environment */
+#endif
/* Use the HUSH parser */
@@ -604,7 +652,7 @@ unsigned long get_board_ddr_clk(void);
#define CONFIG_SYS_QE_FMAN_FW_ADDR (512 * 1130)
#elif defined(CONFIG_NAND)
#define CONFIG_SYS_QE_FMAN_FW_IN_NAND
-#define CONFIG_SYS_QE_FMAN_FW_ADDR (6 * CONFIG_SYS_NAND_BLOCK_SIZE)
+#define CONFIG_SYS_QE_FMAN_FW_ADDR (9 * CONFIG_SYS_NAND_BLOCK_SIZE)
#elif defined(CONFIG_SRIO_PCIE_BOOT_SLAVE)
/*
* Slave has no ucode locally, it can fetch this from remote. When implementing
--
1.7.9.5
2
4
This adds the preset value to register, and setup of baudrate.
Signed-off-by: Kouei Abe <kouei.abe.cp(a)renesas.com>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj(a)renesas.com>
---
drivers/serial/serial_sh.c | 1 +
drivers/serial/serial_sh.h | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index 67cc0dc..0826d59 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -1,5 +1,6 @@
/*
* SuperH SCIF device driver.
+ * Copyright (C) 2013 Renesas Electronics Corporation
* Copyright (C) 2007,2008,2010 Nobuhiro Iwamatsu
* Copyright (C) 2002 - 2008 Paul Mundt
*
diff --git a/drivers/serial/serial_sh.h b/drivers/serial/serial_sh.h
index 7e38a3f..a6558af 100644
--- a/drivers/serial/serial_sh.h
+++ b/drivers/serial/serial_sh.h
@@ -224,6 +224,9 @@ struct uart_port {
# define SCSPTR3 0xffc60020 /* 16 bit SCIF */
# define SCIF_ORER 0x0001 /* Overrun error bit */
# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
+#elif defined(CONFIG_R8A7790)
+# define SCIF_ORER 0x0001
+# define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0, */
#else
# error CPU subtype not defined
#endif
@@ -298,6 +301,9 @@ struct uart_port {
/* SH7763 SCIF2 support */
# define SCIF2_RFDC_MASK 0x001f
# define SCIF2_TXROOM_MAX 16
+#elif defined(CONFIG_R8A7790)
+# define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
+# define SCIF_RFDC_MASK 0x003f
#else
# define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
# define SCIF_RFDC_MASK 0x001f
@@ -579,6 +585,10 @@ SCIF_FNS(SCSPTR, 0, 0, 0, 0)
#else
SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
#endif
+#if defined(CONFIG_R8A7790)
+SCIF_FNS(DL, 0, 0, 0x30, 16)
+SCIF_FNS(CKS, 0, 0, 0x34, 16)
+#endif
SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
#endif
#endif
@@ -720,6 +730,9 @@ static inline int scbrr_calc(struct uart_port port, int bps, int clk)
#define SCBRR_VALUE(bps, clk) scbrr_calc(sh_sci, bps, clk)
#elif defined(__H8300H__) || defined(__H8300S__)
#define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1)
+#elif defined(CONFIG_R8A7790)
+#define SCBRR DL
+#define SCBRR_VALUE(bps, clk) (clk / bps / 16)
#else /* Generic SH */
#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
#endif
--
1.8.3.2
2
4

19 Sep '13
> On Tue, Aug 06, 2013 at 01:45:08PM +0530, Pekon Gupta wrote:
>
> > ti814x_evm has on-board socket for using Micron (MT29Fxx) family of
> > NAND devices to GPMC interface. This patch
> > - adds NAND related pin-mux configuration for same
> > - adds #defines for NAND partitions to TI814x configs
> > - enables support for NAND in TI814x configs
[snip]
>
> > @@ -186,6 +193,14 @@
> > #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */
> > #define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION 1
> > #define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME "u-boot.img"
> > +
> > +#ifdef CONFIG_SPL_OS_BOOT
> > +/* nand */
> > +#define CONFIG_CMD_SPL_NAND_OFS 0x000000 /*
> end of u-boot */
> > +#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x280000
> > +#define CONFIG_CMD_SPL_WRITE_SIZE 0x1000
> > +#endif
>
> Since you aren't adding the SD/MMC defines as well, nor setting
> SPL_OS_BOOT, lets drop these.
>
Sorry but dint get your feedback.
Following are used in SPL boot for loading env and kernel in falcon mode.
Referring: $UBOOT/common/spl/spl_nand.c
- CONFIG_SYS_NAND_SPL_KERNEL_OFFS
- CONFIG_CMD_SPL_WRITE_SIZE
- CONFIG_CMD_SPL_NAND_OFS
May be I put them in wrong place in include/configs/ti814x.h but these
are required for NAND SPL boot. Please confirm ?
> > @@ -242,5 +283,32 @@
> > #define CONFIG_PHY_ADDR 1
> > #define CONFIG_PHY_ET1011C
> > #define CONFIG_PHY_ET1011C_TX_CLK_FIX
> > +#define CONFIG_NAND
> > +/* NAND support */
> > +#ifdef CONFIG_NAND
> > +#define CONFIG_MTD_NAND_OMAP_BCH
> > +#define CONFIG_CMD_NAND
> > +#define CONFIG_CMD_MTDPARTS
> > +#define MTDIDS_DEFAULT "nand0=omap2-nand.0"
> > +#define MTDPARTS_DEFAULT "mtdparts=omap2-
> nand.0:128k(SPL)," \
> > + "128k(u-boot-spl)," \
> > + "2M(u-boot-main)," \
> > + "128k(u-boot-env),4M(kernel),-
> (rootfs)"
>
> Lets get the partition tables right, we've still got 4 locations where
> ROM checks for something, so lets use those for SPL, then U-Boot, then
> U-Boot Env (redundant as well, please), and a block saved off for device
> tree/SPL OS "args" support, then kernel, rootfs.
>
I think TI814x ROM use different NAND layout than AM33xx devices.
I used following NAND layout given in link below as reference:
http://processors.wiki.ti.com/index.php/TI81XX_PSP_UBOOT_User_Guide#EVM_Swi…
These devices belong to omap3 family, but now are merged with am33xx.
> > +#define CONFIG_NAND_OMAP_GPMC
> > +#define GPMC_NAND_ECC_LP_x16_LAYOUT 1
> > +#define NAND_BASE (0x08000000)
>
> Don't need NAND_BASE.
Ok thanks.
- Also removing GPMC_NAND_ECC_LP_x16_LAYOUT as predefined
nand_ecclayouts in omap_gpmc.h are not used anymore.
- Trying to remove dependency on CONFIG_NAND_OMAP_GPMC as
except legacy devices all new platform support ELM based ECC schemes.
>
> > +#define CONFIG_SYS_NAND_BASE (0x08000000) /* physical
> address */
> > + /* to access nand at> */
> > + /* CS0 */
> > +#define CONFIG_SYS_MAX_NAND_DEVICE 1
> > +/* Max number of NAND devices */
> > +#define CONFIG_SYS_NAND_BOOT
> > +#if !defined(CONFIG_SPI_BOOT)
> > +#undef CONFIG_ENV_IS_NOWHERE
> > +#define CONFIG_ENV_IS_IN_NAND
> > +#define CONFIG_ENV_OFFSET 0x260000 /* environment
> starts here */
> > +#define CONFIG_SYS_ENV_SECT_SIZE (128 << 10) /* 128 KiB */
> > +#endif
> > +#endif
>
> And we don't support SPI boot or anything here, so lets just always do
> env on NAND until we have support for other things as well. Thanks!
>
Ok. yes I'll remove them..
with regards, pekon
2
1
Dear Huang,
On 09/02/2013 10:50 AM, Huang Shijie wrote:
> 于 2013年09月02日 16:42, Hector Palacios 写道:
>> I am writing the JFFS2 partition from my custom U-Boot. Do you mean
>> that they way it writes it could not be compatible with what the new
>> driver expects? That sounds really bad.
>
> The mtd code(as well as the gpmi driver) has merge many patch to the kernel,
> BUT, the relative patches are not submitted to uboot maillist. So the
> code is not aligned between the
> uboot and the kernel.
Ok, I just rewrote the JFFS2 partition using the mtd-utils and now it mounts correctly
and without any error.
So does this mean that U-Boot is now unable to properly write a JFFS2 partition for it
to be understood by the linux-next kernel? What is exactly the difference? Does it
only affect Freescale NAND controllers?
I'm including the U-Boot mailing list in CC.
The complete thread for reference: http://patchwork.ozlabs.org/patch/271322/
Best regards,
--
Hector Palacios
4
18
Hello Albert.
Commit 27af930e modified top Makefile as follows:
--- a/Makefile
+++ b/Makefile
@@ -838,7 +838,7 @@ unconfig:
sinclude $(obj).boards.depend
$(obj).boards.depend: boards.cfg
- @awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@
+ @awk '(NF && $$1 !~ /^#/) { print $$7 ": " $$7 "_config; $$(MAKE) -d" }' $< > $@
#
# Functions to generate common board directory names
I thought adding -d option is not what you intended.
So, I posted a patch "[U-Boot] Makefile: Do not show make debug messages"
to delete -d option again.
Does my patch seem to be OK?
I am really suffering from lots of debug messages like follows:
$ make CROSS_COMPILE=arm-linux-gnueabi- omap4_panda
Configuring for omap4_panda board...
make -d
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Reading makefile `Makefile'...
Reading makefile `include/autoconf.mk.dep' (search path) (don't care) (no ~ expansion)...
Reading makefile `include/autoconf.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `include/config.mk' (search path) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/config.mk' (search path) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/include/generated/cc_options.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/include/autoconf.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/include/config.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/arch/arm/config.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/arch/arm/cpu/armv7/config.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/arch/arm/cpu/armv7/omap4/config.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `/home/yamada/workspace/u-boot/board/ti/panda/config.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `.boards.depend' (search path) (don't care) (no ~ expansion)...
Updating makefiles....
Considering target file `.boards.depend'.
Considering target file `boards.cfg'.
Looking for an implicit rule for `boards.cfg'.
Trying pattern rule with stem `boards.cfg'.
Trying implicit prerequisite `boards.cfg.o'.
Trying pattern rule with stem `boards.cfg'.
.....
Best Regards
Masahiro Yamada
3
5

[U-Boot] [PATCH] mx6: compute PLL PFD frequencies rather than using defines
by Pierre Aubert 19 Sep '13
by Pierre Aubert 19 Sep '13
19 Sep '13
Signed-off-by: Pierre Aubert <p.aubert(a)staubli.com>
CC: Stefano Babic <sbabic(a)denx.de>
---
arch/arm/cpu/armv7/mx6/clock.c | 75 ++++++++++++++++++++++++------
arch/arm/include/asm/arch-mx6/crm_regs.h | 11 ----
2 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 7a29c9b..0c59541 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -100,6 +100,51 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
}
/* NOTREACHED */
}
+static u32 mxc_get_pll_pfd(enum pll_clocks pll, int pfd_num)
+{
+ u32 div;
+ u64 freq;
+
+ switch (pll) {
+ case PLL_BUS:
+ div = __raw_readl(&imx_ccm->analog_pfd_528);
+ freq = (u64)decode_pll(PLL_BUS, MXC_HCLK);
+ break;
+ case PLL_USBOTG:
+ div = __raw_readl(&imx_ccm->analog_pfd_480);
+ freq = (u64)decode_pll(PLL_USBOTG, MXC_HCLK);
+ break;
+ default:
+ /* No PFD on other PLL */
+ return 0;
+ }
+ freq *= 18;
+
+ switch (pfd_num) {
+ case 0:
+ div &= BM_ANADIG_PFD_528_PFD0_FRAC;
+ break;
+ case 1:
+ div &= BM_ANADIG_PFD_528_PFD1_FRAC;
+ div >>= BP_ANADIG_PFD_528_PFD1_FRAC;
+ break;
+ case 2:
+ div &= BM_ANADIG_PFD_528_PFD2_FRAC;
+ div >>= BP_ANADIG_PFD_528_PFD2_FRAC;
+ break;
+ case 3:
+ if (pll == PLL_SYS) {
+ /* No PFD3 on PPL2 */
+ return 0;
+ }
+ div &= BM_ANADIG_PFD_528_PFD3_FRAC;
+ div >>= BP_ANADIG_PFD_528_PFD3_FRAC;
+ break;
+ default:
+ return 0;
+ }
+ return freq / div;
+}
static u32 get_mcu_main_clk(void)
{
@@ -144,13 +189,14 @@ u32 get_periph_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
- freq = PLL2_PFD2_FREQ;
+ freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
- freq = PLL2_PFD0_FREQ;
+ freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
- freq = PLL2_PFD2_DIV_FREQ;
+ /* static / 2 divider */
+ freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
break;
default:
break;
@@ -184,7 +230,7 @@ static u32 get_ipg_per_clk(void)
static u32 get_uart_clk(void)
{
u32 reg, uart_podf;
- u32 freq = PLL3_80M;
+ u32 freq = decode_pll(PLL_USBOTG, MXC_HCLK) / 6; /* static divider */
reg = __raw_readl(&imx_ccm->cscdr1);
#ifdef CONFIG_MX6SL
if (reg & MXC_CCM_CSCDR1_UART_CLK_SEL)
@@ -204,7 +250,7 @@ static u32 get_cspi_clk(void)
reg &= MXC_CCM_CSCDR2_ECSPI_CLK_PODF_MASK;
cspi_podf = reg >> MXC_CCM_CSCDR2_ECSPI_CLK_PODF_OFFSET;
- return PLL3_60M / (cspi_podf + 1);
+ return decode_pll(PLL_USBOTG, MXC_HCLK) / (8 * (cspi_podf + 1));
}
static u32 get_axi_clk(void)
@@ -217,9 +263,9 @@ static u32 get_axi_clk(void)
if (cbcdr & MXC_CCM_CBCDR_AXI_SEL) {
if (cbcdr & MXC_CCM_CBCDR_AXI_ALT_SEL)
- root_freq = PLL2_PFD2_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
else
- root_freq = PLL3_PFD1_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_USBOTG, 1);
} else
root_freq = get_periph_clk();
@@ -244,10 +290,10 @@ static u32 get_emi_slow_clk(void)
root_freq = decode_pll(PLL_USBOTG, MXC_HCLK);
break;
case 2:
- root_freq = PLL2_PFD2_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 3:
- root_freq = PLL2_PFD0_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
}
@@ -270,13 +316,14 @@ static u32 get_mmdc_ch0_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
- freq = PLL2_PFD2_FREQ;
+ freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
- freq = PLL2_PFD0_FREQ;
+ freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
- freq = PLL2_PFD2_DIV_FREQ;
+ /* static / 2 divider */
+ freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
}
return freq / (podf + 1);
@@ -329,9 +376,9 @@ static u32 get_usdhc_clk(u32 port)
}
if (clk_sel)
- root_freq = PLL2_PFD0_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_BUS, 0);
else
- root_freq = PLL2_PFD2_FREQ;
+ root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
return root_freq / (usdhc_podf + 1);
}
diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h b/arch/arm/include/asm/arch-mx6/crm_regs.h
index 5e6c4da..64f36f9 100644
--- a/arch/arm/include/asm/arch-mx6/crm_regs.h
+++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
@@ -891,15 +891,4 @@ struct mxc_ccm_reg {
#define BF_ANADIG_PFD_528_PFD0_FRAC(v) \
(((v) << 0) & BM_ANADIG_PFD_528_PFD0_FRAC)
-#define PLL2_PFD0_FREQ 352000000
-#define PLL2_PFD1_FREQ 594000000
-#define PLL2_PFD2_FREQ 400000000
-#define PLL2_PFD2_DIV_FREQ 200000000
-#define PLL3_PFD0_FREQ 720000000
-#define PLL3_PFD1_FREQ 540000000
-#define PLL3_PFD2_FREQ 508200000
-#define PLL3_PFD3_FREQ 454700000
-#define PLL3_80M 80000000
-#define PLL3_60M 60000000
-
#endif /*__ARCH_ARM_MACH_MX6_CCM_REGS_H__ */
--
1.7.6.5
1
1