[U-Boot] [PATCH 0/5] Blackfin fixes for 2009.06

Some random minor bug fixes found during regression testing.
Graf Yang (1): Blackfin: bf518f-ezbrd: reset ethernet PHY during init
Mike Frysinger (4): Blackfin: recurse with early serial initcode Blackfin: fix booting with older bootroms (no EVT1) Blackfin: avoid get_sclk() with early serial debug Blackfin: bf527-ezkit: fix SPI flash env params
blackfin_config.mk | 6 +++- board/bf518f-ezbrd/bf518f-ezbrd.c | 55 ++++++++++++++++++++++++++-- board/bf561-ezkit/u-boot.lds.S | 9 ++++- cpu/blackfin/cpu.c | 10 +++++- cpu/blackfin/initcode.c | 4 ++- cpu/blackfin/serial.h | 10 +++--- include/asm-blackfin/blackfin-config-pre.h | 8 ++++ include/configs/bf527-ezkit.h | 4 +- 8 files changed, 91 insertions(+), 15 deletions(-)

Make sure we recurse through serial_putc() rather than bang on the UART transmit register directly to avoid hardware overflows when using \n.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- cpu/blackfin/initcode.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cpu/blackfin/initcode.c b/cpu/blackfin/initcode.c index aba00e0..c0fe2c6 100644 --- a/cpu/blackfin/initcode.c +++ b/cpu/blackfin/initcode.c @@ -92,7 +92,7 @@ static inline void serial_putc(char c) return;
if (c == '\n') - *pUART_THR = '\r'; + serial_putc('\r');
*pUART_THR = c;

When dropping jump block support, the assumption was that all bootroms supported entry point redirection via the EVT1 register. Unfortunately, this turned out to be incorrect for the oldest Blackfin parts (BF533-0.2 and older and BF561). No one really noticed earlier because these parts usually are booted by bypassing the bootrom entirely, and older BF533 parts are not supported at all (too many anomalies).
Signed-off-by: Mike Frysinger vapier@gentoo.org --- blackfin_config.mk | 6 +++++- board/bf561-ezkit/u-boot.lds.S | 9 ++++++++- cpu/blackfin/cpu.c | 10 +++++++++- cpu/blackfin/initcode.c | 2 ++ include/asm-blackfin/blackfin-config-pre.h | 8 ++++++++ 5 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/blackfin_config.mk b/blackfin_config.mk index 04a7529..05077c8 100644 --- a/blackfin_config.mk +++ b/blackfin_config.mk @@ -36,7 +36,9 @@ endif
SYM_PREFIX = _
-LDR_FLAGS += -J +LDR_FLAGS-y := +LDR_FLAGS-$(CONFIG_BFIN_BOOTROM_USES_EVT1) += -J + LDR_FLAGS += --bmode $(subst BFIN_BOOT_,,$(CONFIG_BFIN_BOOT_MODE)) LDR_FLAGS += --use-vmas ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS) @@ -45,3 +47,5 @@ endif ifneq (,$(findstring s,$(MAKEFLAGS))) LDR_FLAGS += --quiet endif + +LDR_FLAGS += $(LDR_FLAGS-y) diff --git a/board/bf561-ezkit/u-boot.lds.S b/board/bf561-ezkit/u-boot.lds.S index 4220e81..e6d3ddc 100644 --- a/board/bf561-ezkit/u-boot.lds.S +++ b/board/bf561-ezkit/u-boot.lds.S @@ -42,12 +42,19 @@ # define L1_DATA_B_SRAM_SIZE 0 #endif
+/* The 0xC offset is so we don't clobber the tiny LDR jump block. */ +#ifdef CONFIG_BFIN_BOOTROM_USES_EVT1 +# define L1_CODE_ORIGIN L1_INST_SRAM +#else +# define L1_CODE_ORIGIN L1_INST_SRAM + 0xC +#endif + OUTPUT_ARCH(bfin)
MEMORY { ram : ORIGIN = CONFIG_SYS_MONITOR_BASE, LENGTH = CONFIG_SYS_MONITOR_LEN - l1_code : ORIGIN = L1_INST_SRAM, LENGTH = L1_INST_SRAM_SIZE + l1_code : ORIGIN = L1_CODE_ORIGIN, LENGTH = L1_INST_SRAM_SIZE l1_data : ORIGIN = L1_DATA_B_SRAM, LENGTH = L1_DATA_B_SRAM_SIZE }
diff --git a/cpu/blackfin/cpu.c b/cpu/blackfin/cpu.c index c2ff8cd..9bb6407 100644 --- a/cpu/blackfin/cpu.c +++ b/cpu/blackfin/cpu.c @@ -25,12 +25,20 @@ ulong bfin_poweron_retx; __attribute__ ((__noreturn__)) void cpu_init_f(ulong bootflag, ulong loaded_from_ldr) { + extern char _stext_l1; +#ifndef CONFIG_BFIN_BOOTROM_USES_EVT1 + /* Build a NOP slide over the LDR jump block. Whee! */ + char nops[0xC]; + serial_early_puts("NOP Slide\n"); + memset(nops, 0x00, sizeof(nops)); + memcpy(&_stext_l1 - sizeof(nops), nops, sizeof(nops)); +#endif + if (!loaded_from_ldr) { /* Relocate sections into L1 if the LDR didn't do it -- don't * check length because the linker script does the size * checking at build time. */ - extern char _stext_l1; serial_early_puts("L1 Relocate\n"); extern char _stext_l1, _etext_l1, _stext_l1_lma; memcpy(&_stext_l1, &_stext_l1_lma, (&_etext_l1 - &_stext_l1)); diff --git a/cpu/blackfin/initcode.c b/cpu/blackfin/initcode.c index c0fe2c6..a039cbb 100644 --- a/cpu/blackfin/initcode.c +++ b/cpu/blackfin/initcode.c @@ -543,9 +543,11 @@ void initcode(ADI_BOOT_DATA *bootstruct)
serial_putc('T');
+#ifdef CONFIG_BFIN_BOOTROM_USES_EVT1 /* tell the bootrom where our entry point is */ if (CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS) bfin_write_EVT1(CONFIG_SYS_MONITOR_BASE); +#endif
serial_putc('>'); serial_putc('\n'); diff --git a/include/asm-blackfin/blackfin-config-pre.h b/include/asm-blackfin/blackfin-config-pre.h index e973de7..a3db362 100644 --- a/include/asm-blackfin/blackfin-config-pre.h +++ b/include/asm-blackfin/blackfin-config-pre.h @@ -54,6 +54,14 @@ static inline const char *get_bfin_boot_mode(int bfin_boot) } #endif
+/* Most bootroms allow for EVT1 redirection */ +#if (defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) \ + && __SILICON_REVISION__ < 3) || defined(__ADSPBF561__) +# undef CONFIG_BFIN_BOOTROM_USES_EVT1 +#else +# define CONFIG_BFIN_BOOTROM_USES_EVT1 +#endif + /* Define the default SPI CS used when booting out of SPI */ #if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \ defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__) || \

When the clock functions were changed to use cached values (and thereby avoiding expensive math functions), early serial debug broke because the baud programming is called before external memory is available.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- cpu/blackfin/serial.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cpu/blackfin/serial.h b/cpu/blackfin/serial.h index 7b47878..6cbc564 100644 --- a/cpu/blackfin/serial.h +++ b/cpu/blackfin/serial.h @@ -81,11 +81,6 @@
#ifndef __ASSEMBLY__
-/* We cannot use get_sclk() in initcode as it is defined elsewhere. */ -#ifdef BFIN_IN_INITCODE -# define get_sclk() (CONFIG_CLKIN_HZ * CONFIG_VCO_MULT / CONFIG_SCLK_DIV) -#endif - #ifdef __ADSPBF54x__ # define ACCESS_LATCH() # define ACCESS_PORT_IER() @@ -190,6 +185,11 @@ static inline uint16_t serial_early_get_div(void) return divisor; }
+/* We cannot use get_sclk() early on as it uses caches in external memory */ +#if defined(BFIN_IN_INITCODE) || defined(CONFIG_DEBUG_EARLY_SERIAL) +# define get_sclk() (CONFIG_CLKIN_HZ * CONFIG_VCO_MULT / CONFIG_SCLK_DIV) +#endif + __attribute__((always_inline)) static inline void serial_early_set_baud(uint32_t baud) {

The BF527-EZKIT settings for storing the environment in SPI flash wasn't using the correct sector settings for the SPI flash part that is actually on the board.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- include/configs/bf527-ezkit.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/configs/bf527-ezkit.h b/include/configs/bf527-ezkit.h index 42cb0a8..0fe5fa5 100644 --- a/include/configs/bf527-ezkit.h +++ b/include/configs/bf527-ezkit.h @@ -115,9 +115,9 @@ */ #if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER) #define CONFIG_ENV_IS_IN_SPI_FLASH -#define CONFIG_ENV_OFFSET 0x4000 +#define CONFIG_ENV_OFFSET 0x10000 #define CONFIG_ENV_SIZE 0x2000 -#define CONFIG_ENV_SECT_SIZE 0x2000 +#define CONFIG_ENV_SECT_SIZE 0x10000 #else #define CONFIG_ENV_IS_IN_FLASH #define CONFIG_ENV_OFFSET 0x4000

From: Graf Yang graf.yang@analog.com
We don't know what state the ethernet PHY is in when starting up, so make sure we set it to a sane state. This fixes troubles seen when Linux boots up, configures the PHY is a non-default state, and then the system reboots into U-Boot which previously expected a reset state only.
Signed-off-by: Graf Yang graf.yang@analog.com Signed-off-by: Mike Frysinger vapier@gentoo.org --- board/bf518f-ezbrd/bf518f-ezbrd.c | 55 ++++++++++++++++++++++++++++++++++--- 1 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/board/bf518f-ezbrd/bf518f-ezbrd.c b/board/bf518f-ezbrd/bf518f-ezbrd.c index 2c7961a..1761b8e 100644 --- a/board/bf518f-ezbrd/bf518f-ezbrd.c +++ b/board/bf518f-ezbrd/bf518f-ezbrd.c @@ -62,18 +62,65 @@ static void board_init_enetaddr(uchar *mac_addr) eth_setenv_enetaddr("ethaddr", mac_addr); }
+#define KSZ_MAX_HZ 5000000 + +#define KSZ_WRITE 0x02 +#define KSZ_READ 0x03 + +#define KSZ_REG_STPID 0x01 /* Register 1: Chip ID1 / Start Switch */ +#define KSZ_REG_GC9 0x0b /* Register 11: Global Control 9 */ +#define KSZ_REG_P3C0 0x30 /* Register 48: Port 3 Control 0 */ + +static int ksz8893m_transfer(struct spi_slave *slave, uchar dir, uchar reg, + uchar data, uchar result[3]) +{ + unsigned char dout[3] = { dir, reg, data, }; + return spi_xfer(slave, sizeof(dout) * 8, dout, result, SPI_XFER_BEGIN | SPI_XFER_END); +} + +static int ksz8893m_reg_set(struct spi_slave *slave, uchar reg, uchar data) +{ + unsigned char din[3]; + return ksz8893m_transfer(slave, KSZ_WRITE, reg, data, din); +} + +static int ksz8893m_reg_clear(struct spi_slave *slave, uchar reg, uchar mask) +{ + int ret = 0; + unsigned char din[3]; + + ret |= ksz8893m_transfer(slave, KSZ_READ, reg, 0, din); + ret |= ksz8893m_reg_set(slave, reg, din[2] & mask); + + return ret; +} + +static int ksz8893m_reset(struct spi_slave *slave) +{ + int ret = 0; + + /* Disable STPID mode */ + ret |= ksz8893m_reg_clear(slave, KSZ_REG_GC9, 0x01); + + /* Disable VLAN tag insert on Port3 */ + ret |= ksz8893m_reg_clear(slave, KSZ_REG_P3C0, 0x04); + + /* Start switch */ + ret |= ksz8893m_reg_set(slave, KSZ_REG_STPID, 0x01); + + return ret; +} + int board_eth_init(bd_t *bis) { static bool switch_is_alive = false; int ret;
if (!switch_is_alive) { - struct spi_slave *slave = spi_setup_slave(0, 1, 5000000, SPI_MODE_3); + struct spi_slave *slave = spi_setup_slave(0, 1, KSZ_MAX_HZ, SPI_MODE_3); if (slave) { if (!spi_claim_bus(slave)) { - unsigned char dout[3] = { 2, 1, 1, }; - unsigned char din[3]; - ret = spi_xfer(slave, sizeof(dout) * 8, dout, din, SPI_XFER_BEGIN | SPI_XFER_END); + ret = ksz8893m_reset(slave); if (!ret) switch_is_alive = true; spi_release_bus(slave);
participants (1)
-
Mike Frysinger