Skip to contentSkip to conversation

Blackfin updates for 2009.03

PATCH New Mike Frysinger 2 participants 47 messages Jan 23, 2009 – Feb 12, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Blackfin updates for 2009.03

Nothing terribly interesting here. Normal smatterings of bug fixes and minor updates as we fold the external Blackfin fork back into mainline. Everything can be found in the "next" branch of the Blackfin git tree:
git://www.denx.de/git/u-boot-blackfin.git next

Mike Frysinger (40):
Blackfin: add defines to describe active bootrom behavior
Blackfin: add bit defines for DDR parts
Blackfin: convert CMD_LINE_ADDR to CONFIG_LINUX_CMDLINE_{ADDR,SIZE}
Blackfin: set more sane default board config values
Blackfin: rename bootm.c to boot.c
Blackfin: abort dma_memcpy() for L1 scratchpad
Blackfin: split cache handling out of dma_memcpy()
Blackfin: minimize time cache is turned off when replacing cplb
entries
Blackfin: pass --bmode/--initcode when creating ldr
Blackfin: dont generate ldrs with --force
Blackfin: fix dcache handling when doing dma memcpy's
Blackfin: bfin_mac: update port muxing
Blackfin: do not init i2c in Blackfin board init
Blackfin: implement general support for CONFIG_STATUS_LED
Blackfin: respect/check CONFIG_SYS_GBL_DATA_SIZE
Blackfin: respect CONFIG_SYS_MONITOR_LEN for default flash protection
Blackfin: overhaul i2c driver
Blackfin: bf533-ezkit: shuffle flash defines a little
Blackfin: drop dead/wrong debug code in initdram()
Blackfin: bf537-stamp nand: fix more style errors in previous commit
Blackfin: tighten up post memory coding style
Blackfin: resurrect BF533-STAMP video splash driver
Blackfin: punt unused BF533-STAMP definitions
Blackfin: set default boot SPI CS for BF538/BF539
Blackfin: use common memcpy routine during init
Blackfin: respect CONFIG_CLKIN_HALF
Blackfin: add portmuxing for UARTs on the BF51x
Blackfin: just set SP register directly during init
Blackfin: clarify relocation comment during init
Blackfin: pass RETX to Linux
Blackfin: handle new anomalies with reset
Blackfin: support console-over-JTAG
Blackfin: allow serial console to be disabled
Blackfin: update on-chip ROM API
Blackfin: implement real write support for OTP
Blackfin: bootldr: implement BF53x/BF56x LDR loader
smc91111_eeprom: move board-specific init into SMC91111_EEPROM_INIT()
Blackfin: bf533-stamp: rewrite resource swap logic
Blackfin: convert old boards to use COBJS-y Makefile style
Blackfin: fixup misc warnings such as printf's and missing casts

 Makefile                                        |    2 +-
 blackfin_config.mk                              |    4 +
 board/bf533-ezkit/Makefile                      |    8 +-
 board/bf533-ezkit/bf533-ezkit.c                 |   23 +-
 board/bf533-ezkit/flash-defines.h               |    4 +-
 board/bf533-ezkit/flash.c                       |   10 +-
 board/bf533-stamp/Makefile                      |   12 +-
 board/bf533-stamp/bf533-stamp.c                 |   50 +--
 board/bf533-stamp/bf533-stamp.h                 |    3 -
 board/bf533-stamp/video.c                       |  167 +++++++++
 board/bf533-stamp/video.h                       |   25 ++
 board/bf537-stamp/Makefile                      |   10 +-
 board/bf537-stamp/bf537-stamp.c                 |   14 +-
 board/bf537-stamp/nand.c                        |    9 +-
 board/bf537-stamp/post-memory.c                 |   23 +-
 board/bf537-stamp/spi_flash.c                   |    8 +-
 board/bf561-ezkit/Makefile                      |    8 +-
 board/bf561-ezkit/bf561-ezkit.c                 |   14 +-
 common/cmd_bootldr.c                            |  135 +++++++-
 common/cmd_cplbinfo.c                           |    4 +-
 common/cmd_otp.c                                |  163 +++++++---
 common/devices.c                                |    3 +
 cpu/blackfin/Makefile                           |    9 +-
 cpu/blackfin/cache.S                            |    4 +-
 cpu/blackfin/cpu.c                              |    6 +
 cpu/blackfin/i2c.c                              |  428 -----------------------
 cpu/blackfin/initcode.c                         |    2 +-
 cpu/blackfin/jtag-console.c                     |  125 +++++++
 cpu/blackfin/reset.c                            |   20 +-
 cpu/blackfin/serial.c                           |    4 +
 cpu/blackfin/serial.h                           |   15 +-
 cpu/blackfin/start.S                            |   41 +--
 cpu/blackfin/traps.c                            |   52 +--
 drivers/i2c/Makefile                            |    1 +
 drivers/i2c/bfin-twi_i2c.c                      |  285 +++++++++++++++
 drivers/net/bfin_mac.c                          |   47 ++-
 examples/smc91111_eeprom.c                      |   15 +-
 include/asm-blackfin/blackfin-config-post.h     |   84 ++++-
 include/asm-blackfin/blackfin_local.h           |    2 +-
 include/asm-blackfin/mach-common/bits/bootrom.h |   72 +++--
 include/asm-blackfin/mach-common/bits/ebiu.h    |   21 +-
 include/asm-blackfin/mach-common/bits/otp.h     |   21 +-
 include/configs/bf533-ezkit.h                   |    2 +-
 include/configs/bf533-stamp.h                   |    2 +-
 include/configs/bf537-stamp.h                   |   43 +--
 include/devices.h                               |    3 +
 include/status_led.h                            |    3 +
 lib_blackfin/Makefile                           |    2 +-
 lib_blackfin/board.c                            |   37 +-
 lib_blackfin/boot.c                             |   63 ++++
 lib_blackfin/bootm.c                            |   56 ---
 lib_blackfin/string.c                           |   45 ++-
 52 files changed, 1326 insertions(+), 883 deletions(-)
 create mode 100644 board/bf533-stamp/video.c
 create mode 100644 board/bf533-stamp/video.h
 delete mode 100644 cpu/blackfin/i2c.c
 create mode 100644 cpu/blackfin/jtag-console.c
 create mode 100644 drivers/i2c/bfin-twi_i2c.c
 create mode 100644 lib_blackfin/boot.c
 delete mode 100644 lib_blackfin/bootm.c
#1 lore raw

PATCH 1/40 Blackfin: add defines to describe active bootrom behavior

---
 include/asm-blackfin/mach-common/bits/bootrom.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
include/asm-blackfin/mach-common/bits/bootrom.h +11 -0
index 6cdaa4f..bf661f0 100644
@@ -88,6 +88,8 @@
 #define _BOOTROM_REV                   0xEF000040
 #define _BOOTROM_SESR                  0xEF001000
 
+#define BOOTROM_FOLLOWS_C_ABI 1
+
 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 1
 
 /* Not available on initial BF54x or BF52x */
@@ -100,6 +102,9 @@
 
 #endif
 
+#ifndef BOOTROM_FOLLOWS_C_ABI
+#define BOOTROM_FOLLOWS_C_ABI 0
+#endif
 #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
 #endif
@@ -109,6 +114,12 @@
 
 #ifndef __ASSEMBLY__
 
+#if BOOTROM_FOLLOWS_C_ABI
+# define BOOTROM_CALLED_FUNC_ATTR
+#else
+# define BOOTROM_CALLED_FUNC_ATTR __attribute__((saveall))
+#endif
+
 /* Structures for the syscontrol() function */
 typedef struct ADI_SYSCTRL_VALUES {
 	uint16_t uwVrCtl;
Signature · 1 line
1.6.1
#2 lore raw

PATCH 2/40 Blackfin: add bit defines for DDR parts

In reply to Mike Frysinger
---
 include/asm-blackfin/mach-common/bits/ebiu.h |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
include/asm-blackfin/mach-common/bits/ebiu.h +20 -1
index ab530ad..af456fb 100644
@@ -410,12 +410,31 @@
 
 /* EBIU_SDSTAT Masks */
 #define SDCI		0x0001		/* SDRAM controller is idle */
-#define SDSRA		0x0002		/* SDRAM SDRAM self refresh is active */
+#define SDSRA		0x0002		/* SDRAM self refresh is active */
 #define SDPUA		0x0004		/* SDRAM power up active */
 #define SDRS		0x0008		/* SDRAM is in reset state */
 #define SDEASE		0x0010		/* SDRAM EAB sticky error status - W1C */
 #define BGSTAT		0x0020		/* Bus granted */
 
+/* Only available on DDR based-parts */
+#else
+
+/* EBIU_ERRMST Masks */
+#define DEB0_ERROR	0x0001		/* DEB0 access on reserved memory */
+#define DEB1_ERROR	0x0002		/* DEB1 access on reserved memory */
+#define DEB2_ERROR	0x0004		/* DEB2 (USB) access on reserved memory */
+#define CORE_ERROR	0x0008		/* Core access on reserved memory */
+#define DEB0_MERROR	0x0010		/* DEB0 access on reserved memory and DEB0_ERROR is set */
+#define DEB1_MERROR	0x0020		/* DEB1 access on reserved memory and DEB1_ERROR is set */
+#define DEB2_MERROR	0x0040		/* DEB2 access on reserved memory and DEB2_ERROR is set */
+#define CORE_MERROR	0x0080		/* Core access on reserved memory and CORE_ERROR is set */
+
+/* EBIU_RSTCTL Masks */
+#define DDR_SRESET	0x0001		/* Reset Control to DDR Controller */
+#define SRREQ		0x0008		/* Self Refresh Request */
+#define SRACK		0x0010		/* Self Refresh Request Acknowledgement */
+#define MDDRENABLE	0x0020		/* Mobile DDR Enable */
+
 #endif /* EBIU_SDGCTL */
 
 #endif
Signature · 1 line
1.6.1
#3 lore raw

PATCH 3/40 Blackfin: convert CMD_LINE_ADDR to CONFIG_LINUX_CMDLINE_{ADDR, SIZE}

In reply to Mike Frysinger
---
 include/asm-blackfin/blackfin-config-post.h |    7 +++++--
 lib_blackfin/bootm.c                        |    6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)
include/asm-blackfin/blackfin-config-post.h +5 -2
index 0ab68ac..936001a 100644
@@ -65,8 +65,11 @@
 #endif
 
 /* Using L1 scratch pad makes sense for everyone by default. */
-#ifndef CMD_LINE_ADDR
-# define CMD_LINE_ADDR L1_SRAM_SCRATCH
+#ifndef CONFIG_LINUX_CMDLINE_ADDR
+# define CONFIG_LINUX_CMDLINE_ADDR L1_SRAM_SCRATCH
+#endif
+#ifndef CONFIG_LINUX_CMDLINE_SIZE
+# define CONFIG_LINUX_CMDLINE_SIZE L1_SRAM_SCRATCH_SIZE
 #endif
 
 #endif
lib_blackfin/bootm.c +3 -3
index 195eb9c..2954ce6 100644
@@ -20,14 +20,14 @@ 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;
 }
 
Signature · 1 line
1.6.1
#4 lore raw

PATCH 4/40 Blackfin: set more sane default board config values

In reply to Mike Frysinger
---
 include/asm-blackfin/blackfin-config-post.h |   77 ++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 6 deletions(-)
include/asm-blackfin/blackfin-config-post.h +71 -6
index 936001a..21abd72 100644
@@ -1,7 +1,7 @@
 /*
  * blackfin-config-post.h - setup common defines for Blackfin boards based on config.h
  *
- * Copyright (c) 2007 Analog Devices Inc.
+ * Copyright (c) 2007-2008 Analog Devices Inc.
  *
  * Licensed under the GPL-2 or later.
  */
@@ -9,11 +9,6 @@
 #ifndef __ASM_BLACKFIN_CONFIG_POST_H__
 #define __ASM_BLACKFIN_CONFIG_POST_H__
 
-/* Check to make sure everything fits in external RAM */
-#if ((CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) > CONFIG_SYS_MAX_RAM_SIZE)
-# error Memory Map does not fit into configuration
-#endif
-
 /* Sanity check CONFIG_BFIN_CPU */
 #ifndef CONFIG_BFIN_CPU
 # error CONFIG_BFIN_CPU: your board config needs to define this
@@ -72,4 +67,74 @@
 # define CONFIG_LINUX_CMDLINE_SIZE L1_SRAM_SCRATCH_SIZE
 #endif
 
+/* Default/common Blackfin memory layout */
+#ifndef CONFIG_SYS_SDRAM_BASE
+# define CONFIG_SYS_SDRAM_BASE 0
+#endif
+#ifndef CONFIG_SYS_MAX_RAM_SIZE
+# define CONFIG_SYS_MAX_RAM_SIZE (CONFIG_MEM_SIZE * 1024 * 1024)
+#endif
+#ifndef CONFIG_SYS_MONITOR_BASE
+# define CONFIG_SYS_MONITOR_BASE (CONFIG_SYS_MAX_RAM_SIZE - CONFIG_SYS_MONITOR_LEN)
+#endif
+#ifndef CONFIG_SYS_MALLOC_BASE
+# define CONFIG_SYS_MALLOC_BASE (CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN)
+#endif
+#ifndef CONFIG_SYS_GBL_DATA_SIZE
+# define CONFIG_SYS_GBL_DATA_SIZE (128)
+#endif
+#ifndef CONFIG_SYS_GBL_DATA_ADDR
+# define CONFIG_SYS_GBL_DATA_ADDR (CONFIG_SYS_MALLOC_BASE - CONFIG_SYS_GBL_DATA_SIZE)
+#endif
+#ifndef CONFIG_STACKBASE
+# define CONFIG_STACKBASE (CONFIG_SYS_GBL_DATA_ADDR - 4)
+#endif
+#ifndef CONFIG_SYS_MEMTEST_START
+# define CONFIG_SYS_MEMTEST_START 0
+#endif
+#ifndef CONFIG_SYS_MEMTEST_END
+# define CONFIG_SYS_MEMTEST_END (CONFIG_STACKBASE - 8192 + 4)
+#endif
+
+/* Check to make sure everything fits in external RAM */
+#if ((CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) > CONFIG_SYS_MAX_RAM_SIZE)
+# error Memory Map does not fit into configuration
+#endif
+
+/* Default/common Blackfin environment settings */
+#ifndef CONFIG_LOADADDR
+# define CONFIG_LOADADDR 0x1000000
+#endif
+#ifndef CONFIG_SYS_LOAD_ADDR
+# define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
+#endif
+#ifndef CONFIG_SYS_BOOTM_LEN
+# define CONFIG_SYS_BOOTM_LEN 0x4000000
+#endif
+#ifndef CONFIG_SYS_PROMPT
+# define CONFIG_SYS_PROMPT "bfin> "
+#endif
+#ifndef CONFIG_SYS_CBSIZE
+# ifdef CONFIG_CMD_KGDB
+#  define CONFIG_SYS_CBSIZE 1024
+# else
+#  define CONFIG_SYS_CBSIZE 256
+# endif
+#endif
+#ifndef CONFIG_SYS_BARGSIZE
+# define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
+#endif
+#ifndef CONFIG_SYS_PBSIZE
+# define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#endif
+#ifndef CONFIG_SYS_MAXARGS
+# define CONFIG_SYS_MAXARGS 16
+#endif
+#ifndef CONFIG_SYS_HZ
+# define CONFIG_SYS_HZ 1000
+#endif
+#ifndef CONFIG_SYS_BAUDRATE_TABLE
+# define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+#endif
+
 #endif
Signature · 1 line
1.6.1
#5 lore raw

PATCH 5/40 Blackfin: rename bootm.c to boot.c

In reply to Mike Frysinger

The boot file contains functions for more than just "bootm", so rename it accordingly.

---
 lib_blackfin/Makefile |    2 +-
 lib_blackfin/boot.c   |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib_blackfin/bootm.c  |   56 -------------------------------------------------
 3 files changed, 57 insertions(+), 57 deletions(-)
 create mode 100644 lib_blackfin/boot.c
 delete mode 100644 lib_blackfin/bootm.c
lib_blackfin/Makefile +1 -1
index 3f69770..fee0fda 100644
@@ -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
lib_blackfin/boot.c new file +56 -0

56 lines not on this page · raw message

lib_blackfin/bootm.c deleted +0 -56

56 lines not on this page · raw message

Signature · 1 line
1.6.1
#6 lore raw

PATCH 6/40 Blackfin: abort dma_memcpy() for L1 scratchpad

In reply to Mike Frysinger
---
 lib_blackfin/string.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
lib_blackfin/string.c +12 -1
index 6887c93..ab71285 100644
@@ -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 at denx.de.
@@ -130,8 +130,19 @@ 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
+/* 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 ...
+ */
 static void *dma_memcpy(void *dst, const void *src, size_t 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();
+
 	if (dcache_status())
 		blackfin_dcache_flush_range(src, src + count);
 
Signature · 1 line
1.6.1
#7 lore raw

PATCH 7/40 Blackfin: split cache handling out of dma_memcpy()

In reply to Mike Frysinger

Creating a new dma_memcpy() function that skips all cache checks allows us to use the function in very early init where the cache is not yet setup.

---
 lib_blackfin/string.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
lib_blackfin/string.c +17 -8
index ab71285..2a56910 100644
@@ -134,7 +134,7 @@ int strncmp(const char *cs, const char *ct, size_t count)
  * Perhaps we should detect that ?  Nowhere do we actually
  * use dma memcpy for those types of lengths though ...
  */
-static void *dma_memcpy(void *dst, const void *src, size_t count)
+void dma_memcpy_nocache(void *dst, const void *src, size_t count)
 {
 	/* Scratchpad cannot be a DMA source or destination */
 	if (((unsigned long)src >= L1_SRAM_SCRATCH &&
@@ -143,10 +143,9 @@ static void *dma_memcpy(void *dst, const void *src, size_t count)
 	     (unsigned long)dst < L1_SRAM_SCRATCH_END))
 		hang();
 
-	if (dcache_status())
-		blackfin_dcache_flush_range(src, src + count);
-
-	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 */
@@ -165,13 +164,23 @@ 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);
+}
+void *dma_memcpy(void *dst, const void *src, size_t count)
+{
+	if (dcache_status())
+		blackfin_dcache_flush_range(src, src + count);
+
+	dma_memcpy_nocache(dst, src, count);
 
 	if (icache_status())
 		blackfin_icache_flush_range(dst, dst + count);
Signature · 1 line
1.6.1
#8 lore raw

PATCH 8/40 Blackfin: minimize time cache is turned off when replacing cplb entries

In reply to Mike Frysinger
---
 cpu/blackfin/traps.c |   31 +++++++++----------------------
 1 files changed, 9 insertions(+), 22 deletions(-)
cpu/blackfin/traps.c +9 -22
index d17c0a1..e72b347 100644
@@ -117,17 +117,6 @@ void trap_c(struct pt_regs *regs)
 			debug("CPLB addr %p matches map 0x%p - 0x%p\n", new_cplb_addr, bfin_memory_map[i].start, bfin_memory_map[i].end);
 		new_cplb_data = (data ? bfin_memory_map[i].data_flags : bfin_memory_map[i].inst_flags);
 
-		/* Turn the cache off */
-		SSYNC();
-		if (data) {
-			asm(" .align 8; ");
-			*pDMEM_CONTROL &= ~ENDCPLB;
-		} else {
-			asm(" .align 8; ");
-			*pIMEM_CONTROL &= ~ENICPLB;
-		}
-		SSYNC();
-
 		if (data) {
 			CPLB_ADDR_BASE = (uint32_t *)DCPLB_ADDR0;
 			CPLB_DATA_BASE = (uint32_t *)DCPLB_DATA0;
@@ -149,8 +138,17 @@ void trap_c(struct pt_regs *regs)
 
 		debug("evicting entry %i: 0x%p 0x%08X\n", i, *CPLB_ADDR, *CPLB_DATA);
 		last_evicted = i + 1;
+
+		/* need to turn off cplbs whenever we muck with the cplb table */
+#if ENDCPLB != ENICPLB
+# error cplb enable bit violates my sanity
+#endif
+		uint32_t mem_control = (data ? DMEM_CONTROL : IMEM_CONTROL);
+		bfin_write32(mem_control, bfin_read32(mem_control) & ~ENDCPLB);
 		*CPLB_ADDR = new_cplb_addr;
 		*CPLB_DATA = new_cplb_data;
+		bfin_write32(mem_control, bfin_read32(mem_control) | ENDCPLB);
+		SSYNC();
 
 		/* dump current table for debugging purposes */
 		CPLB_ADDR = CPLB_ADDR_BASE;
@@ -158,17 +156,6 @@ void trap_c(struct pt_regs *regs)
 		for (i = 0; i < 16; ++i)
 			debug("%2i 0x%p 0x%08X\n", i, *CPLB_ADDR++, *CPLB_DATA++);
 
-		/* Turn the cache back on */
-		SSYNC();
-		if (data) {
-			asm(" .align 8; ");
-			*pDMEM_CONTROL |= ENDCPLB;
-		} else {
-			asm(" .align 8; ");
-			*pIMEM_CONTROL |= ENICPLB;
-		}
-		SSYNC();
-
 		break;
 	}
 
Signature · 1 line
1.6.1
#9 lore raw

PATCH 9/40 Blackfin: pass --bmode/--initcode when creating ldr

In reply to Mike Frysinger
---
 blackfin_config.mk |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
blackfin_config.mk +4 -0
index c8be75e..7bde449 100644
@@ -33,7 +33,11 @@ endif
 
 SYM_PREFIX = _
 
+LDR_FLAGS += --bmode $(subst BFIN_BOOT_,,$(CONFIG_BFIN_BOOT_MODE))
 LDR_FLAGS += --use-vmas
+ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
+LDR_FLAGS += --initcode $(obj)cpu/$(CPU)/initcode.o
+endif
 ifneq (,$(findstring s,$(MAKEFLAGS)))
 LDR_FLAGS += --quiet
 endif
Signature · 1 line
1.6.1
#10 lore raw

PATCH 10/40 Blackfin: dont generate ldrs with --force

In reply to Mike Frysinger
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index d533564..50e51a5 100644
@@ -317,7 +317,7 @@ $(obj)u-boot.bin:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
 
 $(obj)u-boot.ldr:	$(obj)u-boot
-		$(LDR) -T $(CONFIG_BFIN_CPU) -f -c $@ $< $(LDR_FLAGS)
+		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
 
 $(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
Signature · 1 line
1.6.1
#11 lore raw

PATCH 11/40 Blackfin: fix dcache handling when doing dma memcpy's

In reply to Mike Frysinger

Our dcache invalidate function doesn't just invalidate, it also flushes. So rename the function accordingly and fix the dma_memcpy() function so it doesn't inadvertently corrupt the data destination.

---
 cpu/blackfin/cache.S                  |    4 ++--
 include/asm-blackfin/blackfin_local.h |    2 +-
 lib_blackfin/string.c                 |   11 +++++++----
 3 files changed, 10 insertions(+), 7 deletions(-)
cpu/blackfin/cache.S +2 -2
index 51bdb30..9facadf 100644
@@ -39,7 +39,7 @@ ENTRY(_blackfin_dcache_flush_range)
 	RTS;
 ENDPROC(_blackfin_dcache_flush_range)
 
-ENTRY(_blackfin_dcache_invalidate_range)
+ENTRY(_blackfin_dcache_flush_invalidate_range)
 	R2 = -32;
 	R2 = R0 & R2;
 	P0 = R2;
@@ -58,4 +58,4 @@ ENTRY(_blackfin_dcache_invalidate_range)
 	FLUSHINV[P0];
 	SSYNC;
 	RTS;
-ENDPROC(_blackfin_dcache_invalidate_range)
+ENDPROC(_blackfin_dcache_flush_invalidate_range)
include/asm-blackfin/blackfin_local.h +1 -1
index 6f0e662..c9ee91a 100644
@@ -58,7 +58,7 @@ extern u_long get_sclk(void);
 
 extern void blackfin_icache_flush_range(const void *, const void *);
 extern void blackfin_dcache_flush_range(const void *, const void *);
-extern void blackfin_dcache_invalidate_range(const void *, const void *);
+extern void blackfin_dcache_flush_invalidate_range(const void *, const void *);
 
 /* Use DMA to move data from on chip to external memory.  While this is
  * required for only L1 instruction (it is not directly readable by the
lib_blackfin/string.c +7 -4
index 2a56910..36eecdf 100644
@@ -175,19 +175,22 @@ void dma_memcpy_nocache(void *dst, const void *src, size_t count)
 	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())
+	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;
 }
 
Signature · 1 line
1.6.1
#12 lore raw

PATCH 12/40 Blackfin: bfin_mac: update port muxing

In reply to Mike Frysinger

Adds support more Blackfin parts and fixes broken muxing for older ones.

---
 drivers/net/bfin_mac.c |   47 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 12 deletions(-)
drivers/net/bfin_mac.c +35 -12
index 504fd10..dddbb78 100644
@@ -331,20 +331,43 @@ static int SetupSystemRegs(int *opmode)
 	*pVR_CTL |= CLKBUFOE;
 	/* Set all the pins to peripheral mode */
 
-#ifndef CONFIG_BFIN_MAC_RMII
-	*pPORTH_FER = 0xFFFF;
-#ifdef __ADSPBF52x__
-	*pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2;
-#endif
+#ifdef CONFIG_BFIN_MAC_RMII
+	/* grab RMII pins */
+# if defined(__ADSPBF51x__)
+	*pPORTF_MUX = (*pPORTF_MUX & \
+		~(PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \
+		PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1;
+	*pPORTF_FER |= PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
+	*pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
+	*pPORTG_FER |= PG0 | PG1 | PG2;
+# elif defined(__ADSPBF52x__)
+	*pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
+	*pPORTG_FER |= PG14 | PG15;
+	*pPORTH_MUX = (*pPORTH_MUX & ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK)) | \
+		PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2;
+	*pPORTH_FER |= PH0 | PH1 | PH2 | PH3 | PH4 | PH5 | PH6 | PH7 | PH8;
+# else
+	*pPORTH_FER |= PH0 | PH1 | PH4 | PH5 | PH6 | PH8 | PH9 | PH14 | PH15;
+# endif
 #else
-#if defined(__ADSPBF536__) || defined(__ADSPBF537__)
-	*pPORTH_FER = 0xC373;
-#endif
-#ifdef __ADSPBF52x__
-	*pPORTH_FER = 0x01FF;
-	*pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2;
-#endif
+	/* grab MII & RMII pins */
+# if defined(__ADSPBF51x__)
+	*pPORTF_MUX = (*pPORTF_MUX & \
+		~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK | PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \
+		PORT_x_MUX_0_FUNC_1 | PORT_x_MUX_1_FUNC_1 | PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1;
+	*pPORTF_FER |= PF0 | PF1 | PF2 | PF3 | PF4 | PF5 | PF6 | PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
+	*pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
+	*pPORTG_FER |= PG0 | PG1 | PG2;
+# elif defined(__ADSPBF52x__)
+	*pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
+	*pPORTG_FER |= PG14 | PG15;
+	*pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2;
+	*pPORTH_FER = -1; /* all pins */
+# else
+	*pPORTH_FER = -1; /* all pins */
+# endif
 #endif
+
 	/* MDC  = 2.5 MHz */
 	sysctl = SET_MDCDIV(24);
 	/* Odd word alignment for Receive Frame DMA word */
Signature · 1 line
1.6.1
#13 lore raw

PATCH 13/40 Blackfin: do not init i2c in Blackfin board init

In reply to Mike Frysinger

The common code takes care of calling i2c_init() when needed, so no point in us doing it as well.

---
 lib_blackfin/board.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
lib_blackfin/board.c +0 -15
index 05e66e3..d16c819 100644
@@ -13,7 +13,6 @@
 #include <command.h>
 #include <devices.h>
 #include <environment.h>
-#include <i2c.h>
 #include <malloc.h>
 #include <net.h>
 #include <timestamp.h>
@@ -329,16 +328,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);
@@ -440,10 +429,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)
Signature · 1 line
1.6.1
#14 lore raw

PATCH 14/40 Blackfin: implement general support for CONFIG_STATUS_LED

In reply to Mike Frysinger

Here are the Blackfin-specific and board-independent pieces for status leds.

---
 include/status_led.h |    3 +++
 lib_blackfin/board.c |   10 ++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
include/status_led.h +3 -0
index 79be698..175972a 100644
@@ -346,6 +346,9 @@ void status_led_set  (int led, int state);
 #elif defined(CONFIG_NIOS2)
 /* XXX empty just to avoid the error */
 /************************************************************************/
+#elif defined(CONFIG_BLACKFIN)
+/* XXX empty just to avoid the error */
+/************************************************************************/
 #elif defined(CONFIG_V38B)
 
 # define STATUS_LED_BIT		0x0010			/* Timer7 GPIO */
lib_blackfin/board.c +10 -0
index d16c819..9d7a0f6 100644
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <net.h>
 #include <timestamp.h>
+#include <status_led.h>
 #include <version.h>
 
 #include <asm/cplb.h>
@@ -407,6 +408,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);
@@ -443,6 +449,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
Signature · 1 line
1.6.1
#15 lore raw

PATCH 15/40 Blackfin: respect/check CONFIG_SYS_GBL_DATA_SIZE

In reply to Mike Frysinger

When setting up the global data, rather than relying on sizeof(), use the common CONFIG_SYS_GBL_DATA_SIZE define.

---
 lib_blackfin/board.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib_blackfin/board.c +5 -1
index 9d7a0f6..2feb64b 100644
@@ -278,9 +278,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));
Signature · 1 line
1.6.1
#16 lore raw

PATCH 16/40 Blackfin: respect CONFIG_SYS_MONITOR_LEN for default flash protection

In reply to Mike Frysinger

Respect the CONFIG_SYS_MONITOR_LEN define rather than assuming a size of 128kB when setting up the default flash protection region for U-Boot itself.

---
 lib_blackfin/board.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
lib_blackfin/board.c +3 -3
index 2feb64b..809c68c 100644
@@ -348,14 +348,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;
Signature · 1 line
1.6.1
#17 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

In reply to Mike Frysinger

The current Blackfin i2c driver does not work properly with certain devices due to it breaking up transfers incorrectly. This is a rewrite of the driver and relocates it to the newer place in the source tree.

Also remove duplicated I2C speed defines in Blackfin board configs and disable I2C slave address usage since it isn't implemented.

---
 cpu/blackfin/Makefile         |    2 +-
 cpu/blackfin/i2c.c            |  428 -----------------------------------------
 drivers/i2c/Makefile          |    1 +
 drivers/i2c/bfin-twi_i2c.c    |  285 +++++++++++++++++++++++++++
 include/configs/bf533-ezkit.h |    2 +-
 include/configs/bf533-stamp.h |    2 +-
 include/configs/bf537-stamp.h |   43 +----
 7 files changed, 293 insertions(+), 470 deletions(-)
 delete mode 100644 cpu/blackfin/i2c.c
 create mode 100644 drivers/i2c/bfin-twi_i2c.c
cpu/blackfin/Makefile +1 -1
index 8fed4b4..b90fb48 100644
@@ -17,7 +17,7 @@ EXTRA    :=
 CEXTRA   := initcode.o
 SEXTRA   := start.o
 SOBJS    := interrupt.o cache.o
-COBJS    := cpu.o traps.o interrupts.o reset.o serial.o i2c.o watchdog.o
+COBJS    := cpu.o traps.o interrupts.o reset.o serial.o watchdog.o
 
 ifeq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
 COBJS    += initcode.o
cpu/blackfin/i2c.c deleted +0 -428

428 lines not on this page · raw message

drivers/i2c/Makefile +1 -0
index 6079c05..08cb91d 100644
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libi2c.a
 
+COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
 COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
 COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
drivers/i2c/bfin-twi_i2c.c new file +285 -0

285 lines not on this page · raw message

include/configs/bf533-ezkit.h +1 -1
index e871737..48c0252 100644
@@ -198,7 +198,7 @@
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
 
 #define CONFIG_SYS_I2C_SPEED		50000
-#define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C_SLAVE		0
 
 #define CONFIG_SYS_BOOTM_LEN		0x4000000	/* Large Image Length, set to 64 Meg */
 
include/configs/bf533-stamp.h +1 -1
index 5ad99a2..ee41c7e 100644
@@ -300,7 +300,7 @@
 #define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
 
 #define CONFIG_SYS_I2C_SPEED		50000
-#define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C_SLAVE		0
 #endif /* CONFIG_SOFT_I2C */
 
 /*
include/configs/bf537-stamp.h +4 -39

56 lines not on this page · raw message

Signature · 1 line
1.6.1
#18 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

Quoted 8 lines · Mike Frysinger

The current Blackfin i2c driver does not work properly with certain devices due to it breaking up transfers incorrectly. This is a rewrite of the driver and relocates it to the newer place in the source tree.

Also remove duplicated I2C speed defines in Blackfin board configs and disable I2C slave address usage since it isn't implemented.

include/i2c.h still has this:

static inline void i2c_reg_write(u8 addr, u8 reg, u8 val) {
...

#ifdef CONFIG_BLACKFIN
	/* This ifdef will become unneccessary in a future version of the
	 * blackfin I2C driver.
	 */
	i2c_write(addr, reg, 0, &val, 1);
#else
	i2c_write(addr, reg, 1, &val, 1);

#endif
}

There's a similar #ifdef in i2c_reg_read(). Are these #ifdefs still necessary? If so, could you modify your I2C driver so that they aren't? And then fix i2c.h as well?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#19 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

Quoted 22 lines · On Wednesday 11 February 2009 18:19:36 Timur Tabi wrote:
Quoted 8 lines · Mike Frysinger

The current Blackfin i2c driver does not work properly with certain devices due to it breaking up transfers incorrectly. This is a rewrite of the driver and relocates it to the newer place in the source tree.

Also remove duplicated I2C speed defines in Blackfin board configs and disable I2C slave address usage since it isn't implemented.

include/i2c.h still has this:

static inline void i2c_reg_write(u8 addr, u8 reg, u8 val) {
...

#ifdef CONFIG_BLACKFIN
	/* This ifdef will become unneccessary in a future version of the
	 * blackfin I2C driver.
	 */
	i2c_write(addr, reg, 0, &val, 1);
#else
	i2c_write(addr, reg, 1, &val, 1);
Quoted 6 lines

#endif
}

There's a similar #ifdef in i2c_reg_read(). Are these #ifdefs still necessary? If so, could you modify your I2C driver so that they aren't? And then fix i2c.h as well?

ugh, i told the guy submitting those changes to ignore the Blackfin i2c driver. the ifdef's in the common code should be dropped, thanks for pointing this out.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090211/f825bae6/attachment.pgp

#20 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

Quoted 3 lines · Mike Frysinger

ugh, i told the guy submitting those changes to ignore the Blackfin i2c driver. the ifdef's in the common code should be dropped, thanks for pointing this out.

I know - I'm the guy who made those changes, but I didn't want to ignore blackfin because I wasn't sure when you were going to write your driver, and I didn't want to introduce code that altered the behavior of blackfin.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#21 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

Quoted 8 lines · On Wednesday 11 February 2009 18:44:00 Timur Tabi wrote:
Quoted 3 lines · Mike Frysinger

ugh, i told the guy submitting those changes to ignore the Blackfin i2c driver. the ifdef's in the common code should be dropped, thanks for pointing this out.

I know - I'm the guy who made those changes, but I didn't want to ignore blackfin because I wasn't sure when you were going to write your driver, and I didn't want to introduce code that altered the behavior of blackfin.

i told you at the time that the Blackfin i2c driver in the tree was broken. no matter what your changes did, it wouldnt make the existing situation worse. instead, we'd end up with bit rot like we now have.

will you post a patch to fix the issue or shall i ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090211/1017567e/attachment.pgp

#22 lore raw

PATCH 17/40 Blackfin: overhaul i2c driver

Quoted 1 line · Mike Frysinger

will you post a patch to fix the issue or shall i ?

I'd rather you do it, because then you can test the code to make sure it really works.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#23 lore raw

PATCH 18/40 Blackfin: bf533-ezkit: shuffle flash defines a little

In reply to Mike Frysinger

Some of the flash defines weren't in the correct location and caused build problems in some configurations, so let's move types and defines to better local locations.

---
 board/bf533-ezkit/bf533-ezkit.c   |    9 +++------
 board/bf533-ezkit/flash-defines.h |    4 +---
 board/bf533-ezkit/flash.c         |    4 ++++
 3 files changed, 8 insertions(+), 9 deletions(-)
board/bf533-ezkit/bf533-ezkit.c +3 -6
index 42c4b50..6973082 100644
@@ -1,7 +1,7 @@
 /*
- * U-boot - ezkit533.c
+ * U-boot - main board file
  *
- * Copyright (c) 2005-2007 Analog Devices Inc.
+ * Copyright (c) 2005-2008 Analog Devices Inc.
  *
  * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -26,9 +26,8 @@
  */
 
 #include <common.h>
-#if defined(CONFIG_MISC_INIT_R)
 #include "psd4256.h"
-#endif
+#include "flash-defines.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -58,7 +57,6 @@ phys_size_t initdram(int board_type)
 	return CONFIG_SYS_MAX_RAM_SIZE;
 }
 
-#if defined(CONFIG_MISC_INIT_R)
 /* miscellaneous platform dependent initialisations */
 int misc_init_r(void)
 {
@@ -71,4 +69,3 @@ int misc_init_r(void)
 
 	return 0;
 }
-#endif
board/bf533-ezkit/flash-defines.h +1 -3
index 1a4aa5f..eb0af94 100644
@@ -50,6 +50,7 @@
 #define FLASH_SIZE		0x220000
 #define FLASH_MAN_ST		2
 #define CONFIG_SYS_FLASH0_BASE		0x20000000
+#define CONFIG_SYS_FLASH1_BASE		0x20200000
 #define RESET_VAL		0xF0
 
 flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
@@ -68,9 +69,6 @@ int write_flash(long nOffset, int nValue);
 void get_sector_number(long lOffset, int *pnSector);
 int GetSectorProtectionStatus(flash_info_t * info, int nSector);
 int GetOffset(int nBlock);
-int AFP_NumSectors = 40;
-long AFP_SectorSize1 = 0x10000;
-int AFP_SectorSize2 = 0x4000;
 
 #define WRITESEQ1		0x0AAA
 #define WRITESEQ2		0x0554
board/bf533-ezkit/flash.c +4 -0
index a861e16..539c00d 100644
@@ -29,6 +29,10 @@
 #include <asm/io.h>
 #include "flash-defines.h"
 
+int AFP_NumSectors = 40;
+long AFP_SectorSize1 = 0x10000;
+int AFP_SectorSize2 = 0x4000;
+
 void flash_reset(void)
 {
 	reset_flash();
Signature · 1 line
1.6.1
#24 lore raw

PATCH 19/40 Blackfin: drop dead/wrong debug code in initdram()

In reply to Mike Frysinger

The DEBUG code in initdram() is quite old and was never really useful, so just drop it altogether. Common Blackfin debug code does a better job.

---
 board/bf533-ezkit/bf533-ezkit.c |   14 +-------------
 board/bf533-stamp/bf533-stamp.c |   11 +----------
 board/bf537-stamp/bf537-stamp.c |   14 +-------------
 board/bf561-ezkit/bf561-ezkit.c |   14 +-------------
 4 files changed, 4 insertions(+), 49 deletions(-)
board/bf533-ezkit/bf533-ezkit.c +1 -13
index 6973082..d5f0b7c 100644
@@ -40,21 +40,9 @@ int checkboard(void)
 
 phys_size_t initdram(int board_type)
 {
-#ifdef DEBUG
-	int brate;
-	char *tmp = getenv("baudrate");
-	brate = simple_strtoul(tmp, NULL, 16);
-	printf("Serial Port initialized with Baud rate = %x\n", brate);
-	printf("SDRAM attributes:\n");
-	printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
-	       "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
-	       3, 3, 6, 2, 3);
-	printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
-	printf("Bank size = %d MB\n", CONFIG_SYS_MAX_RAM_SIZE >> 20);
-#endif
 	gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	return CONFIG_SYS_MAX_RAM_SIZE;
+	return gd->bd->bi_memsize;
 }
 
 /* miscellaneous platform dependent initialisations */
board/bf533-stamp/bf533-stamp.c +1 -10
index 0c6324b..1a073a6 100644
@@ -49,18 +49,9 @@ int checkboard(void)
 
 phys_size_t initdram(int board_type)
 {
-#ifdef DEBUG
-	printf("SDRAM attributes:\n");
-	printf
-	    ("  tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
-	     "CAS Latency:%d cycles\n", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
-	     (SDRAM_tRAS >> 6), (SDRAM_tWR >> 19), (SDRAM_CL >> 2));
-	printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
-	printf("Bank size = %d MB\n", 128);
-#endif
 	gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	return (gd->bd->bi_memsize);
+	return gd->bd->bi_memsize;
 }
 
 void swap_to(int device_id)
board/bf537-stamp/bf537-stamp.c +1 -13
index 7303f1b..63992f6 100644
@@ -100,21 +100,9 @@ void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
 
 phys_size_t initdram(int board_type)
 {
-#ifdef DEBUG
-	int brate;
-	char *tmp = getenv("baudrate");
-	brate = simple_strtoul(tmp, NULL, 16);
-	printf("Serial Port initialized with Baud rate = %x\n", brate);
-	printf("SDRAM attributes:\n");
-	printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
-	       "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
-	       3, 3, 6, 2, 3);
-	printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
-	printf("Bank size = %d MB\n", CONFIG_SYS_MAX_RAM_SIZE >> 20);
-#endif
 	gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	return CONFIG_SYS_MAX_RAM_SIZE;
+	return gd->bd->bi_memsize;
 }
 
 #if defined(CONFIG_MISC_INIT_R)
board/bf561-ezkit/bf561-ezkit.c +1 -13
index 7f8598c..5aede17 100644
@@ -39,19 +39,7 @@ int checkboard(void)
 
 phys_size_t initdram(int board_type)
 {
-#ifdef DEBUG
-	int brate;
-	char *tmp = getenv("baudrate");
-	brate = simple_strtoul(tmp, NULL, 16);
-	printf("Serial Port initialized with Baud rate = %x\n", brate);
-	printf("SDRAM attributes:\n");
-	printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
-	       "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
-	       3, 3, 6, 2, 3);
-	printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
-	printf("Bank size = %d MB\n", CONFIG_SYS_MAX_RAM_SIZE >> 20);
-#endif
 	gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	return CONFIG_SYS_MAX_RAM_SIZE;
+	return gd->bd->bi_memsize;
 }
Signature · 1 line
1.6.1
#25 lore raw

PATCH 20/40 Blackfin: bf537-stamp nand: fix more style errors in previous commit

In reply to Mike Frysinger
---
 board/bf537-stamp/nand.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
board/bf537-stamp/nand.c +3 -3
index 20a7d0e..2866834 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2006 Aubrey.Li, aubrey.li at analog.com
+ * Copyright (c) 2006-2007 Analog Devices Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -43,11 +43,11 @@ static void bfin_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 	u32 IO_ADDR_W = (u32) this->IO_ADDR_W;
 
 	if (ctrl & NAND_CTRL_CHANGE) {
-		if( ctrl & NAND_CLE )
+		if (ctrl & NAND_CLE)
 			IO_ADDR_W = CONFIG_SYS_NAND_BASE + BFIN_NAND_CLE;
 		else
 			IO_ADDR_W = CONFIG_SYS_NAND_BASE;
-		if( ctrl & NAND_ALE )
+		if (ctrl & NAND_ALE)
 			IO_ADDR_W = CONFIG_SYS_NAND_BASE + BFIN_NAND_ALE;
 		else
 			IO_ADDR_W = CONFIG_SYS_NAND_BASE;
Signature · 1 line
1.6.1
#26 lore raw

PATCH 21/40 Blackfin: tighten up post memory coding style

In reply to Mike Frysinger

No functional changes here; just cleanup code style a bit.

---
 board/bf537-stamp/post-memory.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)
board/bf537-stamp/post-memory.c +11 -12
index 889aa5c..9626f4c 100644
@@ -21,10 +21,10 @@ int post_init_sdram(int sclk);
 void post_init_uart(int sclk);
 
 const int pll[CCLK_NUM][SCLK_NUM][2] = {
-	{{20, 4}, {20, 5}, {20, 10}},	/* CCLK = 500M */
-	{{16, 4}, {16, 5}, {16, 8}},	/* CCLK = 400M */
-	{{8, 2}, {8, 4}, {8, 5}},	/* CCLK = 200M */
-	{{4, 1}, {4, 2}, {4, 4}}	/* CCLK = 100M */
+	{ {20, 4}, {20, 5}, {20, 10} },	/* CCLK = 500M */
+	{ {16, 4}, {16, 5}, {16, 8} },	/* CCLK = 400M */
+	{ {8, 2}, {8, 4}, {8, 5} },	/* CCLK = 200M */
+	{ {4, 1}, {4, 2}, {4, 4} }	/* CCLK = 100M */
 };
 const char *const log[CCLK_NUM][SCLK_NUM] = {
 	{"CCLK-500MHz SCLK-125MHz:    Writing...\0",
@@ -119,7 +119,8 @@ void post_out_buff(char *buff)
 {
 
 	int i = 0;
-	for (i = 0; i < 0x80000; i++) ;
+	for (i = 0; i < 0x80000; i++)
+		;
 	i = 0;
 	while ((buff[i] != '\0') && (i != 100)) {
 		while (!(*pUART_LSR & 0x20)) ;
@@ -127,7 +128,8 @@ void post_out_buff(char *buff)
 		SSYNC();
 		i++;
 	}
-	for (i = 0; i < 0x80000; i++) ;
+	for (i = 0; i < 0x80000; i++)
+		;
 }
 
 /* Using sw10-PF5 as the hotkey */
@@ -150,9 +152,8 @@ int post_key_pressed(void)
 			value = 0;
 			goto key_pressed;
 		}
-		if (value != 0) {
+		if (value != 0)
 			goto key_pressed;
-		}
 		for (n = 0; n < KEY_DELAY; n++)
 			asm("nop");
 	}
@@ -164,9 +165,8 @@ int post_key_pressed(void)
 			value = 0;
 			goto key_pressed;
 		}
-		if (value != 0) {
+		if (value != 0)
 			goto key_pressed;
-		}
 		for (n = 0; n < KEY_DELAY; n++)
 			asm("nop");
 	}
@@ -178,9 +178,8 @@ int post_key_pressed(void)
 			value = 0;
 			goto key_pressed;
 		}
-		if (value != 0) {
+		if (value != 0)
 			goto key_pressed;
-		}
 		for (n = 0; n < KEY_DELAY; n++)
 			asm("nop");
 	}
Signature · 1 line
1.6.1
#27 lore raw

PATCH 22/40 Blackfin: resurrect BF533-STAMP video splash driver

In reply to Mike Frysinger

This video driver used to live in the Blackfin cpu directory, but it was lost during the unification process. This brings it back.

---
 board/bf533-stamp/Makefile |    9 ++-
 board/bf533-stamp/video.c  |  167 ++++++++++++++++++++++++++++++++++++++++++++
 board/bf533-stamp/video.h  |   25 +++++++
 3 files changed, 197 insertions(+), 4 deletions(-)
 create mode 100644 board/bf533-stamp/video.c
 create mode 100644 board/bf533-stamp/video.h
board/bf533-stamp/Makefile +5 -4
index 5ae0228..5b5e199 100644
@@ -1,7 +1,7 @@
 #
 # U-boot - Makefile
 #
-# Copyright (c) 2005-2007 Analog Device Inc.
+# Copyright (c) 2005-2008 Analog Device Inc.
 #
 # (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -29,10 +29,11 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= $(BOARD).o spi_flash.o
+COBJS-y               := $(BOARD).o spi_flash.o
+COBJS-$(CONFIG_VIDEO) += video.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
+SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
 SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(obj)u-boot.lds
board/bf533-stamp/video.c new file +167 -0

167 lines not on this page · raw message

board/bf533-stamp/video.h new file +25 -0
new file mode 100644
index 0000000..80837e2
@@ -0,0 +1,25 @@
+#include <video_logo.h>
+#define write_dest_byte(val) {*dest++=val;}
+#define BLACK   (0x01800180)	/* black pixel pattern   */
+#define BLUE    (0x296E29F0)	/* blue pixel pattern    */
+#define RED     (0x51F0515A)	/* red pixel pattern     */
+#define MAGENTA (0x6ADE6ACA)	/* magenta pixel pattern */
+#define GREEN   (0x91229136)	/* green pixel pattern   */
+#define CYAN    (0xAA10AAA6)	/* cyan pixel pattern    */
+#define YELLOW  (0xD292D210)	/* yellow pixel pattern  */
+#define WHITE   (0xFE80FE80)	/* white pixel pattern   */
+
+#define true	1
+#define false	0
+
+typedef struct {
+	unsigned int sav;
+	unsigned int eav;
+} system_code_type;
+
+const system_code_type system_code_map[] = {
+	{ 0xFF000080, 0xFF00009D },
+	{ 0xFF0000AB, 0xFF0000B6 },
+	{ 0xFF0000C7, 0xFF0000DA },
+	{ 0xFF0000EC, 0xFF0000F1 },
+};
Signature · 1 line
1.6.1
#28 lore raw

PATCH 23/40 Blackfin: punt unused BF533-STAMP definitions

In reply to Mike Frysinger
---
 board/bf533-stamp/bf533-stamp.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
board/bf533-stamp/bf533-stamp.h +0 -3
index 3b0d620..ebd39c7 100644
@@ -34,9 +34,6 @@ extern volatile unsigned long *ambctl0;
 extern volatile unsigned long *ambctl1;
 extern volatile unsigned long *amgctl;
 
-extern unsigned long pll_div_fact;
-extern void serial_setbrg(void);
-
 /* Definitions used in  Compact Flash Boot support */
 #define FIO_EDGE_CF_BITS	0x0000
 #define FIO_POLAR_CF_BITS	0x0000
Signature · 1 line
1.6.1
#29 lore raw

PATCH 24/40 Blackfin: set default boot SPI CS for BF538/BF539

In reply to Mike Frysinger

The BF538/BF539 use CS2 for booting off of rather than CS1 like newer Blackfin parts.

---
 board/bf537-stamp/spi_flash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
board/bf537-stamp/spi_flash.c +2 -2
index 11a2803..a99c3fa 100644
@@ -182,8 +182,8 @@ static struct manufacturer_info flash_manufacturers[] = {
  *	BF533, BF561: SSEL2
  */
 #ifndef CONFIG_SPI_FLASH_SSEL
-# if defined(__ADSPBF531__) || defined(__ADSPBF532__) || \
-     defined(__ADSPBF533__) || defined(__ADSPBF561__)
+# if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
+     defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__)
 #  define CONFIG_SPI_FLASH_SSEL 2
 # else
 #  define CONFIG_SPI_FLASH_SSEL 1
Signature · 1 line
1.6.1
#30 lore raw

PATCH 25/40 Blackfin: use common memcpy routine during init

In reply to Mike Frysinger

Rather than using a local custom memcpy function, just call the existing optimized Blackfin version.

---
 cpu/blackfin/start.S |   32 +++++++++++---------------------
 1 files changed, 11 insertions(+), 21 deletions(-)
cpu/blackfin/start.S +11 -21
index 9975a0c..6c5fef7 100644
@@ -125,8 +125,9 @@ ENTRY(_start)
 	 */
 	r6 = 1 (x);
 
-	/* Relocate from wherever are (FLASH/RAM/etc...) to the
-	 * hardcoded monitor location in the end of RAM.
+	/* Relocate from wherever are (FLASH/RAM/etc...) to the hardcoded
+	 * monitor location in the end of RAM.  We know that memcpy() only
+	 * uses registers, so it is safe to call here.
 	 */
 	serial_early_puts("Relocate");
 	call _get_pc;
@@ -135,27 +136,16 @@ ENTRY(_start)
 	r2.h = .Loffset;
 	r3.l = _start;
 	r3.h = _start;
-	r1 = r2 - r3;
-
-	r0 = r0 - r1;
-
-	cc = r0 == r3;
+	r2 = r2 - r3;
+	r1 = r0 - r2;
+	cc = r1 == r3;
 	if cc jump .Lnorelocate;
-
 	r6 = 0 (x);
-	p1 = r0;
-
-	p2.l = LO(CONFIG_SYS_MONITOR_BASE);
-	p2.h = HI(CONFIG_SYS_MONITOR_BASE);
-
-	p3 = 0x04;
-	p4.l = LO(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN);
-	p4.h = HI(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN);
-.Lloop1:
-	r1 = [p1 ++ p3];
-	[p2 ++ p3] = r1;
-	cc=p2==p4;
-	if !cc jump .Lloop1;
+
+	r0 = r3;
+	r2.l = LO(CONFIG_SYS_MONITOR_LEN);
+	r2.h = HI(CONFIG_SYS_MONITOR_LEN);
+	call _memcpy_ASM;
 
 	/* Initialize BSS section ... we know that memset() does not
 	 * use the BSS, so it is safe to call here.  The bootrom LDR
Signature · 1 line
1.6.1
#31 lore raw

PATCH 26/40 Blackfin: respect CONFIG_CLKIN_HALF

In reply to Mike Frysinger

As pointed out by Ivan Koryakovskiy, the initialization code was not actually respecting the CONFIG_CLKIN_HALF option when configuring the PLL_CTL register.

---
 cpu/blackfin/initcode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpu/blackfin/initcode.c +1 -1
index ffc8420..e733dd2 100644
@@ -158,7 +158,7 @@ static inline void serial_putc(char c)
 #endif
 
 #ifndef CONFIG_PLL_CTL_VAL
-# define CONFIG_PLL_CTL_VAL (SPORT_HYST | (CONFIG_VCO_MULT << 9))
+# define CONFIG_PLL_CTL_VAL (SPORT_HYST | (CONFIG_VCO_MULT << 9) | CONFIG_CLKIN_HALF)
 #endif
 
 #ifndef CONFIG_EBIU_RSTCTL_VAL
Signature · 1 line
1.6.1
#32 lore raw

PATCH 27/40 Blackfin: add portmuxing for UARTs on the BF51x

In reply to Mike Frysinger
---
 cpu/blackfin/serial.h |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
cpu/blackfin/serial.h +10 -1
index ec40c26..90fceec 100644
@@ -95,7 +95,16 @@
 __attribute__((always_inline))
 static inline void serial_do_portmux(void)
 {
-#ifdef __ADSPBF52x__
+#if defined(__ADSPBF51x__)
+# define DO_MUX(port, mux_tx, mux_rx, tx, rx) \
+	bfin_write_PORT##port##_MUX((bfin_read_PORT##port##_MUX() & ~(PORT_x_MUX_##mux_tx##_MASK | PORT_x_MUX_##mux_rx##_MASK)) | PORT_x_MUX_##mux_tx##_FUNC_2 | PORT_x_MUX_##mux_rx##_FUNC_2); \
+	bfin_write_PORT##port##_FER(bfin_read_PORT##port##_FER() | P##port##tx | P##port##rx);
+	switch (CONFIG_UART_CONSOLE) {
+	case 0: DO_MUX(G, 5, 5, 9, 10);  break;	/* Port G; mux 5; PG9 and PG10 */
+	case 1: DO_MUX(F, 2, 3, 14, 15); break;	/* Port H; mux 2/3; PH14 and PH15 */
+	}
+	SSYNC();
+#elif defined(__ADSPBF52x__)
 # define DO_MUX(port, mux, tx, rx) \
 	bfin_write_PORT##port##_MUX((bfin_read_PORT##port##_MUX() & ~PORT_x_MUX_##mux##_MASK) | PORT_x_MUX_##mux##_FUNC_3); \
 	bfin_write_PORT##port##_FER(bfin_read_PORT##port##_FER() | P##port##tx | P##port##rx);
Signature · 1 line
1.6.1
#33 lore raw

PATCH 28/40 Blackfin: just set SP register directly during init

In reply to Mike Frysinger

No need to set the SP register indirectly to the configured value when it can be set directly.

---
 cpu/blackfin/start.S |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
cpu/blackfin/start.S +2 -3
index 6c5fef7..8617c98 100644
@@ -163,9 +163,8 @@ ENTRY(_start)
 .Lnorelocate:
 
 	/* Setup the actual stack in external memory */
-	r0.h = HI(CONFIG_STACKBASE);
-	r0.l = LO(CONFIG_STACKBASE);
-	sp = r0;
+	sp.h = HI(CONFIG_STACKBASE);
+	sp.l = LO(CONFIG_STACKBASE);
 	fp = sp;
 
 	/* Now lower ourselves from the highest interrupt level to
Signature · 1 line
1.6.1
#34 lore raw

PATCH 29/40 Blackfin: clarify relocation comment during init

In reply to Mike Frysinger

People often ask questions about the init process and when things go from flash to relocated base, so clarify the comments a bit.

---
 cpu/blackfin/start.S |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
cpu/blackfin/start.S +7 -3
index 8617c98..6c8def4 100644
@@ -125,9 +125,11 @@ ENTRY(_start)
 	 */
 	r6 = 1 (x);
 
-	/* Relocate from wherever are (FLASH/RAM/etc...) to the hardcoded
+	/* Relocate from wherever we are (FLASH/RAM/etc...) to the hardcoded
 	 * monitor location in the end of RAM.  We know that memcpy() only
-	 * uses registers, so it is safe to call here.
+	 * uses registers, so it is safe to call here.  Note that this only
+	 * copies to external memory ... we do not start executing out of
+	 * it yet (see "lower to 15" below).
 	 */
 	serial_early_puts("Relocate");
 	call _get_pc;
@@ -172,7 +174,9 @@ ENTRY(_start)
 	 * setting the 15 handler to ".Lenable_nested", raising the 15
 	 * interrupt, and then returning from the highest interrupt
 	 * level to the dummy "jump" until the interrupt controller
-	 * services the pending 15 interrupt.
+	 * services the pending 15 interrupt.  If executing out of
+	 * flash, these steps also changes the code flow from flash
+	 * to external memory.
 	 */
 	serial_early_puts("Lower to 15");
 	r0 = r7;
Signature · 1 line
1.6.1
#35 lore raw

PATCH 30/40 Blackfin: pass RETX to Linux

In reply to Mike Frysinger

Make sure we save the value of RETX at power on and then pass it on to the kernel so that it can nicely debug a "double-fault-caused-a-reset" crash.

---
 cpu/blackfin/cpu.c  |    6 ++++++
 lib_blackfin/boot.c |    9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)
cpu/blackfin/cpu.c +6 -0
index 9efd88e..30c214b 100644
@@ -14,11 +14,14 @@
 #include <asm/blackfin.h>
 #include <asm/cplb.h>
 #include <asm/mach-common/bits/core.h>
+#include <asm/mach-common/bits/ebiu.h>
 #include <asm/mach-common/bits/trace.h>
 
 #include "cpu.h"
 #include "serial.h"
 
+ulong bfin_poweron_retx;
+
 __attribute__ ((__noreturn__))
 void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
 {
@@ -48,6 +51,9 @@ void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
 		bfin_write_EBIU_AMGCTL(CONFIG_EBIU_AMGCTL_VAL);
 #endif
 
+	/* Save RETX so we can pass it while booting Linux */
+	bfin_poweron_retx = bootflag;
+
 #ifdef CONFIG_DEBUG_DUMP
 	/* Turn on hardware trace buffer */
 	bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
lib_blackfin/boot.c +8 -1
index 47e27de..537be2b 100644
@@ -31,6 +31,8 @@ static char *make_command_line(void)
 	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);
@@ -49,7 +51,12 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	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;
Signature · 1 line
1.6.1
#36 lore raw

PATCH 31/40 Blackfin: handle new anomalies with reset

In reply to Mike Frysinger

Workaround fun new anomalies related to software reset of the processor.

---
 cpu/blackfin/reset.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
cpu/blackfin/reset.c +15 -5
index d1e34b3..284cea5 100644
@@ -29,26 +29,35 @@ void bfin_reset(void)
 	 */
 	__builtin_bfin_ssync();
 
-	while (1) {
+	/* The bootrom checks to see how it was reset and will
+	 * automatically perform a software reset for us when
+	 * it starts executing after the core reset.
+	 */
+	if (ANOMALY_05000353 || ANOMALY_05000386) {
 		/* Initiate System software reset. */
 		bfin_write_SWRST(0x7);
 
 		/* Due to the way reset is handled in the hardware, we need
-		 * to delay for 7 SCLKS.  The only reliable way to do this is
-		 * to calculate the CCLK/SCLK ratio and multiply 7.  For now,
+		 * to delay for 10 SCLKS.  The only reliable way to do this is
+		 * to calculate the CCLK/SCLK ratio and multiply 10.  For now,
 		 * we'll assume worse case which is a 1:15 ratio.
 		 */
 		asm(
 			"LSETUP (1f, 1f) LC0 = %0\n"
 			"1: nop;"
 			:
-			: "a" (15 * 7)
+			: "a" (15 * 10)
 			: "LC0", "LB0", "LT0"
 		);
 
 		/* Clear System software reset */
 		bfin_write_SWRST(0);
 
+		/* The BF526 ROM will crash during reset */
+#if defined(__ADSPBF522__) || defined(__ADSPBF524__) || defined(__ADSPBF526__)
+		bfin_read_SWRST();
+#endif
+
 		/* Wait for the SWRST write to complete.  Cannot rely on SSYNC
 		 * though as the System state is all reset now.
 		 */
@@ -59,10 +68,11 @@ void bfin_reset(void)
 			: "a" (15 * 1)
 			: "LC1", "LB1", "LT1"
 		);
+	}
 
+	while (1)
 		/* Issue core reset */
 		asm("raise 1");
-	}
 }
 
 /* We need to trampoline ourselves up into L1 since our linker
Signature · 1 line
1.6.1
#37 lore raw

PATCH 32/40 Blackfin: support console-over-JTAG

In reply to Mike Frysinger

The Blackfin JTAG has the ability to pass data via a back-channel without halting the processor. Utilize that channel to emulate a console.

---
 common/devices.c            |    3 +
 cpu/blackfin/Makefile       |    9 ++--
 cpu/blackfin/jtag-console.c |  125 +++++++++++++++++++++++++++++++++++++++++++
 include/devices.h           |    3 +
 4 files changed, 136 insertions(+), 4 deletions(-)
 create mode 100644 cpu/blackfin/jtag-console.c
common/devices.c +3 -0
index ce3b7a0..38f1bbc 100644
@@ -240,6 +240,9 @@ int devices_init (void)
 #ifdef CONFIG_NETCONSOLE
 	drv_nc_init ();
 #endif
+#ifdef CONFIG_JTAG_CONSOLE
+	drv_jtag_console_init ();
+#endif
 
 	return (0);
 }
cpu/blackfin/Makefile +5 -4
index b90fb48..b4049ff 100644
@@ -17,14 +17,15 @@ EXTRA    :=
 CEXTRA   := initcode.o
 SEXTRA   := start.o
 SOBJS    := interrupt.o cache.o
-COBJS    := cpu.o traps.o interrupts.o reset.o serial.o watchdog.o
+COBJS-y  := cpu.o traps.o interrupts.o reset.o serial.o watchdog.o
+COBJS-$(CONFIG_JTAG_CONSOLE) += jtag-console.o
 
 ifeq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
-COBJS    += initcode.o
+COBJS-y  += initcode.o
 endif
 
-SRCS     := $(SEXTRA:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS     := $(addprefix $(obj),$(COBJS) $(SOBJS))
+SRCS     := $(SEXTRA:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS     := $(addprefix $(obj),$(COBJS-y) $(SOBJS))
 EXTRA    := $(addprefix $(obj),$(EXTRA))
 CEXTRA   := $(addprefix $(obj),$(CEXTRA))
 SEXTRA   := $(addprefix $(obj),$(SEXTRA))
cpu/blackfin/jtag-console.c new file +125 -0

125 lines not on this page · raw message

include/devices.h +3 -0
index 20ddfc4..84c4514 100644
@@ -116,5 +116,8 @@ int	drv_usbtty_init (void);
 #ifdef CONFIG_NETCONSOLE
 int	drv_nc_init (void);
 #endif
+#ifdef CONFIG_JTAG_CONSOLE
+int drv_jtag_console_init (void);
+#endif
 
 #endif	/* _DEVICES_H_ */
Signature · 1 line
1.6.1
#38 lore raw

PATCH 33/40 Blackfin: allow serial console to be disabled

In reply to Mike Frysinger

Some devices have no UART device pulled out, so allow people to disable the driver completely in favor of other methods (like JTAG-console).

---
 cpu/blackfin/serial.c |    4 ++++
 cpu/blackfin/serial.h |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)
cpu/blackfin/serial.c +4 -0
index 0d6f377..42534bd 100644
@@ -29,6 +29,8 @@
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/uart.h>
 
+#ifdef CONFIG_UART_CONSOLE
+
 #if defined(UART_LSR) && (CONFIG_UART_CONSOLE != 0)
 # error CONFIG_UART_CONSOLE must be 0 on parts with only one UART
 #endif
@@ -170,3 +172,5 @@ void serial_puts(const char *s)
 	while (*s)
 		serial_putc(*s++);
 }
+
+#endif
cpu/blackfin/serial.h +4 -0
index 90fceec..f671096 100644
@@ -14,6 +14,10 @@
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/uart.h>
 
+#ifndef CONFIG_UART_CONSOLE
+# define CONFIG_UART_CONSOLE 0
+#endif
+
 #ifdef CONFIG_DEBUG_EARLY_SERIAL
 # define BFIN_DEBUG_EARLY_SERIAL 1
 #else
Signature · 1 line
1.6.1
#39 lore raw

PATCH 34/40 Blackfin: update on-chip ROM API

In reply to Mike Frysinger

This brings the API for the on-chip ROM in line with the toolchain and hardware documentation.

---
 include/asm-blackfin/mach-common/bits/bootrom.h |   63 ++++++++++++----------
 include/asm-blackfin/mach-common/bits/otp.h     |   21 ++++----
 2 files changed, 44 insertions(+), 40 deletions(-)
include/asm-blackfin/mach-common/bits/bootrom.h +34 -29
index bf661f0..fb97ff8 100644
@@ -92,14 +92,6 @@
 
 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 1
 
-/* Not available on initial BF54x or BF52x */
-#if (defined(__ADSPBF54x__) && __SILICON_REVISION__ < 1) || \
-    (defined(__ADSPBF52x__) && __SILICON_REVISION__ < 2)
-#define BOOTROM_CAPS_SYSCONTROL 0
-#else
-#define BOOTROM_CAPS_SYSCONTROL 1
-#endif
-
 #endif
 
 #ifndef BOOTROM_FOLLOWS_C_ABI
@@ -108,9 +100,21 @@
 #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
 #endif
-#ifndef BOOTROM_CAPS_SYSCONTROL
-#define BOOTROM_CAPS_SYSCONTROL 0
-#endif
+
+/* Possible syscontrol action flags */
+#define SYSCTRL_READ        0x00000000    /* read registers */
+#define SYSCTRL_WRITE       0x00000001    /* write registers */
+#define SYSCTRL_SYSRESET    0x00000002    /* perform system reset */
+#define SYSCTRL_CORERESET   0x00000004    /* perform core reset */
+#define SYSCTRL_SOFTRESET   0x00000006    /* perform core and system reset */
+#define SYSCTRL_VRCTL       0x00000010    /* read/write VR_CTL register */
+#define SYSCTRL_EXTVOLTAGE  0x00000020    /* VDDINT supplied externally */
+#define SYSCTRL_INTVOLTAGE  0x00000000    /* VDDINT generated by on-chip regulator */
+#define SYSCTRL_OTPVOLTAGE  0x00000040    /* For Factory Purposes Only */
+#define SYSCTRL_PLLCTL      0x00000100    /* read/write PLL_CTL register */
+#define SYSCTRL_PLLDIV      0x00000200    /* read/write PLL_DIV register */
+#define SYSCTRL_LOCKCNT     0x00000400    /* read/write PLL_LOCKCNT register */
+#define SYSCTRL_PLLSTAT     0x00000800    /* read/write PLL_STAT register */
 
 #ifndef __ASSEMBLY__
 
@@ -132,25 +136,26 @@ typedef struct ADI_SYSCTRL_VALUES {
 #ifndef _BOOTROM_SYSCONTROL
 #define _BOOTROM_SYSCONTROL 0
 #endif
-static uint32_t (* const syscontrol)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
+static uint32_t (* const bfrom_SysControl)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
 
-#endif /* __ASSEMBLY__ */
-
-/* Possible syscontrol action flags */
-#define SYSCTRL_READ        0x00000000    /* read registers */
-#define SYSCTRL_WRITE       0x00000001    /* write registers */
-#define SYSCTRL_SYSRESET    0x00000002    /* perform system reset */
-#define SYSCTRL_SOFTRESET   0x00000004    /* perform core and system reset */
-#define SYSCTRL_VRCTL       0x00000010    /* read/write VR_CTL register */
-#define SYSCTRL_EXTVOLTAGE  0x00000020    /* VDDINT supplied externally */
-#define SYSCTRL_INTVOLTAGE  0x00000000    /* VDDINT generated by on-chip regulator */
-#define SYSCTRL_OTPVOLTAGE  0x00000040    /* For Factory Purposes Only */
-#define SYSCTRL_PLLCTL      0x00000100    /* read/write PLL_CTL register */
-#define SYSCTRL_PLLDIV      0x00000200    /* read/write PLL_DIV register */
-#define SYSCTRL_LOCKCNT     0x00000400    /* read/write PLL_LOCKCNT register */
-#define SYSCTRL_PLLSTAT     0x00000800    /* read/write PLL_STAT register */
-
-#ifndef __ASSEMBLY__
+/* We need a dedicated function since we need to screw with the stack pointer
+ * when resetting.  The on-chip ROM will save/restore registers on the stack
+ * when doing a system reset, so the stack cannot be outside of the chip.
+ */
+__attribute__((__noreturn__))
+static inline void bfrom_SoftReset(void *new_stack)
+{
+	while (1)
+		__asm__ __volatile__(
+			"sp = %[stack];"
+			"jump (%[bfrom_syscontrol]);"
+			: : [bfrom_syscontrol] "p"(bfrom_SysControl),
+				"q0"(SYSCTRL_SOFTRESET),
+				"q1"(0),
+				"q2"(NULL),
+				[stack] "p"(new_stack)
+		);
+}
 
 /* Structures for working with LDRs and boot rom callbacks */
 typedef struct ADI_BOOT_HEADER {
include/asm-blackfin/mach-common/bits/otp.h +10 -11
index d529a0a..4e3f1af 100644
@@ -9,23 +9,22 @@
 
 #include "bootrom.h"
 
-static uint32_t (* const otp_command)(uint32_t command, uint32_t value) = (void *)_BOOTROM_OTP_COMMAND;
-static uint32_t (* const otp_read)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)_BOOTROM_OTP_READ;
-static uint32_t (* const otp_write)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)_BOOTROM_OTP_WRITE;
+static uint32_t (* const bfrom_OtpCommand)(uint32_t command, uint32_t value) = (void *)_BOOTROM_OTP_COMMAND;
+static uint32_t (* const bfrom_OtpRead)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)_BOOTROM_OTP_READ;
+static uint32_t (* const bfrom_OtpWrite)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)_BOOTROM_OTP_WRITE;
 
 #endif
 
 /* otp_command(): defines for "command" */
-#define OTP_INIT             0x00000001
-#define OTP_CLOSE            0x00000002
+#define OTP_INIT                 0x00000001
+#define OTP_CLOSE                0x00000002
 
 /* otp_{read,write}(): defines for "flags" */
-#define OTP_LOWER_HALF       0x00000000 /* select upper/lower 64-bit half (bit 0) */
-#define OTP_UPPER_HALF       0x00000001
-#define OTP_NO_ECC           0x00000010 /* do not use ECC */
-#define OTP_LOCK             0x00000020 /* sets page protection bit for page */
-#define OTP_ACCESS_READ      0x00001000
-#define OTP_ACCESS_READWRITE 0x00002000
+#define OTP_LOWER_HALF           0x00000000 /* select upper/lower 64-bit half (bit 0) */
+#define OTP_UPPER_HALF           0x00000001
+#define OTP_NO_ECC               0x00000010 /* do not use ECC */
+#define OTP_LOCK                 0x00000020 /* sets page protection bit for page */
+#define OTP_CHECK_FOR_PREV_WRITE 0x00000080
 
 /* Return values for all functions */
 #define OTP_SUCCESS          0x00000000
Signature · 1 line
1.6.1
#40 lore raw

PATCH 35/40 Blackfin: implement real write support for OTP

In reply to Mike Frysinger

Now that real documentation has been released for the OTP interface and the on-chip ROM wrt writing/timings, implement support for reading/writing as well as dumping/locking.

---
 common/cmd_otp.c |  157 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 115 insertions(+), 42 deletions(-)
common/cmd_otp.c +115 -42
index 825fa34..ce8c63b 100644
@@ -6,7 +6,7 @@
  * Licensed under the GPL-2 or later.
  */
 
-/* There are 512 128-bit "pages" (0x000 to 0x1FF).
+/* There are 512 128-bit "pages" (0x000 through 0x1FF).
  * The pages are accessable as 64-bit "halfpages" (an upper and lower half).
  * The pages are not part of the memory map.  There is an OTP controller which
  * handles scanning in/out of bits.  While access is done through OTP MMRs,
@@ -17,8 +17,6 @@
 #include <common.h>
 #include <command.h>
 
-#ifdef CONFIG_CMD_OTP
-
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/otp.h>
 
@@ -40,30 +38,87 @@ static const char *otp_strerror(uint32_t err)
 
 #define lowup(x) ((x) % 2 ? "upper" : "lower")
 
-int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+static int check_voltage(void)
+{
+	/* Make sure voltage limits are within datasheet spec */
+	uint16_t vr_ctl = bfin_read_VR_CTL();
+
+#ifdef __ADSPBF54x__
+	/* 0.9V <= VDDINT <= 1.1V */
+	if ((vr_ctl & 0xc) && (vr_ctl & 0xc0) == 0xc0)
+		return 1;
+#else
+	/* for the parts w/out qualification yet */
+	(void)vr_ctl;
+#endif
+
+	return 0;
+}
+
+static void set_otp_timing(bool write)
 {
-	bool force = false;
-	if (!strcmp(argv[1], "--force")) {
-		force = true;
-		argv[1] = argv[0];
-		argv++;
-		--argc;
+	static uint32_t timing;
+	if (!timing) {
+		uint32_t tp1, tp2, tp3;
+		/* OTP_TP1 = 1000 / sclk_period (in nanoseconds)
+		 * OTP_TP1 = 1000 / (1 / get_sclk() * 10^9)
+		 * OTP_TP1 = (1000 * get_sclk()) / 10^9
+		 * OTP_TP1 = get_sclk() / 10^6
+		 */
+		tp1 = get_sclk() / 1000000;
+		/* OTP_TP2 = 400 / (2 * sclk_period)
+		 * OTP_TP2 = 400 / (2 * 1 / get_sclk() * 10^9)
+		 * OTP_TP2 = (400 * get_sclk()) / (2 * 10^9)
+		 * OTP_TP2 = (2 * get_sclk()) / 10^7
+		 */
+		tp2 = (2 * get_sclk() / 10000000) << 8;
+		/* OTP_TP3 = magic constant */
+		tp3 = (0x1401) << 15;
+		timing = tp1 | tp2 | tp3;
 	}
 
+	bfrom_OtpCommand(OTP_INIT, write ? timing : timing & ~(-1 << 15));
+}
+
+int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	uint32_t ret, base_flags;
+	bool prompt_user, force_read;
 	uint32_t (*otp_func)(uint32_t page, uint32_t flags, uint64_t *page_content);
-	if (!strcmp(argv[1], "read"))
-		otp_func = otp_read;
-	else if (!strcmp(argv[1], "write"))
-		otp_func = otp_write;
-	else {
+
+	if (argc < 4) {
  usage:
 		printf("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
+	prompt_user = false;
+	base_flags = 0;
+	if (!strcmp(argv[1], "read"))
+		otp_func = bfrom_OtpRead;
+	else if (!strcmp(argv[1], "dump")) {
+		otp_func = bfrom_OtpRead;
+		force_read = true;
+	} else if (!strcmp(argv[1], "write")) {
+		otp_func = bfrom_OtpWrite;
+		base_flags = OTP_CHECK_FOR_PREV_WRITE;
+		if (!strcmp(argv[2], "--force")) {
+			argv[2] = argv[1];
+			argv++;
+			--argc;
+		} else
+			prompt_user = false;
+	} else if (!strcmp(argv[1], "lock")) {
+		if (argc != 4)
+			goto usage;
+		otp_func = bfrom_OtpWrite;
+		base_flags = OTP_LOCK;
+	} else
+		goto usage;
+
 	uint64_t *addr = (uint64_t *)simple_strtoul(argv[2], NULL, 16);
 	uint32_t page = simple_strtoul(argv[3], NULL, 16);
-	uint32_t flags, ret;
+	uint32_t flags;
 	size_t i, count;
 	ulong half;
 
@@ -81,8 +136,15 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	} else
 		half = 0;
 
+	/* "otp lock" has slightly different semantics */
+	if (base_flags & OTP_LOCK) {
+		count = page;
+		page = (uint32_t)addr;
+		addr = NULL;
+	}
+
 	/* do to the nature of OTP, make sure users are sure */
-	if (!force && otp_func == otp_write) {
+	if (prompt_user) {
 		printf(
 			"Writing one time programmable memory\n"
 			"Make sure your operating voltages and temperature are within spec\n"
@@ -111,30 +173,42 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 				}
 			}
 		}
-
-		/* Only supported in newer silicon ... enable writing */
-#if (0)
-		otp_command(OTP_INIT, ...);
-#else
-		*pOTP_TIMING = 0x32149485;
-#endif
 	}
 
 	printf("OTP memory %s: addr 0x%08lx  page 0x%03X  count %ld ... ",
 		argv[1], addr, page, count);
 
+	set_otp_timing(otp_func == bfrom_OtpWrite);
+	if (otp_func == bfrom_OtpWrite && check_voltage()) {
+		puts("ERROR: VDDINT voltage is out of spec for writing\n");
+		return -1;
+	}
+
+	/* Do the actual reading/writing stuff */
 	ret = 0;
 	for (i = half; i < count + half; ++i) {
-		flags = (i % 2) ? OTP_UPPER_HALF : OTP_LOWER_HALF;
+		flags = base_flags | (i % 2 ? OTP_UPPER_HALF : OTP_LOWER_HALF);
+ try_again:
 		ret = otp_func(page, flags, addr);
-		if (ret & 0x1)
-			break;
-		else if (ret)
+		if (ret & OTP_MASTER_ERROR) {
+			if (force_read) {
+				if (flags & OTP_NO_ECC)
+					break;
+				else
+					flags |= OTP_NO_ECC;
+				puts("E");
+				goto try_again;
+			} else
+				break;
+		} else if (ret)
 			puts("W");
 		else
 			puts(".");
-		++addr;
-		if (i % 2)
+		if (!(base_flags & OTP_LOCK)) {
+			++addr;
+			if (i % 2)
+				++page;
+		} else
 			++page;
 	}
 	if (ret & 0x1)
@@ -143,21 +217,20 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	else
 		puts(" done\n");
 
-	if (otp_func == otp_write)
-		/* Only supported in newer silicon ... disable writing */
-#if (0)
-		otp_command(OTP_INIT, ...);
-#else
-		*pOTP_TIMING = 0x1485;
-#endif
+	/* Make sure we disable writing */
+	set_otp_timing(false);
+	bfrom_OtpCommand(OTP_CLOSE, 0);
 
 	return ret;
 }
 
-U_BOOT_CMD(otp, 6, 0, do_otp,
-	"otp - One-Time-Programmable sub-system\n",
+U_BOOT_CMD(otp, 7, 0, do_otp,
+	"otp     - One-Time-Programmable sub-system\n",
 	"read <addr> <page> [count] [half]\n"
+	" - read 'count' half-pages starting at 'page' (offset 'half') to 'addr'\n"
+	"otp dump <addr> <page> [count] [half]\n"
+	" - like 'otp read', but skip read errors\n"
 	"otp write [--force] <addr> <page> [count] [half]\n"
-	"    - read/write 'count' half-pages starting at page 'page' (offset 'half')\n");
-
-#endif
+	" - write 'count' half-pages starting at 'page' (offset 'half') from 'addr'\n"
+	"otp lock <page> <count>\n"
+	" - lock 'count' pages starting at 'page'\n");
Signature · 1 line
1.6.1
#41 lore raw

PATCH 36/40 Blackfin: bootldr: implement BF53x/BF56x LDR loader

In reply to Mike Frysinger

The BF53x/BF56x parts do not have an on-chip ROM to boot LDRs out of arbitrary memory locations, so implement a basic one in software.

---
 common/cmd_bootldr.c |  137 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 124 insertions(+), 13 deletions(-)
common/cmd_bootldr.c +124 -13
index e6474aa..a969242 100644
@@ -16,6 +16,127 @@
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/bootrom.h>
 
+/* Simple sanity check on the specified address to make sure it contains
+ * an LDR image of some sort.
+ */
+static bool ldr_valid_signature(uint8_t *data)
+{
+#if defined(__ADSPBF561__)
+
+	/* BF56x has a 4 byte global header */
+	if (data[3] == 0xA0)
+		return true;
+
+#elif defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
+      defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) || \
+      defined(__ADSPBF538__) || defined(__ADSPBF539__)
+
+	/* all the BF53x should start at this address mask */
+	uint32_t addr;
+	memmove(&addr, data, sizeof(addr));
+	if ((addr & 0xFF0FFF0F) == 0xFF000000)
+		return true;
+#else
+
+	/* everything newer has a magic byte */
+	uint32_t count;
+	memmove(&count, data + 8, sizeof(count));
+	if (data[3] == 0xAD && count == 0)
+		return true;
+
+#endif
+
+	return false;
+}
+
+/* If the Blackfin is new enough, the Blackfin on-chip ROM supports loading
+ * LDRs from random memory addresses.  So whenever possible, use that.  In
+ * the older cases (BF53x/BF561), parse the LDR format ourselves.
+ */
+#define ZEROFILL  0x0001
+#define RESVECT   0x0002
+#define INIT      0x0008
+#define IGNORE    0x0010
+#define FINAL     0x8000
+static void ldr_load(uint8_t *base_addr)
+{
+#if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
+  /*defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) ||*/\
+    defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__)
+
+	void *ret;
+
+	uint32_t addr;
+	uint32_t count;
+	uint16_t flags;
+
+	/* the bf56x has a 4 byte global header ... but it is useless to
+	 * us when booting an LDR from a memory address, so skip it
+	 */
+# ifdef __ADSPBF561__
+	base_addr += 4;
+# endif
+
+	memmove(&flags, base_addr + 8, sizeof(flags));
+	bfin_write_EVT1(flags & RESVECT ? 0xFFA00000 : 0xFFA08000);
+
+	do {
+		/* block header may not be aligned */
+		memmove(&addr, base_addr, sizeof(addr));
+		memmove(&count, base_addr+4, sizeof(count));
+		memmove(&flags, base_addr+8, sizeof(flags));
+		base_addr += sizeof(addr) + sizeof(count) + sizeof(flags);
+
+		printf("loading to 0x%08x (0x%x bytes) flags: 0x%04x\n",
+			addr, count, flags);
+
+		if (!(flags & IGNORE)) {
+			if (flags & ZEROFILL)
+				memset((void *)addr, 0x00, count);
+			else
+				memcpy((void *)addr, base_addr, count);
+
+			if (flags & INIT) {
+				void (*init)(void) = (void *)addr;
+				init();
+			}
+		}
+
+		if (!(flags & ZEROFILL))
+			base_addr += count;
+	} while (!(flags & FINAL));
+
+#endif
+}
+
+/* For BF537, we use the _BOOTROM_BOOT_DXE_FLASH funky ROM function.
+ * For all other BF53x/BF56x, we just call the entry point.
+ * For everything else (newer), we use _BOOTROM_MEMBOOT ROM function.
+ */
+static void ldr_exec(void *addr)
+{
+#if defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__)
+
+	/* restore EVT1 to reset value as this is what the bootrom uses as
+	 * the default entry point when booting the final block of LDRs
+	 */
+	bfin_write_EVT1(L1_INST_SRAM);
+	__asm__("call (%0);" : : "a"(_BOOTROM_MEMBOOT), "q7"(addr) : "RETS", "memory");
+
+#elif defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
+      defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__)
+
+	void (*ldr_entry)(void) = bfin_read_EVT1();
+	ldr_entry();
+
+#else
+
+	int32_t (*BOOTROM_MEM)(void *, int32_t, int32_t, void *) = (void *)_BOOTROM_MEMBOOT;
+	BOOTROM_MEM(addr, 0, 0, NULL);
+
+#endif
+}
+
 /*
  * the bootldr command loads an address, checks to see if there
  *   is a Boot stream that the on-chip BOOTROM can understand,
@@ -23,11 +144,9 @@
  *   to also add booting from SPI, or TWI, but this function does
  *   not currently support that.
  */
-
 int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	void *addr;
-	uint32_t *data;
 
 	/* Get the address */
 	if (argc < 2)
@@ -36,22 +155,14 @@ int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		addr = (void *)simple_strtoul(argv[1], NULL, 16);
 
 	/* Check if it is a LDR file */
-	data = addr;
-#if defined(__ADSPBF54x__) || defined(__ADSPBF52x__)
-	if ((*data & 0xFF000000) == 0xAD000000 && data[2] == 0x00000000) {
-#else
-	if (*data == 0xFF800060 || *data == 0xFF800040 || *data == 0xFF800020) {
-#endif
-		/* We want to boot from FLASH or SDRAM */
+	if (ldr_valid_signature(addr)) {
 		printf("## Booting ldr image at 0x%p ...\n", addr);
+		ldr_load(addr);
 
 		icache_disable();
 		dcache_disable();
 
-		__asm__(
-			"jump (%1);"
-			:
-			: "q7" (addr), "a" (_BOOTROM_MEMBOOT));
+		ldr_exec(addr);
 	} else
 		printf("## No ldr image@address 0x%p\n", addr);
 
Signature · 1 line
1.6.1
#42 lore raw

PATCH 37/40 smc91111_eeprom: move board-specific init into SMC91111_EEPROM_INIT()

In reply to Mike Frysinger

Rather than sticking Blackfin-specific stuff into the eeprom example, use an indirect macro so that any board can override it with their own magic sauce in their board config file.

Also fix some spurious semi-colons in defines while I'm at it ...

---
 examples/smc91111_eeprom.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
examples/smc91111_eeprom.c +6 -9
index 62347c7..39e5306 100644
@@ -33,15 +33,14 @@
 
 #ifdef CONFIG_DRIVER_SMC91111
 
-#ifdef pFIO0_DIR
-# define pFIO_DIR    pFIO0_DIR
-# define pFIO_FLAG_S pFIO0_FLAG_S
+#ifndef SMC91111_EEPROM_INIT
+# define SMC91111_EEPROM_INIT()
 #endif
 
 #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
-#define EEPROM		0x1;
-#define MAC		0x2;
-#define	UNKNOWN		0x4;
+#define EEPROM		0x1
+#define MAC		0x2
+#define UNKNOWN		0x4
 
 void dump_reg (void);
 void dump_eeprom (void);
@@ -66,9 +65,7 @@ int smc91111_eeprom (int argc, char *argv[])
 		return (0);
 	}
 
-	*pFIO_DIR = 0x01;
-	*pFIO_FLAG_S = 0x01;
-	SSYNC();
+	SMC91111_EEPROM_INIT();
 
 	if ((SMC_inw (BANK_SELECT) & 0xFF00) != 0x3300) {
 		printf ("Can't find SMSC91111\n");
Signature · 1 line
1.6.1
#43 lore raw

PATCH 37/40 smc91111_eeprom: move board-specific init into SMC91111_EEPROM_INIT()

Quoted 5 lines · On Friday 23 January 2009 13:00:38 Mike Frysinger wrote:

Rather than sticking Blackfin-specific stuff into the eeprom example, use an indirect macro so that any board can override it with their own magic sauce in their board config file.

Also fix some spurious semi-colons in defines while I'm at it ...

Ben: this changes Blackfin-specific code in the smc91111_eeprom.c example ... -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090125/1d705623/attachment.pgp

#44 lore raw

PATCH 38/40 Blackfin: bf533-stamp: rewrite resource swap logic

In reply to Mike Frysinger

The old swap function tended to clobber unrelated pins and screw up masks. Rewrite the thing from scratch so it only uses the resources it needs.

---
 board/bf533-stamp/bf533-stamp.c |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)
board/bf533-stamp/bf533-stamp.c +15 -24
index 1a073a6..44ebc93 100644
@@ -54,29 +54,23 @@ phys_size_t initdram(int board_type)
 	return gd->bd->bi_memsize;
 }
 
+/* PF0 and PF1 are used to switch between the ethernet and flash:
+ *         PF0  PF1
+ *  flash:  0    0
+ *  ether:  1    0
+ */
 void swap_to(int device_id)
 {
-
-	if (device_id == ETHERNET) {
-		*pFIO_DIR = PF0;
-		SSYNC();
-		*pFIO_FLAG_S = PF0;
-		SSYNC();
-	} else if (device_id == FLASH) {
-		*pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
-		*pFIO_FLAG_S = (PF4 | PF3 | PF2);
-		*pFIO_MASKA_D = (PF8 | PF6 | PF5);
-		*pFIO_MASKB_D = (PF7);
-		*pFIO_POLAR = (PF8 | PF6 | PF5);
-		*pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
-		*pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
-		*pFIO_FLAG_D = (PF4 | PF3 | PF2);
-		SSYNC();
-	} else {
-		printf("Unknown bank to switch\n");
-	}
-
-	return;
+	bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
+	SSYNC();
+	bfin_write_FIO_FLAG_C(PF1);
+	if (device_id == ETHERNET)
+		bfin_write_FIO_FLAG_S(PF0);
+	else if (device_id == FLASH)
+		bfin_write_FIO_FLAG_C(PF0);
+	else
+		printf("Unknown device to switch\n");
+	SSYNC();
 }
 
 #if defined(CONFIG_MISC_INIT_R)
@@ -104,9 +98,6 @@ int misc_init_r(void)
 	if (cf_stat) {
 		printf("Booting from COMPACT flash\n");
 
-		/* Set cycle time for CF */
-		*(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
-
 		for (i = 0; i < 0x1000; i++)
 			asm("nop;");
 		for (i = 0; i < 0x1000; i++)
Signature · 1 line
1.6.1
#45 lore raw

PATCH 39/40 Blackfin: convert old boards to use COBJS-y Makefile style

In reply to Mike Frysinger
---
 board/bf533-ezkit/Makefile |    8 ++++----
 board/bf533-stamp/Makefile |    7 ++++---
 board/bf537-stamp/Makefile |   10 ++++++----
 board/bf537-stamp/nand.c   |    3 ---
 board/bf561-ezkit/Makefile |    8 ++++----
 5 files changed, 18 insertions(+), 18 deletions(-)
board/bf533-ezkit/Makefile +4 -4
index 6a45b7c..1260277 100644
@@ -29,11 +29,11 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= $(BOARD).o flash.o
+COBJS-y	:= $(BOARD).o flash.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(obj)u-boot.lds
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
board/bf533-stamp/Makefile +4 -3
index 5b5e199..a03fe89 100644
@@ -29,12 +29,13 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS-y               := $(BOARD).o spi_flash.o
+COBJS-y	:= $(BOARD).o
+COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
 COBJS-$(CONFIG_VIDEO) += video.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS-y))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(obj)u-boot.lds
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
board/bf537-stamp/Makefile +6 -4
index e5ef9af..cb38b96 100644
@@ -29,11 +29,13 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= $(BOARD).o post-memory.o spi_flash.o cmd_bf537led.o nand.o
+COBJS-y	:= $(BOARD).o post-memory.o cmd_bf537led.o
+COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
+COBJS-$(CONFIG_CMD_NAND)   += nand.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(obj)u-boot.lds
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
board/bf537-stamp/nand.c +0 -3
index 2866834..181e83d 100644
@@ -23,8 +23,6 @@
 #include <common.h>
 #include <asm/io.h>
 
-#if defined(CONFIG_CMD_NAND)
-
 #include <nand.h>
 
 #define CONCAT(a,b,c,d) a ## b ## c ## d
@@ -100,4 +98,3 @@ int board_nand_init(struct nand_chip *nand)
 
 	return 0;
 }
-#endif
board/bf561-ezkit/Makefile +4 -4
index e7ee243..daebb74 100644
@@ -29,11 +29,11 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= $(BOARD).o
+COBJS-y	:= $(BOARD).o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(obj)u-boot.lds
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
Signature · 1 line
1.6.1
#46 lore raw

PATCH 40/40 Blackfin: fixup misc warnings such as printf's and missing casts

In reply to Mike Frysinger
---
 board/bf533-ezkit/flash.c     |    6 +++---
 board/bf537-stamp/spi_flash.c |    4 ++--
 common/cmd_bootldr.c          |    4 +---
 common/cmd_cplbinfo.c         |    4 ++--
 common/cmd_otp.c              |    6 +++---
 cpu/blackfin/traps.c          |   21 +++++++++++----------
 lib_blackfin/boot.c           |    2 +-
 7 files changed, 23 insertions(+), 24 deletions(-)
board/bf533-ezkit/flash.c +3 -3
index 539c00d..ab808d8 100644
@@ -127,7 +127,7 @@ void flash_print_info(flash_info_t * info)
 		printf("ST Microelectronics ");
 		break;
 	default:
-		printf("Unknown Vendor: (0x%08X) ", info->flash_id);
+		printf("Unknown Vendor: (0x%08lX) ", info->flash_id);
 		break;
 	}
 	for (i = 0; i < info->sector_count; ++i) {
@@ -215,7 +215,7 @@ int write_data(long lStart, long lCount, uchar * pnData)
 		read_flash(ulOffset, &d);
 		if (d != 0xffff) {
 			printf
-			    ("Flash not erased at offset 0x%x Please erase to reprogram \n",
+			    ("Flash not erased at offset 0x%lx Please erase to reprogram\n",
 			     ulOffset);
 			return FLASH_FAIL;
 		}
@@ -234,7 +234,7 @@ int write_data(long lStart, long lCount, uchar * pnData)
 		read_flash(ulOffset, &d);
 		if (d != 0xffff) {
 			printf
-			    ("Flash not erased at offset 0x%x Please erase to reprogram \n",
+			    ("Flash not erased at offset 0x%lx Please erase to reprogram\n",
 			     ulOffset);
 			return FLASH_FAIL;
 		}
board/bf537-stamp/spi_flash.c +2 -2
index a99c3fa..99caa96 100644
@@ -797,8 +797,8 @@ int eeprom_info(void)
 		ret = 1;
 	else
 		printf("SPI Device: %s 0x%02X (%s) 0x%02X 0x%02X\n"
-			"Parameters: num sectors = %i, sector size = %i, write size = %i\n"
-			"Flash Size: %i mbit (%i mbyte)\n"
+			"Parameters: num sectors = %lu, sector size = %lu, write size = %i\n"
+			"Flash Size: %lu mbit (%lu mbyte)\n"
 			"Status: 0x%02X\n",
 			flash.flash->name, flash.manufacturer_id, flash.manufacturer->name,
 			flash.device_id1, flash.device_id2, flash.num_sectors,
common/cmd_bootldr.c +1 -3
index a969242..f8db0bc 100644
@@ -64,8 +64,6 @@ static void ldr_load(uint8_t *base_addr)
   /*defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) ||*/\
     defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__)
 
-	void *ret;
-
 	uint32_t addr;
 	uint32_t count;
 	uint16_t flags;
@@ -126,7 +124,7 @@ static void ldr_exec(void *addr)
 #elif defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
       defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__)
 
-	void (*ldr_entry)(void) = bfin_read_EVT1();
+	void (*ldr_entry)(void) = (void *)bfin_read_EVT1();
 	ldr_entry();
 
 #else
common/cmd_cplbinfo.c +2 -2
index b2bbec1..eae1f53 100644
@@ -26,11 +26,11 @@ static const char *cplb_page_size(uint32_t data)
  */
 static void show_cplb_table(uint32_t *addr, uint32_t *data)
 {
-	size_t i;
+	int i;
 	printf("      Address     Data   Size  Valid  Locked\n");
 	for (i = 1; i <= 16; ++i) {
 		printf(" %2i 0x%p  0x%05X   %s     %c      %c\n",
-			i, *addr, *data,
+			i, (void *)*addr, *data,
 			cplb_page_size(*data),
 			(*data & CPLB_VALID ? 'Y' : 'N'),
 			(*data & CPLB_LOCK ? 'Y' : 'N'));
common/cmd_otp.c +3 -3
index ce8c63b..08d7b7e 100644
@@ -149,8 +149,8 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			"Writing one time programmable memory\n"
 			"Make sure your operating voltages and temperature are within spec\n"
 			"   source address:  0x%p\n"
-			"   OTP destination: %s page 0x%03X - %s page 0x%03X\n"
-			"   number to write: %ld halfpages\n"
+			"   OTP destination: %s page 0x%03X - %s page 0x%03lX\n"
+			"   number to write: %lu halfpages\n"
 			" type \"YES\" (no quotes) to confirm: ",
 			addr,
 			lowup(half), page,
@@ -175,7 +175,7 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		}
 	}
 
-	printf("OTP memory %s: addr 0x%08lx  page 0x%03X  count %ld ... ",
+	printf("OTP memory %s: addr 0x%p  page 0x%03X  count %zu ... ",
 		argv[1], addr, page, count);
 
 	set_otp_timing(otp_func == bfrom_OtpWrite);
cpu/blackfin/traps.c +11 -10
index e72b347..a2c6f1e 100644
@@ -111,7 +111,7 @@ void trap_c(struct pt_regs *regs)
 		}
 		if (i == ARRAY_SIZE(bfin_memory_map)) {
 			printf("%cCPLB exception outside of memory map@0x%p\n",
-				(data ? 'D' : 'I'), new_cplb_addr);
+				(data ? 'D' : 'I'), (void *)new_cplb_addr);
 			bfin_panic(regs);
 		} else
 			debug("CPLB addr %p matches map 0x%p - 0x%p\n", new_cplb_addr, bfin_memory_map[i].start, bfin_memory_map[i].end);
@@ -207,20 +207,21 @@ static const char *symbol_lookup(unsigned long addr, unsigned long *caddr)
 static void decode_address(char *buf, unsigned long address)
 {
 	unsigned long sym_addr;
+	void *paddr = (void *)address;
 	const char *sym = symbol_lookup(address, &sym_addr);
 
 	if (sym) {
-		sprintf(buf, "<0x%p> { %s + 0x%x }", address, sym, address - sym_addr);
+		sprintf(buf, "<0x%p> { %s + 0x%lx }", paddr, sym, address - sym_addr);
 		return;
 	}
 
 	if (!address)
-		sprintf(buf, "<0x%p> /* Maybe null pointer? */", address);
+		sprintf(buf, "<0x%p> /* Maybe null pointer? */", paddr);
 	else if (address >= CONFIG_SYS_MONITOR_BASE &&
 	         address < CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
-		sprintf(buf, "<0x%p> /* somewhere in u-boot */", address);
+		sprintf(buf, "<0x%p> /* somewhere in u-boot */", paddr);
 	else
-		sprintf(buf, "<0x%p> /* unknown address */", address);
+		sprintf(buf, "<0x%p> /* unknown address */", paddr);
 }
 
 static char *strhwerrcause(uint16_t hwerrcause)
@@ -260,7 +261,7 @@ static char *strexcause(uint16_t excause)
 void dump(struct pt_regs *fp)
 {
 	char buf[150];
-	size_t i;
+	int i;
 	uint16_t hwerrcause, excause;
 
 	if (!ENABLE_DUMP)
@@ -275,8 +276,8 @@ void dump(struct pt_regs *fp)
 	printf("SEQUENCER STATUS:\n");
 	printf(" SEQSTAT: %08lx  IPEND: %04lx  SYSCFG: %04lx\n",
 		fp->seqstat, fp->ipend, fp->syscfg);
-	printf("  HWERRCAUSE: 0x%lx: %s\n", hwerrcause, strhwerrcause(hwerrcause));
-	printf("  EXCAUSE   : 0x%lx: %s\n", excause, strexcause(excause));
+	printf("  HWERRCAUSE: 0x%x: %s\n", hwerrcause, strhwerrcause(hwerrcause));
+	printf("  EXCAUSE   : 0x%x: %s\n", excause, strexcause(excause));
 	for (i = 6; i <= 15; ++i) {
 		if (fp->ipend & (1 << i)) {
 			decode_address(buf, bfin_read32(EVT0 + 4*i));
@@ -310,7 +311,7 @@ void dump(struct pt_regs *fp)
 	printf(" P0 : %08lx    P1 : %08lx    P2 : %08lx    P3 : %08lx\n",
 		fp->p0, fp->p1, fp->p2, fp->p3);
 	printf(" P4 : %08lx    P5 : %08lx    FP : %08lx    SP : %08lx\n",
-		fp->p4, fp->p5, fp->fp, fp);
+		fp->p4, fp->p5, fp->fp, (unsigned long)fp);
 	printf(" LB0: %08lx    LT0: %08lx    LC0: %08lx\n",
 		fp->lb0, fp->lt0, fp->lc0);
 	printf(" LB1: %08lx    LT1: %08lx    LC1: %08lx\n",
@@ -336,7 +337,7 @@ void dump_bfin_trace_buffer(void)
 {
 	char buf[150];
 	unsigned long tflags;
-	size_t i = 0;
+	int i = 0;
 
 	if (!ENABLE_DUMP)
 		return;
lib_blackfin/boot.c +1 -1
index 537be2b..951d5b0 100644
@@ -47,7 +47,7 @@ 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();
Signature · 1 line
1.6.1