summaryrefslogtreecommitdiff
path: root/lib_blackfin
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-01-28 21:09:32 +0100
committerWolfgang Denk <wd@denx.de>2009-01-28 21:09:32 +0100
commitee64d0acc93f4f15850736eafaacdeadd7f12d25 (patch)
treec3cbea9a94ac333eaaaa0f6d277d5b6c1fe9759c /lib_blackfin
parent9cda4f104b5313fadc21b75aa781c7a6aaf6ea60 (diff)
parentfe033ad6d0883063fe857237abb9436fab03208c (diff)
downloadu-boot-imx-ee64d0acc93f4f15850736eafaacdeadd7f12d25.zip
u-boot-imx-ee64d0acc93f4f15850736eafaacdeadd7f12d25.tar.gz
u-boot-imx-ee64d0acc93f4f15850736eafaacdeadd7f12d25.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-blackfin
Diffstat (limited to 'lib_blackfin')
-rw-r--r--lib_blackfin/Makefile2
-rw-r--r--lib_blackfin/board.c37
-rw-r--r--lib_blackfin/boot.c (renamed from lib_blackfin/bootm.c)19
-rw-r--r--lib_blackfin/string.c45
4 files changed, 66 insertions, 37 deletions
diff --git a/lib_blackfin/Makefile b/lib_blackfin/Makefile
index 3f69770..fee0fda 100644
--- a/lib_blackfin/Makefile
+++ b/lib_blackfin/Makefile
@@ -37,7 +37,7 @@ SOBJS-y += memmove.o
SOBJS-y += memset.o
COBJS-y += board.o
-COBJS-y += bootm.o
+COBJS-y += boot.o
COBJS-y += cache.o
COBJS-y += muldi3.o
COBJS-y += post.o
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index ddf8144..01b71d4 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -13,10 +13,10 @@
#include <command.h>
#include <devices.h>
#include <environment.h>
-#include <i2c.h>
#include <malloc.h>
#include <net.h>
#include <timestamp.h>
+#include <status_led.h>
#include <version.h>
#include <asm/cplb.h>
@@ -279,9 +279,13 @@ void board_init_f(ulong bootflag)
dcache_enable();
#endif
+#ifdef DEBUG
+ if (CONFIG_SYS_GBL_DATA_SIZE < sizeof(*gd))
+ hang();
+#endif
serial_early_puts("Init global data\n");
gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
- memset((void *)gd, 0, sizeof(gd_t));
+ memset((void *)gd, 0, CONFIG_SYS_GBL_DATA_SIZE);
/* Board data initialization */
addr = (CONFIG_SYS_GBL_DATA_ADDR + sizeof(gd_t));
@@ -331,16 +335,6 @@ void board_init_f(ulong bootflag)
board_init_r((gd_t *) gd, 0x20000010);
}
-#if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C)
-static int init_func_i2c(void)
-{
- puts("I2C: ");
- i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
- puts("ready\n");
- return (0);
-}
-#endif
-
void board_init_r(gd_t * id, ulong dest_addr)
{
extern void malloc_bin_reloc(void);
@@ -356,14 +350,14 @@ void board_init_r(gd_t * id, ulong dest_addr)
#endif
#if !defined(CONFIG_SYS_NO_FLASH)
- /* There are some other pointer constants we must deal with */
- /* configure available FLASH banks */
+ /* Initialize the flash and protect u-boot by default */
extern flash_info_t flash_info[];
ulong size = flash_init();
puts("Flash: ");
print_size(size, "\n");
flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
- CONFIG_SYS_FLASH_BASE + 0x1ffff, &flash_info[0]);
+ CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
+ &flash_info[0]);
bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
bd->bi_flashsize = size;
bd->bi_flashoffset = 0;
@@ -420,6 +414,11 @@ void board_init_r(gd_t * id, ulong dest_addr)
/* Initialize the console (after the relocation and devices init) */
console_init_r();
+#ifdef CONFIG_STATUS_LED
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
+ status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
+#endif
+
/* Initialize from environment */
if ((s = getenv("loadaddr")) != NULL)
load_addr = simple_strtoul(s, NULL, 16);
@@ -442,10 +441,6 @@ void board_init_r(gd_t * id, ulong dest_addr)
bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
#endif
-#if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C)
- init_func_i2c();
-#endif
-
display_global_data();
#if defined(CONFIG_POST)
@@ -460,6 +455,10 @@ void board_init_r(gd_t * id, ulong dest_addr)
void hang(void)
{
+#ifdef CONFIG_STATUS_LED
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+ status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
+#endif
puts("### ERROR ### Please RESET the board ###\n");
while (1)
/* If a JTAG emulator is hooked up, we'll automatically trigger
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/boot.c
index 195eb9c..951d5b0 100644
--- a/lib_blackfin/bootm.c
+++ b/lib_blackfin/boot.c
@@ -1,5 +1,5 @@
/*
- * U-boot - bootm.c - misc boot helper functions
+ * U-boot - boot.c - misc boot helper functions
*
* Copyright (c) 2005-2008 Analog Devices Inc.
*
@@ -20,17 +20,19 @@ extern void swap_to(int device_id);
static char *make_command_line(void)
{
- char *dest = (char *)CMD_LINE_ADDR;
+ char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
char *bootargs = getenv("bootargs");
if (bootargs == NULL)
return NULL;
- strncpy(dest, bootargs, 0x1000);
- dest[0xfff] = 0;
+ strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
+ dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
return dest;
}
+extern ulong bfin_poweron_retx;
+
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
int (*appl) (char *cmdline);
@@ -45,11 +47,16 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
appl = (int (*)(char *))images->ep;
- printf("Starting Kernel at = %x\n", appl);
+ printf("Starting Kernel at = %p\n", appl);
cmdline = make_command_line();
icache_disable();
dcache_disable();
- (*appl) (cmdline);
+ asm __volatile__(
+ "RETX = %[retx];"
+ "CALL (%0);"
+ :
+ : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
+ );
/* does not return */
return 1;
diff --git a/lib_blackfin/string.c b/lib_blackfin/string.c
index 6887c93..36eecdf 100644
--- a/lib_blackfin/string.c
+++ b/lib_blackfin/string.c
@@ -1,7 +1,7 @@
/*
* U-boot - string.c Contains library routines.
*
- * Copyright (c) 2005-2007 Analog Devices Inc.
+ * Copyright (c) 2005-2008 Analog Devices Inc.
*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
@@ -130,12 +130,22 @@ int strncmp(const char *cs, const char *ct, size_t count)
# define bfin_write_MDMA_D0_IRQ_STATUS bfin_write_MDMA1_D0_IRQ_STATUS
# define bfin_read_MDMA_D0_IRQ_STATUS bfin_read_MDMA1_D0_IRQ_STATUS
#endif
-static void *dma_memcpy(void *dst, const void *src, size_t count)
+/* This version misbehaves for count values of 0 and 2^16+.
+ * Perhaps we should detect that ? Nowhere do we actually
+ * use dma memcpy for those types of lengths though ...
+ */
+void dma_memcpy_nocache(void *dst, const void *src, size_t count)
{
- if (dcache_status())
- blackfin_dcache_flush_range(src, src + count);
+ /* Scratchpad cannot be a DMA source or destination */
+ if (((unsigned long)src >= L1_SRAM_SCRATCH &&
+ (unsigned long)src < L1_SRAM_SCRATCH_END) ||
+ ((unsigned long)dst >= L1_SRAM_SCRATCH &&
+ (unsigned long)dst < L1_SRAM_SCRATCH_END))
+ hang();
- bfin_write_MDMA_D0_IRQ_STATUS(DMA_DONE | DMA_ERR);
+ bfin_write_MDMA_S0_CONFIG(0);
+ bfin_write_MDMA_D0_CONFIG(0);
+ bfin_write_MDMA_D0_IRQ_STATUS(DMA_RUN | DMA_DONE | DMA_ERR);
/* Copy sram functions from sdram to sram */
/* Setup destination start address */
@@ -154,20 +164,33 @@ static void *dma_memcpy(void *dst, const void *src, size_t count)
/* Enable source DMA */
bfin_write_MDMA_S0_CONFIG(DMAEN);
- SSYNC();
bfin_write_MDMA_D0_CONFIG(WNR | DMAEN);
+ SSYNC();
while (bfin_read_MDMA_D0_IRQ_STATUS() & DMA_RUN)
- bfin_write_MDMA_D0_IRQ_STATUS(bfin_read_MDMA_D0_IRQ_STATUS() | DMA_DONE | DMA_ERR);
- bfin_write_MDMA_D0_IRQ_STATUS(bfin_read_MDMA_D0_IRQ_STATUS() | DMA_DONE | DMA_ERR);
+ continue;
+
+ bfin_write_MDMA_D0_IRQ_STATUS(bfin_read_MDMA_D0_IRQ_STATUS() | DMA_RUN | DMA_DONE | DMA_ERR);
+ bfin_write_MDMA_D0_CONFIG(0);
+ bfin_write_MDMA_S0_CONFIG(0);
+}
+/* We should do a dcache invalidate on the destination after the dma, but since
+ * we lack such hardware capability, we'll flush/invalidate the destination
+ * before the dma and bank on the idea that u-boot is single threaded.
+ */
+void *dma_memcpy(void *dst, const void *src, size_t count)
+{
+ if (dcache_status()) {
+ blackfin_dcache_flush_range(src, src + count);
+ blackfin_dcache_flush_invalidate_range(dst, dst + count);
+ }
+
+ dma_memcpy_nocache(dst, src, count);
if (icache_status())
blackfin_icache_flush_range(dst, dst + count);
- if (dcache_status())
- blackfin_dcache_invalidate_range(dst, dst + count);
-
return dst;
}