2005-09-22 07:16:57 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2005
|
|
|
|
* Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2005-09-22 07:16:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/processor.h>
|
2009-02-20 09:19:18 +00:00
|
|
|
#include <asm/io.h>
|
2005-09-22 07:16:57 +00:00
|
|
|
#include <command.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2005-09-22 07:16:57 +00:00
|
|
|
int board_early_init_f (void)
|
|
|
|
{
|
2009-09-09 14:25:29 +00:00
|
|
|
unsigned long CPC0_CR0Reg;
|
2005-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
/*
|
2006-01-18 19:03:15 +00:00
|
|
|
* Setup GPIO pins
|
2005-09-22 07:16:57 +00:00
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
CPC0_CR0Reg = mfdcr(CPC0_CR0);
|
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg |
|
2009-02-20 09:19:18 +00:00
|
|
|
((CONFIG_SYS_EEPROM_WP | CONFIG_SYS_PB_LED |
|
|
|
|
CONFIG_SYS_SELF_RST | CONFIG_SYS_INTA_FAKE) << 5));
|
2005-09-22 07:16:57 +00:00
|
|
|
|
2006-03-06 12:03:37 +00:00
|
|
|
/* set output pins to high */
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32((void *)GPIO0_OR, CONFIG_SYS_EEPROM_WP);
|
2006-03-06 12:03:37 +00:00
|
|
|
/* setup for output (LED=off) */
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32((void *)GPIO0_TCR, CONFIG_SYS_EEPROM_WP | CONFIG_SYS_PB_LED);
|
2005-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) PB0; active low; level sensitive
|
|
|
|
* IRQ 26 (EXT IRQ 1) PB1; active low; level sensitive
|
|
|
|
* IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive
|
|
|
|
* IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive
|
|
|
|
* IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
|
|
|
|
* IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
|
|
|
|
* IRQ 31 (EXT IRQ 6) unused
|
|
|
|
*/
|
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, 0xFFFFFF81); /* 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-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int misc_init_r (void)
|
|
|
|
{
|
2009-09-09 14:25:29 +00:00
|
|
|
unsigned long CPC0_CR0Reg;
|
2005-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
/* adjust flash start and offset */
|
|
|
|
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
|
|
|
gd->bd->bi_flashoffset = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select cts (and not dsr) on uart1
|
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
CPC0_CR0Reg = mfdcr(CPC0_CR0);
|
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00001000);
|
2005-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check Board Identity:
|
|
|
|
*/
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
2005-10-13 14:45:02 +00:00
|
|
|
char str[64];
|
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
|
|
|
int i = getenv_f("serial#", str, sizeof(str));
|
2005-09-22 07:16:57 +00:00
|
|
|
|
|
|
|
puts ("Board: ");
|
|
|
|
|
|
|
|
if (i == -1) {
|
|
|
|
puts ("### No HW ID - assuming CPCI2DP");
|
|
|
|
} else {
|
|
|
|
puts(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" (Ver 1.0)");
|
|
|
|
|
|
|
|
putc ('\n');
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_EEPROM_WREN)
|
2005-09-22 07:16:57 +00:00
|
|
|
/* Input: <dev_addr> I2C address of EEPROM device to enable.
|
2005-12-03 23:40:34 +00:00
|
|
|
* <state> -1: deliver current state
|
|
|
|
* 0: disable write
|
2005-09-22 07:16:57 +00:00
|
|
|
* 1: enable write
|
2005-12-03 23:40:34 +00:00
|
|
|
* Returns: -1: wrong device address
|
|
|
|
* 0: dis-/en- able done
|
2005-09-22 07:16:57 +00:00
|
|
|
* 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-09-22 07:16:57 +00:00
|
|
|
return -1;
|
2005-12-03 23:40:34 +00:00
|
|
|
} else {
|
2005-09-22 07:16:57 +00:00
|
|
|
switch (state) {
|
|
|
|
case 1:
|
|
|
|
/* Enable write access, clear bit GPIO_SINT2. */
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32((void *)GPIO0_OR,
|
|
|
|
in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_EEPROM_WP);
|
2005-09-22 07:16:57 +00:00
|
|
|
state = 0;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
/* Disable write access, set bit GPIO_SINT2. */
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32((void *)GPIO0_OR,
|
|
|
|
in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
|
2005-09-22 07:16:57 +00:00
|
|
|
state = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Read current status back. */
|
2009-02-20 09:19:18 +00:00
|
|
|
state = (0 == (in_be32((void *)GPIO0_OR) &
|
|
|
|
CONFIG_SYS_EEPROM_WP));
|
2005-09-22 07:16:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_EEPROM_WREN)
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2005-09-22 07:16:57 +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-09-22 07:16:57 +00:00
|
|
|
if (state < 0) {
|
|
|
|
puts ("Query of write access state failed.\n");
|
2005-12-03 23:40:34 +00:00
|
|
|
} else {
|
2005-09-22 07:16:57 +00:00
|
|
|
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-09-22 07:16:57 +00:00
|
|
|
state = 0;
|
|
|
|
}
|
2005-12-03 23:40:34 +00:00
|
|
|
} else {
|
2005-09-22 07:16:57 +00:00
|
|
|
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-12-03 23:40:34 +00:00
|
|
|
} else {
|
2005-09-22 07:16:57 +00:00
|
|
|
/* Enable write access. */
|
2008-10-16 13:01:15 +00:00
|
|
|
state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 1);
|
2005-09-22 07:16:57 +00:00
|
|
|
}
|
|
|
|
if (state < 0) {
|
|
|
|
puts ("Setup of write access state failed.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
2006-01-18 19:03:15 +00:00
|
|
|
eepwren, 2, 0, do_eep_wren,
|
2009-01-28 00:03:12 +00:00
|
|
|
"Enable / disable / query EEPROM write access",
|
2009-05-24 15:06:54 +00:00
|
|
|
""
|
|
|
|
);
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */
|