Make autocomplete work with HUSH parser too.
PATCH 1/8 Make autocomplete work with HUSH parser too.
Auto complete did not work when the HUSH parser was selected. Fix this obvious problem.
---
---
README | 4 ---- common/main.c | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-)
README +0 -4
@@ -1511,10 +1511,6 @@ The following options need to be configured: Enable auto completion of commands using TAB. - Note that this feature has NOT been implemented yet - for the "hush" shell. - - CFG_HUSH_PARSER Define this variable to enable the "hush" shell (from
common/main.c +23 -2
@@ -718,10 +718,11 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num } } -static int cread_line (char *buf,unsigned int *len) +static int cread_line (const char *const prompt,char *buf,unsigned int *len) {unsigned long num =0 ;unsigned long eol_num =0 ; +int num2, col;unsigned long rlen;unsigned long wlen;char ichar;
@@ -840,6 +841,7 @@ static int cread_line(char *buf, unsigned int *len) insert = !insert;break ;case CTL_CH ('x' ): +case CTL_CH ('u' ):/* like that too */ BEGINNING_OF_LINE ();ERASE_TO_EOL ();break ;
@@ -889,6 +891,25 @@ static int cread_line(char *buf, unsigned int *len)REFRESH_TO_EOL ();continue ; } +#ifdef CONFIG_AUTO_COMPLETE +case '\t' : + +/* do not autocomplete when in the middle */ +if (num < eol_num) { +getcmd_cbeep (); +break ; + } + + buf[num] ='\0' ; + col =strlen (prompt) + eol_num; + num2 = num; +if (cmd_auto_complete (prompt, buf, &num2, &col)) { + col = num2 - num; + num += col; + eol_num += col; + } +break ; +#endif default :cread_add_char (ichar, insert, &num, &eol_num, buf, *len);break ;
@@ -931,7 +952,7 @@ int readline (const char *const prompt)puts (prompt); - rc =cread_line (p, &len); + rc =cread_line (prompt, p, &len);return rc <0 ? rc : len;#else char *p = console_buffer;
PATCH 2/8 Support LATTICE FPGA parts using JTAG programming. Interface to FPGA API.
Add support for Lattice FPGA parts programmed using JTAG.
---
---
common/Makefile | 4 common/fpga.c | 30 +++ common/lattice.c | 218 ++++++++++++++++++++++++ common/lattice_ec.c | 461 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/fpga.h | 3 include/lattice.h | 85 +++++++++ include/lattice_ec.h | 85 +++++++++ 7 files changed, 884 insertions(+), 2 deletions(-)
common/Makefile +3 -1
@@ -47,7 +47,9 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ env_nvram.o env_nowhere.o \ exports.o \ flash.o fpga.o ft_build.o \ - hush.o kgdb.o lcd.o lists.o lynxkdi.o \ + hush.o kgdb.o \ + lattice.o lattice_ec.o lattice_ivm_core.o lattice_ivm_supp.o \ + lcd.o lists.o lynxkdi.o \ memsize.o miiphybb.o miiphyutil.o \ s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \ usb.o usb_kbd.o usb_storage.o \
common/fpga.c +30 -0
@@ -28,6 +28,7 @@#include <common.h> /* core U-Boot definitions */ #include <xilinx.h> /* xilinx specific definitions */ #include <altera.h> /* altera specific definitions */ +#include <lattice.h> /* lattice specific definitions */ #if defined(CONFIG_FPGA )
@@ -150,6 +151,14 @@ static int fpga_dev_info( int devnum )fpga_no_sup ( (char *)__FUNCTION__,"Altera devices" );#endif break ; +case fpga_lattice: +#if CONFIG_FPGA &CFG_FPGA_LATTICE +printf ("Lattice Device\nDescriptor @ 0x%p\n" , desc ); + ret_val =lattice_info ( desc->devdesc ); +#else +fpga_no_sup ( __FUNCTION__,"Lattice devices" ); +#endif +break ;default :printf ("%s: Invalid or unsupported device type %d\n" , __FUNCTION__, desc->devtype );
@@ -188,6 +197,13 @@ int fpga_reloc( fpga_type devtype, void *desc, ulong reloc_off )fpga_no_sup ( (char *)__FUNCTION__,"Altera devices" );#endif break ; +case fpga_lattice: +#if CONFIG_FPGA &CFG_FPGA_LATTICE + ret_val =lattice_reloc ( desc, reloc_off ); +#else +fpga_no_sup ( __FUNCTION__,"Lattice devices" ); +#endif +break ;default :printf ("%s: Invalid or unsupported device type %d\n" , __FUNCTION__, devtype );
@@ -281,6 +297,13 @@ int fpga_load( int devnum, void *buf, size_t bsize )fpga_no_sup ( (char *)__FUNCTION__,"Altera devices" );#endif break ; +case fpga_lattice: +#if CONFIG_FPGA &CFG_FPGA_LATTICE + ret_val =lattice_load ( desc->devdesc, buf, bsize ); +#else +fpga_no_sup ( __FUNCTION__,"Lattice devices" ); +#endif +break ;default :printf ("%s: Invalid or unsupported device type %d\n" , __FUNCTION__, desc->devtype );
@@ -314,6 +337,13 @@ int fpga_dump( int devnum, void *buf, size_t bsize )fpga_no_sup ( (char *)__FUNCTION__,"Altera devices" );#endif break ; +case fpga_lattice: +#if CONFIG_FPGA &CFG_FPGA_LATTICE + ret_val =lattice_dump ( desc->devdesc, buf, bsize ); +#else +fpga_no_sup ( __FUNCTION__,"Lattice devices" ); +#endif +break ;default :printf ("%s: Invalid or unsupported device type %d\n" , __FUNCTION__, desc->devtype );
common/lattice.c new file +218 -0
218 lines not on this page · raw message
common/lattice_ec.c new file +461 -0
461 lines not on this page · raw message
include/fpga.h +2 -1
@@ -47,7 +47,7 @@/* FPGA Manufacturer bits in CONFIG_FPGA */ #define CFG_FPGA_XILINX CFG_FPGA_MAN( 0x1 )#define CFG_FPGA_ALTERA CFG_FPGA_MAN( 0x2 ) - +#define CFG_FPGA_LATTICE CFG_FPGA_MAN( 0x4 )/* fpga_xxxx function return value definitions */ #define FPGA_SUCCESS 0
@@ -61,6 +61,7 @@ typedef enum { /* typedef fpga_type */ fpga_min_type,/* range check value */ fpga_xilinx,/* Xilinx Family) */ fpga_altera,/* unimplemented */ + fpga_lattice,/* lattice */ fpga_undefined /* invalid range check value */ } fpga_type;/* end, typedef fpga_type */
include/lattice.h new file +85 -0
85 lines not on this page · raw message
include/lattice_ec.h new file +85 -0
85 lines not on this page · raw message
PATCH 3/8 Support LATTICE FPGA parts using JTAG programming. JTAG core.
In reply to Pantelis AntoniouAdd support for Lattice FPGA parts programmed using JTAG.
---
---
common/lattice_ivm_core.c | 750 ++++++++++++++++++++++++++++++++++++++++++++ include/lattice_ivm_core.h | 214 +++++++++++++ include/lattice_vmopcode.h | 286 +++++++++++++++++ 3 files changed, 1250 insertions(+), 0 deletions(-)
common/lattice_ivm_core.c new file +750 -0
@@ -0,0 +1,750 @@ +/* +* (C) Copyright 2006 - Embedded Alley Solutions Inc. +* by Pantelis Antoniou, pantelis at embeddedalley.com +* +* Based on redboot's lattice_ivm_core.c +* +* This file was based on ASP8347DB's redboot sources +* with the same name. The file was not carrying any copyright +* markings while RedBoot is clearly GPL licensed. + +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +*/ + +#include <common.h> +#include <malloc.h> +#include <lattice.h> +#include <lattice_ec.h> + +#include <lattice_ivm_core.h> +#include <lattice_vmopcode.h> + +#if (CONFIG_FPGA &CFG_FPGA_LATTICE ) + +/* Enable/Disable debug console messages */ +#ifdef FPGA_DEBUG +#define PRINTF(fmt,args...) printf (fmt ,##args) +#else +#define PRINTF(fmt,args...) +#endif + +/* +* Reset all global variables to a known state, as this code may be +* reused (but not reloaded) +*/ +void ispvm_reset (struct ispvm_desc *d,void *input_cookie) +{ + d->cookie = input_cookie; + + d->flow_control =0x0000 ; + d->data_type =0x0000 ; + d->end_DR =DRPAUSE ; + d->end_IR =IRPAUSE ; + d->head_DR =0 ; + d->head_IR =0 ; + d->tail_DR =0 ; + d->tail_IR =0 ; + d->data_size =0 ; + d->frequency =1000 ; + d->max_size =0 ; + d->shift_value =0 ; + d->repeat_loops =0 ; + d->vendor =LATTICE ; + d->current_jtag_state =0 ; + d->heap_memory =NULL ; + d->heap_counter =0 ; + d->intel_data_idx =0 ; + d->intel_buffer_size =0 ; + d->TDO_size =0 ; + d->MASK_size =0 ; + d->TDI_size =0 ; + d->DMASK_size =0 ; + d->LCOUNT_size =0 ; + d->HDR_size =0 ; + d->TDR_size =0 ; + d->HIR_size =0 ; + d->TIR_size =0 ; + d->HEAP_size =0 ; + +if (d->out_MASK_data) +free (d->out_MASK_data); +if (d->in_TDI_data) +free (d->in_TDI_data); +if (d->out_TDO_data) +free (d->out_TDO_data); +if (d->HIR_data) +free (d->HIR_data); +if (d->TIR_data) +free (d->TIR_data); +if (d->HDR_data) +free (d->HDR_data); +if (d->TDR_data) +free (d->TDR_data); +if (d->intel_buffer) +free (d->intel_buffer); +if (d->out_DMASK_data) +free (d->out_DMASK_data); +if (d->LVDS_list) +free (d->LVDS_list); + + d->out_MASK_data =NULL ; + d->in_TDI_data =NULL ; + d->out_TDO_data =NULL ; + d->HIR_data =NULL ; + d->TIR_data =NULL ; + d->HDR_data =NULL ; + d->TDR_data =NULL ; + d->intel_buffer =NULL ; + d->out_DMASK_data =NULL ; + d->LVDS_list =NULL ; + + d->out_MASK_data_size =0 ; + d->in_TDI_data_size =0 ; + d->out_TDO_data_size =0 ; + d->HIR_data_size =0 ; + d->TIR_data_size =0 ; + d->HDR_data_size =0 ; + d->TDR_data_size =0 ; + d->intel_buffer_alloc_size =0 ; + d->out_DMASK_data_size =0 ; + d->LVDS_list_size =0 ; + + d->LVDS_pair_count =0 ; +} + +/* Enable the port to the device and set the state to RESET (TLR). */ +void ispvm_start (struct ispvm_desc *d) +{ +/* turn the Lattice Cable on */ +lattice_ec_write_port (d->cookie,LATTICE_JTAG_CE ,1 ); +/* step devices to RESET state */ +ispvm_state_machine (d,RESET ); +} + +/* +* Set the state of devices to RESET to enable the devices and disable +* the port. +*/ +void ispvm_end (struct ispvm_desc *d) +{ +/* step devices to RESET state */ +ispvm_state_machine (d,RESET ); +/* wake up devices */ +udelay (1000 ); +/* disable the Lattice Cable */ +lattice_ec_write_port (d->cookie,LATTICE_JTAG_CE ,0 ); +} + +/* Calculate the 32-bit CRC. */ +u16 ispvm_crc (struct ispvm_desc *d,u8 data,u16 ccrc) +{ +int i; +u8 fdata =0 ; +u16 crce; +static const u16 crc_table[16 ] = { +0x0000 ,0xCC01 ,0xD801 ,0x1400 , +0xF001 ,0x3C00 ,0x2800 ,0xE401 , +0xA001 ,0x6C00 ,0x7800 ,0xB401 , +0x5000 ,0x9C01 ,0x8801 ,0x4400 + }; + +for (i =0 ; i <8 ; i++) { + fdata <<=1 ; +if (data &0x01 ) + fdata |=0x01 ; + data >>=1 ; + } + + crce = crc_table[ccrc &0xF ]; + ccrc = (ccrc >>4 ) &0x0FFF ; + ccrc = ccrc ^ crce ^ crc_table[fdata &0xF ]; + crce = crc_table[ccrc &0xF ]; + ccrc = (ccrc >>4 ) &0x0FFF ; + ccrc = ccrc ^ crce ^ crc_table[(fdata >>4 ) &0xF ]; + +return ccrc; +} + +int ispvm_validate_version (struct ispvm_desc *d,const char *version) +{ +static const char *vertab[] = { +"__VME2.0" , +"__VME3.0" , +"____12.0" , +NULL + }; +int i, j, ret; + + ret =0 ; +for (i =0 ; vertab[i] !=NULL ; i++) { +for (j =0 ; j <8 ; j++) { +if (version[j] != vertab[i][j]) { + ret =VME_VERSION_FAILURE ; +break ; + } + ret =0 ; + } + +if (ret ==0 ) +break ; + } + +return ret; +} + +/* +* Returns a byte to the caller. The returned byte depends on the +* d->data_type register. If the HEAP_IN bit is set, then the byte +* is returned from the HEAP. If the LHEAP_IN bit is set, then +* the byte is returned from the intelligent buffer. Otherwise, +* the byte is returned directly from the VME file. +*/ +int ispvm_get (struct ispvm_desc *d) +{ +if (d->data_type &HEAP_IN ) { +if (d->heap_counter > d->heap_repeat_size) +return -1 ; +return d->heap_memory[d->heap_counter++]; + } + +if (d->data_type &LHEAP_IN ) { +if (d->intel_data_idx > d->intel_buffer_size) +return -1 ; +return d->intel_buffer[d->intel_buffer_size++]; + } + +/* get next byte from buffer */ +return lattice_ec_next_byte (d->cookie); +} + +/* +* Allocate memory based on target. The memory size is specified +* by size. +*/ +int ispvm_alloc (struct ispvm_desc *d,int target,int size) +{ +switch (target) { +case XTDI : +case TDI : +if (d->in_TDI_data !=NULL && d->in_TDI_data_size <= size) +break ; + +if (d->in_TDI_data !=NULL ) { +free (d->in_TDI_data); + d->in_TDI_data =NULL ; + d->in_TDI_data_size =0 ; + } + d->in_TDI_data =malloc (size /8 +2 ); +if (d->in_TDI_data !=NULL ) + d->in_TDI_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case XTDO : +case TDO : +if (d->out_TDO_data !=NULL && d->out_TDO_data_size <= size) +break ; + +if (d->out_TDO_data !=NULL ) { +free (d->out_TDO_data); + d->out_TDO_data =NULL ; + d->out_TDO_data_size =0 ; + } + d->out_TDO_data =malloc (size /8 +2 ); +if (d->out_TDO_data !=NULL ) + d->out_TDO_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case MASK : +if (d->out_MASK_data !=NULL && d->out_MASK_data_size <= size) +break ; + +if (d->out_MASK_data !=NULL ) { +free (d->out_MASK_data); + d->out_MASK_data =NULL ; + d->out_MASK_data_size =0 ; + } + d->out_MASK_data =malloc (size /8 +2 ); +if (d->out_MASK_data !=NULL ) + d->out_MASK_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case HIR : +if (d->HIR_data !=NULL && d->HIR_data_size <= size) +break ; + +if (d->HIR_data !=NULL ) { +free (d->HIR_data); + d->HIR_data =NULL ; + d->HIR_data_size =0 ; + } + d->HIR_data =malloc (size /8 +2 ); +if (d->HIR_data !=NULL ) + d->HIR_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case TIR : +if (d->TIR_data !=NULL && d->TIR_data_size <= size) +break ; + +if (d->TIR_data !=NULL ) { +free (d->TIR_data); + d->TIR_data =NULL ; + d->TIR_data_size =0 ; + } + d->TIR_data =malloc (size /8 +2 ); +if (d->TIR_data !=NULL ) + d->TIR_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case HDR : +if (d->HDR_data !=NULL && d->HDR_data_size <= size) +break ; + +if (d->HDR_data !=NULL ) { +free (d->HDR_data); + d->HDR_data =NULL ; + d->HDR_data_size =0 ; + } + d->HDR_data =malloc (size /8 +2 ); +if (d->HDR_data !=NULL ) + d->HDR_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case TDR : +if (d->TDR_data !=NULL && d->TDR_data_size <= size) +break ; + +if (d->TDR_data !=NULL ) { +free (d->TDR_data); + d->TDR_data =NULL ; + d->TDR_data_size =0 ; + } + d->TDR_data =malloc (size /8 +2 ); +if (d->TDR_data !=NULL ) + d->TDR_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case HEAP : +if (d->heap_memory !=NULL && d->heap_memory_size <= size) +break ; + +if (d->heap_memory !=NULL ) { +free (d->heap_memory); + d->heap_memory =NULL ; + d->heap_memory_size =0 ; + } + d->heap_memory =malloc (size +2 ); +if (d->heap_memory !=NULL ) + d->heap_memory_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case DMASK : +if (d->out_DMASK_data !=NULL && d->out_DMASK_data_size <= size) +break ; + +if (d->out_DMASK_data !=NULL ) { +free (d->out_DMASK_data); + d->out_DMASK_data =NULL ; + d->out_DMASK_data_size =0 ; + } + d->out_DMASK_data =malloc (size /8 +2 ); +if (d->out_DMASK_data !=NULL ) + d->out_DMASK_data_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case LHEAP : +if (d->intel_buffer !=NULL && d->intel_buffer_alloc_size <= size) +break ; + +if (d->intel_buffer !=NULL ) { +free (d->intel_buffer); + d->intel_buffer =NULL ; + d->intel_buffer_alloc_size =0 ; + } + d->intel_buffer =malloc (size +2 ); +if (d->intel_buffer !=NULL ) + d->intel_buffer_alloc_size = size; +else +return VME_OUT_OF_MEMORY ; +break ; + +case LVDS : +if (d->LVDS_list !=NULL && d->LVDS_list_size <= size) +break ; + +if (d->LVDS_list !=NULL ) { +free (d->LVDS_list); + d->LVDS_list =NULL ; + d->LVDS_list_size =0 ; + } + d->LVDS_list =malloc (size *sizeof (LVDSPair)); +if (d->LVDS_list !=NULL ) { +memset (d->LVDS_list,0 , size *sizeof (LVDSPair)); + d->LVDS_list_size = size; + }else +return VME_OUT_OF_MEMORY ; +break ; + +default : +break ; + } + +return 0 ; +} + +/* +* This is the heart of the embedded engine. All the high-level opcodes +* are extracted here. Once they have been identified, then it +* will call other functions to handle the processing. +*/ +int ispvm_code (struct ispvm_desc *d) +{ +int i, j, state, opcode; +int ret =0 ; + +/* +* Check the compression flag only if this is the first time +* this function is entered. Do not check the compression flag if +* it is being called recursively from other functions within +* the embedded engine. +*/ +if (!(d->data_type &LHEAP_IN ) && !(d->data_type &HEAP_IN )) { + ret =ispvm_get (d); +if (ret ==-1 ) +return VME_INVALID_FILE ; +if (ret ==0xf1 ) + d->data_type |=COMPRESS ; +else if (ret ==0xf2 ) + d->data_type &= ~COMPRESS ; +else +return VME_INVALID_FILE ; + } + +/* Begin looping through all the VME opcodes. */ +while ((opcode =ispvm_get (d)) >=0 ) { + +switch (opcode) { + +/* Step the JTAG state machine. */ +case STATE : +PRINTF ("STATE:\n" ); + state =ispvm_get (d); +if (state ==-1 ) +return VME_INVALID_FILE ; +ispvm_state_machine (d, state); +break ; + +/* Shift in data into the device. */ +case SIR : +PRINTF ("SIR:\n" ); + + ret =ispvm_shift (d, opcode); +if (ret !=0 ) +return ret; +break ; + +case SDR : +PRINTF ("SDR:\n" ); + ret =ispvm_shift (d, opcode); +if (ret !=0 ) +return ret; +break ; + +case XSDR : +PRINTF ("XSDR:\n" ); + ret =ispvm_shift (d, opcode); +if (ret !=0 ) +return ret; +break ; + +/* perform delay */ +case WAIT : +PRINTF ("WAIT:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; +if (j &0x8000 ) { + i = j & ~0x8000 ; +while (i-- >0 ) +udelay (1000 ); + }else +udelay (j); +break ; + +/* Issue clock toggles. */ +case TCK : +PRINTF ("TCK:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; +for (i =0 ; i < j; i++) +ispvm_clock (d); +break ; + +/* Set the ENDDR. */ +case ENDDR : +PRINTF ("ENDDR:\n" ); + d->end_DR =ispvm_get (d); +break ; + +/* Set the ENDIR. */ +case ENDIR : +PRINTF ("ENDIR:\n" ); + d->end_IR =ispvm_get (d); +break ; + +/* +* Set the header/trailer of the device in order to +* bypass successfully. +*/ +case HIR : +PRINTF ("HIR:\n" ); + ret =ispvm_amble (d, opcode); +if (ret !=0 ) +return ret; +break ; + +case TIR : +PRINTF ("TIR:\n" ); + ret =ispvm_amble (d, opcode); +if (ret !=0 ) +return ret; +break ; + +case HDR : +PRINTF ("HDR:\n" ); + ret =ispvm_amble (d, opcode); +if (ret !=0 ) +return ret; +break ; + +case TDR : +PRINTF ("TDR:\n" ); + ret =ispvm_amble (d, opcode); +if (ret !=0 ) +return ret; +break ; + +/* +* The maximum RAM required to support processing +* one row of the VME file. +*/ +case MEM : +PRINTF ("MEM:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->max_size = j; +break ; + +/* Set the VENDOR type. */ +case VENDOR : +PRINTF ("VENDOR:\n" ); + opcode =ispvm_get (d); +switch (opcode) { +case LATTICE : + d->vendor =LATTICE ; +break ; +case ALTERA : + d->vendor =ALTERA ; +break ; +case XILINX : + d->vendor =XILINX ; +break ; +default : +return VME_INVALID_FILE ; + } +break ; + +/* +* Set the flow control. Flow control determines the +* personality of the embedded engine. +*/ +case SETFLOW : +PRINTF ("SETFLOW:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->flow_control |= j &0xffff ; +break ; + +/* Unset the flow control. */ +case RESETFLOW : +PRINTF ("RESETFLOW:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->flow_control &= ~j &0xffff ; +break ; + +/* Allocate heap size to store loops. */ +case HEAP : +PRINTF ("HEAP:\n" ); + ret =ispvm_get (d); +if (ret !=SECUREHEAP ) +return VME_INVALID_FILE ; + + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->heap_repeat_size = j; + +/* +* Store the maximum size of the HEAP buffer. +* Used to convert VME to HEX. +*/ +if (d->heap_repeat_size > d->HEAP_size) + d->HEAP_size = d->heap_repeat_size; + + j =ispvm_alloc (d,HEAP , d->heap_repeat_size); +if (j !=0 ) +return VME_OUT_OF_MEMORY ; +break ; + +/* Execute loops. */ +case REPEAT : +PRINTF ("REPEAT:\n" ); + d->repeat_loops =0 ; + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + ret =ispvm_loop (d, j); +if (ret !=0 ) +return ret; +break ; + +/* Exit point from processing loops. */ +case ENDLOOP : +PRINTF ("ENDLOOP:\n" ); +return ret; + +/* +* The only valid exit point that indicates end +* of programming. +*/ +case ENDVME : +PRINTF ("ENDVME:\n" ); +return ret; + +/* Right-shift address. */ +case SHR : +PRINTF ("SHR:\n" ); + d->flow_control |=SHIFTRIGHT ; + d->shift_value = d->repeat_loops *ispvm_get (d); +break ; + +/* Left-shift address. */ +case SHL : +PRINTF ("SHL:\n" ); + d->flow_control |=SHIFTLEFT ; + d->shift_value = d->repeat_loops *ispvm_get (d); +break ; + +/* Set the d->frequency. */ +case FREQUENCY : +PRINTF ("FREQUENCY:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->frequency = j /1000 ; +break ; + +/* Process LCOUNT command. */ +case LCOUNT : +PRINTF ("LCOUNT:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + ret =ispvm_lcount (d, j); +if (ret !=0 ) +return ret; +break ; + +/* Set the flow control to verify USERCODE. */ +case VUES : +PRINTF ("VUES:\n" ); + d->flow_control |=VERIFYUES ; +break ; + +/* Display comment. */ +case COMMENT : +PRINTF ("COMMENT:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + j =ispvm_comment (d, j); +if (j ==-1 ) +return VME_INVALID_FILE ; +break ; + +/* Process LVDS command. */ +case LVDS : +PRINTF ("LVDS:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + j =ispvm_process_lvds (d, j); +if (j ==-1 ) +return VME_INVALID_FILE ; +break ; + +/* Discard header. */ +case HEADER : +PRINTF ("HEADER:\n" ); + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + j =ispvm_header (d, j); +if (j ==-1 ) +return VME_INVALID_FILE ; +break ; + +/* Invalid opcode encountered. */ +default : +return VME_INVALID_FILE ; + } + } + +/* +* Invalid exit point. Processing the token 'ENDVME' is the only +* valid way to exit the embedded engine. +*/ +return VME_INVALID_FILE ; +} + +#endif
include/lattice_ivm_core.h new file +214 -0
214 lines not on this page · raw message
include/lattice_vmopcode.h new file +286 -0
286 lines not on this page · raw message
PATCH 4/8 Support LATTICE FPGA parts using JTAG programming. Support functions.
In reply to Pantelis AntoniouAdd support for Lattice FPGA parts programmed using JTAG.
---
---
common/lattice_ivm_supp.c | 1426 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1426 insertions(+), 0 deletions(-)
common/lattice_ivm_supp.c new file +1426 -0
@@ -0,0 +1,1426 @@ +/* +* (C) Copyright 2006 - Embedded Alley Solutions Inc. +* by Pantelis Antoniou, pantelis at embeddedalley.com +* +* Based on redboot's lattice_ivm_core.c +* +* This file was based on ASP8347DB's redboot sources +* with the same name. The file was not carrying any copyright +* markings while RedBoot is clearly GPL licensed. + +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +*/ + +#include <common.h> +#include <malloc.h> +#include <lattice.h> +#include <lattice_ec.h> + +#include <lattice_ivm_core.h> +#include <lattice_vmopcode.h> + +#if (CONFIG_FPGA &CFG_FPGA_LATTICE ) + +/* Enable/Disable debug console messages */ +#ifdef FPGA_DEBUG +#define PRINTF(fmt,args...) printf (fmt ,##args) +#else +#define PRINTF(fmt,args...) +#endif + +/* +* Returns a VME-encoded number, usually used to indicate the +* bit length of an SIR/SDR command. +*/ +int ispvm_data_size (struct ispvm_desc *d) +{ +int i, j, val; + + i = j =0 ; +while ((val =ispvm_get (d)) !=-1 && (val &0x80 )) { + j |= (val &0x7F ) << i; + i +=7 ; + } +if (val ==-1 ) +return -1 ; + j |= (val &0x7F ) << i; +return j; +} + +/* Processes the TDI/TDO/MASK/DMASK etc of an SIR/SDR command. */ +int ispvm_data_code (struct ispvm_desc *d) +{ +int ret, data; +int data_source =0 ;/* source file by default */ + +if (d->data_type &HEAP_IN ) + data_source =1 ;/* source from memory */ + +/* Clear the data type register. */ + d->data_type &= ~(MASK_DATA +TDI_DATA +TDO_DATA +DMASK_DATA ); + +/* +* Iterate through SIR/SDR command and look +* for TDI, TDO, MASK, etc. +*/ +while ((data =ispvm_get (d)) >=0 ) { + + ret =ispvm_alloc (d, data, d->max_size); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + +switch (data) { + +case TDI : +/* +* Store the maximum size of the TDI buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->TDI_size) + d->TDI_size = d->data_size; + +/* +* Updated data type register to indicate that TDI data +* is currently being used. Process the data in the VME +* file into the TDI buffer. +*/ + d->data_type |=TDI_DATA ; + ret =ispvm_data (d, d->in_TDI_data); +if (ret !=0 ) +return VME_INVALID_FILE ; +break ; + +case XTDO : +/* +* Store the maximum size of the TDO buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->TDO_size) + d->TDO_size = d->data_size; + +/* +* Updated data type register to indicate that TDO data +* is currently being used. +*/ + d->data_type |=TDO_DATA ; +break ; + +case TDO : +/* +* Store the maximum size of the TDO buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->TDO_size) + d->TDO_size = d->data_size; + +/* +* Updated data type register to indicate that TDO data +* is currently being used. Process the data in the VME +* file into the TDO buffer. +*/ + d->data_type |=TDO_DATA ; + ret =ispvm_data (d, d->out_TDO_data); +if (ret !=0 ) +return VME_INVALID_FILE ; +break ; + +case MASK : +/* +* Store the maximum size of the MASK buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->MASK_size) + d->MASK_size = d->data_size; + +/* +* Updated data type register to indicate that MASK data +* is currently being used. Process the data in the VME +* file into the TDO buffer. +*/ + d->data_type |=MASK_DATA ; + ret =ispvm_data (d, d->out_MASK_data); +if (ret !=0 ) +return VME_INVALID_FILE ; +break ; + +case DMASK : +/* +* Store the maximum size of the DMASK buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->DMASK_size) + d->DMASK_size = d->data_size; + +/* +* Updated data type register to indicate that DMASK +* data is currently being used. Process the data in +* the VME file into the TDO buffer. +*/ + + d->data_type |=DMASK_DATA ; + ret =ispvm_data (d, d->out_DMASK_data); +if (ret !=0 ) +return VME_INVALID_FILE ; +break ; + +case CONTINUE : +return 0 ; + +/* Encountered invalid opcode. */ +default : +return VME_INVALID_FILE ; + } + +if (data ==TDI ) { +/* +* Left bit shift. Used when performing +* algorithm looping. +*/ +if (d->flow_control &SHIFTLEFT ) { +ispvm_bit_shift (d,SHL , d->shift_value); + d->flow_control &= ~SHIFTLEFT ; + } + +/* +* Right bit shift. Used when performing +* algorithm looping. +*/ +if (d->flow_control &SHIFTRIGHT ) { +ispvm_bit_shift (d,SHR , d->shift_value); + d->flow_control &= ~SHIFTRIGHT ; + } + } + +if (data_source) + d->data_type |=HEAP_IN ;/* restore data from memory */ + } + +if (data_source)/* fetch data from heap memory upon return */ + d->data_type |=HEAP_IN ; + +if (data <0 ) +return VME_INVALID_FILE ;/* invalid opcode */ + +return 0 ; +} + +/* +* Extract one row of data operand from the current data type opcode. Perform +* the decompression if necessary. Extra RAM is not required for the +* decompression process. The decompression scheme employed in this module +* is on row by row basis. The format of the data stream: +* [compression code][compressed data stream] +* 0x00 --No compression +* 0x01 --Compress by 0x00. +* Example: +* Original stream: 0x000000000000000000000001 +* Compressed stream: 0x01000901 +* Detail: 0x01 is the code, 0x00 is the key, +* 0x09 is the count of 0x00 bytes, +* 0x01 is the uncompressed byte. +* 0x02 --Compress by 0xFF. +* Example: +* Original stream: 0xFFFFFFFFFFFFFFFFFFFFFF01 +* Compressed stream: 0x02FF0901 +* Detail: 0x02 is the code, 0xFF is the key, +* 0x09 is the count of 0xFF bytes, +* 0x01 is the uncompressed byte. +* 0x03 +* : : +* 0xFE -- Compress by nibble blocks. +* Example: +* Original stream: 0x84210842108421084210 +* Compressed stream: 0x0584210 +* Detail: 0x05 is the code, means 5 nibbles block. +* 0x84210 is the 5 nibble blocks. +* The whole row is 80 bits given by d->data_size +* The number of times the block repeat itself +* is found by d->data_size/(4*0x05) which is 4. +* 0xFF -- Compress by the most frequently happen byte. +* Example: +* Original stream: 0x04020401030904040404 +* Compressed stream: 0xFF04(0,1,0x02,0,1,0x01,1,0x03,1,0x09,0,0,0) +* or: 0xFF044090181C240 +* Detail: 0xFF is the code, 0x04 is the key. +* a bit of 0 represent the key shall be put into +* the current bit position and a bit of 1 +* represent copying the next of 8 bits of data +* in. +*/ + +int ispvm_data (struct ispvm_desc *d,u8 *ptr) +{ +int i, j, k, l, size, gotdata, FFcount, compress, data; +u8 compr_char, val; +int compression =0 ; + + gotdata =0 ; + FFcount =0 ; + compress =0 ; + data =0 ; + compr_char =0xff ; + +/*convert number in bits to bytes */ +if (d->data_size %8 >0 ) + size = d->data_size /8 +1 ; +else + size = d->data_size /8 ; + +/* +* If there is compression, then check if compress by +* key of 0x00 or 0xFF +* or by other keys or by nibble blocks +*/ +if (d->data_type &COMPRESS ) { + compression =1 ; + + compress =ispvm_get (d); +if (compress ==-1 ) +return VME_INVALID_FILE ; + +if (compress ==VAR && (d->data_type &HEAP_IN )) { + gotdata =1 ; + d->data_type &= ~HEAP_IN ; + compress =ispvm_get (d); +if (compress ==-1 ) +return VME_INVALID_FILE ; + } + +switch (compress) { + +/* No compression */ +case 0x00 : + compression =0 ; +break ; + +/* Compress by byte 0x00 */ +case 0x01 : + compr_char =0x00 ; +break ; + +/* Compress by byte 0xFF */ +case 0x02 : + compr_char =0xFF ; +break ; + +/* Huffman encoding */ +case 0xFF : + j =ispvm_get (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + + compr_char = j; + + i =8 ; +for (l =0 ; l < size; l++) { + ptr[l] =0x00 ; +if (i >7 ) { + data =ispvm_get (d); +if (data ==-1 ) +return VME_INVALID_FILE ; + i =0 ; + } +if ((data << i++) &0x80 ) { + k =8 ; + }else { + ptr[l] = compr_char; + k =0 ; + } + +for (j =0 ; j < k; j++) { +if (i >7 ) { + data =ispvm_get (d); +if (data ==-1 ) +return VME_INVALID_FILE ; + i =0 ; + } + ptr[l] |= ((data << i++) &0x80 ) >> j; + } + } + size =0 ; +break ; + +default : +for (l =0 ; l < size; l++) + ptr[l] =0x00 ; + +for (l =0 ; l < compress; l++) { +if ((l %2 ) ==0 ) { + data =ispvm_get (d); +if (data ==-1 ) +return VME_INVALID_FILE ; + } +for (i =0 ; i < size *2 / compress; i++) { + j = l + i * compress; +/* clear the nibble to zero first */ +if (j %2 ) { +if (l %2 ) + val = data &0x0F ; +else + val = data >>4 ; + }else { +if (l %2 ) + val = data <<4 ; +else + val = data &0xF0 ; + } + + ptr[j /2 ] |= val; + } + } + size =0 ; +break ; + } + } + + FFcount =0 ; + +/* Decompress by byte 0x00 or 0xFF */ +for (l =0 ; l < size; l++) { +if (FFcount <=0 ) { + data =ispvm_get (d); +if (data ==-1 ) +return VME_INVALID_FILE ; + +if (data ==VAR && (d->data_type &HEAP_IN ) && + !gotdata && !(d->data_type &COMPRESS )) { + gotdata =1 ; + d->data_type &= ~HEAP_IN ; + data =ispvm_get (d); +if (data ==-1 ) +return VME_INVALID_FILE ; + } + ptr[l] = data &0xff ; + +/* decompression is on? set num. of 0xff/0x00 bytes */ +if (compression && data == compr_char) { + FFcount =ispvm_data_size (d); +if (FFcount ==-1 ) +return VME_INVALID_FILE ; + } + }else { + FFcount--;/* Use up the 0xFF chain first */ + ptr[l] = compr_char &0xff ; + } + } + +if (gotdata) { + d->data_type |=HEAP_IN ; + gotdata =0 ; + } + +return 0 ; +} + +/* Processes the SDR/XSDR/SIR commands. */ +int ispvm_shift (struct ispvm_desc *d,int code) +{ +int i, j; +int ret; + + ret =0 ; + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + + d->data_size = j; + +/* clear the flags first */ + d->data_type &= ~(SIR_DATA +EXPRESS +SDR_DATA ); + +switch (code) { + +case SIR : + d->data_type |=SIR_DATA ; +/* +* 1/15/04 If performing cascading, then go +* directly to SHIFTIR. +* Else, go to IRPAUSE before going to SHIFTIR +*/ +if (d->flow_control &CASCADE ) { +ispvm_state_machine (d,SHIFTIR ); +break ; + } +ispvm_state_machine (d,IRPAUSE ); +ispvm_state_machine (d,SHIFTIR ); +if (d->head_IR >0 ) { +ispvm_bypass (d,HIR , d->head_IR); +ispvm_clock (d); + } +break ; + +case XSDR : +/* mark simultaneous in and out */ + d->data_type |=EXPRESS ; +/* fall-through */ + +case SDR : + d->data_type |=SDR_DATA ; + +/* +* 1/15/04 If already in SHIFTDR, then do not move +* state or shift in header. This would imply that the +* previously shifted frame was a cascaded frame. +*/ +if (d->current_jtag_state ==SHIFTDR ) +break ; + +/* +* 1/15/04 If performing cascading, then go directly +* to SHIFTDR. Else, go to DRPAUSE before going to SHIFTDR +*/ +if (d->flow_control &CASCADE ) { +if (d->current_jtag_state ==DRPAUSE ) { +ispvm_state_machine (d,SHIFTDR ); +/* +* 1/15/04 If cascade flag has been set and +* the current state is DRPAUSE, this implies +* that the first cascaded frame is about to be +* shifted in. The header must be shifted prior +* to shifting the first cascaded frame. +*/ +if (d->head_DR >0 ) { +ispvm_bypass (d,HDR , d->head_DR); +ispvm_clock (d); + } + }else +ispvm_state_machine (d,SHIFTDR ); + }else { +ispvm_state_machine (d,DRPAUSE ); +ispvm_state_machine (d,SHIFTDR ); +if (d->head_DR >0 ) { +ispvm_bypass (d,HDR , d->head_DR); +ispvm_clock (d); + } + } +break ; + +default : +return VME_INVALID_FILE ; + } + + ret =ispvm_data_code (d); +if (ret !=0 ) +return VME_INVALID_FILE ; + +if (d->data_type &DMASK_DATA ) { + ret =ispvm_read_and_save (d, d->data_size); +if (!ret) { +if (d->tail_DR >0 ) { +ispvm_clock (d); +ispvm_bypass (d,TDR , d->tail_DR); + } +ispvm_state_machine (d,DRPAUSE ); +ispvm_state_machine (d,SHIFTDR ); +if (d->head_DR >0 ) { +ispvm_bypass (d,HDR , d->head_DR); +ispvm_clock (d); + } +for (i =0 ; i < d->data_size /8 +1 ; i++) + d->in_TDI_data[i] = d->out_TDO_data[i]; + d->data_type &= ~(TDO_DATA +DMASK_DATA ); + ret =ispvm_send (d, d->data_size); + } + }else if (d->data_type &TDO_DATA ) { + ret =ispvm_read (d, d->data_size); +if (ret ==-1 && d->vendor ==XILINX ) { +for (j =0 ; j <30 ; j++) { + ret =ispvm_read (d, d->data_size); +if (!ret) +break ; + +/* Always DRPAUSE */ +ispvm_state_machine (d,DRPAUSE ); + +/* Bypass other devices when appropriate */ +ispvm_bypass (d,TDR , d->tail_DR); +ispvm_state_machine (d, d->end_DR); +ispvm_state_machine (d,IDLE ); +udelay (1000 ); + } + } + }else + ret =ispvm_send (d, d->data_size);/*TDI only */ + +/*transfer the input data to the output buffer for the next verify */ +if ((d->data_type &EXPRESS ) || + (code ==SDR && d->out_TDO_data !=NULL )) +for (i =0 ; i < d->data_size /8 +1 ; i++) + d->out_TDO_data[i] = d->in_TDI_data[i]; + +switch (code) { + +case SIR : +/* 1/15/04 If not performing cascading, then shift ENDIR */ +if ((d->flow_control &CASCADE )) +break ; + +if (d->tail_IR >0 ) { +ispvm_clock (d); +ispvm_bypass (d,TIR , d->tail_IR); + } +ispvm_state_machine (d, d->end_IR); +break ; + +case XSDR : +case SDR : +/* 1/15/04 If not performing cascading, then shift ENDDR */ +if ((d->flow_control &CASCADE )) +break ; + +if (d->tail_DR >0 ) { +ispvm_clock (d); +ispvm_bypass (d,TDR , d->tail_DR); + } +ispvm_state_machine (d, d->end_DR); +break ; + +default : +break ; + } + +return ret; +} + +/* This routine is to extract Header and Trailer parameter for SIR and +* SDR operations. +* +* The Header and Trailer parameter are the pre-amble and post-amble bit +* stream need to be shifted into TDI or out of TDO of the devices. Mostly +* is for the purpose of bypassing the leading or trailing devices. ispVM +* supports only shifting data into TDI to bypass the devices. +* +* For a single device, the header and trailer parameters are all set to 0 +* as default by ispVM. If it is for multiple devices, the header and trailer +* value will change as specified by the VME file. +*/ + +int ispvm_amble (struct ispvm_desc *d,int code) +{ +int j, ret; +int compress =0 ; + + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + + d->data_size = j; + +if (d->data_size) { +/* +* Discard the TDI byte and set the compression bit in the +* data type register to false if compression is set +* because TDI data after HIR/HDR/TIR/TDR is not compressed. +*/ + j =ispvm_get (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + +if (d->data_type &COMPRESS ) { + d->data_type &= ~(COMPRESS ); + compress =1 ; + } + } + +switch (code) { +case HIR : +/* +* Store the maximum size of the HIR buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->HIR_size) + d->HIR_size = d->data_size; + +/* Assign the HIR value and allocate memory. */ + d->head_IR = d->data_size; +if (d->head_IR) { + ret =ispvm_alloc (d,HIR , d->head_IR); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + ret =ispvm_data (d, d->HIR_data); +if (ret !=0 ) +return VME_INVALID_FILE ; + + } +break ; + +case TIR : +/* +* Store the maximum size of the TIR buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->TIR_size) + d->TIR_size = d->data_size; + +/* Assign the TIR value and allocate memory. */ + d->tail_IR = d->data_size; +if (d->tail_IR) { + ret =ispvm_alloc (d,TIR , d->tail_IR); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + ret =ispvm_data (d, d->TIR_data); +if (ret !=0 ) +return VME_INVALID_FILE ; + } +break ; + +case HDR : +/* +* Store the maximum size of the HDR buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->HDR_size) + d->HDR_size = d->data_size; + +/* Assign the HDR value and allocate memory. */ + d->head_DR = d->data_size; +if (d->head_DR) { + ret =ispvm_alloc (d,HDR , d->head_DR); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + ret =ispvm_data (d, d->HDR_data); +if (ret !=0 ) +return VME_INVALID_FILE ; + } +break ; + +case TDR : + +/* +* Store the maximum size of the TDR buffer. +* Used to convert VME to HEX. +*/ +if (d->data_size > d->TDR_size) + d->TDR_size = d->data_size; + +/* Assign the TDR value and allocate memory. */ + d->tail_DR = d->data_size; +if (d->tail_DR) { + ret =ispvm_alloc (d,TDR , d->tail_DR); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + ret =ispvm_data (d, d->TDR_data); +if (ret !=0 ) +return VME_INVALID_FILE ; + } +break ; + +default : +break ; + } + +/* Re-enable compression if it was previously set. */ +if (compress) + d->data_type |=COMPRESS ; + +if (d->data_size >0 &&ispvm_get (d) !=CONTINUE ) +return VME_INVALID_FILE ;/* invalid opcode */ + +return 0 ; +} + +/* +* Perform the function call upon by the REPEAT opcode. +* Memory is to be allocated to store the entire loop from REPEAT to ENDLOOP. +* After the loop is stored then execution begin. The REPEATLOOP flag is set +* on the d->flow_control register to indicate the repeat loop is in session +* and therefore fetch opcode from the memory instead of from the file. +*/ +int ispvm_loop (struct ispvm_desc *d,int repeats) +{ +int i, j; +int ret =0 ; + + d->shift_value =0 ; +for (i =0 ; i < d->heap_repeat_size; i++) { + j =ispvm_get (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->heap_memory[i] = j; + } + +if (d->heap_memory[i -1 ] !=ENDLOOP ) +return VME_INVALID_FILE ; + + d->flow_control |=REPEATLOOP ; + d->data_type |=HEAP_IN ; + +for (i =0 ; i < repeats; i++) { + d->heap_counter =0 ; + ret =ispvm_code (d); + d->repeat_loops++; +if (ret <0 ) +break ; + } + + d->data_type &= ~HEAP_IN ; + d->flow_control &= ~REPEATLOOP ; +return ret; +} + +/* +* Shift the TDI stream left or right by the number of bits. The data in +* d->in_TDI_data is of the VME format, so the actual shifting is the reverse of +* IEEE 1532 or SVF format. +*/ +int ispvm_bit_shift (struct ispvm_desc *d,int mode,u16 bits) +{ +u16 i, size, j; + +if (d->data_size %8 >0 ) + size = d->data_size /8 +1 ; +else + size = d->data_size /8 ; + +switch (mode) { + +case SHR : +for (i =0 ; i < size; i++) { +if (d->in_TDI_data[i] ==0 ) +continue ; + j = bits; +while (j >0 ) { + d->in_TDI_data[i] <<=1 ; +if (d->in_TDI_data[i] ==0 ) { + i--; + d->in_TDI_data[i] =1 ; + } + j--; + } + } +break ; + +case SHL : +for (i =0 ; i < size; i++) { +if (d->in_TDI_data[i] ==0 ) +continue ; + j = bits; +while (j >0 ) { + d->in_TDI_data[i] >>=1 ; +if (d->in_TDI_data[i] ==0 ) { + i--; + d->in_TDI_data[i] =8 ; + } + j--; + } + } +break ; + +default : +return VME_INVALID_FILE ; + } + +return 0 ; +} + +/* Displays the SVF comments. */ +int ispvm_comment (struct ispvm_desc *d,int size) +{ +int i, j; + +/* Print character to the terminal. */ +printf ("VM-Comment: " ); +for (i =0 ; i < size; i++) { + j =ispvm_get (d); +if (j ==-1 ) +return VME_INVALID_FILE ; +printf ("%c" , j); + } +printf ("\n" ); + +return 0 ; +} + +/* Iterate the length of the header and discard it. */ +int ispvm_header (struct ispvm_desc *d,int size) +{ +int i, j; + +for (i =0 ; i < size; i++) { + j =ispvm_get (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + } +return 0 ; +} + +/* Process the intelligent programming loops. */ +int ispvm_lcount (struct ispvm_desc *d,int size) +{ +int i, j, k; +int ret =0 ; +int repheap =0 ; + + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + + d->intel_buffer_size = j; + +/* Allocate memory for intel buffer. */ + ret =ispvm_alloc (d,LHEAP , d->intel_buffer_size); +if (ret !=0 ) +return VME_OUT_OF_MEMORY ; + +/* +* Store the maximum size of the intelligent buffer. +* Used to convert VME to HEX. +*/ +if (d->intel_buffer_size > d->LCOUNT_size) + d->LCOUNT_size = d->intel_buffer_size; + +/* Copy intel data to the buffer */ +for (i =0 ; i < d->intel_buffer_size; i++) { + k =ispvm_get (d); +if (k ==-1 ) +return VME_INVALID_FILE ; + d->intel_buffer[i] = k; + } + +/* +* Set the data type register to get data from the +* intelligent data buffer. +*/ + d->data_type |=LHEAP_IN ; + +/* +* If the HEAP_IN flag is set, temporarily unset the flag +* so data will be retrieved from the status buffer. +*/ +if (d->data_type &HEAP_IN ) { + d->data_type &= ~HEAP_IN ; + repheap =1 ; + } + +/* Iterate through the intelligent programming command. */ +for (i =0 ; i < size; i++) { + d->intel_data_idx =0 ; + +/* +* Make recursive call to process the intelligent +* programming commands. +*/ + ret =ispvm_code (d); +if (ret >=0 ) +break ;/* success? */ + } + +/* +* If HEAP_IN flag was temporarily disabled, +* re-enable it before exiting. +*/ +if (repheap) + d->data_type |=HEAP_IN ; + +/* +* Set the data type register to not get data from +* the intelligent data buffer. +*/ + d->data_type &= ~LHEAP_IN ; +return ret; +} + +/* Applies a single pulse to TCK. */ +void ispvm_clock (struct ispvm_desc *d) +{ +int idle; + + idle =1000 / d->frequency + !!(1000 % d->frequency); + +/* NOTE: we assume that at least one usec will pass +* until getting the port toggled +*/ + idle--; + +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TCK ,0x01 ); +if (idle >0 ) +udelay (idle); + +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TCK ,0x00 ); +if (idle >0 ) +udelay (idle); +} + +/* +* This procedure takes care of the HIR, HDR, TIR, TDR for the +* purpose of putting the other devices into Bypass mode. The +* current state is checked to find out if it is at DRPAUSE or +* IRPAUSE. If it is at DRPAUSE, perform bypass register scan. +* If it is at IRPAUSE, scan into instruction registers the bypass +* instruction. +*/ +void ispvm_bypass (struct ispvm_desc *d,int scan_type,u16 bits) +{ +int i, j, bit; +u8 val =0 ; +u8 *pcSource =0 ; + +if (bits <=0 ) +return ; + +switch (scan_type) { +case HIR : + pcSource = d->HIR_data; +break ; +case TIR : + pcSource = d->TIR_data; +break ; +case HDR : + pcSource = d->HDR_data; +break ; +case TDR : + pcSource = d->TDR_data; +break ; +default : +break ; + } + + j =0 ; +for (i =0 ; i < bits -1 ; i++) { +/* Scan instruction or bypass register */ +if (i %8 ==0 ) + val = pcSource[j++]; + bit = !!((val << (i %8 )) &0x80 ); +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , bit); +ispvm_clock (d); + } + +if ((i %8 ) ==0 ) + val = pcSource[j++]; + + bit = !!((val << (i %8 )) &0x80 ); +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , bit); +} + +/* +* This procedure steps all devices in the daisy chain from a given +* JTAG state to the next desirable state. If the next state is TLR, +* the JTAG state machine is brute forced into TLR by driving TMS +* high and pulse TCK 6 times. +*/ +void ispvm_state_machine (struct ispvm_desc *d,int next) +{ +/* +* JTAG state machine transition trajectory table +*/ +static const struct { +u8 cur_state;/* From this state */ +u8 next_state;/* Step to this state */ +u8 pattern;/* Tragectory of TMS */ +u8 pulses;/* Number of steps */ + } jtag_transitions[24 ] = { +/* Transitions from RESET */ + {RESET ,RESET ,0xFC ,6 }, + {RESET ,IDLE ,0x00 ,1 }, + {RESET ,DRPAUSE ,0x50 ,5 }, + {RESET ,IRPAUSE ,0x68 ,6 }, + +/* Transitions from IDLE */ + {IDLE ,RESET ,0xE0 ,3 }, + {IDLE ,DRPAUSE ,0xA0 ,4 }, + {IDLE ,IRPAUSE ,0xD0 ,5 }, + +/* Transitions from DRPAUSE */ + {DRPAUSE ,RESET ,0xF8 ,5 }, + {DRPAUSE ,IDLE ,0xC0 ,3 }, + {DRPAUSE ,IRPAUSE ,0xF4 ,7 }, + +/* Transitions from IRPAUSE */ + {IRPAUSE ,RESET ,0xF8 ,5 }, + {IRPAUSE ,IDLE ,0xC0 ,3 }, + {IRPAUSE ,DRPAUSE ,0xE8 ,6 }, + +/* Extra transitions using SHIFTDR */ + {DRPAUSE ,SHIFTDR ,0x80 ,2 }, + {IRPAUSE ,SHIFTDR ,0xE0 ,5 }, + {SHIFTDR ,DRPAUSE ,0x80 ,2 }, + {SHIFTDR ,IDLE ,0xC0 ,3 }, + +/* Extra transitions using SHIFTIR */ + {IRPAUSE ,SHIFTIR ,0x80 ,2 }, + {SHIFTIR ,IRPAUSE ,0x80 ,2 }, + {SHIFTIR ,IDLE ,0xC0 ,3 }, + +/* 11/15/05 Nguyen changed to support DRCAPTURE */ + {DRPAUSE ,DRCAPTURE ,0xE0 ,4 }, + {DRCAPTURE ,DRPAUSE ,0x80 ,2 }, + {IDLE ,DRCAPTURE ,0x80 ,2 }, + {IRPAUSE ,DRCAPTURE ,0xE0 ,4 } + }; + +int i, j, maxstate; + +/* already there? */ +if (d->current_jtag_state == next && next !=RESET ) +return ; + + maxstate =sizeof (jtag_transitions) /sizeof (jtag_transitions[0 ]); +for (j =0 ; j < maxstate; j++) +if (d->current_jtag_state == jtag_transitions[j].cur_state && + next == jtag_transitions[j].next_state) +break ; + + d->current_jtag_state = next; +for (i =0 ; i < jtag_transitions[j].pulses; i++) { +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TMS , + (jtag_transitions[j].pattern << i) &0x80 ); +ispvm_clock (d); + } + +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI ,0 ); +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TMS ,0 ); +} + +/* +* Send the TDI data stream to devices. The data stream can be +* instructions or data. +*/ +int ispvm_send (struct ispvm_desc *d,u16 size) +{ +int i, j, bit; +u8 val =0 ; + +for (i =0 , j =0 ; i < size -1 ; i++) { +if ((i %8 ) ==0 ) + val = d->in_TDI_data[j++]; + bit = !!((val << (i %8 )) &0x80 ); +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , bit); +ispvm_clock (d); + } + +/* Take care of the last bit */ +if ((i %8 ) ==0 ) + val = d->in_TDI_data[j]; + + bit = !!((val << (i %8 )) &0x80 ); +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , bit); + +/* 1/15/04 Clock in last bit for the first n-1 cascaded frames */ +if (d->flow_control &CASCADE ) +ispvm_clock (d); + +return 0 ; +} + +/* Read the data stream from devices and verify. */ +int ispvm_read (struct ispvm_desc *d,u16 size) +{ +int i, j, k, bit, lasti, errors, dflg; +u8 data, mask, indata, display; + + errors =0 ; + lasti = size -1 ; + j =0 ; + k =0 ; + dflg =1 ; + data =0 ; + mask =0 ; + indata =0 ; + display =0 ; + +/* +* If mask is not all zeros, then set the display flag to 0x00, +* otherwise it shall be set to 0x01 to indicate that data read from +* the device shall be displayed. If VME_DEBUG is defined, always +* display data. +*/ +for (i =0 ; i < (size +7 ) /8 ; i++) { +if (d->data_type &MASK_DATA ) { +if (d->out_MASK_data[i] !=0x00 ) { + dflg =0 ; +break ; + } + }else { + dflg =0x00 ; +break ; + } + } + +/* Begin shifting data in and out of the device. */ +for (i =0 ; i < size; i++) { +if (k ==0 ) { +/* Grab byte from TDO buffer. */ +if (d->data_type &TDO_DATA ) + data = d->out_TDO_data[j]; + +/* Grab byte from MASK buffer. */ +if (d->data_type &MASK_DATA ) + mask = d->out_MASK_data[j]; +else + mask =0xFF ; + +/* Grab byte from TDI buffer. */ +if (d->data_type &TDI_DATA ) + indata = d->in_TDI_data[j]; + + j++; + } + + bit =lattice_ec_read_port (d->cookie); + +if (dflg) { + display <<=1 ; + display |= bit; + } + +/* Check if data read from port matches with expected TDO. */ +if (d->data_type &TDO_DATA ) { +if ((mask << k) &0x80 ) { +if (bit != !!((data << k) &0x80 )) { + errors++; + dflg =1 ; + } + } + } + +/* Write TDI data to the port. */ +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , + (((indata << k) &0x80 ) ?0x01 :0x00 )); + +/* Clock data out from the data shift register. */ +if (i < lasti || (d->flow_control &CASCADE )) +ispvm_clock (d); + + k++; +if (k >=8 ) { + +if (dflg) { +/* +* Store displayed data in the TDO buffer. +* By reusing the TDO buffer to store displayed +* data, there is no need to allocate a buffer +* simply to hold display data. This will not +* cause any false verification errors because +* the true TDO byte has already been consumed. +*/ + d->out_TDO_data[j -1 ] = display; + display =0 ; + } + k =0 ; + } + } + +if (dflg) { +/* Display data read from the device. */ +printf ("\nDisplay Data: 0x" ); + +for (i = ((size +7 ) /8 ); i >0 ; i--) { + mask = d->out_TDO_data[i -1 ]; + data =0 ; + +/* Flip mask and store it in data. */ +for (j =0 ; j <8 ; j++) { + data <<=1 ; +if (mask &0x01 ) + data |=0x01 ; + mask >>=1 ; + } + +printf (" %02X" , ((unsigned int )data) &0xff ); + } +printf ("\n\n" ); + } + +if (errors >0 ) { +if (d->flow_control &VERIFYUES ) { +printf ("USERCODE verification failed." +" Continue programming......\n\n" ); + d->flow_control &= ~VERIFYUES ; +return 0 ; + } + +return VME_VERIFICATION_FAILURE ; + + } + +if (d->flow_control &VERIFYUES ) { +printf ("USERCODE verification passed." +" Programming aborted. \n\n" ); + d->flow_control &= ~VERIFYUES ; +return 1 ; + } +return 0 ; +} + +/* Support dynamic I/O. */ +int ispvm_read_and_save (struct ispvm_desc *d,u16 size) +{ +int i, j, k, l, m, lasti, bit, outbit; +u8 data, dmask, indata, outdata; + + lasti = size -1 ; + j =0 ; + k =0 ; + l =0 ; + m =0 ; + data =0 ; + dmask =0 ; + indata =0 ; + +/* Iterate through the data bits. */ +for (i =0 ; i < size; i++) { +if (k ==0 ) { +/* Grab byte from DMASK buffer. */ +if (d->data_type &DMASK_DATA ) + dmask = d->out_DMASK_data[j]; +else + dmask =0x00 ; + +/* Grab byte from TDI buffer. */ +if (d->data_type &TDI_DATA ) + indata = d->in_TDI_data[j]; + + j++; + } + + bit =lattice_ec_read_port (d->cookie); + data = !!((indata << k) &0x80 ); + +/* Initialize the byte to be zero. */ +if (l %8 ==0 ) + d->out_TDO_data[l /8 ] =0x00 ; + +/* +* Use TDI, DMASK, and device TDO to create new TDI (actually +* stored in d->out_TDO_data). +*/ +if ((dmask << k) &0x80 ) { + +if (d->LVDS_list) { +for (m =0 ; m < d->LVDS_pair_count; m++) { +if (d->LVDS_list[m].negative_idx + == i) { + d->LVDS_list[m].update =0x01 ; +break ; + } + } + } + +/* DMASK bit is 1, use TDI. */ + outbit = data &1 ; + }else + outbit = bit; + +/* DMASK bit is 0, use device TDO. */ + outdata = outbit << (7 - l %8 ); + d->out_TDO_data[l /8 ] |= outdata; + +/* Shift in TDI in order to get TDO out. */ + l++; +lattice_ec_write_port (d->cookie,LATTICE_JTAG_TDI , data); +if (i < lasti) +ispvm_clock (d); + + k++; +if (k >=8 ) + k =0 ; + } + +/* +* If d->LVDS_list exists and pairs need updating, then update +* the negative-pair to receive the flipped positive-pair value. +*/ +if (!d->LVDS_list) +return 0 ; + +for (m =0 ; m < d->LVDS_pair_count; m++) +if (d->LVDS_list[m].update) +break ; + +/* update not found? */ +if (m >= d->LVDS_pair_count) +return 0 ; + +/* Read the positive value and flip it. */ + outdata = d->out_TDO_data[d->LVDS_list[m].positive_idx /8 ]; + data = !((outdata << (d->LVDS_list[m].positive_idx %8 )) &0x80 ); + +/* Get the byte that needs modification. */ + indata = d->out_TDO_data[d->LVDS_list[m].negative_idx /8 ]; + +if (data) { +/* Copy over the current byte and set the negative bit to 1 */ + data =0x00 ; +for (i =7 ; i >=0 ; i--) { + data <<=1 ; +if (7 - (d->LVDS_list[m].negative_idx %8 ) == i) +/* Set negative bit to 1. */ + data |=0x01 ; +else if (indata &0x80 ) + data |=0x01 ; + + indata <<=1 ; + } + + + }else { +/* Copy over the current byte and set the negative bit to 0. */ + data =0x00 ; +for (i =7 ; i >=0 ; i--) { + data <<=1 ; +if (7 - (d->LVDS_list[m].negative_idx %8 ) == i) +/* Set negative bit to 0. */ + data |=0x00 ; +else if (indata &0x80 ) + data |=0x01 ; + + indata <<=1 ; + } + } + +/* Store the modified byte. */ + d->out_TDO_data[d->LVDS_list[m].negative_idx /8 ] = data; + +return 0 ; +} + +int ispvm_process_lvds (struct ispvm_desc *d,int count) +{ +int i, j; +/* LVDSPair * pLVDSPair = NULL; */ + +/* Allocate memory to hold LVDS pairs. */ + j =ispvm_alloc (d,LVDS , count); +if (j !=0 ) +return VME_OUT_OF_MEMORY ; + d->LVDS_pair_count = count; + +/* Iterate through each given LVDS pair. */ +for (i =0 ; i < count; i++) { +/* +* Assign the positive and negative indices +* of the LVDS pair. +*/ + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + + d->LVDS_list[i].positive_idx = j; + + j =ispvm_data_size (d); +if (j ==-1 ) +return VME_INVALID_FILE ; + d->LVDS_list[i].negative_idx = j; + } + +return 0 ; +} + +#endif
PATCH 5/8 Adds support for RedBoot
In reply to Pantelis AntoniouProvide support for RedBoot's FIS & config variables.
For PPC provide also a way to boot a redboot compiled Linux kernel. The bd_t is different in that case.
---
---
README | 70 ++++ common/Makefile | 1 common/cmd_bootm.c | 20 + common/redboot.c | 978 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/redboot.h | 98 +++++ 5 files changed, 1166 insertions(+), 1 deletions(-)
README +70 -0
@@ -2324,6 +2324,76 @@ Low Level (hardware related) configuration options: some other boot loader or by a debugger which performs these intializations itself. +- CONFIG_REDBOOT + Add support for read-only parsing of the FIS & config areas. + For PPC also add an option to boot a kernel compiled for RedBoot. + + The redboot command is also enabled conditional on CFG_CMD_FLASH. + + - Select a different FIS + > redboot fis select ([bank] [sector] | reset) + + - Display FIS + > redboot fis list + + - Set an environment variable from a member variable of a FIS entry + + > redboot fis setenv var type name + + Where type: flash_base, mem_base, size, entry_point, data_length. + + An example given a FIS entry of + + Name FLASH addr Mem addr Datalen Length Entry point + Linux 0xF0470000 0x00100000 0x000FA000 0x00100000 0x00100000 + + > redboot fis setenv linux_base flash_base Linux + + Would set the environment variable linux_base to 0xf0470000 + + - Print either all the RedBoot config variables or a specific one + + > redboot config printenv [config-var] [member] + + member is one of value, type, enable-sense, enable-key with value + being the default one. + + - Set an environment variable from a RedBoot config variable + + > redboot config setenv var config-var [member] + + For example when given a config variable of + + tsec1_esa=00:08:e5:11:32:33 + type=esa enable-sense=true + + > redboot config setenv ethaddr tsec1_esa + + would set the ethaddr environment variable to 00:08:e5:11:32:33 + + - Boot a RedBoot kernel [PPC specific] + + > redboot exec address + + The PPC bd_t differs for kernels compiled for redboot; this command + lets you boot such a kernel. + + RedBoot config defaults (can be overriden on board config): + + - Sector containing the FIS area (negative values for counting from the end) + CONFIG_REDBOOT_FIS_DIRECTORY_BLOCK -1 + + - FIS directory entry size + CONFIG_REDBOOT_DIRECTORY_ENTRY_SIZE 0x100 + + - Size of the config area + CONFIG_REDBOOT_FLASH_CONFIG_SIZE 4096 + + - Size of the script config variables + CONFIG_REDBOOT_FLASH_SCRIPT_SIZE 256 + + - Size of the string config variables + CONFIG_REDBOOT_FLASH_STRING_SIZE 128 Building the Software: ======================
common/Makefile +1 -0
@@ -51,6 +51,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ lattice.o lattice_ec.o lattice_ivm_core.o lattice_ivm_supp.o \ lcd.o lists.o lynxkdi.o \ memsize.o miiphybb.o miiphyutil.o \ + redboot.o \ s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \ usb.o usb_kbd.o usb_storage.o \ virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o
common/cmd_bootm.c +19 -1
@@ -146,6 +146,12 @@ extern void lynxkdi_boot( image_header_t * );#define CFG_BOOTM_LEN 0x800000/* use 8MByte as default max gunzip size */ #endif +#ifdef CONFIG_REDBOOT_BD_T_SIZE +extern void board_redboot_bd_t_adapt (void *kbd, +ulong cmd_start,ulong cmd_end, +ulong initrd_start,ulong initrd_end); +#endif +image_header_t header;ulong load_addr =CFG_LOAD_ADDR ;/* Default Load Address */
@@ -533,6 +539,11 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,char *of_flat_tree =NULL ;ulong of_data =0 ;#endif +#ifdef CONFIG_REDBOOT_BD_T_SIZE +#define BD_T_SIZE max(sizeof(bd_t), CONFIG_REDBOOT_BD_T_SIZE) +#else +#define BD_T_SIZE sizeof(bd_t) +#endif if ((s =getenv ("initrd_high" )) !=NULL ) {/* a value of "no" or a similar string will act like 0,
@@ -575,7 +586,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,debug ("=> set upper limit to 0x%08lX\n" , sp); cmdline = (char *)((sp -CFG_BARGSIZE ) & ~0xF ); - kbd = (bd_t *)(((ulong )cmdline -sizeof (bd_t)) & ~0xF ); + kbd = (bd_t *)(((ulong )cmdline -BD_T_SIZE ) & ~0xF );if ((s =getenv ("bootargs" )) ==NULL ) s ="" ;
@@ -904,6 +915,13 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, initrd_end =0 ; } +/* redboot bd_t modify */ +#ifdef CONFIG_REDBOOT_BD_T_SIZE +if ((s =getenv ("redboot_bd_t" )) !=NULL ) +board_redboot_bd_t_adapt (kbd, cmd_start, cmd_end, + initrd_start, initrd_end); +#endif +debug ("## Transferring control to Linux (at address %08lx) ...\n" , (ulong )kernel);
common/redboot.c new file +978 -0
978 lines not on this page · raw message
include/redboot.h new file +98 -0
98 lines not on this page · raw message
PATCH 6/8 Support Analogue Micro's ASP8347DB board. CONFIG file.
In reply to Pantelis AntoniouAdd support for Analogue Micro's ASP8347DB board. The board is originally shipped with RedBoot. All appropriate settings are migrated to u-boot & the old kernel booted; a drop in bootloader replacement.
---
---
include/configs/ASP8347DB.h | 690 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 690 insertions(+), 0 deletions(-)
include/configs/ASP8347DB.h new file +690 -0
@@ -0,0 +1,690 @@ +/* +* (C) Copyright 2006 +* Pantelis Antoniou, Embedded Alley pantelis at embeddedalley.com +* +* Based on TQM834x by +* Wolfgang Denk, DENX Software Engineering, wd at 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 +*/ + +/* +* ASP8347DB board configuration file +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#define DEBUG +#undef DEBUG + +/* +* High Level Configuration Options +*/ +#define CONFIG_E300 1/* E300 Family */ +#define CONFIG_MPC83XX 1/* MPC83XX family */ +#define CONFIG_MPC834X 1/* MPC834X specific */ +#define CONFIG_MPC8349 1/* MPC8349 specific */ +#define CONFIG_ASP8347DB 1/* ASP8347DB board specific */ + +/* IMMR Base Addres Register, use Freescale default: 0xff400000 */ +#define CFG_IMMR 0xff000000 + +/* System clock. Primary input clock when in PCI host mode */ +#define CONFIG_83XX_CLKIN 66666000/* 66,666 MHz */ + +/* +* Local Bus LCRR +* LCRR: DLL bypass, Clock divider is 8 +* +* for CSB = 266 MHz it gives LCB clock frequency = 33 MHz +* +* External Local Bus rate is +* CLKIN * HRCWL_CSB_TO_CLKIN / HRCWL_LCL_BUS_TO_SCB_CLK / LCRR_CLKDIV +*/ +#define CFG_LCRR (LCRR_DBYP | LCRR_CLKDIV_8) + +/* board pre init: do not call, nothing to do */ +#undef CONFIG_BOARD_EARLY_INIT_F + +/* detect the number of flash banks */ +#define CONFIG_BOARD_EARLY_INIT_R + +/* auto complete please */ +#define CONFIG_AUTO_COMPLETE + +/* +* DDR Setup +*/ +#define CFG_DDR_BASE 0x00000000/* DDR is system memory */ +#define CFG_SDRAM_BASE CFG_DDR_BASE +#define CFG_SDRAM_SIZE 128 +#define CFG_DDR_SDRAM_BASE CFG_DDR_BASE +#define DDR_CASLAT_25 /* CASLAT set to 2.5 */ +#undef CONFIG_DDR_ECC/* only for ECC DDR module */ +#undef CONFIG_SPD_EEPROM/* do not use SPD EEPROM for DDR setup */ + +#define CFG_MEMTEST_START 0x00100000/* memtest region */ +#define CFG_MEMTEST_END 0x00200000 + +/* +* FLASH on the Local Bus +*/ +#define CFG_FLASH_CFI /* use the Common Flash Interface */ +#define CFG_FLASH_CFI_DRIVER /* use the CFI driver */ +#undef CFG_FLASH_CHECKSUM +#define CFG_FLASH_BASE 0xf0000000/* start of FLASH */ +#define CFG_FLASH_SIZE 64/* FLASH size in MB */ + +/* buffered writes in the AMD chip set is not supported yet */ +#undef CFG_FLASH_USE_BUFFER_WRITE + +/* +* FLASH bank number detection +*/ + +#define CFG_MAX_FLASH_BANKS 1 +#define CFG_MAX_FLASH_SECT 512/* max sectors per device */ + +/* 32 bit device at 0x80000000 via GPCM (0x8000_1801) */ +#define CFG_BR0_PRELIM ((CFG_FLASH_BASE & BR_BA) | \ + BR_MS_GPCM | BR_PS_16 | BR_V) + +/* FLASH timing */ +#define CFG_OR_TIMING_FLASH (OR_GPCM_CSNT | OR_GPCM_BCTLD | \ + OR_GPCM_CSNT | OR_GPCM_ACS_0b11 | \ + OR_GPCM_SCY_7 | OR_GPCM_TRLX | \ + OR_GPCM_EHTR) + +#define CFG_PRELIM_OR_AM 0xfc000000/* OR addr mask: 64MB */ + +#define CFG_OR0_PRELIM (CFG_PRELIM_OR_AM | CFG_OR_TIMING_FLASH) + +#define CFG_LBLAWAR0_PRELIM 0x8000001c/* 32 MB size (2^(size + 1)) */ +#define CFG_LBLAWBAR0_PRELIM CFG_FLASH_BASE/* Window base at flash base */ + +#define ASP8347DB_FPGA_BASE 0xf8000000 + +/* FPGA : 32bit */ +#define CFG_BR1_PRELIM ((ASP8347DB_FPGA_BASE & BR_BA) | \ + BR_MS_GPCM | BR_PS_32 | BR_V) +#define CFG_OR1_PRELIM (0xffff0000 | OR_GPCM_ACS_0b11 | \ + OR_GPCM_SCY_15 | OR_GPCM_TRLX | \ + OR_GPCM_EHTR) +#define CFG_LBLAWBAR1_PRELIM ASP8347DB_FPGA_BASE +#define CFG_LBLAWAR1_PRELIM 0x80000016 + +/* disable remaining mappings */ +#define CFG_BR2_PRELIM 0x00000000 +#define CFG_OR2_PRELIM 0x00000000 +#define CFG_LBLAWBAR2_PRELIM 0x00000000 +#define CFG_LBLAWAR2_PRELIM 0x00000000 + +#define CFG_BR3_PRELIM 0x00000000 +#define CFG_OR3_PRELIM 0x00000000 +#define CFG_LBLAWBAR3_PRELIM 0x00000000 +#define CFG_LBLAWAR3_PRELIM 0x00000000 + +#define CFG_BR4_PRELIM 0x00000000 +#define CFG_OR4_PRELIM 0x00000000 +#define CFG_LBLAWBAR4_PRELIM 0x00000000 +#define CFG_LBLAWAR4_PRELIM 0x00000000 + +#define CFG_BR5_PRELIM 0x00000000 +#define CFG_OR5_PRELIM 0x00000000 +#define CFG_LBLAWBAR5_PRELIM 0x00000000 +#define CFG_LBLAWAR5_PRELIM 0x00000000 + +#define CFG_BR6_PRELIM 0x00000000 +#define CFG_OR6_PRELIM 0x00000000 +#define CFG_LBLAWBAR6_PRELIM 0x00000000 +#define CFG_LBLAWAR6_PRELIM 0x00000000 + +#define CFG_BR7_PRELIM 0x00000000 +#define CFG_OR7_PRELIM 0x00000000 +#define CFG_LBLAWBAR7_PRELIM 0x00000000 +#define CFG_LBLAWAR7_PRELIM 0x00000000 + +/* +* Monitor config +*/ +#define CFG_MONITOR_BASE TEXT_BASE + +#if (CFG_MONITOR_BASE <CFG_FLASH_BASE ) +#define CFG_RAMBOOT +#else +#undef CFG_RAMBOOT +#endif + +#define CONFIG_L1_INIT_RAM +#define CFG_INIT_RAM_LOCK 1 +#define CFG_INIT_RAM_ADDR 0xFD000000/* Initial RAM address */ +#define CFG_INIT_RAM_END 0x1000/* End of used area in RAM */ + +#define CFG_GBL_DATA_SIZE 0x100/* num bytes initial data */ +#define CFG_GBL_DATA_OFFSET (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE) +#define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET + +#define CFG_MONITOR_LEN (256 * 1024)/* Reserve 256 kB for Mon */ +#define CFG_MALLOC_LEN (128 * 1024)/* Reserved for malloc */ + +/* +* Serial Port +*/ +#define CONFIG_CONS_INDEX 1 +#undef CONFIG_SERIAL_SOFTWARE_FIFO +#define CFG_NS16550 +#define CFG_NS16550_SERIAL +#define CFG_NS16550_REG_SIZE 1 +#define CFG_NS16550_CLK get_bus_freq(0) + +#define CFG_BAUDRATE_TABLE \ + {300, 600, 1200, 2400, 4800, 9600, 19200, 38400,115200} + +#define CFG_NS16550_COM1 (CFG_IMMR + 0x4500) +#define CFG_NS16550_COM2 (CFG_IMMR + 0x4600) + +/* +* I2C +*/ +#undef CONFIG_HARD_I2C/* I2C with hardware support */ +#undef CONFIG_SOFT_I2C/* I2C bit-banged */ +#define CFG_I2C_SPEED 400000/* I2C speed: 400KHz */ +#define CFG_I2C_SLAVE 0x7F/* slave address */ +#define CFG_I2C_OFFSET 0x3000 + +/* +* TSEC +*/ +#define CONFIG_TSEC_ENET /* tsec ethernet support */ +#define CONFIG_MII + +#define CFG_TSEC1_OFFSET 0x24000 +#define CFG_TSEC1 (CFG_IMMR + CFG_TSEC1_OFFSET) +#define CFG_TSEC2_OFFSET 0x25000 +#define CFG_TSEC2 (CFG_IMMR + CFG_TSEC2_OFFSET) + +#if defined(CONFIG_TSEC_ENET ) + +#ifndef CONFIG_NET_MULTI +#define CONFIG_NET_MULTI +#endif + +#define CONFIG_MPC83XX_TSEC1 1 +#define CONFIG_MPC83XX_TSEC1_NAME "TSEC0" +#define CONFIG_MPC83XX_TSEC2 1 +#define CONFIG_MPC83XX_TSEC2_NAME "TSEC1" +#define TSEC1_PHY_ADDR 1 +#define TSEC2_PHY_ADDR 2 +#define TSEC1_PHYIDX 0 +#define TSEC2_PHYIDX 0 + +/* Options are: TSEC[0-1] */ +#define CONFIG_ETHPRIME "TSEC0" + +#endif /* CONFIG_TSEC_ENET */ + +/* +* General PCI +* Addresses are mapped 1-1. +*/ +#define CONFIG_PCI + +#if defined(CONFIG_PCI ) + +#define CONFIG_PCI_PNP /* do pci plug-and-play */ +#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ + +/* PCI1 host bridge */ +#define CFG_PCI1_MEM_BASE 0xc0000000 +#define CFG_PCI1_MEM_PHYS CFG_PCI1_MEM_BASE +#define CFG_PCI1_MEM_SIZE 0x20000000/* 512M */ +#define CFG_PCI1_IO_BASE 0xe2000000 +#define CFG_PCI1_IO_PHYS CFG_PCI1_IO_BASE +#define CFG_PCI1_IO_SIZE 0x1000000/* 16M */ + + +#undef CONFIG_EEPRO100 +#define CONFIG_EEPRO100 +#undef CONFIG_TULIP + +#if !defined(CONFIG_PCI_PNP ) +#define PCI_ENET0_IOADDR CFG_PCI1_IO_BASE +#define PCI_ENET0_MEMADDR CFG_PCI1_MEM_BASE +#define PCI_IDSEL_NUMBER 0x1c/* slot0 (IDSEL) = 28 */ +#endif + +#define CFG_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ + +#endif /* CONFIG_PCI */ + +/* +* Environment +*/ +#define CONFIG_ENV_OVERWRITE + +#ifndef CFG_RAMBOOT +#define CFG_ENV_IS_IN_FLASH 1 +#define CFG_ENV_ADDR (CFG_MONITOR_BASE + 0x40000) +#define CFG_ENV_SECT_SIZE 0x10000/* 64K(one sector) for env */ +#define CFG_ENV_SIZE 0x2000 +#else +#define CFG_NO_FLASH 1/* Flash is not usable now */ +#define CFG_ENV_IS_NOWHERE 1/* Store ENV in memory only */ +#define CFG_ENV_ADDR (CFG_MONITOR_BASE - 0x1000) +#define CFG_ENV_SIZE 0x2000 +#endif + +#define CONFIG_LOADS_ECHO 1/* echo on serial download */ +#define CFG_LOADS_BAUD_CHANGE 1/* allow baudrate change */ + +/* Common commands */ +#define CFG_CMD_ASP8347DB_COMMON CFG_CMD_PING \ + | CFG_CMD_MII | CFG_CMD_JFFS2 + +#if defined(CFG_RAMBOOT ) + +#if defined(CONFIG_PCI ) +#define CONFIG_COMMANDS ((CONFIG_CMD_DFL | CFG_CMD_PCI \ + | CFG_CMD_ASP8347DB_COMMON) \ + & \ + ~(CFG_CMD_ENV | CFG_CMD_LOADS)) +#else +#define CONFIG_COMMANDS ((CONFIG_CMD_DFL \ + | CFG_CMD_ASP8347DB_COMMON) \ + & \ + ~(CFG_CMD_ENV | CFG_CMD_LOADS)) +#endif + +#else /* CFG_RAMBOOT */ + +#if defined(CONFIG_PCI ) +#define CONFIG_COMMANDS (CONFIG_CMD_DFL | CFG_CMD_PCI \ + | CFG_CMD_ASP8347DB_COMMON) +#else +#define CONFIG_COMMANDS (CONFIG_CMD_DFL \ + | CFG_CMD_ASP8347DB_COMMON) +#endif + +#endif /* CFG_RAMBOOT */ + +#include <cmd_confdefs.h> + +/* +* Miscellaneous configurable options +*/ +#define CFG_LONGHELP /* undef to save memory */ +#define CFG_LOAD_ADDR 0x2000000/* default load address */ +#define CFG_PROMPT "=> "/* Monitor Command Prompt */ + +#define CONFIG_CMDLINE_EDITING 1/* add command line history */ +#define CFG_HUSH_PARSER 1/* Use the HUSH parser */ +#ifdef CFG_HUSH_PARSER +#define CFG_PROMPT_HUSH_PS2 "> " +#endif + +#if (CONFIG_COMMANDS &CFG_CMD_KGDB ) +#define CFG_CBSIZE 1024/* Console I/O Buffer Size */ +#else +#define CFG_CBSIZE 256/* Console I/O Buffer Size */ +#endif + +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16)/* print buffer size */ +#define CFG_MAXARGS 16/* max num of command args */ +#define CFG_BARGSIZE CFG_CBSIZE/* boot arg buffer size */ +#define CFG_HZ 1000/* decrementer freq: 1ms */ + +#undef CONFIG_WATCHDOG/* watchdog disabled */ + +/* +* For booting Linux, the board info and command line data +* have to be in the first 8 MB of memory, since this is +* the maximum mapped by the Linux kernel during initialization. +*/ +#define CFG_BOOTMAPSZ (8 << 20)/* Initial Memory map for Linux */ + +/* +* Cache Configuration +*/ +#define CFG_DCACHE_SIZE 32768 +#define CFG_CACHELINE_SIZE 32 +#if (CONFIG_COMMANDS &CFG_CMD_KGDB ) +#define CFG_CACHELINE_SHIFT 5/*log base 2 of the above value*/ +#endif + +#define CFG_HRCW_LOW ( \ + HRCWL_LCL_BUS_TO_SCB_CLK_1X1 | \ + HRCWL_DDR_TO_SCB_CLK_1X1 | \ + HRCWL_CSB_TO_CLKIN_4X1 | \ + HRCWL_VCO_BYPASS | \ + HRCWL_CORE_TO_CSB_1_5X1) + +#define CFG_HRCW_HIGH ( \ + HRCWH_PCI_HOST | \ + HRCWH_32_BIT_PCI | \ + HRCWH_PCI1_ARBITER_ENABLE | \ + HRCWH_PCI2_ARBITER_DISABLE | \ + HRCWH_CORE_ENABLE | \ + HRCWH_FROM_0X00000100 | \ + HRCWH_BOOTSEQ_DISABLE | \ + HRCWH_SW_WATCHDOG_DISABLE | \ + HRCWH_ROM_LOC_LOCAL_16BIT | \ + HRCWH_TSEC1M_IN_GMII | \ + HRCWH_TSEC2M_IN_GMII) + +/* System IO Config */ +#if 0 +#define CFG_SICRH SICRH_TSOBI1 +#define CFG_SICRL SICRL_LDP_A +#else +#define CFG_SICRH 0x000000a0 +#define CFG_SICRL 0x80000000 +#endif + +/* i-cache and d-cache disabled */ +#define CFG_HID0_INIT 0x000000000 +#define CFG_HID0_FINAL CFG_HID0_INIT +#define CFG_HID2 HID2_HBE + +/* DDR 0 - 128 */ +#define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_10 | \ + BATL_MEMCOHERENCE) +#define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_256M | \ + BATU_VS | BATU_VP) + +/* DCACHE */ +#define CFG_IBAT1L (CFG_INIT_RAM_ADDR | BATL_PP_10 | \ + BATL_MEMCOHERENCE) +#define CFG_IBAT1U (CFG_INIT_RAM_ADDR | BATU_BL_128K | \ + BATU_VS | BATU_VP) + +#define CFG_IBAT2L 0 +#define CFG_IBAT2U 0 + +/* PCI */ +#ifdef CONFIG_PCI +#define CFG_IBAT3L (CFG_PCI1_MEM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE) +#define CFG_IBAT3U (CFG_PCI1_MEM_BASE | BATU_BL_256M | BATU_VS | BATU_VP) +#define CFG_IBAT4L (CFG_PCI1_MEM_BASE + 0x10000000 | BATL_PP_10 | \ + BATL_MEMCOHERENCE) +#define CFG_IBAT4U (CFG_PCI1_MEM_BASE + 0x10000000 | BATU_BL_256M | \ + BATU_VS | BATU_VP) +#define CFG_IBAT5L (CFG_PCI1_IO_BASE | BATL_PP_10 | BATL_CACHEINHIBIT | \ + BATL_GUARDEDSTORAGE) +#define CFG_IBAT5U (CFG_PCI1_IO_BASE + 0x10000000 | BATU_BL_16M | \ + BATU_VS | BATU_VP) +#else +#define CFG_IBAT3L (0) +#define CFG_IBAT3U (0) +#define CFG_IBAT4L (0) +#define CFG_IBAT4U (0) +#define CFG_IBAT5L (0) +#define CFG_IBAT5U (0) +#endif + +/* IMMR */ +#define CFG_IBAT6L (CFG_IMMR | BATL_PP_10 | BATL_CACHEINHIBIT | \ + BATL_GUARDEDSTORAGE) +#define CFG_IBAT6U (CFG_IMMR | BATU_BL_1M | BATU_VS | BATU_VP) + +/* FLASH */ +#define CFG_IBAT7L (CFG_FLASH_BASE | BATL_PP_10 | BATL_CACHEINHIBIT | \ + BATL_GUARDEDSTORAGE) +#define CFG_IBAT7U (CFG_FLASH_BASE | BATU_BL_256M | BATU_VS | BATU_VP) + +#define CFG_DBAT0L CFG_IBAT0L +#define CFG_DBAT0U CFG_IBAT0U +#define CFG_DBAT1L CFG_IBAT1L +#define CFG_DBAT1U CFG_IBAT1U +#define CFG_DBAT2L CFG_IBAT2L +#define CFG_DBAT2U CFG_IBAT2U +#define CFG_DBAT3L CFG_IBAT3L +#define CFG_DBAT3U CFG_IBAT3U +#define CFG_DBAT4L CFG_IBAT4L +#define CFG_DBAT4U CFG_IBAT4U +#define CFG_DBAT5L CFG_IBAT5L +#define CFG_DBAT5U CFG_IBAT5U +#define CFG_DBAT6L CFG_IBAT6L +#define CFG_DBAT6U CFG_IBAT6U +#define CFG_DBAT7L CFG_IBAT7L +#define CFG_DBAT7U CFG_IBAT7U + +/* +* Internal Definitions +* +* Boot Flags +*/ +#define BOOTFLAG_COLD 0x01/* Normal Power-On: Boot from FLASH */ +#define BOOTFLAG_WARM 0x02/* Software reboot */ + +#if (CONFIG_COMMANDS &CFG_CMD_KGDB ) +#define CONFIG_KGDB_BAUDRATE 230400/* speed of kgdb serial port */ +#define CONFIG_KGDB_SER_INDEX 2/* which serial port to use */ +#endif + +/* +* Environment Configuration +*/ + +#if defined(CONFIG_TSEC_ENET ) +#define CONFIG_ETHADDR D2:DA:5E:44:BC:29 +#define CONFIG_HAS_ETH1 +#define CONFIG_ETH1ADDR 1E:F3:40:21:92:53 +#endif + +#define CONFIG_IPADDR 192.168.1.249 + +#define CONFIG_HOSTNAME asp8347db +#define CONFIG_ROOTPATH /exports/asp8347db-root +#define CONFIG_BOOTFILE uImage-rattler + +#define CONFIG_SERVERIP 192.168.1.10 +#define CONFIG_GATEWAYIP 192.168.1.1 +#define CONFIG_NETMASK 255.255.255.0 + +#define CONFIG_LOADADDR 200000/* default for tftp and bootm */ + +#define CONFIG_BOOTDELAY 6/* -1 disables auto-boot */ +#undef CONFIG_BOOTARGS/* the boot command will set bootargs */ + +#define CONFIG_BAUDRATE 38400 + +#define CONFIG_PREBOOT "echo;" \ + "echo Type \"run flash_nfs\" to mount root filesystem over NFS;" \ + "echo" + +#undef CONFIG_BOOTARGS + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "netdev=eth0\0" \ + "hostname=asp8347db\0" \ + "nfsargs=setenv bootargs root=/dev/nfs rw " \ + "nfsroot=${serverip}:${rootpath}\0" \ + "ramargs=setenv bootargs root=/dev/ram rw\0" \ + "addip=setenv bootargs ${bootargs} " \ + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ + ":${hostname}:${netdev}:off panic=1\0" \ + "addtty=setenv bootargs ${bootargs} console=ttyS0,${baudrate}\0"\ + "flash_nfs=run nfsargs addip addtty;" \ + "bootm ${kernel_addr}\0" \ + "flash_self=run ramargs addip addtty;" \ + "bootm ${kernel_addr} ${ramdisk_addr}\0" \ + "net_nfs=tftp 200000 ${bootfile};run nfsargs addip addtty;" \ + "bootm\0" \ + "rootpath=/exports/asp8347db-root\0" \ + "bootfile=uImage-rattler\0" \ + "kernel_addr=80060000\0" \ + "ramdisk_addr=80160000\0" \ + "load=tftp 100000 /tftpboot/asp8347db/u-boot.bin\0" \ + "update=protect off 80000000 8003ffff; " \ + "era 80000000 8003ffff; cp.b 100000 80000000 40000\0" \ + "upd=run load;run update\0" \ + "" + +#define CONFIG_BOOTCOMMAND "run flash_self" + +/* +* JFFS2 partitions +*/ +/* mtdparts command line support */ +#define CONFIG_JFFS2_CMDLINE +#define MTDIDS_DEFAULT "nor0=ASP8347DB" + +/* default mtd partition table */ +#define MTDPARTS_DEFAULT "mtdparts=ASP8347DB:" \ + "256k(u-boot),64k(env),64k(env2)," \ + "64k(ASP8347DB.FPGA)," \ + "4m(jffs2),1m(Linux)," \ + "27136k(spare)," \ + "64k(RedBoot);"\ +/* +* Lattice FPGA configuration support +*/ +#define CONFIG_FPGA_COUNT 1 +#define CONFIG_FPGA CFG_LATTICE_EC +#define CFG_FPGA_PROG_FEEDBACK + +/* +* Enable the call to misc_init_r() for miscellaneous platform +* dependent initialization. +*/ +#define CONFIG_MISC_INIT_R + +/* +* Enable call to last_stage_init() +*/ +#define CONFIG_LAST_STAGE_INIT + +/* +* RedBoot support (this is conditional to CFG_CMD_FLASH) +*/ +#define CONFIG_REDBOOT 1 +#define CONFIG_REDBOOT_FLASH_SCRIPT_SIZE 512 +#define CONFIG_REDBOOT_FLASH_CONFIG_SIZE 65536 + +#ifndef __ASSEMBLY__ + +/* Damn RedBoot has a totally different bd_t */ +typedef struct redboot_bd_info { +unsigned int bi_tag;/* Should be 0x42444944 "BDID" */ +unsigned int bi_size;/* Size of this structure */ +unsigned int bi_revision;/* revision of this structure */ +unsigned int bi_bdate;/* bootstrap date, i.e. 0x19971106 */ +unsigned int bi_memstart;/* Memory start address */ +unsigned int bi_memsize;/* Memory (end) size in bytes */ +unsigned int bi_intfreq;/* Internal Freq, in Hz */ +unsigned int bi_busfreq;/* Bus Freq, in Hz */ +unsigned int bi_cpmfreq;/* CPM Freq, in Hz */ +unsigned int bi_brgfreq;/* BRG Freq, in Hz */ +unsigned int bi_vco;/* VCO Out from PLL */ +unsigned int bi_pci_freq;/* PCI Freq, in Hz */ +unsigned int bi_baudrate;/* Default console baud rate */ +unsigned int bi_immr;/* IMMR when called from boot rom */ +unsigned char bi_enetaddr[6 ]; +unsigned int bi_flashbase;/* Physical address of FLASH memory */ +unsigned int bi_flashsize;/* Length of FLASH memory */ +int bi_flashwidth;/* Width (8,16,32,64) */ +unsigned char *bi_cmdline;/* Pointer to command line */ +unsigned char bi_esa[3 ][6 ];/* Ethernet station addresses */ +unsigned int bi_ramdisk_begin; +unsigned int bi_ramdisk_end; +struct {/* info about [main] video screen */ +short x_res;/* Horizontal resolution in pixels */ +short y_res;/* Vertical resolution in pixels */ +short bpp;/* Bits/pixel */ +short mode;/* Type of pixels (packed, indexed) */ +unsigned long fb;/* frame buffer (pixel) memory */ + } bi_video; +void (*bi_cputc)(char );/* Write a character */ +char (*bi_cgetc)(void );/* Read a character */ +int (*bi_ctstc)(void );/* Test for input */ +}redboot_bd_t ; + +#endif + +#define CONFIG_REDBOOT_BD_T_SIZE sizeof(redboot_bd_t) + +/* +* Status LEDs +*/ +#define CONFIG_STATUS_LED 1/* Status LED enabled */ +#define CONFIG_BOARD_SPECIFIC_LED /* board has board specific leds */ + +#define STATUS_LED_BIT LED1 + +#define STATUS_LED_PERIOD (CFG_HZ / 2) +#define STATUS_LED_STATE STATUS_LED_BLINKING + +#define STATUS_LED_ACTIVE 1/* LED on for bit == 0 */ +#define STATUS_LED_BOOT 0/* LED 0 used for boot status */ + +#ifndef __ASSEMBLY__ + +/* LEDs */ + +/* led_id_t is unsigned int mask */ +typedef unsigned int led_id_t ; + +#define __led_toggle (_msk) \ + do { \ + ((volatile immap_t *)CFG_IMMR)->pgio[0].dat ^= (_msk); \ + } while(0) + +#define __led_set (_msk, _st) \ + do { \ + if ((_st)) \ + ((volatile immap_t *)CFG_IMMR)->pgio[0].dat |= \ + (_msk); \ + else \ + ((volatile immap_t *)CFG_IMMR)->pgio[0].dat &= \ + ~(_msk); \ + } while(0) + +#define __led_init (msk, st) __led_set(msk, st) + +#endif + +/* +* GPIOS +*/ + +/* easy powerpc bit defines */ +#define _B (x) (1 << (31 - (x))) + +/* GPIO1 */ +#define ECP_TMS _B(2)/* FPGA programming */ +#define ECP_TCK _B(3) +#define ECP_TDI _B(4) +#define ECP_TDO _B(5) +#define FPGA_RST _B(6)/* FPGA reset */ +#define USB0_RST _B(7)/* USB0 reset */ +#define USB1_RST _B(8)/* USB1 reset */ +#define LED1 _B(9) +#define LED2 _B(10) +#define LED3 _B(11) +#define LED4 _B(12) +#define LED_ALL (LED1 | LED2 | LED3 /* | LED4 */ ) + +/* GPIO2 */ +#define PHY1_RST _B(13)/* PHY1 reset */ +#define PHY2_RST _B(14)/* PHY2 reset */ +#define ETH_RST _B(19)/* Ethernet global reset */ +#define ETH_EN _B(18)/* Ethernet global enable */ + +#endif /* __CONFIG_H */
PATCH 7/8 Support Analogue Micro's ASP8347DB board. Implementation.
In reply to Pantelis AntoniouAdd support for Analogue Micro's ASP8347DB board. The board is originally shipped with RedBoot. All appropriate settings are migrated to u-boot & the old kernel booted; a drop in bootloader replacement.
---
---
MAKEALL | 3 Makefile | 3 board/asp8347db/Makefile | 52 ++++++ board/asp8347db/asp8347db.c | 371 +++++++++++++++++++++++++++++++++++++++++++ board/asp8347db/config.mk | 23 +++ board/asp8347db/fpga.c | 240 ++++++++++++++++++++++++++++ board/asp8347db/pci.c | 222 ++++++++++++++++++++++++++ board/asp8347db/u-boot.lds | 122 ++++++++++++++ include/status_led.h | 2 9 files changed, 1037 insertions(+), 1 deletions(-)
MAKEALL +2 -1
@@ -130,7 +130,8 @@ LIST_8260=" \ ######################################################################### LIST_83xx=" \ - TQM834x MPC8349EMDS MPC8349ITX MPC8360EMDS \ + ASP8347DB TQM834x MPC8349EMDS MPC8349ITX \ + MPC8360EMDS \ "
Makefile +3 -0
@@ -1588,6 +1588,9 @@ r5200_config : unconfig ## MPC83xx Systems ######################################################################### +ASP8347DB_config: unconfig + @$(MKCONFIG) $(@:_config=) ppc mpc83xx asp8347db + TQM834x_config: unconfig @$(MKCONFIG) $(@:_config=) ppc mpc83xx tqm834x
board/asp8347db/Makefile new file +52 -0
52 lines not on this page · raw message
board/asp8347db/asp8347db.c new file +371 -0
371 lines not on this page · raw message
board/asp8347db/config.mk new file +23 -0
@@ -0,0 +1,23 @@ +# +# Copyright 2004 Freescale Semiconductor, Inc. +# +# 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 +# + +TEXT_BASE = 0xf0000000
board/asp8347db/fpga.c new file +240 -0
240 lines not on this page · raw message
board/asp8347db/pci.c new file +222 -0
222 lines not on this page · raw message
board/asp8347db/u-boot.lds new file +122 -0
122 lines not on this page · raw message
include/status_led.h +2 -0
@@ -355,6 +355,8 @@ void status_led_set (int led, int state);# define STATUS_LED_ACTIVE 0/* LED on for bit == 0 */ # define STATUS_LED_BOOT 0/* LED 0 used for boot status */ +#elif defined(CONFIG_ASP8347DB ) +/* XXX empty just to avoid the error */ #else # error Status LED configuration missing#endif
PATCH 8/8 Pantelis Antoniou MAINTAINER update.
In reply to Pantelis AntoniouUpdate with my new email address, add as a maintainer of ASP8347DB. Also move NETVIA to unmaintained section.
---
---
MAINTAINERS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
MAINTAINERS +3 -2
@@ -21,9 +21,9 @@ Greg Allen <[email protected]> UTX8245 MPC8245 -Pantelis Antoniou <[email protected]> +Pantelis Antoniou <[email protected]> - NETVIA MPC8xx + ASP8347DB MPC834x Reinhard Arlt <[email protected]>
@@ -368,6 +368,7 @@ Unknown / orphaned boards: IAD210 MPC8xx MBX MPC8xx MBX860T MPC8xx + NETVIA MPC8xx NX823 MPC8xx RPXClassic MPC8xx RPXlite MPC8xx