Commit c837dcb1 authored by wdenk's avatar wdenk
Browse files

* The PS/2 mux on the BMS2003 board needs 450 ms after power on

  before we can access it; add delay in case we are faster (with no
  CF card inserted)

* Cleanup of some init functions

* Make sure SCC Ethernet is always stopped by the time we boot Linux
  to avoid Linux crashes by early packets coming in.

* Accelerate flash accesses on LWMON board by using buffered writes
parent b0aef11c
......@@ -2,6 +2,17 @@
Changes since U-Boot 1.0.1:
======================================================================
* The PS/2 mux on the BMS2003 board needs 450 ms after power on
before we can access it; add delay in case we are faster (with no
CF card inserted)
* Cleanup of some init functions
* Make sure SCC Ethernet is always stopped by the time we boot Linux
to avoid Linux crashes by early packets coming in.
* Accelerate flash accesses on LWMON board by using buffered writes
* Fix typo in Makefile;
fix problem with PARTNUM detection
......
......@@ -33,7 +33,7 @@
/*
** Note 1: In this file, you have to provide the following functions:
** ------
** int board_pre_init(void)
** int board_early_init_f(void)
** int checkboard(void)
** long int initdram(int board_type)
** called from 'board_init_f()' into 'common/board.c'
......@@ -145,7 +145,7 @@ const uint sdram_table[] = {
/*
* Very early board init code (fpga boot, etc.)
*/
int board_pre_init (void)
int board_early_init_f (void)
{
volatile immap_t *immr = (immap_t *) CFG_IMMR;
......
......@@ -675,7 +675,7 @@ static __inline__ void set_msr (unsigned long msr)
asm volatile ("mtmsr %0"::"r" (msr));
}
int board_pre_init (void)
int board_early_init_f (void)
{
unsigned char c_value = 0;
unsigned long msr;
......
......@@ -58,7 +58,7 @@ in_flash:
call cpu_init_f
debug leds
board_init_f: (common/board.c)
board_pre_init:
board_early_init_f:
remap gt regs?
map PCI mem/io
map device space
......
......@@ -61,7 +61,7 @@ extern void invalidate_l1_instruction_cache (void);
/* Unfortunately, we cant change it while we are in flash, so we initialize it
* to the "final" value. This means that any debug_led calls before
* board_pre_init wont work right (like in cpu_init_f).
* board_early_init_f wont work right (like in cpu_init_f).
* See also my_remap_gt_regs below. (NTL)
*/
......@@ -237,11 +237,11 @@ static void gt_cpu_config (void)
}
/*
* board_pre_init.
* board_early_init_f.
*
* set up gal. device mappings, etc.
*/
int board_pre_init (void)
int board_early_init_f (void)
{
uchar sram_boot = 0;
......
......@@ -61,7 +61,7 @@ extern void invalidate_l1_instruction_cache (void);
/* Unfortunately, we cant change it while we are in flash, so we initialize it
* to the "final" value. This means that any debug_led calls before
* board_pre_init wont work right (like in cpu_init_f).
* board_early_init_f wont work right (like in cpu_init_f).
* See also my_remap_gt_regs below. (NTL)
*/
......@@ -237,11 +237,11 @@ static void gt_cpu_config (void)
}
/*
* board_pre_init.
* board_early_init_f.
*
* set up gal. device mappings, etc.
*/
int board_pre_init (void)
int board_early_init_f (void)
{
uchar sram_boot = 0;
......
......@@ -31,7 +31,7 @@ void _default_hdlr (void)
printf ("default_hdlr\n");
}
int board_pre_init (void)
int board_early_init_f (void)
{
/* init seven segment led display and switch off */
sevenseg_set(SEVENSEG_OFF);
......
......@@ -31,7 +31,7 @@ void _default_hdlr (void)
printf ("default_hdlr\n");
}
int board_pre_init (void)
int board_early_init_f (void)
{
/* init seven segment led display and switch off */
sevenseg_set(SEVENSEG_OFF);
......
......@@ -26,7 +26,7 @@ long int spd_sdram (void);
#include <asm/processor.h>
int board_pre_init (void)
int board_early_init_f (void)
{
mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
mtdcr (uicer, 0x00000000); /* disable all ints */
......
......@@ -32,7 +32,7 @@ extern void Plx9030Init(void);
/* We have to clear the initial data area here. Couldn't have done it
* earlier because DRAM had not been initialized.
*/
int board_pre_init(void)
int board_early_init_f(void)
{
/* enable DUAL UART Mode on CPC45 */
......
......@@ -170,7 +170,7 @@ init_sio (int led, unsigned long base)
int
/**********************************************************/
board_post_init (void)
board_late_init (void)
/**********************************************************/
{
return (0);
......
......@@ -109,7 +109,7 @@ extern char bootscript[];
static void init_sdram (void);
/* ------------------------------------------------------------------------- */
int board_pre_init (void)
int board_early_init_f (void)
{
/* Running from ROM: global data is still READONLY */
init_sdram ();
......
......@@ -51,7 +51,7 @@ const unsigned char fpgadata[] =
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
out32(GPIO0_OR, CFG_NAND0_CE); /* set initial outputs */
out32(GPIO0_OR, CFG_NAND1_CE); /* set initial outputs */
......
......@@ -32,7 +32,7 @@
long int fixed_sdram (void);
int board_pre_init (void)
int board_early_init_f (void)
{
uint reg;
unsigned char *fpga_base = (unsigned char *) CFG_FPGA_BASE;
......
......@@ -104,7 +104,7 @@ static const unsigned int sdram_table[] =
/* ------------------------------------------------------------------------- */
int board_pre_init (void)
int board_early_init_f (void)
{
volatile immap_t *im = (immap_t *)CFG_IMMR;
volatile cpm8xx_t *cp = &(im->im_cpm);
......
......@@ -188,7 +188,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
* Setup CS4 to enable the Board Control/Status registers.
* Otherwise the smcs won't work.
*/
int board_pre_init (void)
int board_early_init_f (void)
{
volatile t_ep_regs *regs = (t_ep_regs*)CFG_REGS_BASE;
volatile immap_t *immap = (immap_t *)CFG_IMMR;
......
......@@ -31,7 +31,7 @@
#define IBM405GP_GPIO0_ODR 0xef600718 /* GPIO Open Drain */
#define IBM405GP_GPIO0_IR 0xef60071c /* GPIO Input */
int board_pre_init (void)
int board_early_init_f (void)
{
/*-------------------------------------------------------------------------+
......
......@@ -31,7 +31,7 @@
/* ------------------------------------------------------------------------- */
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* Set port pin in escc2 to keep living, and configure user led output
......
......@@ -46,7 +46,7 @@ const unsigned char fpgadata[] = {
#include "../common/fpga.c"
int board_pre_init (void)
int board_early_init_f (void)
{
DECLARE_GLOBAL_DATA_PTR;
......
......@@ -50,7 +50,7 @@ const unsigned char fpgadata[] =
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -48,7 +48,7 @@ const unsigned char fpgadata[] = {
#include "../common/fpga.c"
int board_pre_init (void)
int board_early_init_f (void)
{
DECLARE_GLOBAL_DATA_PTR;
......
......@@ -57,7 +57,7 @@ int cpci405_version(void);
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
#ifndef CONFIG_CPCI405_VER2
int index, len, i;
......
......@@ -28,7 +28,7 @@
long int fixed_sdram( void );
int board_pre_init (void)
int board_early_init_f (void)
{
uint reg;
......
......@@ -52,7 +52,7 @@ const unsigned char fpgadata[] = {
#include "../common/fpga.c"
int board_pre_init (void)
int board_early_init_f (void)
{
DECLARE_GLOBAL_DATA_PTR;
......
......@@ -137,7 +137,7 @@ static int fpgaBoot (void)
}
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* Init pci regs
......
......@@ -35,7 +35,7 @@ const unsigned char fpgadata[] =
int filesize = sizeof(fpgadata);
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -53,7 +53,7 @@ const unsigned char fpgadata[] = {
#include "../common/fpga.c"
int board_pre_init (void)
int board_early_init_f (void)
{
DECLARE_GLOBAL_DATA_PTR;
......
......@@ -29,7 +29,7 @@
/* ------------------------------------------------------------------------- */
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -29,7 +29,7 @@
/* ------------------------------------------------------------------------- */
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -53,7 +53,7 @@ const unsigned char fpgadata[] =
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
unsigned long cntrl0Reg;
......
......@@ -50,7 +50,7 @@ const unsigned char fpgadata[] =
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -35,7 +35,7 @@ const unsigned char fpgadata[] =
int filesize = sizeof(fpgadata);
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -50,7 +50,7 @@ const unsigned char fpgadata[] =
int gunzip(void *, int, unsigned char *, int *);
int board_pre_init (void)
int board_early_init_f (void)
{
/*
* IRQ 0-15 405GP internally generated; active high; level sensitive
......
......@@ -58,7 +58,7 @@ in_flash:
call cpu_init_f
debug leds
board_init_f: (common/board.c)
board_pre_init:
board_early_init_f:
remap gt regs?
map PCI mem/io
map device space
......
......@@ -57,7 +57,7 @@ extern void zuma_mbox_init(void);
/* Unfortunately, we cant change it while we are in flash, so we initialize it
* to the "final" value. This means that any debug_led calls before
* board_pre_init wont work right (like in cpu_init_f).
* board_early_init_f wont work right (like in cpu_init_f).
* See also my_remap_gt_regs below. (NTL)
*/
......@@ -182,11 +182,11 @@ gt_cpu_config(void)
}
/*
* board_pre_init.
* board_early_init_f.
*
* set up gal. device mappings, etc.
*/
int board_pre_init (void)
int board_early_init_f (void)
{
uchar sram_boot = 0;
......
......@@ -4,7 +4,7 @@
#include "exbitgen.h"
/* ************************************************************************ */
int board_pre_init (void)
int board_early_init_f (void)
/* ------------------------------------------------------------------------ --
* Purpose :
* Remarks :
......
......@@ -85,7 +85,7 @@ const uint sdram_table[] = {
/* ------------------------------------------------------------------------- */
int board_pre_init(void)
int board_early_init_f(void)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
......
......@@ -40,7 +40,7 @@
int
/**********************************************************/
board_post_init (void)
board_late_init (void)
/**********************************************************/
{
return (0);
......
......@@ -50,10 +50,10 @@ int board_init (void)
return 0;
}
int board_post_init(void)
int board_late_init(void)
{
setenv("stdout", "serial");
setenv("stderr", "serial");
setenv("stdout", "serial");
setenv("stderr", "serial");
return 0;
}
......@@ -71,5 +71,5 @@ int dram_init (void)
gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
return 0;
return 0;
}
......@@ -47,6 +47,9 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
*/
static ulong flash_get_size (vu_long *addr, flash_info_t *info);
static int write_data (flash_info_t *info, ulong dest, ulong data);
#ifdef CFG_FLASH_USE_BUFFER_WRITE
static int write_data_buf (flash_info_t * info, ulong dest, uchar * cp, int len);
#endif
static void flash_get_offsets (ulong base, flash_info_t *info);
/*-----------------------------------------------------------------------
......@@ -480,6 +483,17 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/*
* handle FLASH_WIDTH aligned part
*/
#ifdef CFG_FLASH_USE_BUFFER_WRITE
while(cnt >= FLASH_WIDTH) {
i = CFG_FLASH_BUFFER_SIZE > cnt ?
(cnt & ~(FLASH_WIDTH - 1)) : CFG_FLASH_BUFFER_SIZE;
if((rc = write_data_buf(info, wp, src,i)) != 0)
return rc;
wp += i;
src += i;
cnt -=i;
}
#else
while (cnt >= FLASH_WIDTH) {
data = 0;
for (i=0; i<FLASH_WIDTH; ++i) {
......@@ -491,6 +505,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
wp += FLASH_WIDTH;
cnt -= FLASH_WIDTH;
}
#endif /* CFG_FLASH_USE_BUFFER_WRITE */
if (cnt == 0) {
return (0);
......@@ -511,6 +526,28 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
return (write_data(info, wp, data));
}
/*-----------------------------------------------------------------------
* Check flash status, returns:
* 0 - OK
* 1 - timeout
*/
static int flash_status_check(vu_long *addr, ulong tout, char * prompt)
{
ulong status;
ulong start;
/* Wait for command completion */
start = get_timer (0);
while(((status = *addr) & 0x00800080) != 0x00800080) {
if (get_timer(start) > tout) {
printf("Flash %s timeout at address %p\n", prompt, addr);
*addr = 0x00FF00FF; /* restore read mode */
return (1);
}
}
return 0;
}
/*-----------------------------------------------------------------------
* Write a word to Flash, returns:
* 0 - OK
......@@ -520,8 +557,6 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
static int write_data (flash_info_t *info, ulong dest, ulong data)
{
vu_long *addr = (vu_long *)dest;
ulong status;
ulong start;
int flag;
/* Check if Flash is (sufficiently) erased */
......@@ -538,13 +573,8 @@ static int write_data (flash_info_t *info, ulong dest, ulong data)
if (flag)
enable_interrupts();
start = get_timer (0);
while (((status = *addr) & 0x00800080) != 0x00800080) {
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
*addr = 0x00FF00FF; /* restore read mode */
return (1);
}
if (flash_status_check(addr, CFG_FLASH_WRITE_TOUT, "write") != 0) {
return (1);
}
*addr = 0x00FF00FF; /* restore read mode */
......@@ -552,5 +582,46 @@ static int write_data (flash_info_t *info, ulong dest, ulong data)
return (0);
}
#ifdef CFG_FLASH_USE_BUFFER_WRITE
/*-----------------------------------------------------------------------
* Write a buffer to Flash, returns:
* 0 - OK
* 1 - write timeout
*/
static int write_data_buf(flash_info_t * info, ulong dest, uchar * cp, int len)
{
vu_long *addr = (vu_long *)dest;
int sector;
int cnt;
int retcode;
vu_long * src = (vu_long *)cp;
vu_long * dst = (vu_long *)dest;
/* find sector */
for(sector = info->sector_count - 1; sector >= 0; sector--) {
if(dest >= info->start[sector])
break;
}
*addr = 0x00500050; /* clear status */
*addr = 0x00e800e8; /* write buffer */
if((retcode = flash_status_check(addr, CFG_FLASH_BUFFER_WRITE_TOUT,
"write to buffer")) == 0) {
cnt = len / FLASH_WIDTH;
*addr = (cnt-1) | ((cnt-1) << 16);
while(cnt-- > 0) {
*dst++ = *src++;
}
*addr = 0x00d000d0; /* write buffer confirm */
retcode = flash_status_check(addr, CFG_FLASH_BUFFER_WRITE_TOUT,
"buffer write");
}
*addr = 0x00FF00FF; /* restore read mode */
*addr = 0x00500050; /* clear status */
return retcode;
}
#endif /* CFG_USE_FLASH_BUFFER_WRITE */
/*-----------------------------------------------------------------------
*/
......@@ -339,14 +339,14 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
#endif
/***********************************************************************
F* Function: int board_pre_init (void) P*A*Z*
F* Function: int board_early_init_f (void) P*A*Z*
*
P* Parameters: none
P*
P* Returnvalue: int
P* - 0 is always returned.
*
Z* Intention: This function is the board_pre_init() method implementation
Z* Intention: This function is the board_early_init_f() method implementation