2005-11-15 09:35:59 +00:00
|
|
|
/*
|
2007-07-09 08:10:06 +00:00
|
|
|
* (C) Copyright 2005-2007
|
2005-11-15 09:35:59 +00:00
|
|
|
* Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/processor.h>
|
2007-07-09 08:10:06 +00:00
|
|
|
#include <asm/io.h>
|
2005-11-15 09:35:59 +00:00
|
|
|
#include <command.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
extern void lxt971_no_sleep(void);
|
|
|
|
|
|
|
|
int board_early_init_f (void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* IRQ 0-15 405GP internally generated; active high; level sensitive
|
|
|
|
* IRQ 16 405GP internally generated; active low; level sensitive
|
|
|
|
* IRQ 17-24 RESERVED
|
|
|
|
* IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
|
|
|
|
* IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
|
|
|
|
* IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
|
|
|
|
* IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
|
|
|
|
* IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
|
|
|
|
* IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
|
|
|
|
* IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
|
|
|
|
*/
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
|
|
|
|
mtdcr(UIC0ER, 0x00000000); /* disable all ints */
|
|
|
|
mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
|
|
|
|
mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */
|
|
|
|
mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
|
|
|
|
mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/
|
|
|
|
mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
|
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset CPLD via GPIO12 (CS3) pin
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_PLD_RESET);
|
2005-11-15 09:35:59 +00:00
|
|
|
udelay(1000); /* wait 1ms */
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_PLD_RESET);
|
2005-11-15 09:35:59 +00:00
|
|
|
udelay(1000); /* wait 1ms */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int misc_init_r (void)
|
|
|
|
{
|
|
|
|
/* adjust flash start and offset */
|
|
|
|
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
|
|
|
gd->bd->bi_flashoffset = 0;
|
|
|
|
|
2008-05-20 14:00:29 +00:00
|
|
|
/*
|
2005-11-15 09:35:59 +00:00
|
|
|
* Setup and enable EEPROM write protection
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check Board Identity:
|
|
|
|
*/
|
2009-02-20 09:19:18 +00:00
|
|
|
#define LED_REG (CONFIG_SYS_PLD_BASE + 0x1000)
|
2005-11-15 09:35:59 +00:00
|
|
|
int checkboard (void)
|
|
|
|
{
|
2006-01-18 19:06:44 +00:00
|
|
|
char str[64];
|
2005-11-15 09:35:59 +00:00
|
|
|
int flashcnt;
|
|
|
|
int delay;
|
|
|
|
|
|
|
|
puts ("Board: ");
|
|
|
|
|
Rename getenv_r() into getenv_f()
While running from flash, i. e. before relocation, we have only a
limited C runtime environment without writable data segment. In this
phase, some configurations (for example with environment in EEPROM)
must not use the normal getenv(), but a special function. This
function had been called getenv_r(), with the idea that the "_r"
suffix would mean the same as in the _r_eentrant versions of some of
the C library functions (for example getdate vs. getdate_r, getgrent
vs. getgrent_r, etc.).
Unfortunately this was a misleading name, as in U-Boot the "_r"
generally means "running from RAM", i. e. _after_ relocation.
To avoid confusion, rename into getenv_f() [as "running from flash"]
Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2010-07-24 19:55:43 +00:00
|
|
|
if (getenv_f("serial#", str, sizeof(str)) == -1) {
|
2005-11-15 09:35:59 +00:00
|
|
|
puts ("### No HW ID - assuming CMS700");
|
|
|
|
} else {
|
|
|
|
puts(str);
|
|
|
|
}
|
|
|
|
|
2009-02-20 09:19:18 +00:00
|
|
|
printf(" (PLD-Version=%02d)\n",
|
|
|
|
in_8((void *)(CONFIG_SYS_PLD_BASE + 0x1001)));
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Flash LEDs
|
|
|
|
*/
|
|
|
|
for (flashcnt = 0; flashcnt < 3; flashcnt++) {
|
2009-02-20 09:19:18 +00:00
|
|
|
out_8((void *)LED_REG, 0x00); /* LEDs off */
|
2005-11-15 09:35:59 +00:00
|
|
|
for (delay = 0; delay < 100; delay++)
|
|
|
|
udelay(1000);
|
2009-02-20 09:19:18 +00:00
|
|
|
out_8((void *)LED_REG, 0x0f); /* LEDs on */
|
2005-11-15 09:35:59 +00:00
|
|
|
for (delay = 0; delay < 50; delay++)
|
|
|
|
udelay(1000);
|
|
|
|
}
|
2009-02-20 09:19:18 +00:00
|
|
|
out_8((void *)LED_REG, 0x70);
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_EEPROM_WREN)
|
2005-11-15 09:35:59 +00:00
|
|
|
/* Input: <dev_addr> I2C address of EEPROM device to enable.
|
|
|
|
* <state> -1: deliver current state
|
|
|
|
* 0: disable write
|
|
|
|
* 1: enable write
|
|
|
|
* Returns: -1: wrong device address
|
|
|
|
* 0: dis-/en- able done
|
|
|
|
* 0/1: current state if <state> was -1.
|
|
|
|
*/
|
|
|
|
int eeprom_write_enable (unsigned dev_addr, int state)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
if (CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) {
|
2005-11-15 09:35:59 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
switch (state) {
|
|
|
|
case 1:
|
|
|
|
/* Enable write access, clear bit GPIO_SINT2. */
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_EEPROM_WP);
|
2005-11-15 09:35:59 +00:00
|
|
|
state = 0;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
/* Disable write access, set bit GPIO_SINT2. */
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
|
2005-11-15 09:35:59 +00:00
|
|
|
state = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Read current status back. */
|
2008-10-16 13:01:15 +00:00
|
|
|
state = (0 == (in_be32((void *)GPIO0_OR) & CONFIG_SYS_EEPROM_WP));
|
2005-11-15 09:35:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2005-11-15 09:35:59 +00:00
|
|
|
{
|
|
|
|
int query = argc == 1;
|
|
|
|
int state = 0;
|
|
|
|
|
|
|
|
if (query) {
|
|
|
|
/* Query write access state. */
|
2008-10-16 13:01:15 +00:00
|
|
|
state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, -1);
|
2005-11-15 09:35:59 +00:00
|
|
|
if (state < 0) {
|
|
|
|
puts ("Query of write access state failed.\n");
|
|
|
|
} else {
|
|
|
|
printf ("Write access for device 0x%0x is %sabled.\n",
|
2008-10-16 13:01:15 +00:00
|
|
|
CONFIG_SYS_I2C_EEPROM_ADDR, state ? "en" : "dis");
|
2005-11-15 09:35:59 +00:00
|
|
|
state = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ('0' == argv[1][0]) {
|
|
|
|
/* Disable write access. */
|
2008-10-16 13:01:15 +00:00
|
|
|
state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 0);
|
2005-11-15 09:35:59 +00:00
|
|
|
} else {
|
|
|
|
/* Enable write access. */
|
2008-10-16 13:01:15 +00:00
|
|
|
state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 1);
|
2005-11-15 09:35:59 +00:00
|
|
|
}
|
|
|
|
if (state < 0) {
|
|
|
|
puts ("Setup of write access state failed.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
|
2009-05-24 15:06:54 +00:00
|
|
|
"Enable / disable / query EEPROM write access",
|
|
|
|
""
|
|
|
|
);
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */
|
2005-11-15 09:35:59 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void reset_phy(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_LXT971_NO_SLEEP
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable sleep mode in LXT971
|
|
|
|
*/
|
|
|
|
lxt971_no_sleep();
|
|
|
|
#endif
|
|
|
|
}
|