* "last user address" is set even if bootp is used without parameters
(and it uses default address).
+======================================================================
+Modifications for 0.7.3:
+======================================================================
+
+* PCMCIA support added / extended; we can now boot from PCMCIA memory
+ devices like harddisk adapters or CompactFlash cards (tested with
+ "ARGOSY PnPIDE D5" IDE harddisk adapter and "STI Flash 5.0" CF
+ card. Other card types are recognised, too (for instance, the
+ "Xircom CreditCard 10/100 CE3-10/100" and "ELSA AirLancer MC-11"
+ are recognized as "network adapter cards".
+
+----------------------------------------------------------------------
+NETWORK patch by Paolo Scaffardi (Fri, 12 Jan 2001 13:00:03 +0100)
+----------------------------------------------------------------------
+* Environment variable "autoload" can now be set in default
+ environment using configuration #define CFG_AUTOLOAD.
+----------------------------------------------------------------------
+
+----------------------------------------------------------------------
+DPRAM patch by Paolo Scaffardi (Fri, 12 Jan 2001 13:00:03 +0100)
+----------------------------------------------------------------------
+* Completed and fully supported DPRAM allocation functions for MPC8xx
+ architecture (set CFG_ALLOC_DPRAM or fixed values are still used)
+----------------------------------------------------------------------
+
+----------------------------------------------------------------------
+COMMANDS patch by Paolo Scaffardi (Fri, 12 Jan 2001 13:00:03 +0100)
+----------------------------------------------------------------------
+* Add 'run' command to run a script defined into a environment
+ variable (compiled if CFG_CMD_RUN included with CONFIG_COMMANDS)
+ [completely re-written -wd]
+* Add 'askenv' command to ask an environment variable to the user
+ (compiled if CFG_CMD_ASKENV included with CONFIG_COMMANDS)
+----------------------------------------------------------------------
+
+----------------------------------------------------------------------
+GENIETV patch by Paolo Scaffardi (Fri, 12 Jan 2001 13:00:03 +0100)
+----------------------------------------------------------------------
+* Initialize built-in environment with correct CRC value (computed by
+ 'tools/envcrc.c')
+* Added support for AMDLV040B 512Kb flash in flash.h
+* Changed TEXTBASE in GENIETV configuration
+* Added VIDEO_ADDR definition to config_GENIETV.h
+----------------------------------------------------------------------
+
+* Make "reset" command work on RSD Proto board (Marius Gröger)
+
+* Make invalid address used for do_reset() configurable
+
+* Modified 405 configuration (Stefan Roese)
+
======================================================================
Modifications for 0.7.2:
======================================================================
# load other configuration
include $(TOPDIR)/config.mk
-SUBDIRS = $(ARCH) cpu/$(CPU) board/$(BOARD) common net disk examples tools
+SUBDIRS = tools $(ARCH) cpu/$(CPU) board/$(BOARD) common net disk examples
#########################################################################
# ppcboot objects....order is important (i.e. start must be first)
\( -name 'core' -o -name '*.bak' \
-o -name '*.o' -o -name '*.a' \) -print`
rm -f examples/hello_world examples/timer
- rm -f tools/img2srec tools/mkimage tools/easylogo/easylogo
+ rm -f tools/img2srec tools/mkimage tools/envcrc
+ rm -f tools/easylogo/easylogo
rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
clobber: clean
- Console Baudrate:
CONFIG_BAUDRATE - in bps
- Select one of 9600, 19200, 38400, 57600, 115200
- (or 230400 if CONFIG_COGENT is defined)
+ Select one of the baudrates listed in
+ CFG_BAUDRATE_TABLE, see below.
- Boot Delay: CONFIG_BOOTDELAY - in seconds
Delay before automatically booting the default image;
- Kgdb Serial Baudrate: (if CFG_CMD_KGDB is defined)
CONFIG_KGDB_BAUDRATE
- Select one of 9600, 19200, 38400, 57600, 115200
- (or 230400 if CONFIG_COGENT is defined)
+ Select one of the baudrates listed in
+ CFG_BAUDRATE_TABLE, see below.
- Monitor Functions:
CONFIG_COMMANDS
= everything except KGDB
If you don't define CONFIG_COMMANDS it defaults to
-CFG_CMD_DFL .
+ CFG_CMD_DFL .
EXAMPLE: If you want all functions except of network
support you can write:
the application (usually a Linux kernel) when it is
bootet
+- CFG_BAUDRATE_TABLE:
+ List of legal baudrate settings for this board.
+
- CFG_MEMTEST_START, CFG_MEMTEST_END:
Begin and End addresses of the area used by the
simple memory test.
working with the compiled-in default environment - *silently*!!!
[This is necessary, because the first environment variable we need is
the "baudrate" setting for the console - if we have a bad CRC, we
-don't have any device yet whewre we could complain.]
+don't have any device yet where we could complain.]
Note: once the monitor has been relocated, then it will complain if
the default environment is used; a new CRC is computed as sson as you
once they have been set once.
-Please note that changes to some configuration parameters (like
-console baudrate) may take only effect after the next boot (yes,
-that's just like Windoze :-).
+Please note that changes to some configuration parameters may take
+only effect after the next boot (yes, that's just like Windoze :-).
}
-#ifdef CONFIG_PCMCIA
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
#ifdef CFG_PCMCIA_MEM_ADDR
volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR;
return 0;
}
-#endif /* CONFIG_PCMCIA */
+#endif /* CFG_CMD_PCMCIA */
return (0);
}
-#ifdef CONFIG_PCMCIA
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
#ifdef CFG_PCMCIA_MEM_ADDR
volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR;
return 0;
}
-#endif
\ No newline at end of file
+#endif /* CFG_CMD_PCMCIA */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .rel.text : { *(.rel.text) }
+ .rela.text : { *(.rela.text) }
+ .rel.data : { *(.rel.data) }
+ .rela.data : { *(.rela.data) }
+ .rel.rodata : { *(.rel.rodata) }
+ .rela.rodata : { *(.rela.rodata) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) }
+ .plt : { *(.plt) }
+ .text :
+ {
+ /* WARNING - the following is hand-optimized to fit within */
+ /* the sector layout of our flash chips! XXX FIXME XXX */
+
+ cpu/mpc8xx/start.o (.text)
+ common/dlmalloc.o (.text)
+ ppc/ppcstring.o (.text)
+ ppc/vsprintf.o (.text)
+ ppc/crc32.o (.text)
+ ppc/zlib.o (.text)
+
+ . = env_offset;
+ common/environment.o(.text)
+ *(.text)
+ *(.fixup)
+ *(.got1)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata1)
+ }
+ .fini : { *(.fini) } =0
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+
+ /* Read-write section, merged into data segment: */
+ . = (. + 0x0FFF) & 0xFFFFF000;
+ _erotext = .;
+ PROVIDE (erotext = .);
+ .reloc :
+ {
+ *(.got)
+ _GOT2_TABLE_ = .;
+ *(.got2)
+ _FIXUP_TABLE_ = .;
+ *(.fixup)
+ }
+ __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+ __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+ .data :
+ {
+ *(.data)
+ *(.data1)
+ *(.sdata)
+ *(.sdata2)
+ *(.dynamic)
+ CONSTRUCTORS
+ }
+ _edata = .;
+ PROVIDE (edata = .);
+
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ . = ALIGN(4096);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(4096);
+ __init_end = .;
+
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss) *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ . = ALIGN(256 * 1024);
+ .ppcenv :
+ {
+ common/environment.o (.ppcenv)
+ }
+ _end = . ;
+ PROVIDE (end = .);
+}
+
immr->im_ioport.iop_padir |= 0x4000;
/* get temporary BD; no need for permanent alloc */
- bd_off = m8xx_cpm_dpbase_align(8);
+ bd_off = dpram_base_align(8);
bd = (cbd_t *)(immr->im_cpm.cp_dpmem + bd_off);
/*-----------------------------------------------------------------------
* Functions
*/
+#if 0
static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
static void flash_get_offsets (ulong base, flash_info_t *info);
static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info);
+#endif
+static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
/*-----------------------------------------------------------------------
*/
*
* The monitor always occupies the _first_ part of the _first_ Flash bank.
*/
+#if 0
static int
flash_protect(int flag, ulong from, ulong to, flash_info_t *info)
{
}
return (rc);
}
+#endif /* 0 */
/*-----------------------------------------------------------------------
*/
+#if 0
static void
flash_get_offsets(ulong base, flash_info_t *info)
{
}
}
+#endif /* 0 */
/*-----------------------------------------------------------------------
*/
/*
* The following code cannot be run from FLASH!
*/
-
+#if 0
static ulong
flash_get_size(vu_long *addr, flash_info_t *info)
{
return (info->size);
}
+#endif /* 0 */
/*-----------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
-#ifdef CONFIG_PCMCIA
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
#ifdef CFG_PCMCIA_MEM_ADDR
volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR;
return 0;
}
-#endif /* CONFIG_PCMCIA */
+#endif /* CFG_CMD_PCMCIA */
/* ------------------------------------------------------------------------- */
cmd_boot.o cmd_bootm.o cmd_cache.o \
cmd_console.o cmd_eeprom.o cmd_flash.o \
cmd_ide.o cmd_mem.o cmd_net.o \
- cmd_nvedit.o s_record.o dlmalloc.o \
+ cmd_nvedit.o cmd_pcmcia.o \
+ s_record.o dlmalloc.o \
kgdb.o console.o lists.o devices.o
OBJS = $(AOBJS) $(COBJS)
$(LIB): .depend $(COBJS)
$(AR) crv $@ $(COBJS)
+environment.o: environment.S ../tools/envcrc
+ $(CC) $(AFLAGS) -DENV_CRC=$(shell ../tools/envcrc) -c -o $@ environment.S
+
#########################################################################
.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#include <net.h>
#endif
+#ifdef CFG_ALLOC_DPRAM
+#include <commproc.h>
+#endif
#include <version.h>
static char *failed = "*** failed ***\n";
n = hz / 1000000L;
- l = sprintf(buf, "%ld", n);
+ l = sprintf (buf, "%ld", n);
#if defined(CFG_CLKS_IN_HZ)
m = (hz % 1000000L) / 1000L;
if (m != 0)
- sprintf(buf+l, ".%03ld", m);
+ sprintf (buf+l, ".%03ld", m);
#endif
return (buf);
i = getenv_r ("baudrate", tmp, sizeof(tmp));
baudrate = (i > 0) ? (int)simple_strtoul(tmp, NULL, 10) : CONFIG_BAUDRATE;
+#ifdef CFG_ALLOC_DPRAM
+ /*
+ * set up dual port ram alloc area
+ * if used, it is needed by serial, scc and i2c.
+ */
+ dpram_init ();
+#endif
+
/* set up serial port */
serial_init (idata->cpu_clk, baudrate);
prt_8260_clks();
#endif /* CONFIG_8260 */
- printf ("Initializing...\n CPU: "); /* Check CPU */
+ puts ("Initializing...\n CPU: "); /* Check CPU */
if (checkcpu(idata->cpu_clk) < 0) {
- printf (failed);
+ puts (failed);
hang();
}
- printf (" Board: "); /* Check Board */
+ puts (" Board: "); /* Check Board */
if ((board_type = checkboard()) < 0) {
- printf (failed);
+ puts (failed);
hang();
}
#if defined(CONFIG_COGENT) || defined(CONFIG_SXNI855T) || defined(CONFIG_RSD_PROTO)
/* miscellaneous platform dependent initialisations */
if (misc_init_f() < 0) {
- printf (failed);
+ puts (failed);
hang();
}
#endif
- printf (" DRAM: ");
+ puts (" DRAM: ");
if ((dram_size = initdram (board_type)) > 0) {
printf ("%2ld MB\n", dram_size >> 20);
} else {
- printf (failed);
+ puts (failed);
hang();
}
extern void malloc_bin_reloc (ulong);
#ifdef DEBUG
- printf(" Now running in RAM - dest_addr = 0x%08lx\n", dest_addr);
+ printf (" Now running in RAM - dest_addr = 0x%08lx\n", dest_addr);
#endif
/* Save a global pointer to the board info struct */
*/
trap_init(dest_addr);
- printf (" FLASH: ");
+ puts (" FLASH: ");
if ((flash_size = flash_init ()) > 0) {
if (flash_size >= (1 << 20)) {
printf ("%2ld kB\n", flash_size >> 10);
}
} else {
- printf (failed);
+ puts (failed);
hang();
}
bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
defined(CONFIG_IVMS8) || \
defined(CONFIG_IP860)
# ifdef DEBUG
- printf(" Reset Ethernet PHY\n");
+ puts (" Reset Ethernet PHY\n");
# endif
reset_phy ();
#endif
-#ifdef CONFIG_PCMCIA
- printf(" PCMCIA: ");
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)
+ puts (" PCMCIA:");
pcmcia_init();
#endif
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
- printf (" IDE: ");
+# ifdef CONFIG_IDE_PCCARD
+ puts (" PCMCIA:");
+# else
+ puts (" IDE: ");
+# endif
ide_init(bd);
-#endif
+#endif /* CFG_CMD_IDE */
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
- printf (" KGDB: ");
+ puts (" KGDB: ");
kgdb_init();
#endif
#ifdef DEBUG
- printf(" Monitor relocated to 0x%08lx\n", dest_addr);
+ printf (" Monitor relocated to 0x%08lx\n", dest_addr);
#endif
/*
void hang(void)
{
- printf ("### ERROR ### Please RESET the board ###\n");
+ puts ("### ERROR ### Please RESET the board ###\n");
for (;;);
}
#include <zlib.h>
int gunzip (void *, int, unsigned char *, int *);
-void run_default_command (int len, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
+void run_command (const char *cmd, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
static void *zalloc(void *, unsigned, unsigned);
static void zfree(void *, void *, unsigned);
#if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
void do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
- run_default_command (-1, cmdtp, bd, flag);
+ run_command ("bootcmd", cmdtp, bd, flag);
}
#endif
#include <ata.h>
#include <cmd_ide.h>
#include <cmd_disk.h>
+#include <cmd_pcmcia.h>
#include <mpc8xx.h>
/* stdlib.h causes some compatibility problems; should fixe these! -- wd */
/* Current offset for IDE0 / IDE1 bus access */
static ulong bus_offset[CFG_IDE_MAXBUS] = {
CFG_ATA_IDE0_OFFSET,
-#ifdef CFG_ATA_IDE1_OFFSET
+#if CFG_IDE_MAXBUS > 1
CFG_ATA_IDE1_OFFSET,
#endif
};
unsigned char c;
int i, bus;
+#ifdef CONFIG_IDE_PCCARD
+ extern int pcmcia_on (void);
+
+ /* initialize the PCMCIA IDE adapter card */
+ if (pcmcia_on())
+ return;
+ udelay (1000000); /* 1 s */
+ puts (" ");
+#endif
+
/* Initialize PIO timing tables */
for (i=0; i <= IDE_MAX_PIO_MODE; ++i) {
pio_config_clk[i].t_setup = PCMCIA_MK_CLKS(pio_config_ns[i].t_setup,
udelay (10000); /* 10 ms */
c = inb (dev, ATA_STATUS);
+ i++;
if (i > (ATA_RESET_TIME * 100)) {
puts ("** Timeout **\n");
ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
if ((i >= 100) && ((i%100)==0)) {
putc ('.');
}
- i++;
} while (c & ATA_STAT_BUSY);
if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) {
immr->im_ioport.iop_pcso &= ~(CFG_PC_IDE_RESET);
immr->im_ioport.iop_pcdir |= CFG_PC_IDE_RESET; /* Make output */
-#if 1
/* assert IDE RESET signal */
immr->im_ioport.iop_pcdat &= ~(CFG_PC_IDE_RESET);
udelay (20000);
/* de-assert RESET signal of IDE */
immr->im_ioport.iop_pcdat |= CFG_PC_IDE_RESET;
-#else
- /* assert IDE RESET signal */
- immr->im_ioport.iop_pcdat |= CFG_PC_IDE_RESET;
- udelay (20000);
- /* de-assert RESET signal of IDE */
- immr->im_ioport.iop_pcdat &= ~(CFG_PC_IDE_RESET);
-#endif
#else
#error IDE reset pin not configured
-#endif
+#endif /* CFG_PC_IDE_RESET */
#ifdef CFG_PB_IDE_MOTOR
immr->im_cpm.cp_pbpar &= ~(CFG_PB_IDE_MOTOR); /* IDE Motor in pin */
void setenv (char *varname, char *varvalue)
{
- char *argv[4] = { "setenv", varname, varvalue, NULL };
- _do_setenv (bd_ptr, 0, 3, argv);
+ char *argv[4] = { "setenv", varname, varvalue, NULL };
+ _do_setenv (bd_ptr, 0, 3, argv);
}
-void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+void do_setenv (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc,
+ char *argv[])
{
- if (argc < 2) {
- printf ("Usage:\n%s\n", cmdtp->usage);
- return;
- }
+ if (argc < 2) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+ }
+
+ _do_setenv (bd, flag, argc, argv);
+}
+
+/************************************************************************
+ * Prompt for environment variable
+ */
+
+#if (CONFIG_COMMANDS & CFG_CMD_ASKENV)
+void do_askenv (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc,
+ char *argv[])
+{
+ extern char console_buffer[CFG_CBSIZE];
+ char message[CFG_CBSIZE];
+ int size = CFG_CBSIZE - 1;
+ int len;
+ char *local_args[4];
+
+ local_args[0] = argv[0];
+ local_args[1] = argv[1];
+ local_args[2] = NULL;
+ local_args[3] = NULL;
+
+ if (argc < 2) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+ }
+ /* Check the syntax */
+ switch (argc) {
+ case 1:
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+
+ case 2: /* askenv envname */
+ sprintf (message, "Please enter '%s':", argv[1]);
+ break;
+
+ case 3: /* askenv envname size */
+ sprintf (message, "Please enter '%s':", argv[1]);
+ size = simple_strtoul (argv[2], NULL, 10);
+ break;
+
+ default: /* askenv envname message1 ... messagen size */
+ {
+ int i;
+ int pos = 0;
+
+ for (i = 2; i < argc - 1; i++) {
+ if (pos) {
+ message[pos++] = ' ';
+ }
+ strcpy (message+pos, argv[i]);
+ pos += strlen(argv[i]);
+ }
+ message[pos] = '\0';
+ size = simple_strtoul (argv[argc - 1], NULL, 10);
+ }
+ }
+
+ if (size >= CFG_CBSIZE)
+ size = CFG_CBSIZE - 1;
+
+ if (size <= 0)
+ return;
+
+ /* prompt for input */
+ len = readline (message);
+
+ if (size < len)
+ console_buffer[size] = '\0';
+
+ len = 2;
+ if (console_buffer[0] != '\0') {
+ local_args[2] = console_buffer;
+ len = 3;
+ }
- _do_setenv (bd, flag, argc, argv);
+ // Continue calling setenv code
+ _do_setenv (bd, flag, len, local_args);
}
+#endif /* CFG_CMD_ASKENV */
/************************************************************************
* Look up variable from environment,
#include <mpc8xx_irq.h>
#include <ppcboot.h>
#include <command.h>
+#include <config.h>
+#include <pcmcia.h>
#include <cmd_pcmcia.h>
#include <mpc8xx.h>
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
+ ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_PCCARD))
-static int hardware_enable (int slot);
-static int hardware_disable(int slot);
-static int voltage_set(int slot, int vcc, int vpp);
+int pcmcia_on (void);
+
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
+static void pcmcia_off (void);
+static int hardware_disable(int slot);
+#endif
+static int hardware_enable (int slot);
+static int voltage_set(int slot, int vcc, int vpp);
+#ifdef CONFIG_IDE_PCCARD
+static void print_funcid (int func);
+static void print_fixed (volatile uchar *p);
+static int identify (volatile uchar *p);
+static int check_ide_device (void);
+#endif /* CONFIG_IDE_PCCARD */
static u_int m8xx_get_graycode(u_int size);
#if 0
#endif
/* ------------------------------------------------------------------------- */
-/* Autoconfigure boards if no settings are defined */
-#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || defined(CONFIG_TQM860L)
-#define CONFIG_TQM8xxL
-#endif
-
-#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
-
-/* The RPX series use SLOT_B */
-#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
-# define CONFIG_PCMCIA_SLOT_B
-#endif
-
-/* The ADS board use SLOT_A */
-#ifdef CONFIG_ADS
-# define CONFIG_PCMCIA_SLOT_A
-#endif
-
-/* The FADS series are a mess */
-#ifdef CONFIG_FADS
-# if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860) || defined(CONFIG_MPC821)
-# define CONFIG_PCMCIA_SLOT_A
-# else
-# define CONFIG_PCMCIA_SLOT_B
-# endif
-#endif
-
-/* The TQM8xxL modules use SLOT_A on MPC860, SLOT_B else */
-#ifdef CONFIG_TQM8xxL
-# if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860)
-# define CONFIG_PCMCIA_SLOT_A
-# else /* ! 860, 860T */
-# define CONFIG_PCMCIA_SLOT_B
-# endif /* 860, 860T */
-#endif /* CONFIG_TQM8xxL */
-
-#endif /* !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B) */
-
-/* Make sure exactly one slot is defined - we support only one for now */
-#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
-#error Neither CONFIG_PCMCIA_SLOT_A nor CONFIG_PCMCIA_SLOT_B configured
-#endif
-#if defined(CONFIG_PCMCIA_SLOT_A) && defined(CONFIG_PCMCIA_SLOT_B)
-#error Both CONFIG_PCMCIA_SLOT_A and CONFIG_PCMCIA_SLOT_B configured
-#endif
-
-#define PCMCIA_SOCKETS_NO 1
-#define PCMCIA_MEM_WIN_NO 4
-#define PCMCIA_IO_WIN_NO 2
-
-/* define _slot_ to be able to optimize macros */
-#ifdef CONFIG_PCMCIA_SLOT_A
-# define _slot_ 0
-# define PCMCIA_SLOT_MSG "SLOT_A"
-#else
-# define _slot_ 1
-# define PCMCIA_SLOT_MSG "SLOT_B"
-#endif
-
-/*
- * The TQM850L hardware has two pins swapped! Grrrrgh!
- */
-#ifdef CONFIG_TQM850L
-#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXOE
-#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXRESET
-#else
-#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXRESET
-#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXOE
-#endif
/* look up table for pgcrx registers */
#define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
-/*
- * This structure is used to address each window in the PCMCIA controller.
- *
- * Keep in mind that we assume that pcmcia_win_t[n+1] is mapped directly
- * after pcmcia_win_t[n]...
- */
-
-typedef struct {
- uint br;
- uint or;
-} pcmcia_win_t;
+const char *indent = "\t ";
+/* ------------------------------------------------------------------------- */
+#ifdef DEBUG
+#define PCMCIA_DEBUG(fmt,args...) do { printf (fmt ,##args); } while (0)
+#else
+#define PCMCIA_DEBUG(fmt,args...)
+#endif
/* ------------------------------------------------------------------------- */
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
+
void do_pinit (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
- int i;
- u_long reg, base;
- pcmcia_win_t *win;
if (argc != 2) {
printf ("Usage: pinit {on | off}\n");
return;
}
if (strcmp(argv[1],"on") == 0) {
- printf ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
+ pcmcia_on ();
+ } else if (strcmp(argv[1],"off") == 0) {
+ pcmcia_off ();
+ } else {
+ printf ("Usage: pinit {on | off}\n");
+ return;
+ }
+
+ return;
+}
+#endif /* CFG_CMD_PCMCIA */
- /* intialize the fixed memory windows */
- win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
- base = CFG_PCMCIA_MEM_ADDR;
+/* ------------------------------------------------------------------------- */
- if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
- printf ("Cannot set window size to 0x%08x\n",
- CFG_PCMCIA_MEM_SIZE);
- return;
+int pcmcia_on (void)
+{
+ int i;
+ u_long reg, base;
+ pcmcia_win_t *win;
+
+ PCMCIA_DEBUG ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
+
+ /* intialize the fixed memory windows */
+ win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
+ base = CFG_PCMCIA_MEM_ADDR;
+
+ if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
+ printf ("Cannot set window size to 0x%08x\n",
+ CFG_PCMCIA_MEM_SIZE);
+ return (1);
+ }
+
+ for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
+ win->br = base;
+
+ switch (i) {
+#ifdef CONFIG_IDE_PCCARD
+ case 0: { /* map attribute memory */
+ win->or = ( PCMCIA_BSIZE_64M
+ | PCMCIA_PPS_8
+ | PCMCIA_PRS_ATTR
+ | PCMCIA_PSLOT_B
+ | PCMCIA_PV
+ | 0x00024480 ); /* fixed access timing */
+ break;
+ }
+
+ case 1: { /* map I/O window for data reg */
+ win->or = ( PCMCIA_BSIZE_1K
+ | PCMCIA_PPS_16
+ | PCMCIA_PRS_IO
+ | PCMCIA_PSLOT_B
+ | PCMCIA_PV
+ | 0x00024480 ); /* fixed access timing */
+ break;
+ }
+
+ case 2: { /* map I/O window for command/ctrl reg block */
+ win->or = ( PCMCIA_BSIZE_1K
+ | PCMCIA_PPS_8
+ | PCMCIA_PRS_IO
+ | PCMCIA_PSLOT_B
+ | PCMCIA_PV
+ | 0x00024480 ); /* fixed access timing */
+ break;
+ }
+#endif
+ default: /* set to not valid */
+ win->or = 0;
+ break;
}
-#if 0
-XXX XXX XXX
-if(mem->flags & MAP_ATTRIB)
- reg |= 0x00000010;
-if(mem->flags & MAP_WRPROT)
- reg |= 0x00000002;
+ PCMCIA_DEBUG ("MemWin %d: Base 0x%08lX\n", i, base);
+ base += CFG_PCMCIA_MEM_SIZE;
+ ++win;
+ }
+
+ /* turn off voltage */
+ if (voltage_set(_slot_, 0, 0))
+ return (1);
-if(mem->flags & MAP_16BIT)
- reg |= 0x00000040;
+ /* Enable external hardware */
+ if (hardware_enable(_slot_))
+ return (1);
-if(mem->flags & MAP_ACTIVE)
- reg |= 0x00000001;
-XXX XXX XXX
+#ifdef CONFIG_IDE_PCCARD
+ if (check_ide_device())
+ return (1);
#endif
+ return (0);
+}
- for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
- win->br = base;
- win->or = 0; /* set to not valid */
-printf ("MemWin %d: Base 0x%08lX\n", i, base);
- base += CFG_PCMCIA_MEM_SIZE;
- ++win;
- }
+/* ------------------------------------------------------------------------- */
- /* turn off voltage */
- voltage_set(_slot_, 0, 0);
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
- /* Enable external hardware */
- hardware_enable(_slot_);
+static void pcmcia_off (void)
+{
+ int i;
+ pcmcia_win_t *win;
- } else if (strcmp(argv[1],"off") == 0) {
- printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
+ printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
- /* clear interrupt state, and disable interrupts */
- ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
- ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
+ /* clear interrupt state, and disable interrupts */
+ ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
+ ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
- /* turn off interrupt and disable CxOE */
- PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
+ /* turn off interrupt and disable CxOE */
+ PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
- /* turn off memory windows */
- win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
+ /* turn off memory windows */
+ win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
- for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
- /* disable memory window */
- win->or = 0;
- ++win;
+ for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
+ /* disable memory window */
+ win->or = 0;
+ ++win;
+ }
+
+ /* turn off voltage */
+ voltage_set(_slot_, 0, 0);
+
+ /* disable external hardware */
+ printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
+ hardware_disable(_slot_);
+}
+
+#endif /* CFG_CMD_PCMCIA */
+
+/* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_IDE_PCCARD
+
+#define MAX_TUPEL_SZ 512
+#define MAX_FEATURES 4
+
+static int check_ide_device (void)
+{
+ volatile uchar *ident = NULL;
+ volatile uchar *feature_p[MAX_FEATURES];
+ volatile uchar *p, *start;
+ int n_features = 0;
+ uchar func_id = ~0;
+ uchar code, len;
+ ushort config_base = 0;
+ int found = 0;
+ int i;
+
+ PCMCIA_DEBUG ("PCMCIA MEM: %08lX\n", CFG_PCMCIA_MEM_ADDR);
+
+ start = p = (volatile uchar *) CFG_PCMCIA_MEM_ADDR;
+
+ while ((p - start) < MAX_TUPEL_SZ) {
+
+ code = *p; p += 2;
+
+ if (code == 0xFF) { /* End of chain */
+ break;
}
- /* turn off voltage */
- voltage_set(_slot_, 0, 0);
+ len = *p; p += 2;
+#ifdef DEBUG
+ { volatile uchar *q = p;
+ printf ("\nTuple code %02x length %d\n\tData:",
+ code, len);
- /* disable external hardware */
- printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
- hardware_disable(_slot_);
- } else {
- printf ("Usage: pinit {on | off}\n");
- return;
+ for (i = 0; i < len; ++i) {
+ printf (" %02x", *q);
+ q+= 2;
+ }
+ }
+#endif /* DEBUG */
+ switch (code) {
+ case CISTPL_VERS_1:
+ ident = p + 4;
+ break;
+ case CISTPL_FUNCID:
+ func_id = *p;
+ break;
+ case CISTPL_FUNCE:
+ if (n_features < MAX_FEATURES)
+ feature_p[n_features++] = p;
+ break;
+ case CISTPL_CONFIG:
+ config_base = (*(p+6) << 8) + (*(p+4));
+ PCMCIA_DEBUG ("\n## Config_base = %04x ###\n", config_base);
+ default:
+ break;
+ }
+ p += 2 * len;
}
- return;
+ found = identify (ident);
+
+ if (func_id != ((uchar)~0)) {
+ print_funcid (func_id);
+
+ if (func_id == CISTPL_FUNCID_FIXED)
+ found = 1;
+ else
+ return (1); /* no disk drive */
+ }
+
+ for (i=0; i<n_features; ++i) {
+ print_fixed (feature_p[i]);
+ }
+
+ if (!found) {
+ printf ("unknown card type\n");
+ return (1);
+ }
+
+ /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
+ *((uchar *)(CFG_PCMCIA_MEM_ADDR + config_base)) = 1;
+
+ return (0);
}
+#endif /* CONFIG_IDE_PCCARD */
+
+/* ------------------------------------------------------------------------- */
+
/* ---------------------------------------------------------------------------- */
/* board specific stuff: */
{
return 0; /* No hardware to enable */
}
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
static int hardware_disable(int slot)
{
return 0; /* No hardware to disable */
}
-#endif /* CONFIG_RPXCLASSIC */
+#endif /* CFG_CMD_PCMCIA */
+#endif /* CONFIG_RPXCLASSIC */
/* ---------------------------------------------------------------------------- */
/* (F)ADS Boards from Motorola */
return 0;
}
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
static int hardware_disable(int slot)
{
*((uint *)BCSR1) &= ~BCSR1_PCCEN;
return 0;
}
+#endif /* CFG_CMD_PCMCIA */
#endif /* (F)ADS */
/* TQM8xxL Boards by TQ Components */
/* ---------------------------------------------------------------------------- */
+#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
+ defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L)
+# ifndef CONFIG_TQM8xxL
+# define CONFIG_TQM8xxL
+# endif
+#endif
+
#ifdef CONFIG_TQM8xxL
#define PCMCIA_BOARD_MSG "TQM8xxL"
volatile sysconf8xx_t *sysp;
uint reg, mask;
-printf ("hardware_enable: TQM8xxL Slot %c\n", 'A'+slot);
-
-if (slot != 1) {
- printf ("## Only Slot B supported for now ##\n");
- return (1);
-}
+ PCMCIA_DEBUG ("hardware_enable: TQM8xxL Slot %c\n", 'A'+slot);
immap = (immap_t *)CFG_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
* Disable PCMCIA buffers (isolate the interface)
* and assert RESET signal
*/
-printf ("Disable PCMCIA buffers and assert RESET\n");
+ PCMCIA_DEBUG ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
- reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
PCMCIA_PGCRX(_slot_) = reg;
udelay(500);
immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
/* remove all power */
+
immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
/*
* Make sure there is a card in the slot, then configure the interface.
*/
-printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
-printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
-printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
+ PCMCIA_DEBUG ("[%d] %s: PIPR(%p)=0x%x\n",
+ __LINE__,__FUNCTION__,
+ &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
if (pcmp->pcmc_pipr & 0x00001800) {
-printf ("##### hardware_enable - no card in slot\n");
- return (-1);
+ printf (" No Card found\n");
+ return (1);
}
-printf ("# hardware_enable - card found\n");
/*
* Power On.
*/
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
reg = pcmp->pcmc_pipr;
-printf ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
-(reg&PCMCIA_VS1(slot))?"n":"ff", (reg&PCMCIA_VS2(slot))?"n":"ff");
+ PCMCIA_DEBUG ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
+ reg,
+ (reg&PCMCIA_VS1(slot))?"n":"ff",
+ (reg&PCMCIA_VS2(slot))?"n":"ff");
if ((reg & mask) == mask) {
immap->im_ioport.iop_pcdat |= 0x0004;
-printf ("PCMCIA Power on 5.0 Volt\n");
+ puts (" 5.0V card found: ");
} else {
immap->im_ioport.iop_pcdat |= 0x0002;
-printf ("PCMCIA Power on 3.3 Volt\n");
+ puts (" 3.3V card found: ");
}
immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
-
+#if 0
/* VCC switch error flag, PCMCIA slot INPACK_ pin */
cp->cp_pbdir &= ~(0x0020 | 0x0010);
cp->cp_pbpar &= ~(0x0020 | 0x0010);
udelay(500000);
-
-printf ("Enable PCMCIA buffers and stop RESET\n");
+#endif
+ PCMCIA_DEBUG ("Enable PCMCIA buffers and stop RESET\n");
reg = PCMCIA_PGCRX(_slot_);
- reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
PCMCIA_PGCRX(_slot_) = reg;
- udelay(500);
-printf ("# hardware_enable done\n");
+ udelay(250000); /* some cards need >150 ms to come up :-( */
+
+ PCMCIA_DEBUG ("# hardware_enable done\n");
+
return (0);
}
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
static int hardware_disable(int slot)
{
volatile immap_t *immap;
volatile pcmconf8xx_t *pcmp;
u_long reg;
-printf ("hardware_disable: TQM8xxL Slot %c\n", 'A'+slot);
-
-if (slot != 1) {
- printf ("## Only Slot B supported for now ##\n");
- return (1);
-}
+ PCMCIA_DEBUG ("hardware_disable: TQM8xxL Slot %c\n", 'A'+slot);
immap = (immap_t *)CFG_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
/*
* Disable PCMCIA buffers (isolate the interface)
*/
-printf ("Disable PCMCIA buffers\n");
+ PCMCIA_DEBUG ("Disable PCMCIA buffers\n");
PCMCIA_PGCRX(_slot_) &= ~__MY_PCMCIA_GCRX_CXOE;
udelay(500);
-printf ("Disable PCMCIA buffers and assert RESET\n");
+ PCMCIA_DEBUG ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
return (0);
}
+#endif /* CFG_CMD_PCMCIA */
volatile pcmconf8xx_t *pcmp;
u_long reg;
-printf ("voltage_set: TQM8xxL Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
-'A'+slot,vcc/10,vcc%10,vpp/10,vcc%10);
-
-if (slot != 1) {
- printf ("## Only Slot B supported for now ##\n");
- return (1);
-}
+ PCMCIA_DEBUG ("voltage_set: TQM8xxL Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
+ 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
immap = (immap_t *)CFG_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
* Disable PCMCIA buffers (isolate the interface)
* and assert RESET signal
*/
-printf ("Disable PCMCIA buffers and assert RESET\n");
+ PCMCIA_DEBUG ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
- reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
PCMCIA_PGCRX(_slot_) = reg;
udelay(500);
* 5 Volts Enable and 3 Volts enable,
* Turn off all power
*/
-printf ("PCMCIA power OFF\n");
+ PCMCIA_DEBUG ("PCMCIA power OFF\n");
immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
/* Checking supported voltages */
-printf ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
-(pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
+ PCMCIA_DEBUG ("PIPR: 0x%x --> %s\n",
+ pcmp->pcmc_pipr,
+ (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
immap->im_ioport.iop_pcdat |= reg;
immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
-if (reg) {
-printf ("PCMCIA powered at %sV\n",(reg&0x0004)?"5.0":"3.3");
-} else {
-printf ("PCMCIA powered down\n");
-}
+ if (reg) {
+ PCMCIA_DEBUG ("PCMCIA powered at %sV\n",
+ (reg&0x0004) ? "5.0" : "3.3");
+ } else {
+ PCMCIA_DEBUG ("PCMCIA powered down\n");
+ }
done:
-printf ("Enable PCMCIA buffers and stop RESET\n");
+ PCMCIA_DEBUG ("Enable PCMCIA buffers and stop RESET\n");
reg = PCMCIA_PGCRX(_slot_);
- reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
PCMCIA_PGCRX(_slot_) = reg;
udelay(500);
-printf ("voltage_set: TQM8xxL Slot %c, DONE\n", slot+'A');
+ PCMCIA_DEBUG ("voltage_set: TQM8xxL Slot %c, DONE\n", slot+'A');
return (0);
}
/* ------------------------------------------------------------------------- */
+#ifdef CONFIG_IDE_PCCARD
+static void print_funcid (int func)
+{
+ puts (indent);
+ switch (func) {
+ case CISTPL_FUNCID_MULTI:
+ puts (" Multi-Function");
+ break;
+ case CISTPL_FUNCID_MEMORY:
+ puts (" Memory");
+ break;
+ case CISTPL_FUNCID_SERIAL:
+ puts (" Serial Port");
+ break;
+ case CISTPL_FUNCID_PARALLEL:
+ puts (" Parallel Port");
+ break;
+ case CISTPL_FUNCID_FIXED:
+ puts (" Fixed Disk");
+ break;
+ case CISTPL_FUNCID_VIDEO:
+ puts (" Video Adapter");
+ break;
+ case CISTPL_FUNCID_NETWORK:
+ puts (" Network Adapter");
+ break;
+ case CISTPL_FUNCID_AIMS:
+ puts (" AIMS Card");
+ break;
+ case CISTPL_FUNCID_SCSI:
+ puts (" SCSI Adapter");
+ break;
+ default:
+ puts (" Unknown");
+ break;
+ }
+ puts (" Card\n");
+}
+#endif /* CONFIG_IDE_PCCARD */
+
+/* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_IDE_PCCARD
+static void print_fixed (volatile uchar *p)
+{
+ if (p == NULL)
+ return;
+
+ puts(indent);
+
+ switch (*p) {
+ case CISTPL_FUNCE_IDE_IFACE:
+ { uchar iface = *(p+2);
+
+ puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
+ puts (" interface ");
+ break;
+ }
+ case CISTPL_FUNCE_IDE_MASTER:
+ case CISTPL_FUNCE_IDE_SLAVE:
+ { uchar f1 = *(p+2);
+ uchar f2 = *(p+4);
+
+ puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
+
+ if (f1 & CISTPL_IDE_UNIQUE)
+ puts (" [unique]");
+
+ puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
+
+ if (f2 & CISTPL_IDE_HAS_SLEEP)
+ puts (" [sleep]");
+
+ if (f2 & CISTPL_IDE_HAS_STANDBY)
+ puts (" [standby]");
+
+ if (f2 & CISTPL_IDE_HAS_IDLE)
+ puts (" [idle]");
+
+ if (f2 & CISTPL_IDE_LOW_POWER)
+ puts (" [low power]");
+
+ if (f2 & CISTPL_IDE_REG_INHIBIT)
+ puts (" [reg inhibit]");
+
+ if (f2 & CISTPL_IDE_HAS_INDEX)
+ puts (" [index]");
+
+ if (f2 & CISTPL_IDE_IOIS16)
+ puts (" [IOis16]");
+
+ break;
+ }
+ }
+ putc ('\n');
+}
+#endif /* CONFIG_IDE_PCCARD */
+
+/* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_IDE_PCCARD
+
+#define MAX_IDENT_CHARS 64
+#define MAX_IDENT_FIELDS 4
+
+static uchar *known_cards[] = {
+ "ARGOSY PnPIDE D5",
+ NULL
+};
+
+static int identify (volatile uchar *p)
+{
+ uchar id_str[MAX_IDENT_CHARS];
+ uchar data;
+ uchar *t;
+ uchar **card;
+ int i, done;
+
+ if (p == NULL)
+ return (0); /* Don't know */
+
+ t = id_str;
+ done =0;
+
+ for (i=0; i<=4 && !done; ++i, p+=2) {
+ while ((data = *p) != '\0') {
+ if (data == 0xFF) {
+ done = 1;
+ break;
+ }
+ *t++ = data;
+ if (t == &id_str[MAX_IDENT_CHARS-1]) {
+ done = 1;
+ break;
+ }
+ p += 2;
+ }
+ if (!done)
+ *t++ = ' ';
+ }
+ *t = '\0';
+ while (--t > id_str) {
+ if (*t == ' ')
+ *t = '\0';
+ else
+ break;
+ }
+ puts (id_str);
+ putc ('\n');
+
+ for (card=known_cards; *card; ++card) {
+ PCMCIA_DEBUG ("## Compare against \"%s\"\n", *card);
+ if (strcmp(*card, id_str) == 0) { /* found! */
+ PCMCIA_DEBUG ("## CARD FOUND ##\n");
+ return (1);
+ }
+ }
+
+ return (0); /* don't know */
+}
+#endif /* CONFIG_IDE_PCCARD */
/* ------------------------------------------------------------------------- */
+#endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_PCCARD) */
#include <cmd_ide.h>
#include <cmd_disk.h>
#include <cmd_console.h>
+#include <cmd_pcmcia.h>
#include <cmd_eeprom.h>
cmd_tbl_t cmd_tbl[] = {
CMD_TBL_GO
+ CMD_TBL_RUN
CMD_TBL_BOOTM
CMD_TBL_BOOTP
CMD_TBL_TFTPB
CMD_TBL_BASE
CMD_TBL_PRINTENV
CMD_TBL_SETENV
+ CMD_TBL_ASKENV
CMD_TBL_SAVEENV
CMD_TBL_PROTECT
CMD_TBL_FLERASE
CMD_TBL_IRQINFO
CMD_TBL_CONINFO
CMD_TBL_IDE
+ CMD_TBL_PINIT
CMD_TBL_LOOP
CMD_TBL_MTEST
CMD_TBL_ICACHE
#include <ppcboot.h>
#include <stdarg.h>
#include <malloc.h>
-#include <devices.h>
+#include <console.h>
static int console_setfile(int file, device_t *dev)
-{
+{
int error = 0;
-
+
if (dev == NULL)
return -1 ;
case stdin:
case stdout:
case stderr:
- // Start new device
+ // Start new device
if (dev->start)
{
error = dev->start() ;
if (error < 0)
break;
}
-
+
// Assign the new device (leaving the existing one started)
stdio_devices[file] = dev ;
-
+
// Update monitor functions (to use the console stuff by other applications)
switch (file){
case stdin:
bd_ptr->bi_mon_fnc->getc = dev->getc ;
bd_ptr->bi_mon_fnc->tstc = dev->tstc ;
- break;
+ break;
case stdout:
bd_ptr->bi_mon_fnc->putc = dev->putc ;
bd_ptr->bi_mon_fnc->puts = dev->puts ;
bd_ptr->bi_mon_fnc->printf = printf ;
- break;
+ break;
}
break;
-
+
default: // Invalid file ID
error = -1 ;
}
{
if (file < MAX_FILES)
return stdio_devices[file]->getc();
-
+
return -1 ;
}
{
if (file < MAX_FILES)
return stdio_devices[file]->tstc();
-
+
return -1 ;
}
if (idata->relocated)
// Get from the standard input
return fgetc (stdin);
-
+
// Send directly to the handler
return serial_getc();
}
if (idata->relocated)
// Test the standard input
return ftstc (stdin);
-
+
// Send directly to the handler
return serial_tstc();
}
if (idata->relocated)
// Send to the standard output
fputc (stdout, c);
- else
+ else
// Send directly to the handler
serial_putc(c);
}
if (idata->relocated)
// Send to the standard output
fputs (stdout, s);
- else
+ else
// Send directly to the handler
serial_puts(s);
}
default:
return -1 ;
}
-
+
// Check for valid device name
-
+
for(i=1; i<=ListNumItems(devlist); i++)
{
device_t *dev = ListGetPtrToItem (devlist,i) ;
-
+
if (strcmp (devname, dev->name) == 0)
{
- if (dev->flags & flag)
+ if (dev->flags & flag)
return console_setfile(file, dev) ;
-
+
return -1 ;
}
}
-
+
return -1 ;
}
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
idata->relocated = 0 ; // Use these pointers before relocation
- idata->bi_mon_fnc.getc = serial_getc;
- idata->bi_mon_fnc.tstc = serial_tstc;
- idata->bi_mon_fnc.putc = serial_putc;
- idata->bi_mon_fnc.puts = serial_puts;
+ idata->bi_mon_fnc.getc = serial_getc;
+ idata->bi_mon_fnc.tstc = serial_tstc;
+ idata->bi_mon_fnc.putc = serial_putc;
+ idata->bi_mon_fnc.puts = serial_puts;
idata->bi_mon_fnc.printf = serial_printf;
}
// Scan devices looking for input and output devices
for (i=1; (i<=items) && ((inputdev == NULL) || (outputdev == NULL)); i++)
- {
+ {
device_t *dev = ListGetPtrToItem(devlist, i) ;
-
+
if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev==NULL))
inputdev = dev ;
if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev==NULL))
outputdev = dev ;
}
-
+
// Initializes output console first
if (outputdev != NULL)
{
console_setfile(stdout, outputdev);
console_setfile(stderr, outputdev);
}
-
+
// Initializes input console
if (inputdev != NULL)
console_setfile(stdin, inputdev);
// Print informations
- printf(" Input: ");
+ printf(" In: ");
if (stdio_devices[stdin] == NULL)
printf("No input devices available!\n");
else
- {
printf("%s\n", stdio_devices[stdin]->name);
- }
-
- printf(" Output: ");
+
+ printf(" Out: ");
if (stdio_devices[stdout] == NULL)
printf("No output devices available!\n");
else
- printf("%s\n", stdio_devices[stdout]->name);
-
+ printf("%s\n", stdio_devices[stdout]->name);
+
+ printf(" Err: ");
+ if (stdio_devices[stderr] == NULL)
+ printf("No error devices available!\n");
+ else
+ printf("%s\n", stdio_devices[stderr]->name);
+
// Setting environment variables
for (i=0; i<3; i++)
setenv(stdio_names[i], stdio_devices[i]->name);
if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
return ;
- // Set the relocation flag
+ // Set the relocation flag
idata->relocated = reloc_offset;
}
#include <stdarg.h>
#include <malloc.h>
#include <devices.h>
+#include <i2c.h>
list_t devlist = 0 ;
device_t *stdio_devices[] = {NULL,NULL,NULL} ;
eputs("Cannot initialize the list of devices!\n");
return -1 ;
}
-
+#if defined(CONFIG_I2C) && !defined(CONFIG_MPC8260)
+ i2c_init();
+#endif
#ifdef CONFIG_VIDEO
drv_video_init();
#endif
environment:
.globl env_crc
env_crc:
+#ifdef ENV_CRC // If we are building with computed CRC...
+ .long ENV_CRC // ...use it!
+#else
.long ~0
+#endif
+ .globl env_data
+env_data:
#ifdef CONFIG_BOOTARGS
.ascii "bootargs="
.ascii CONFIG_BOOTARGS
.ascii MK_STR(CONFIG_SERVERIP)
.ascii "\0"
#endif
-
+#ifdef CFG_AUTOLOAD
+ .ascii "autoload="
+ .ascii CFG_AUTOLOAD
+ .ascii "\0"
+#endif
/* terminate list of environment strings */
.ascii "\0"
#include <command.h>
int readline (const char *const prompt);
-void run_default_command (int l, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
+void run_command (const char *cmd, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
static int parse_line (char *, char *[]);
-static void run_command (int len, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
char console_buffer[CFG_CBSIZE]; /* console I/O buffer */
static char erase_seq[] = "\b \b"; /* erase sequence */
static char tab_seq[] = " "; /* used to expand TABs */
+#if (CONFIG_COMMANDS & CFG_CMD_RUN)
+void do_run (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+#endif
+
/****************************************************************************/
void main_loop(bd_t *bd)
if (autoboot) {
autoboot = 0;
- run_default_command (1, cmdtp, bd, flag);
+ run_command ("bootcmd", cmdtp, bd, flag);
continue;
}
printf ("<INTERRUPT>\n");
continue;
}
- run_command (len, cmdtp, bd, flag);
+ run_command (len ? NULL : "", cmdtp, bd, flag);
}
}
#if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
/* avoid "bootd" recursion */
- if ((len < 0) && (cmdtp->cmd == do_bootd)) {
+ if ((len == -1) && (cmdtp->cmd == do_bootd)) {
#ifdef DEBUG_PARSER
printf ("[%s]\n", finaltoken);
#endif
return 0;
}
#endif /* CFG_CMD_BOOTD */
+
+#if (CONFIG_COMMANDS & CFG_CMD_RUN)
+ /* avoid "run" recursion */
+ if ((len == -2) && (cmdtp->cmd == do_run)) {
+#ifdef DEBUG_PARSER
+ printf ("[%s]\n", finaltoken);
+#endif
+ printf ("'run' recursion detected\n");
+ return 0;
+ }
+#endif /* CFG_CMD_RUN */
/* OK - call function */
(cmdtp->cmd) (cmdtp, bd, flag, argc, argv);
/****************************************************************************/
/*
- * "len" is used to indicate if we're executing normal input
- * (len > 0), just re-executing the last command when the user
- * presses only ENTER (len == 0), or executing the default command
- * (len < 0).
+ * "cmd" is used to indicate if we are executing normal user input
+ * (cmd == NULL), re-executing the last command when the user presses
+ * only ENTER (cmd != NULL && strlen(cmd) == 0), or running a command
+ * stored in an environment variable ("cmd" contains the name of that
+ * variable).
*/
-static void run_command (int len,
+void run_command (const char *cmd,
cmd_tbl_t *cmdtp, bd_t *bd, int flag)
{
static char lastcommand[CFG_CBSIZE] = { 0, };
- static int lastlen = 0;
-
- if (len > 0) { /* Process a new command */
- memcpy (lastcommand, console_buffer, len);
- lastcommand[len] = 0;
- lastlen = len;
- } else if (len < 0) { /* Process default command */
- char *str = getenv ("bootcmd");
-
- if (!str)
- return;
-
- strcpy (lastcommand, str);
- lastlen = len;
- } else { /* Process last command (len = 0) */
- /* Check if we have a valid command stored */
- if (lastcommand[0] == 0)
- return;
-
- flag |= CMD_FLAG_REPEAT;
- }
+ static const char *last_cmd;
+
+ if (cmd) {
+ if (*cmd) { /* got the name of a variable to run */
+ char *str = getenv ((char *)cmd);
+
+ if (!str)
+ return;
+ strcpy (lastcommand, str);
+ last_cmd = cmd;
+ } else { /* re-executing previous command */
+
+ /* Check if we have a valid command stored */
+ if (lastcommand[0] == 0)
+ return;
+
+ flag |= CMD_FLAG_REPEAT;
+ last_cmd = "";
+ }
+ } else { /* cmd == NULL: process user input */
+ strcpy (lastcommand, console_buffer);
+ last_cmd = NULL;
+ }
#ifdef DEBUG_PARSER
- printf ("[RUN_COMMAND] lastlen=%d -> %s\n", lastlen, lastcommand);
+ printf ("[RUN_COMMAND] last_cmd=\"%s\" -> %s\n",
+ last_cmd ? last_cmd : "NULL", lastcommand);
#endif
/* Process separators and check for non-valid repeatable commands */
- if (process_separators (lastcommand, lastlen, cmdtp, bd, flag) == 0) {
+ if (process_separators (lastcommand, strlen(lastcommand),
+ cmdtp, bd, flag) == 0) {
lastcommand[0] = 0;
- lastlen = 0;
+ last_cmd = "";
}
}
/****************************************************************************/
-void run_default_command (int l, cmd_tbl_t *cmdtp, bd_t *bd, int flag)
+#if (CONFIG_COMMANDS & CFG_CMD_RUN)
+void do_run (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
{
- run_command(-1, cmdtp, bd, flag) ;
-}
+ int i;
-/****************************************************************************/
+ if (argc < 2) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+ }
+
+ for (i=1; i<argc; ++i) {
+ run_command (argv[i], cmdtp, bd, flag);
+ }
+}
+#endif
void do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
- ulong msr, addr;
-
-
- /* Interrupts and MMU off */
- __asm__ ("mtspr 81, 0
- mfmsr %0": "=r"(msr) : );
- msr &= ~0x1030;
- __asm__ ("mtmsr %0"::"r"(msr) );
-
- /* jump to reset vector*/
- addr = 0xfff0100;
- ((void (*)(void ))addr)();
+ ulong msr, addr;
+
+ /* Interrupts and MMU off */
+ __asm__ ("mtspr 81, 0" );
+
+ /* Interrupts and MMU off */
+ __asm__ __volatile__ ("mfmsr %0" : "=r"(msr) : );
+ msr &= ~0x1030;
+ __asm__ __volatile__ ("mtmsr %0" : : "r"(msr) );
+
+ /*
+ * Trying to execute the next instruction at a non-existing address
+ * should cause a machine check, resulting in reset
+ */
+#ifdef CFG_RESET_ADDRESS
+ addr = CFG_RESET_ADDRESS;
+#else
+ /*
+ * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
+ * - sizeof (ulong) is usually a valid address. Better pick an address
+ * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
+ * "(ulong)-1" used to be a good choice for many systems...
+ */
+ addr = CFG_MONITOR_BASE - sizeof (ulong);
+#endif
+ ((void (*)(void ))addr)();
}
/* Interrupts and MMU off */
__asm__ __volatile__ ("mfmsr %0" : "=r"(msr) : );
- msr &= ~(MSR_EE|MSR_IR|MSR_DR);
+ msr &= ~(MSR_ME|MSR_EE|MSR_IR|MSR_DR);
__asm__ __volatile__ ("mtmsr %0" : : "r"(msr) );
/*
- * Trying to execute the next instruction at a non-existing address
- * should cause a machine check, resulting in reset
- */
-#if 0
- addr = (ulong)-1;
+ * Trying to execute the next instruction at a non-existing address
+ * should cause a machine check, resulting in reset
+ */
+#ifdef CFG_RESET_ADDRESS
+ addr = CFG_RESET_ADDRESS;
#else
/*
- * -1 was actually a valid address on my system, so I got a
- * Software Emulation exception instead of a Machine Check
- * exception. Let's try to pick a better address...
+ * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
+ * - sizeof (ulong) is usually a valid address. Better pick an address
+ * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
*/
addr = CFG_MONITOR_BASE - sizeof (ulong);
#endif
#include <ppcboot.h>
#include <commproc.h>
-void m8xx_cpm_init(uint base, uint size)
+#ifdef CFG_ALLOC_DPRAM
+
+void dpram_init(void)
{
/* Pointer to initial global data area */
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
/* Reclaim the DP memory for our use. */
- idata->dp_alloc_base = base;
- idata->dp_alloc_top = idata->dp_alloc_base + size;
+ idata->dp_alloc_base = CPM_DATAONLY_BASE ;
+ idata->dp_alloc_top = idata->dp_alloc_base + CPM_DATAONLY_SIZE ;
}
/* Allocate some memory from the dual ported ram. We may want to
* enforce alignment restrictions, but right now everyone is a good
* citizen.
*/
-uint m8xx_cpm_dpalloc(uint size)
+uint dpram_alloc(uint size)
{
/* Pointer to initial global data area */
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- uint retloc;
+ uint addr = idata->dp_alloc_base ;
if ((idata->dp_alloc_base + size) >= idata->dp_alloc_top)
return(CPM_DP_NOSPACE);
- retloc = idata->dp_alloc_base;
idata->dp_alloc_base += size;
-#if 0
- serial_printf("Requested %d bytes\n", size);
- serial_printf("DPRAM BASE=%08x DPRAM TOP=%08x\n",
- idata->dp_alloc_base,
- idata->dp_alloc_top);
- serial_printf("Returned %08x\n", retloc);
-#endif
-
- return(retloc);
+ return addr;
}
-uint m8xx_cpm_dpbase(void)
+uint dpram_base(void)
{
/* Pointer to initial global data area */
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- uint retloc = idata->dp_alloc_base;
-
-#if 0
- serial_printf("Returned %08x\n", retloc);
-#endif
- return retloc;
+ return idata->dp_alloc_base ;
}
/* Allocate some memory from the dual ported ram. We may want to
* enforce alignment restrictions, but right now everyone is a good
* citizen.
*/
-uint m8xx_cpm_dpalloc_align(uint size, uint align)
+uint dpram_alloc_align(uint size, uint align)
{
/* Pointer to initial global data area */
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- uint retloc, mask = align -1;
+ uint addr, mask = align -1 ;
- if ((idata->dp_alloc_base + size) >= idata->dp_alloc_top)
- return(CPM_DP_NOSPACE);
+ addr = (idata->dp_alloc_base + mask) & ~mask;
- retloc = (idata->dp_alloc_base + mask) & ~mask;
- idata->dp_alloc_base += size;
+ if ((addr + size) >= idata->dp_alloc_top)
+ return(CPM_DP_NOSPACE);
-#if 0
- serial_printf("Requested %d bytes\n", size);
- serial_printf("DPRAM BASE=%08x DPRAM TOP=%08x\n",
- idata->dp_alloc_base,
- idata->dp_alloc_top);
- serial_printf("Returned %08x\n", retloc);
-#endif
+ idata->dp_alloc_base = addr + size;
- return(retloc);
+ return addr;
}
-uint m8xx_cpm_dpbase_align(uint align)
+uint dpram_base_align(uint align)
{
/* Pointer to initial global data area */
init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- uint mask = align-1, retloc = (idata->dp_alloc_base + mask) & ~mask;
-#if 0
- serial_printf("Returned %08x\n", retloc);
-#endif
- return retloc;
+ uint mask = align-1 ;
+
+ return (idata->dp_alloc_base + mask) & ~mask;
}
+
+#endif /* CFG_ALLOC_DPRAM */
* Trying to execute the next instruction at a non-existing address
* should cause a machine check, resulting in reset
*/
-#if 0
- addr = (ulong)-1;
+#ifdef CFG_RESET_ADDRESS
+ addr = CFG_RESET_ADDRESS;
#else
/*
- * -1 was actually a valid address on my system, so I got a
- * Software Emulation exception instead of a Machine Check
- * exception. Let's try to pick a better address...
+ * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
+ * - sizeof (ulong) is usually a valid address. Better pick an address
+ * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
+ * "(ulong)-1" used to be a good choice for many systems...
*/
addr = CFG_MONITOR_BASE - sizeof (ulong);
#endif
#if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(FEC_ENET)
-#define BD_OFFSET 0x860 /* offset to begin of DPRAM + allocation for serial IF*/
-
/* Ethernet Transmit and Receive Buffers */
#define DBUF_LENGTH 1520
txIdx = 0;
if (!rtx) {
- rtx = (RTXBD *) (immr->im_cpm.cp_dpmem +
- m8xx_cpm_dpalloc_align(sizeof(RTXBD),8));
+#ifdef CFG_ALLOC_DPRAM
+ rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + dpram_alloc_align(sizeof(RTXBD),8));
+#else
+ rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + CPM_FEC_BASE);
+#endif
}
/*
* Setup Receiver Buffer Descriptors (13.14.24.18)
#include <commproc.h>
#include <i2c.h>
-#define DEBUG_STEP 0
-#define PRINTD(x) if (DEBUG_STEP) printf(x);
+// **********************************
+// ** DEBUG MACROS
+// **********************************
+
+//#define CONFIG_I2C_DEBUG
#define DELAY_US 100000 // us to wait before checking the I2c
-//#define DEBUG_I2C_RATE 0 // To show selected I2C bus rate
+// **********************************
+// ** CONSTANTS
+// **********************************
-#define I2C_PRAM 0
#define CPCR_FLAG 0x01
#define I2C_CPCR_CMD ( ( 0<<(15-7) ) | ( 1 << (15-11) ) | CPCR_FLAG )
#define I2C_RX_LEN 128 /* Receive buffer length */
#define RXBD_E 0x8000 /* Receive buffer is empty and can be used by CPM */
#define RXBD_W 0x2000 /* Wrap, last receive buffer in buffer circle */
-typedef struct I2C_BD
-{
- unsigned short status;
- unsigned short length;
- unsigned char *addr;
-} I2C_BD;
+// **********************************
+// ** VARIABLES
+// **********************************
+
+#ifdef CFG_ALLOC_DPRAM
+static unsigned char *rxbuf, *txbuf;
+#else
+static unsigned char rxbuf[I2C_RX_LEN], *txbuf[I2C_TX_LEN];
+#endif
+static cbd_t *rxbd, *txbd;
-static I2C_BD *rxbd, *txbd; /* buffer descriptors are defined */
- /* globally for this file */
+volatile i2c8xx_t *i2c;
+volatile cbd_t *tbdf, *rbdf;
+volatile iic_t *iip;
-static unsigned char
- rxbuf[I2C_RX_LEN],
- txbuf[I2C_TX_LEN];
+// **********************************
+// ** FUNCTIONS
+// **********************************
// Returns the best value of I2BRG to meet desired clock speed of I2C with
// input parameters (clock speed, filter, and predivider value).
// It returns computer speed value and the difference between it and desired
// speed.
-static inline int i2c_roundrate (int hz, int speed, int filter, int modval,
+static inline int i2c_roundrate (int hz, int speed, int filter, int modval,
int *brgval, int *totspeed)
{
int moddiv = 1 << (5-(modval & 3)),
brgdiv = hz / (moddiv * speed);
*brgval = brgdiv / 2 - 3 - 2*filter ;
-
+
if ((*brgval < 0) || (*brgval > 255))
return -1 ;
-
+
brgdiv = 2 * (*brgval + 3 + 2 * filter) ;
div = moddiv * brgdiv ;
*totspeed = hz / div ;
-
+
return 0;
}
bestspeed_modval=0,
bestspeed_filter=0,
totspeed,
- filter=0; // Use this fixed value
+ filter=0; // Use this fixed value 'cause the filter has a bug!
-// for (filter = 0; filter < 2; filter++)
+#if 0
+ for (filter = 0; filter < 2; filter++)
+#endif
for (modval = 0; modval < 4; modval++)
- if (i2c_roundrate ( hz, speed,
- filter, modval,
+ if (i2c_roundrate ( hz, speed,
+ filter, modval,
&brgval, &totspeed) == 0)
{
int diff = speed - totspeed ;
-
+
if ((diff >= 0) && (diff < bestspeed_diff))
{
bestspeed_diff = diff ;
}
}
-#ifdef DEBUG_I2C_RATE
- printf("Best is:\n");
- printf("\nCPU=%dhz RATE=%d F=%d I2MOD=%08x I2BRG=%08x DIFF=%dhz",
- hz, speed,
- bestspeed_filter, bestspeed_modval, bestspeed_brgval,
- bestspeed_diff);
-#endif
- i2c->i2c_i2mod |= ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3);
+ i2c->i2c_i2mod |= ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3);
i2c->i2c_i2brg = bestspeed_brgval & 0xff;
-#ifdef DEBUG_I2C_RATE
+#ifdef CONFIG_I2C_DEBUG
printf("i2mod=%08x i2brg=%08x\n", i2c->i2c_i2mod, i2c->i2c_i2brg);
#endif
return 1 ;
}
-volatile i2c8xx_t *i2c;
-volatile cbd_t *tbdf, *rbdf;
-volatile iic_t *iip;
-
-void i2c_init(int speed)
+int i2c_setspeed (int speed)
{
- init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- immap_t *immap = (immap_t *)CFG_IMMR ;
- volatile cpm8xx_t *cp;
-
- /* Get pointer to Communication Processor
- * and to internal registers
- */
- cp = (cpm8xx_t *)&immap->im_cpm ;
- iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
- i2c = (i2c8xx_t *)&(immap->im_i2c);
-
- // Disable relocation
- iip->iic_rpbase = 0 ;
-
- /* Initialize Port B I2C pins.
- */
- cp->cp_pbpar |= 0x00000030;
- cp->cp_pbdir |= 0x00000030;
- cp->cp_pbodr |= 0x00000030;
-
- /* Disable interrupts.
- */
- i2c->i2c_i2mod = 0;
- i2c->i2c_i2cmr = 0;
- i2c->i2c_i2cer = 0xff;
-
- // Set the I2C BRG Clock division factor from desired i2c rate
- // and current CPU rate (we assume sccr dfbgr field is 0;
- // divide BRGCLK by 1)
-
- PRINTD("\n[I2C ] Setting rate...");
- i2c_setrate (idata->cpu_clk, speed) ;
-
- /* Set I2C controller in master mode
- */
- i2c->i2c_i2com = 0x01;
-
- // Set SDMA bus arbitration level to 5 (SDCR)
- immap->im_siu_conf.sc_sdcr = 0x0001 ;
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
- /* Initialize Tx/Rx parameters.*/
-#if 0
- iip->iic_rbptr = iip->iic_rbase = BD_IIC_START ;//2018 ;
- iip->iic_tbptr = iip->iic_tbase = iip->iic_rbase + sizeof(I2C_BD) ; //2020 ;
+ // Set the I2C BRG Clock division factor from desired i2c rate
+ // and current CPU rate (we assume sccr dfbgr field is 0;
+ // divide BRGCLK by 1)
+
+ debug("\n[I2C ] Setting rate...");
+
+ i2c_setrate (idata->cpu_clk , speed) ;
+
+ return ERROR_I2C_NONE ;
+}
+
+int i2c_init(void)
+{
+ immap_t *immap = (immap_t *)CFG_IMMR ;
+ volatile cpm8xx_t *cp;
+
+ /* Get pointer to Communication Processor
+ * and to internal registers
+ */
+ cp = (cpm8xx_t *)&immap->im_cpm ;
+ iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
+ i2c = (i2c8xx_t *)&(immap->im_i2c);
+
+ // Disable relocation
+ iip->iic_rpbase = 0 ;
+
+ /* Initialize Port B I2C pins. */
+ cp->cp_pbpar |= 0x00000030;
+ cp->cp_pbdir |= 0x00000030;
+ cp->cp_pbodr |= 0x00000030;
+
+ /* Disable interrupts. */
+ i2c->i2c_i2mod = 0;
+ i2c->i2c_i2cmr = 0;
+ i2c->i2c_i2cer = 0xff;
+
+ /* Set I2C controller in master mode */
+ i2c->i2c_i2com = 0x01;
+
+ // Set SDMA bus arbitration level to 5 (SDCR)
+ immap->im_siu_conf.sc_sdcr = 0x0001 ;
+
+#ifdef CFG_ALLOC_DPRAM
+ /* Initialize Tx/Rx parameters.*/
+ iip->iic_rbptr = iip->iic_rbase = dpram_alloc_align(sizeof(cbd_t),8) ;
+ iip->iic_tbptr = iip->iic_tbase = dpram_alloc_align(sizeof(cbd_t),8) ;
+
+ rxbd = (cbd_t *)((unsigned char *)&cp->cp_dpmem[iip->iic_rbase]);
+ txbd = (cbd_t *)((unsigned char *)&cp->cp_dpmem[iip->iic_tbase]);
+
+ // Alloc rx and tx buffers into DPRAM
+ rxbuf = (unsigned char *)&cp->cp_dpmem[dpram_alloc(I2C_RX_LEN)] ;
+ txbuf = (unsigned char *)&cp->cp_dpmem[dpram_alloc(I2C_TX_LEN)] ;
#else
- iip->iic_rbptr = iip->iic_rbase = m8xx_cpm_dpbase_align(8) ;
- iip->iic_tbptr = iip->iic_tbase = iip->iic_rbase + sizeof(I2C_BD);
-#endif
- rxbd = (I2C_BD *)((unsigned char *)&cp->cp_dpmem[iip->iic_rbase]);
- txbd = (I2C_BD *)((unsigned char *)&cp->cp_dpmem[iip->iic_tbase]);
-
-#if DEBUG_STEP
- printf("rbase = %04x\n", iip->iic_rbase);
- printf("tbase = %04x\n", iip->iic_tbase);
- printf("Rxbd1=%08x\n", (int)rxbd);
- printf("Txbd1=%08x\n", (int)txbd);
-#endif
+ {
+ ulong base = CPM_I2C_BASE ;
+
+ /* Initialize Tx/Rx parameters.*/
+ iip->iic_rbptr = iip->iic_rbase = base ; base += sizeof(cbd_t) ;
+ iip->iic_tbptr = iip->iic_tbase = base ; base += sizeof(cbd_t) ;
- cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
+ rxbd = (cbd_t *)((unsigned char *)&cp->cp_dpmem[iip->iic_rbase]);
+ txbd = (cbd_t *)((unsigned char *)&cp->cp_dpmem[iip->iic_tbase]);
+ }
+#endif
- /* Set big endian byte order
- */
- iip->iic_tfcr = 0x15;
- iip->iic_rfcr = 0x15;
+#ifdef CONFIG_I2C_DEBUG
+ printf("Rxbd = %08x\n", (int)rxbd);
+ printf("Txbd = %08x\n", (int)txbd);
+ printf("Rxbuf = %08x (%d)\n", (int)rxbuf, I2C_RX_LEN);
+ printf("Txbuf = %08x (%d)\n", (int)txbuf, I2C_TX_LEN);
+#endif
- /* Set maximum receive size.
- */
- iip->iic_mrblr = 128;
+ cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_INIT_TRX) | CPM_CR_FLG;
+ while (cp->cp_cpcr & CPM_CR_FLG);
- PRINTD("\n[I2C ] Clearing the buffer memory...");
+ /* Set big endian byte order */
+ iip->iic_tfcr = 0x15;
+ iip->iic_rfcr = 0x15;
- // Clear the buffer memory
- memset ((char *)rxbuf, I2C_RX_LEN, 0);
- memset ((char *)txbuf, I2C_TX_LEN, 0);
+ /* Set maximum receive size. */
+ iip->iic_mrblr = I2C_RX_LEN;
- PRINTD("\n[I2C ] Initializing BD's...");
+ debug("\n[I2C ] Clearing the buffer memory...");
- // Initialize the BD's
+ // Clear the buffer memory
+ memset ((char *)rxbuf, I2C_RX_LEN, 0);
+ memset ((char *)txbuf, I2C_TX_LEN, 0);
+
+ debug("\n[I2C ] Initializing BD's...");
- // Rx: Wrap, no interrupt, empty
- rxbd->addr = rxbuf;
- rxbd->status = 0xa800;
+ // Initialize the BD's
+
+ // Rx: Wrap, no interrupt, empty
+ rxbd->cbd_bufaddr = (ulong)rxbuf;
+ rxbd->cbd_sc = 0xa800;
- // Tx: Wrap, no interrupt, not ready to send, last
- txbd->addr = txbuf;
- txbd->status = 0x2800;
+ // Tx: Wrap, no interrupt, not ready to send, last
+ txbd->cbd_bufaddr = (ulong)txbuf;
+ txbd->cbd_sc = 0x2800;
+
+ // Clear events and interrupts
+ i2c->i2c_i2cer = 0xff ;
+ i2c->i2c_i2cmr = 0 ;
- // Clear events and interrupts
- i2c->i2c_i2cer = 0xff ;
- i2c->i2c_i2cmr = 0 ;
+ return ERROR_I2C_NONE ;
}
-void i2c_send( unsigned char address,
+int i2c_send( unsigned char address,
unsigned char secondary_address,
int enable_secondary,
unsigned short size, unsigned char dataout[] )
{
- int i,j;
-
- if( size > I2C_TX_LEN ) /* Trying to send message larger than BD */
- return;
-
- PRINTD("\n[I2C ] Waiting for transmit buffer empty...");
- while( txbd->status & TXBD_R ) ; // Loop until previous data sent
-
- PRINTD("\n[I2C ] Formatting addresses...");
- if( enable_secondary ) /* Device has an internal address */
- {
- txbd->length = size + 2; /* Length of message plus dest addresses */
- txbd->addr[0] = address;
- txbd->addr[0] &= ~(0x01);
- txbd->addr[1] = secondary_address;
- i = 2;
- }
- else
- {
- txbd->length = size + 1; /* Length of message plus dest address */
- txbd->addr[0] = address; /* Write destination address to BD */
- txbd->addr[0] &= ~(0x01); /* Set address to write */
- i = 1;
- }
-
-#if DEBUG_STEP
- printf("Length = %d addr[0] = %08x addr[1] = %08x\n",
- txbd->length,
- txbd->addr[0],
- txbd->addr[1]);
+ unsigned char *buffer = (unsigned char *)txbd->cbd_bufaddr ;
+ int i,j;
+
+ if( size > I2C_TX_LEN ) /* Trying to send message larger than BD */
+ return ERROR_I2C_LENGTH;
+
+ debug("\n[I2C ] Waiting for transmit buffer empty...");
+ while( txbd->cbd_sc & TXBD_R ) ; // Loop until previous data sent
+
+ debug("\n[I2C ] Formatting addresses...");
+ if( enable_secondary ) /* Device has an internal address */
+ {
+ txbd->cbd_datlen = size + 2; /* Length of message plus dest addresses */
+ buffer[0] = address;
+ buffer[0] &= ~(0x01);
+ buffer[1] = secondary_address;
+ i = 2;
+ }
+ else
+ {
+ txbd->cbd_datlen = size + 1; /* Length of message plus dest address */
+ buffer[0] = address; /* Write destination address to BD */
+ buffer[0] &= ~(0x01); /* Set address to write */
+ i = 1;
+ }
+
+#ifdef CONFIG_I2C_DEBUG
+ printf("Length = %d addr[0] = %08x addr[1] = %08x\n",
+ txbd->cbd_datlen,
+ buffer[0],
+ buffer[1]);
#endif
+
+ /* Copy data to send into buffer */
+ debug("\n[I2C ] Copying data into buffer...");
+ for( j = 0; j < size; i++, j++ )
+ buffer[ i ] = dataout[j];
+
+ /* Ready to Transmit, wrap, last */
+ debug("\n[I2C ] Waiting to transmit...");
+ txbd->cbd_sc = txbd->cbd_sc | TXBD_R | TXBD_W | TXBD_L | TXBD_S ;
+
+ /* Enable I2C */
+ debug("\n[I2C ] Enabling I2C...");
+ i2c->i2c_i2mod |= 1;
+
+ /* Transmit */
+ debug("\n[I2C ] Transmitting...");
+ i2c->i2c_i2com |= 0x80;
- /* Copy data to send into buffer */
-
- PRINTD("\n[I2C ] Copying data into buffer...");
-
- for( j = 0; j < size; i++, j++ )
- txbd->addr[ i ] = dataout[j];
-
- /* Ready to Transmit, wrap, last */
-
- PRINTD("\n[I2C ] Waiting to transmit...");
-
- txbd->status = txbd->status | TXBD_R | TXBD_W | TXBD_L | TXBD_S ;
-
- /* Enable I2C */
-
- PRINTD("\n[I2C ] Enabling I2C...");
- i2c->i2c_i2mod |= 1;
-
- /* Transmit */
- PRINTD("\n[I2C ] Transmitting...");
- i2c->i2c_i2com |= 0x80;
-
- PRINTD("\n[I2C ] Waiting for transmit buffer empty...");
- udelay (DELAY_US) ; // This is a patch!
-
- while( txbd->status & TXBD_R );
-
- /* Turn off I2C */
- PRINTD("\n[I2C ] Turning off I2C...");
- i2c->i2c_i2mod &= (~1);
-
-#if DEBUG_STEP
- printf("\nTXBD->CBD_SC=%08x\n", txbd->status);
+ debug("\n[I2C ] Waiting for transmit buffer empty...");
+ udelay (DELAY_US) ; // Why without this it doesnt work?
+ while( txbd->cbd_sc & TXBD_R );
+
+ /* Turn off I2C */
+ debug("\n[I2C ] Turning off I2C...");
+ i2c->i2c_i2mod &= (~1);
- if (txbd->status & 4)
- while(1);
-#endif
+ return ERROR_I2C_NONE ;
}
-void i2c_receive(unsigned char address,
+int i2c_receive(unsigned char address,
unsigned char secondary_address,
- int enable_secondary,
+ int enable_secondary,
unsigned short size_to_expect, unsigned char datain[] )
{
- int i, j;
-
- if( size_to_expect > I2C_RX_LEN )
- return; /* Expected to receive too much */
-
- /* Turn on I2C */
- i2c->i2c_i2mod |= 0x01;
-
- /* Setup TXBD for destination address */
- if( enable_secondary )
- {
- txbd->length = 2;
- txbd->addr[0] = address | 0x00; /* Write data */
- txbd->addr[1] = secondary_address; /* Internal address */
- txbd->status = TXBD_R;
-
- /* Reset the rxbd */
- rxbd->status = RXBD_E | RXBD_W;
-
- /* Begin transmission */
- i2c->i2c_i2com |= 0x80;
-
- }
- else
- {
- txbd->length = 1 + size_to_expect;
- txbd->addr[0] = address | 0x01;
-
-
- /* Buffer ready to transmit, wrap, loop */
- txbd->status |= TXBD_R | TXBD_W | TXBD_L;
-
- /* Reset the rxbd */
- rxbd->status = RXBD_E | RXBD_W;
-
- /* Begin transmission */
- i2c->i2c_i2com |= 0x80;
-
- while( txbd->status & TXBD_R); /* Loop until transmit completed */
- }
-
- while( rxbd->status & RXBD_E); /* Wait until receive is finished */
-
- for( i= 0, j = 0; j < size_to_expect; j++, i++ ) /* Copy data to datain[] */
- datain[j] = rxbd->addr[i];
-
- /* Turn off I2C */
- i2c->i2c_i2mod &= (~1);
+ unsigned char *buffer = (unsigned char *)txbd->cbd_bufaddr ;
+ int i, j;
+
+ if( size_to_expect > I2C_RX_LEN )
+ return ERROR_I2C_LENGTH; /* Expected to receive too much */
+
+ /* Turn on I2C */
+ i2c->i2c_i2mod |= 0x01;
+
+ /* Setup TXBD for destination address */
+ if( enable_secondary )
+ {
+ txbd->cbd_datlen = 2;
+ buffer[0] = address | 0x00; /* Write data */
+ buffer[1] = secondary_address; /* Internal address */
+ txbd->cbd_sc = TXBD_R;
+
+ /* Reset the rxbd */
+ rxbd->cbd_sc = RXBD_E | RXBD_W;
+
+ /* Begin transmission */
+ i2c->i2c_i2com |= 0x80;
+ }
+ else
+ {
+ txbd->cbd_datlen = 1 + size_to_expect;
+ buffer[0] = address | 0x01;
+
+ /* Buffer ready to transmit, wrap, loop */
+ txbd->cbd_sc |= TXBD_R | TXBD_W | TXBD_L;
+
+ /* Reset the rxbd */
+ rxbd->cbd_sc = RXBD_E | RXBD_W;
+
+ /* Begin transmission */
+ i2c->i2c_i2com |= 0x80;
+
+ while( txbd->cbd_sc & TXBD_R); /* Loop until transmit completed */
+ }
+
+ while( rxbd->cbd_sc & RXBD_E); /* Wait until receive is finished */
+
+ for( i= 0, j = 0; j < size_to_expect; j++, i++ ) /* Copy data to datain[] */
+ datain[j] = buffer[i];
+
+ /* Turn off I2C */
+ i2c->i2c_i2mod &= (~1);
+
+ return ERROR_I2C_NONE ;
}
-#endif /* CONFIG_I2C */
+#endif
#if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(SCC_ENET)
-#if 0
-#define BD_OFFSET 0x860 /* offset to begin of DPRAM + allocation for serial IF*/
-#endif
-
/* Ethernet Transmit and Receive Buffers */
#define DBUF_LENGTH 1520
static RTXBD *rtx;
-
int eth_send(volatile void *packet, int length)
{
int i, j=0;
rxIdx = 0;
txIdx = 0;
- /* assign static pointer to BD area */
-#if 0
- rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + BD_OFFSET);
-#else
+#ifdef CFG_ALLOC_DPRAM
rtx = (RTXBD *) (immr->im_cpm.cp_dpmem +
- m8xx_cpm_dpalloc_align(sizeof(RTXBD), 8));
+ dpram_alloc_align(sizeof(RTXBD), 8));
+#else
+ rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + CPM_SCC_BASE);
#endif /* 0 */
#if (defined(PA_ENET_RXD) && defined(PA_ENET_TXD))
#if (!defined(CONFIG_8xx_CONS_SMC1)) && (defined(CONFIG_MPC823) || defined(CONFIG_MPC850))
volatile iop8xx_t *ip = (iop8xx_t *)&(im->im_ioport);
#endif
- uint dpaddr, dpsize, size;
+ uint dpaddr;
/* initialize pointers to SMC */
* the buffer descriptors.
*/
- dpaddr = CPM_DATAONLY_BASE;
- dpsize = CPM_DATAONLY_SIZE;
-
-#if defined(CONFIG_MBX)
- board_serial_init();
-#endif /* CONFIG_MBX */
+#ifdef CFG_ALLOC_DPRAM
+ dpaddr = dpram_alloc_align (sizeof(cbd_t)*2 + 2, 8) ;
+#else
+ dpaddr = CPM_SERIAL_BASE ;
+#endif
- /* Set the physical address of the host memory buffers in
- * the buffer descriptors.
+ /* Allocate space for two buffer descriptors in the DP ram.
+ * For now, this address seems OK, but it may have to
+ * change with newer versions of the firmware.
+ * damm: allocating space after the two buffers for rx/tx data
*/
rbdf = (cbd_t *)&cp->cp_dpmem[dpaddr];
up->smc_rfcr = SMC_EB;
up->smc_tfcr = SMC_EB;
- /* Updating dpram address and size
- */
- size = ((sizeof(cbd_t)*2 + 2) + 15) & ~15;
- dpaddr += size;
- dpsize -= size;
-
- /* Initialize CPM
- */
- m8xx_cpm_init(dpaddr, dpsize);
+#if defined(CONFIG_MBX)
+ board_serial_init();
+#endif /* CONFIG_MBX */
/* Set UART mode, 8 bit, no parity, one stop.
* Enable receive and transmit.
static void video_encoder_init (void)
{
#ifdef VIDEO_I2C
+ extern int i2c_setspeed (int speed);
+
// Initialize the I2C
PRINTD("\n[VIDEO ENCODER] Initializing I2C bus...");
- i2c_init (VIDEO_I2C_RATE);
+ i2c_setspeed (VIDEO_I2C_RATE);
#ifdef CONFIG_FADS
// Reset ADV7176 chip
/*
* Init PIT
*/
+#if defined(CFG_CLKS_IN_HZ)
+ set_pit(bd->bi_intfreq / 1000);
+#else
set_pit(bd->bi_intfreq * 1000);
+#endif /* CFG_CLKS_IN_HZ */
#endif /* CONFIG_PPC405 */
#ifdef CONFIG_ADCIOP
#define CFG_CMD_BOOTD 0x00004000 /* bootd */
#define CFG_CMD_CONSOLE 0x00008000 /* coninfo */
#define CFG_CMD_EEPROM 0x00010000 /* EEPROM read/write support */
+#define CFG_CMD_ASKENV 0x00020000 /* ask for env variable */
+#define CFG_CMD_RUN 0x00040000 /* run command in env variable */
#define CFG_CMD_ALL 0xFFFFFFFF /* ALL commands */
CFG_CMD_PCMCIA | \
CFG_CMD_PCI | \
CFG_CMD_IRQ | \
- CFG_CMD_EEPROM )
+ CFG_CMD_EEPROM | \
+ CFG_CMD_ASKENV )
/* Default configuration
*/
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CMD_TBL_IDE MK_CMD_TBL_ENTRY( \
"ide", 3, 5, 1, do_ide, \
- "ide - IDE sub-system", \
+ "ide - IDE sub-system\n", \
"reset - reset IDE controller\n" \
"ide info - show available IDE devices\n" \
"ide device [dev] - show or set current device\n" \
#define CMD_TBL_SAVEENV
#endif /* CFG_CMD_ENV */
+#if (CONFIG_COMMANDS & CFG_CMD_ASKENV)
+#define CMD_TBL_ASKENV MK_CMD_TBL_ENTRY( \
+ "askenv", 8, CFG_MAXARGS, 1, do_askenv, \
+ "askenv - get environment variables from stdin\n", \
+ "name [message] [size]\n" \
+ " - get environment variable 'name' from stdin (max 'size' chars)\n" \
+ "askenv name\n" \
+ " - get environment variable 'name' from stdin\n" \
+ "askenv name size\n" \
+ " - get environment variable 'name' from stdin (max 'size' chars)\n" \
+ "askenv name [message] size\n" \
+ " - display 'message' string and get environment variable 'name'" \
+ "from stdin (max 'size' chars)\n" \
+),
+void do_askenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+#else
+#define CMD_TBL_ASKENV
+#endif /* CFG_CMD_ASKENV */
+
+#if (CONFIG_COMMANDS & CFG_CMD_RUN)
+#define CMD_TBL_RUN MK_CMD_TBL_ENTRY( \
+ "run", 3, CFG_MAXARGS, 1, do_run, \
+ "run - run commands in an environment variable\n", \
+ "var [...]\n" \
+ " - run the commands in the environment variable(s) 'var'\n" \
+),
+void do_run (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+#else
+#define CMD_TBL_RUN
+#endif /* CFG_CMD_RUN */
+
#endif /* _CMD_NVEDIT_H */
#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
#define CMD_TBL_PINIT MK_CMD_TBL_ENTRY( \
"pinit", 4, 2, 1, do_pinit, \
- "pinit - initialize PCMCIA sub-system\n", \
- NULL \
+ "pinit - PCMCIA sub-system\n", \
+ "on - power on PCMCIA socket\n" \
+ "pinit off - power off PCMCIA socket\n" \
),
void do_pinit (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4))
+/* DPRAM defines and allocation functions
+*/
+
/* The dual ported RAM is multi-functional. Some areas can be (and are
* being) used for microcode. There is an area that can only be used
* as data ram for buffer descriptors, which is all we use right now.
* Currently the first 512 and last 256 bytes are used for microcode.
*/
+#ifdef CFG_ALLOC_DPRAM
+
#define CPM_DATAONLY_BASE ((uint)0x0800)
#define CPM_DATAONLY_SIZE ((uint)0x0700)
#define CPM_DP_NOSPACE ((uint)0x7fffffff)
+void dpram_init(void);
+uint dpram_base(void);
+uint dpram_base_align(uint align);
+uint dpram_alloc(uint size);
+uint dpram_alloc_align(uint size,uint align);
+
+#else
+
+#define CPM_SERIAL_BASE 0x0800
+#define CPM_I2C_BASE 0x0820
+#define CPM_SPI_BASE 0x0840
+#define CPM_FEC_BASE 0x0860
+#define CPM_WLKBD_BASE 0x0880
+#define CPM_SCC_BASE 0x0900
+
+#endif
+
+#define BD_IIC_START ((uint) 0x0400) // <- please use CPM_I2C_BASE !!
+
/* Export the base address of the communication processor registers
* and dual port ram.
*/
extern cpm8xx_t *cpmp; /* Pointer to comm processor */
-void m8xx_cpm_init(uint base, uint size);
-uint m8xx_cpm_dpalloc(uint size);
-uint m8xx_cpm_dpbase(void);
-uint m8xx_cpm_dpalloc_align(uint size,uint align);
-uint m8xx_cpm_dpbase_align(uint align);
-
/* Buffer descriptors used by many of the CPM protocols.
*/
typedef struct cpm_buf_desc {
ushort tmp_mb; /* temp */
} hdlc_pram_t;
-#define BD_IIC_START ((ushort)0x0400)
-
/* CPM interrupts. There are nearly 32 interrupts generated by CPM
* channels or devices. All of these are presented to the PPC core
* as a single interrupt. The CPM interrupt handler dispatches its
{ 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, \
57600, 115200, 230400, 460800, 921600 }
+#define CFG_CLKS_IN_HZ 1 /* everything, incl board info, in Hz */
+
#define CFG_LOAD_ADDR 0x100000 /* default load address */
#define CFG_EXTBDINFO 1 /* To use extended board_into (bd_t) */
/*-----------------------------------------------------------------------
* Definitions for initial stack pointer and data area (in RAM)
*/
-#define CFG_INIT_RAM_ADDR 0x8000 /* inside of SDRAM */
+#define CFG_INIT_RAM_ADDR 0x00df0000 /* inside of SDRAM */
#define CFG_INIT_RAM_END 0x0f00 /* End of used area in RAM */
#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
{ 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, \
57600, 115200, 230400, 460800, 921600 }
+#define CFG_CLKS_IN_HZ 1 /* everything, incl board info, in Hz */
+
#define CFG_LOAD_ADDR 0x100000 /* default load address */
#define CFG_EXTBDINFO 1 /* To use extended board_into (bd_t) */
* Please note that CFG_SDRAM_BASE _must_ start at 0
*/
#define CFG_SDRAM_BASE 0x00000000
-#define CFG_FLASH_BASE 0xFFFD0000
+#define CFG_FLASH_BASE 0xFFFE0000
#define CFG_MONITOR_BASE CFG_FLASH_BASE
-#define CFG_MONITOR_LEN (192 * 1024) /* Reserve 196 kB for Monitor */
+#define CFG_MONITOR_LEN (128 * 1024) /* Reserve 128 kB for Monitor */
#define CFG_MALLOC_LEN (128 * 1024) /* Reserve 128 kB for malloc() */
/*
/*-----------------------------------------------------------------------
* Definitions for initial stack pointer and data area (in RAM)
*/
-#define CFG_INIT_RAM_ADDR 0x8000 /* inside of SDRAM */
+#define CFG_INIT_RAM_ADDR 0x00df0000 /* inside of SDRAM */
#define CFG_INIT_RAM_END 0x0f00 /* End of used area in RAM */
#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
{ 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, \
57600, 115200, 230400, 460800, 921600 }
+#define CFG_CLKS_IN_HZ 1 /* everything, incl board info, in Hz */
+
#define CFG_LOAD_ADDR 0x100000 /* default load address */
#define CFG_EXTBDINFO 1 /* To use extended board_into (bd_t) */
/*-----------------------------------------------------------------------
* Definitions for initial stack pointer and data area (in DPRAM)
*/
-#define CFG_INIT_RAM_ADDR 0x8000 /* inside of SDRAM */
+#define CFG_INIT_RAM_ADDR 0x00df0000 /* inside of SDRAM */
#define CFG_INIT_RAM_END 0x0f00 /* End of used area in RAM */
#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
#define CONFIG_VIDEO 1 // To enable video controller support
#define CONFIG_I2C 1 // To enable I2C support
-#define CONFIG_PCMCIA 1 // To enable PCMCIA support
+//Now included by CFG_CMD_PCMCIA
+//#define CONFIG_PCMCIA 1 // To enable PCMCIA support
/* Video related */
#define __CONFIG_H
#define CONFIG_ETHADDR 08:00:22:50:70:63 // Ethernet address
-#define CONFIG_ENV_OVERWRITE 1 // Overwrite the environment
+#define CONFIG_ENV_OVERWRITE 1 // Overwrite the environment
-#define CONFIG_VIDEO 1 // To enable the video initialization
-#define CONFIG_VIDEO_ADDR 0x00200000
-#define CONFIG_I2C 1 // Needed for 7176 & 7177
-#define CONFIG_PCMCIA 1 // To enable the PCMCIA initialization
+#define CFG_ALLOC_DPRAM // Use dynamic DPRAM allocation
-#define CFG_PCMCIA_IO_ADDR 0xff020000
-#define CFG_PCMCIA_IO_SIZE 0x10000
-#define CFG_PCMCIA_MEM_ADDR 0xe0000000
-#define CFG_PCMCIA_MEM_SIZE 0x10000
+#define CFG_AUTOLOAD "n" // No autoload
+
+//#define CONFIG_VIDEO 1 // To enable the video initialization
+//#define CONFIG_VIDEO_ADDR 0x00200000
+//#define CONFIG_I2C 1 // Needed for 7176 & 7177
+//#define CONFIG_PCMCIA 1 // To enable the PCMCIA initialization
+
+//#define CFG_PCMCIA_IO_ADDR 0xff020000
+//#define CFG_PCMCIA_IO_SIZE 0x10000
+//#define CFG_PCMCIA_MEM_ADDR 0xe0000000
+//#define CFG_PCMCIA_MEM_SIZE 0x10000
/* Video related */
-#define CONFIG_VIDEO_LOGO 1 // Show the logo
-#define CONFIG_VIDEO_ENCODER_AD7177 1 // Enable this encoder
-#define CONFIG_VIDEO_ENCODER_AD7177_ADDR 0xF4 // ALSB to ground
+//#define CONFIG_VIDEO_LOGO 1 // Show the logo
+//#define CONFIG_VIDEO_ENCODER_AD7177 1 // Enable this encoder
+//#define CONFIG_VIDEO_ENCODER_AD7177_ADDR 0xF4 // ALSB to ground
/* Wireless 56Khz 4PPM keyboard on SMCx */
-#define CONFIG_WL_4PPM_KEYBOARD 0
-#define CONFIG_WL_4PPM_KEYBOARD_SMC 0 // SMC to use (0 indexed)
+//#define CONFIG_WL_4PPM_KEYBOARD 0
+//#define CONFIG_WL_4PPM_KEYBOARD_SMC 0 // SMC to use (0 indexed)
/*
* High Level Configuration Options
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
#undef CONFIG_8xx_CONS_NONE
-#define CONFIG_BAUDRATE 4800
+#define CONFIG_BAUDRATE 9600
-#if 0 // Debugging
-#define MPC8XX_FACT 5 /* Multiply by 5 */
-#else
#define MPC8XX_FACT 12 /* Multiply by 12 */
-#endif
-#define MPC8XX_XIN 4000000 /* 4 MHz clock */
+#define MPC8XX_XIN 5000000 /* 4 MHz clock */
#define MPC8XX_HZ ((MPC8XX_XIN) * (MPC8XX_FACT))
#define CFG_PLPRCR_MF ((MPC8XX_FACT-1) << 20)
#define CONFIG_LOADS_ECHO 0 /* Dont echoes received characters */
#define CONFIG_BOOTARGS ""
#define CONFIG_BOOTCOMMAND \
-"bootp ;" \
+"bootp; tftp; " \
"setenv bootargs console=tty0 console=ttyS0 " \
"root=/dev/nfs nfsroot=$(serverip):$(rootpath) " \
"ip=$(ipaddr):$(serverip):$(gatewayip):$(subnetmask):$(hostname):eth0:off ;" \
#else
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 128 kB for Monitor */
#endif
-#undef CFG_MONITOR_BASE 0x200000 /* to run ppcboot from RAM */
+#undef CFG_MONITOR_BASE /* 0x200000 to run ppcboot from RAM */
#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
#endif
-#undef CONFIG_BOOTARGS
+#define CONFIG_ETHADDR 00:D0:93:00:05:B5
+
+#undef CONFIG_BOOTARGS
#define CONFIG_BOOTCOMMAND \
"bootp; " \
"setenv bootargs root=/dev/nfs rw nfsroot=$(serverip):$(rootpath) " \
"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \
- "bootm"
+ "bootm"
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_FLASH_BASE 0x40000000
-#ifdef DEBUG
+#if defined(DEBUG) || (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#define CFG_PCMCIA_IO_SIZE ( 64 << 20 )
/*-----------------------------------------------------------------------
- *
+ * IDE/ATA stuff (Supports IDE harddisk on PCMCIA Adapter)
+ *-----------------------------------------------------------------------
+ */
+
+#define CONFIG_IDE_PCCARD 1 /* Use IDE with PC Card Adapter */
+
+#undef CONFIG_IDE_PCMCIA /* Direct IDE not supported */
+#undef CONFIG_IDE_LED /* LED for ide not supported */
+#undef CONFIG_IDE_RESET /* reset for ide not supported */
+
+#define CFG_IDE_MAXBUS 1 /* max. 1 IDE bus */
+#define CFG_IDE_MAXDEVICE 1 /* max. 1 drive per IDE bus */
+
+#define CFG_ATA_IDE0_OFFSET 0x0000
+#define CFG_ATA_IDE1_OFFSET 0x0C00
+
+#define CFG_ATA_BASE_ADDR CFG_PCMCIA_MEM_ADDR
+
+/* Offset for data I/O */
+#define CFG_ATA_DATA_OFFSET (CFG_PCMCIA_MEM_SIZE + 0x320)
+
+/* Offset for normal register accesses */
+#define CFG_ATA_REG_OFFSET (2 * CFG_PCMCIA_MEM_SIZE + 0x320)
+
+/* Offset for alternate registers */
+#define CFG_ATA_ALT_OFFSET 0x0100
+
+/*-----------------------------------------------------------------------
+ *
*-----------------------------------------------------------------------
*
*/
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_FLASH_BASE 0x40000000
-#ifdef DEBUG
+#if defined(DEBUG) || (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_FLASH_BASE 0x40000000
-#ifdef DEBUG
+#if defined(DEBUG) || (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_FLASH_BASE 0x40000000
-#ifdef DEBUG
+#if defined(DEBUG) || (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#define CFG_PCMCIA_IO_ADDR (0xEC000000)
#define CFG_PCMCIA_IO_SIZE ( 64 << 20 )
+/*-----------------------------------------------------------------------
+ * IDE/ATA stuff (Supports IDE harddisk on PCMCIA Adapter)
+ *-----------------------------------------------------------------------
+ */
+
+#define CONFIG_IDE_PCCARD 1 /* Use IDE with PC Card Adapter */
+
+#undef CONFIG_IDE_PCMCIA /* Direct IDE not supported */
+#undef CONFIG_IDE_LED /* LED for ide not supported */
+#undef CONFIG_IDE_RESET /* reset for ide not supported */
+
+#define CFG_IDE_MAXBUS 1 /* max. 1 IDE bus */
+#define CFG_IDE_MAXDEVICE 1 /* max. 1 drive per IDE bus */
+
+#define CFG_ATA_IDE0_OFFSET 0x0000
+#define CFG_ATA_IDE1_OFFSET 0x0C00
+
+#define CFG_ATA_BASE_ADDR CFG_PCMCIA_MEM_ADDR
+
+/* Offset for data I/O */
+#define CFG_ATA_DATA_OFFSET (CFG_PCMCIA_MEM_SIZE + 0x320)
+
+/* Offset for normal register accesses */
+#define CFG_ATA_REG_OFFSET (2 * CFG_PCMCIA_MEM_SIZE + 0x320)
+
+/* Offset for alternate registers */
+#define CFG_ATA_ALT_OFFSET 0x0100
+
/*-----------------------------------------------------------------------
*
*-----------------------------------------------------------------------
#if (CMA_MB_CAPS & CMA_MB_CAP_SER2) && !(CMA_MB_CAPS & CMA_MB_CAP_SERPAR)
#error 2nd dual serial capability defined without serial/parallel capability
#endif
-
#include <board/cogent/mb.h>
-
#endif /* _CONFIG_COGENT_COMMON_H */
* (second 2 for CMA120 only)
*/
#define CFG_CMA_MB_BASE 0x00000000 /* base of m/b address space */
+
#include <config_cogent_common.h>
+
#define CFG_CMA_CONS_SERIAL /* use Cogent motherboard serial for console */
#define CONFIG_CONS_INDEX 1
#define CFG_CMA_LCD_HEARTBEAT /* define for sec rotator in lcd corner */
#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+#define CFG_ALLOC_DPRAM 1 /* use allocation routines */
/*
* Low Level Configuration Settings
* (address mappings, register initial values, etc.)
#define CONFIG_BAUDRATE 9600
#endif
-#define CONFIG_COMMANDS (CFG_CMD_ALL & \
- ~(CFG_CMD_NET|CFG_CMD_KGDB|CFG_CMD_IDE|CFG_CMD_PCI|CFG_CMD_EEPROM))
+#define CONFIG_COMMANDS (CFG_CMD_ALL & ~( \
+ CFG_CMD_NET | \
+ CFG_CMD_KGDB | \
+ CFG_CMD_IDE | \
+ CFG_CMD_PCMCIA | \
+ CFG_CMD_PCI | \
+ CFG_CMD_EEPROM ))
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
/*
* (C) Copyright 2000
* Murray Jensen <Murray.Jensen@cmst.csiro.au>
- *
+ *
* (C) Copyright 2000
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
* Configuation settings for the R&S Protocol Board board.
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
#undef CONFIG_CONS_NONE /* define if console on neither */
#define CONFIG_CONS_INDEX 1 /* which SMC/SCC channel for console */
-/*
+/*
* select ethernet configuration
*
* if either CONFIG_ETHER_ON_SCC or CONFIG_ETHER_ON_FCC is selected, then
#undef CONFIG_ETHER_NONE /* define if ethernet on neither */
#define CONFIG_ETHER_INDEX 2 /* which SCC/FCC channel for ethernet */
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+
/* enable I2C */
#define CONFIG_I2C 1
#define CFG_IMMR PHYS_IMMR
-/* turn off NVRAM env feature */
-#undef CONFIG_NVRAM_ENV
+/*-----------------------------------------------------------------------
+ * Reset Address
+ *
+ * In order to reset the CPU, ppcboot jumps to a special address which
+ * causes a machine check exception. The default address for this is
+ * CFG_MONITOR_BASE - sizeof (ulong), which might not always work, eg. when
+ * testing the monitor in RAM using a JTAG debugger.
+ *
+ * Just set CFG_RESET_ADDRESS to an address that you know is sure to
+ * cause a bus error on your hardware.
+ */
+#define CFG_RESET_ADDRESS 0x20000000
/*-----------------------------------------------------------------------
* Hard Reset Configuration Words
#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
/*-----------------------------------------------------------------------
- * FLASH organization
+ * FLASH and environment organization
*/
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
#define CFG_MAX_FLASH_SECT 63 /* max number of sectors on one chip */
#define CFG_FLASH_ERASE_TOUT 12000 /* Timeout for Flash Erase (in ms) */
#define CFG_FLASH_WRITE_TOUT 3000 /* Timeout for Flash Write (in ms) */
+/* turn off NVRAM env feature */
+#undef CONFIG_NVRAM_ENV
+
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_ADDR (PHYS_FLASH + 0x8000) /* Addr of Environment Sector */
#define CFG_ENV_SECT_SIZE 0x8000 /* Total Size of Environment Sector */
* HID1 has only read-only information - nothing to set.
*/
#define CFG_HID0_INIT (HID0_ICE|HID0_DCE|HID0_ICFI|HID0_DCI|HID0_IFEM|HID0_ABE)
-#define CFG_HID0_FINAL (HID0_ICE|HID0_IFEM|HID0_ABE)
+#define CFG_HID0_FINAL (HID0_ICE|HID0_IFEM|HID0_ABE|HID0_EMCP)
#define CFG_HID2 0
/*-----------------------------------------------------------------------
*/
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_PBME | SYPCR_LBME | \
SYPCR_SWRI | SYPCR_SWP)
-
+
/*-----------------------------------------------------------------------
* TMCNTSC - Time Counter Status and Control 4-40
*-----------------------------------------------------------------------
#else /* !CONFIG_MPC8260 */
-void i2c_init(int speed);
-void i2c_send( unsigned char address,
+int i2c_init(void);
+int i2c_send( unsigned char address,
unsigned char secondary_address,
int enable_secondary,
unsigned short size, unsigned char dataout[] );
-void i2c_receive(unsigned char address,
+int i2c_receive(unsigned char address,
unsigned char secondary_address,
int enable_secondary,
unsigned short size_to_expect, unsigned char datain[] );
#endif
+#define ERROR_I2C_NONE 0
+#define ERROR_I2C_LENGTH 1
+
#endif
* MA 02111-1307 USA
*/
-#ifndef _PCMCIA_H
+#ifndef _PCMCIA_H
#define _PCMCIA_H
#include <ppcboot.h>
#include <config.h>
-#ifdef CONFIG_IDE_PCMCIA
/*
* Allow configuration to select PCMCIA slot,
* or try to generate a useful default
*/
+#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
+ ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_PCCARD))
+
#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
/* The RPX series use SLOT_B */
# define CONFIG_PCMCIA_SLOT_B
# endif
#elif defined(CONFIG_TQM860L) || defined(CONFIG_TQM855L) /* The TQM8xxL modules */
-# define CONFIG_PCMCIA_SLOT_A /* ... use SLOT_A on MPC860/855 */
+# define CONFIG_PCMCIA_SLOT_A /* ... use SLOT_A on MPC860/855 */
#elif defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L)
# define CONFIG_PCMCIA_SLOT_B /* ... and SLOT_B else */
#elif defined(CONFIG_SPD823TS) /* The SPD8xx use SLOT_B */
#error Both CONFIG_PCMCIA_SLOT_A and CONFIG_PCMCIA_SLOT_B configured
#endif
+#endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_PCCARD) */
+
#define PCMCIA_SOCKETS_NO 1
#define PCMCIA_MEM_WIN_NO 4
#define PCMCIA_IO_WIN_NO 2
/* define _slot_ to be able to optimize macros */
#ifdef CONFIG_PCMCIA_SLOT_A
# define _slot_ 0
-# define PCMCIA_SLOT_MSG "SLOT_A"
+# define PCMCIA_SLOT_MSG "slot A"
# define PCMCIA_SLOT_x PCMCIA_PSLOT_A
#else
# define _slot_ 1
-# define PCMCIA_SLOT_MSG "SLOT_B"
+# define PCMCIA_SLOT_MSG "slot B"
# define PCMCIA_SLOT_x PCMCIA_PSLOT_B
#endif
#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXOE
#endif
-/* look up table for pgcrx registers */
-
-#if 0
-static u_int *pcmcia_pgcrx[2] = {
- &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
- &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
-};
-
-#define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
-#endif
-
/*
* This structure is used to address each window in the PCMCIA controller.
*
ulong or;
} pcmcia_win_t;
-#endif /* CONFIG_IDE_PCMCIA */
-
/*
* Definitions for PCMCIA control registers to operate in IDE mode
*
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR0 0xFE100000
+#define CFG_PCMCIA_PBR0 0xFE100000
#define CFG_PCMCIA_POR0 ( PCMCIA_BSIZE_2 \
| PCMCIA_PPS_16 \
| PCMCIA_PRS_MEM \
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR1 0xFE100080
+#define CFG_PCMCIA_PBR1 0xFE100080
#define CFG_PCMCIA_POR1 ( PCMCIA_BSIZE_8 \
| PCMCIA_PPS_8 \
| PCMCIA_PRS_MEM \
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR2 0xFE100100
+#define CFG_PCMCIA_PBR2 0xFE100100
#define CFG_PCMCIA_POR2 ( PCMCIA_BSIZE_8 \
| PCMCIA_PPS_8 \
| PCMCIA_PRS_MEM \
/* Window 3:
* not used
*/
-#define CFG_PCMCIA_PBR3 0
-#define CFG_PCMCIA_POR3 0
+#define CFG_PCMCIA_PBR3 0
+#define CFG_PCMCIA_POR3 0
/* Window 4:
* Base: 0xFE100C00 CS1
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR4 0xFE100C00
+#define CFG_PCMCIA_PBR4 0xFE100C00
#define CFG_PCMCIA_POR4 ( PCMCIA_BSIZE_2 \
| PCMCIA_PPS_16 \
| PCMCIA_PRS_MEM \
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR5 0xFE100C80
+#define CFG_PCMCIA_PBR5 0xFE100C80
#define CFG_PCMCIA_POR5 ( PCMCIA_BSIZE_8 \
| PCMCIA_PPS_8 \
| PCMCIA_PRS_MEM \
* Common Memory Space
*/
-#define CFG_PCMCIA_PBR6 0xFE100D00
+#define CFG_PCMCIA_PBR6 0xFE100D00
#define CFG_PCMCIA_POR6 ( PCMCIA_BSIZE_8 \
| PCMCIA_PPS_8 \
| PCMCIA_PRS_MEM \
/* Window 7:
* not used
*/
-#define CFG_PCMCIA_PBR7 0
-#define CFG_PCMCIA_POR7 0
+#define CFG_PCMCIA_PBR7 0
+#define CFG_PCMCIA_POR7 0
+
+/**********************************************************************/
+
+/*
+ * CIS Tupel codes
+ */
+#define CISTPL_NULL 0x00
+#define CISTPL_DEVICE 0x01
+#define CISTPL_LONGLINK_CB 0x02
+#define CISTPL_INDIRECT 0x03
+#define CISTPL_CONFIG_CB 0x04
+#define CISTPL_CFTABLE_ENTRY_CB 0x05
+#define CISTPL_LONGLINK_MFC 0x06
+#define CISTPL_BAR 0x07
+#define CISTPL_PWR_MGMNT 0x08
+#define CISTPL_EXTDEVICE 0x09
+#define CISTPL_CHECKSUM 0x10
+#define CISTPL_LONGLINK_A 0x11
+#define CISTPL_LONGLINK_C 0x12
+#define CISTPL_LINKTARGET 0x13
+#define CISTPL_NO_LINK 0x14
+#define CISTPL_VERS_1 0x15
+#define CISTPL_ALTSTR 0x16
+#define CISTPL_DEVICE_A 0x17
+#define CISTPL_JEDEC_C 0x18
+#define CISTPL_JEDEC_A 0x19
+#define CISTPL_CONFIG 0x1a
+#define CISTPL_CFTABLE_ENTRY 0x1b
+#define CISTPL_DEVICE_OC 0x1c
+#define CISTPL_DEVICE_OA 0x1d
+#define CISTPL_DEVICE_GEO 0x1e
+#define CISTPL_DEVICE_GEO_A 0x1f
+#define CISTPL_MANFID 0x20
+#define CISTPL_FUNCID 0x21
+#define CISTPL_FUNCE 0x22
+#define CISTPL_SWIL 0x23
+#define CISTPL_END 0xff
+
+/*
+ * CIS Function ID codes
+ */
+#define CISTPL_FUNCID_MULTI 0x00
+#define CISTPL_FUNCID_MEMORY 0x01
+#define CISTPL_FUNCID_SERIAL 0x02
+#define CISTPL_FUNCID_PARALLEL 0x03
+#define CISTPL_FUNCID_FIXED 0x04
+#define CISTPL_FUNCID_VIDEO 0x05
+#define CISTPL_FUNCID_NETWORK 0x06
+#define CISTPL_FUNCID_AIMS 0x07
+#define CISTPL_FUNCID_SCSI 0x08
+
+/*
+ * Fixed Disk FUNCE codes
+ */
+#define CISTPL_IDE_INTERFACE 0x01
+
+#define CISTPL_FUNCE_IDE_IFACE 0x01
+#define CISTPL_FUNCE_IDE_MASTER 0x02
+#define CISTPL_FUNCE_IDE_SLAVE 0x03
+
+/* First feature byte */
+#define CISTPL_IDE_SILICON 0x04
+#define CISTPL_IDE_UNIQUE 0x08
+#define CISTPL_IDE_DUAL 0x10
+
+/* Second feature byte */
+#define CISTPL_IDE_HAS_SLEEP 0x01
+#define CISTPL_IDE_HAS_STANDBY 0x02
+#define CISTPL_IDE_HAS_IDLE 0x04
+#define CISTPL_IDE_LOW_POWER 0x08
+#define CISTPL_IDE_REG_INHIBIT 0x10
+#define CISTPL_IDE_HAS_INDEX 0x20
+#define CISTPL_IDE_IOIS16 0x40
#endif /* _PCMCIA_H */
* ppcboot starts it up.
*/
typedef struct bd_info {
-#ifdef CFG_EXTBDINFO
- unsigned char bi_s_version[4]; /* Version of this structure */
-#endif
unsigned long bi_memstart; /* start of DRAM memory */
unsigned long bi_memsize; /* size of DRAM memory in bytes */
unsigned long bi_flashstart; /* start of FLASH memory */
unsigned long bi_vco; /* VCO Out from PLL, in MHz */
#endif
unsigned long bi_baudrate; /* Console Baudrate */
-#ifdef CFG_EXTBDINFO
+#if defined(CONFIG_PPC405)
+ unsigned char bi_s_version[4]; /* Version of this structure */
unsigned char bi_r_version[32]; /* Version of the ROM (IBM) */
unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */
unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */
unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
+ unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */
#endif
mon_fnc_t *bi_mon_fnc; /* Pointer to monitor functions */
} bd_t;
unsigned long env_valid; /* Checksum of Environment valid? */
unsigned long relocated; /* Relocat. offset when running in RAM */
mon_fnc_t bi_mon_fnc; /* Monitor functions */
-#ifdef CONFIG_8xx
+#ifdef CFG_ALLOC_DPRAM
unsigned int dp_alloc_base;
unsigned int dp_alloc_top;
#endif
int ftstc(int file);
int fgetc(int file);
-#ifdef CONFIG_PCMCIA
int pcmcia_init (void);
-#endif
#endif /* _PPCBOOT_H_ */
#ifndef __VERSION_H__
#define __VERSION_H__
-#define PPCBOOT_VERSION "ppcboot 0.7.2"
+#define PPCBOOT_VERSION "ppcboot 0.7.3"
#endif /* __VERSION_H__ */
static void ArpHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len);
static void ArpTimeout(void);
-int ArpTry;
+int ArpTry = 0;
/*
* Handle a ARP received packet.
include $(TOPDIR)/config.mk
-BINS = img2srec mkimage
+BINS = img2srec mkimage envcrc
-OBJS = img2srec.o mkimage.o crc32.o
+OBJS = img2srec.o mkimage.o crc32.o envcrc.o
TOOLSUBDIRS = gdb
#
# Use native tools and options
#
-CPPFLAGS = -Wall -pedantic -O
-CFLAGS = $(CPPFLAGS) -I../include
+CPPFLAGS = -Wall -pedantic -I../include -I..
+CFLAGS = $(CPPFLAGS) -O
CC = $(HOSTCC)
MAKEDEPEND = makedepend
all: .depend $(BINS) subdirs
+envcrc: envcrc.o crc32.o environment.o
+ $(CC) $(CFLAGS) -o $@ $^
+
+environment.S: ../common/environment.S
+ ln -sf $^ $@
+
img2srec: img2srec.o
$(CC) $(CFLAGS) -s -o $@ $^
mkimage: mkimage.o crc32.o
$(CC) -g $(CFLAGS) -o $@ $^
+envcrc.o: envcrc.c
+ $(CC) -g $(CFLAGS) -c $<
+
crc32.o: crc32.c
$(CC) -g $(CFLAGS) -c $<
#########################################################################
.depend: Makefile $(OBJS:.o=.c)
- $(CC) -M $(CPPFLAGS) -I../include $(OBJS:.o=.c) > $@
+ $(CC) -M $(CPPFLAGS) $(OBJS:.o=.c) > $@
sinclude .depend
--- /dev/null
+/*
+ * (C) Copyright 2001
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define __ASSEMBLY__ /* Dirty trick to get only #defines */
+#include <config.h>
+#undef __ASSEMBLY__
+
+#if defined(CFG_ENV_IS_IN_FLASH)
+# ifndef CFG_ENV_ADDR
+# define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
+# endif
+# ifndef CFG_ENV_OFFSET
+# define CFG_ENV_OFFSET (CFG_ENV_ADDR - CFG_FLASH_BASE)
+# endif
+# ifndef CFG_ENV_SIZE
+# define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
+# endif
+# if (CFG_ENV_ADDR >= CFG_FLASH_BASE) && \
+ (CFG_ENV_ADDR+CFG_ENV_SIZE) <= (CFG_FLASH_BASE + CFG_MONITOR_LEN)
+# define ENV_IS_EMBEDDED
+# endif
+#endif /* CFG_ENV_IS_IN_FLASH */
+
+extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
+
+#ifdef ENV_IS_EMBEDDED
+extern unsigned int env_size ;
+extern unsigned char environment ;
+extern unsigned char env_data ;
+#endif /* ENV_IS_EMBEDDED */
+
+int main (int argc, char **argv)
+{
+#ifdef ENV_IS_EMBEDDED
+ int crc ;
+ unsigned char *envptr = &environment,
+ *dataptr = &env_data;
+ unsigned int datasize = env_size - (dataptr - envptr) ;
+
+ crc = crc32(0, dataptr, datasize) ;
+
+ // Check if verbose mode is activated passing a parameter to the program
+ if (argc > 1) {
+ printf("CRC32 from offset %08X to %08X of environment = %08X\n",
+ (unsigned int)(dataptr - envptr),
+ (unsigned int)(dataptr - envptr) + datasize,
+ crc);
+ } else {
+ printf("0x%08X\n", crc);
+ }
+#else
+ printf("0\n");
+#endif
+ return EXIT_SUCCESS;
+}