From 30ce5ab043db0b34838ad2d294561992bdb5236a Mon Sep 17 00:00:00 2001 From: wdenk Date: Sun, 9 Jan 2005 18:12:51 +0000 Subject: [PATCH] * Patch by Gleb Natapov, 07 Sep 2004: mpc824x: set PCI latency timer to a sane value (is 0 after reset). * Patch by Kurt Stremerch, 03 Sep 2004: Add bitstream configuration option for fpga command (Xilinx only). --- CHANGELOG | 7 +++ common/cmd_fpga.c | 121 +++++++++++++++++++++++++++++++++++++++++ cpu/mpc824x/cpu_init.c | 2 +- 3 files changed, 129 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b6f3c89611..4dd8038d96 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,13 @@ Changes for U-Boot 1.1.3: ====================================================================== +* Patch by Gleb Natapov, 07 Sep 2004: + mpc824x: set PCI latency timer to a sane value + (is 0 after reset). + +* Patch by Kurt Stremerch, 03 Sep 2004: + Add bitstream configuration option for fpga command (Xilinx only). + * Patch by Kurt Stremerch, 03 Sep 2004: Add Xilinx Spartan2E family FPGA support diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index 325fdd1420..7c762bab92 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -52,8 +52,122 @@ static int fpga_get_op (char *opstr); #define FPGA_NONE -1 #define FPGA_INFO 0 #define FPGA_LOAD 1 +#define FPGA_LOADB 2 #define FPGA_DUMP 3 +/* Convert bitstream data and load into the fpga */ +int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) +{ + int length; + char* swapdata; + int swapsize; + char buffer[80]; + char *ptr; + char *dataptr; + int data; + int i; + int rc; + + dataptr = fpgadata; + +#if CFG_FPGA_XILINX + /* skip the first 13 bytes of the bitsteam, their meaning is unknown */ + dataptr+=13; + + /* get design name (identifier, length, string) */ + if (*dataptr++ != 0x61) { + PRINTF(__FUNCTION__ ": Design name identifier not recognized in bitstream.\n"); + return FPGA_FAIL; + } + + length = (*dataptr << 8) + *(dataptr+1); + dataptr+=2; + for(i=0;i= size) { + printf(__FUNCTION__ ": Could not find right length of data in bitstream.\n"); + return FPGA_FAIL; + } + + /* allocate memory */ + swapdata = (char *)malloc(swapsize); + if (swapdata == NULL) { + printf(__FUNCTION__ ": Could not allocate %d bytes memory !\n",swapsize); + return FPGA_FAIL; + } + + /* read data into memory and swap bits */ + ptr = swapdata; + for (i = 0; i < swapsize; i++) { + data = 0x00; + data |= (*dataptr & 0x01) << 7; + data |= (*dataptr & 0x02) << 5; + data |= (*dataptr & 0x04) << 3; + data |= (*dataptr & 0x08) << 1; + data |= (*dataptr & 0x10) >> 1; + data |= (*dataptr & 0x20) >> 3; + data |= (*dataptr & 0x40) >> 5; + data |= (*dataptr & 0x80) >> 7; + *ptr++ = data; + dataptr++; + } + + rc = fpga_load(dev, swapdata, swapsize); + free(swapdata); + return rc; +#else + printf("Bitstream support only for Xilinx devices.\n"); + return FPGA_FAIL; +#endif +} + /* ------------------------------------------------------------------------- */ /* command form: * fpga @@ -118,6 +232,10 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) rc = fpga_load (dev, fpga_data, data_size); break; + case FPGA_LOADB: + rc = fpga_loadbitstream(dev, fpga_data, data_size); + break; + case FPGA_DUMP: rc = fpga_dump (dev, fpga_data, data_size); break; @@ -145,6 +263,8 @@ static int fpga_get_op (char *opstr) if (!strcmp ("info", opstr)) { op = FPGA_INFO; + } else if (!strcmp ("loadb", opstr)) { + op = FPGA_LOADB; } else if (!strcmp ("load", opstr)) { op = FPGA_LOAD; } else if (!strcmp ("dump", opstr)) { @@ -163,5 +283,6 @@ U_BOOT_CMD (fpga, 6, 1, do_fpga, "fpga operations:\n" "\tinfo\tlist known device information.\n" "\tload\tLoad device from memory buffer.\n" + "\tloadb\tLoad device from bitstream buffer (Xilinx devices only).\n" "\tdump\tLoad device to memory buffer.\n"); #endif /* CONFIG_FPGA && CONFIG_COMMANDS & CFG_CMD_FPGA */ diff --git a/cpu/mpc824x/cpu_init.c b/cpu/mpc824x/cpu_init.c index d0c7a3bcab..965f4fd5ed 100644 --- a/cpu/mpc824x/cpu_init.c +++ b/cpu/mpc824x/cpu_init.c @@ -90,7 +90,7 @@ cpu_init_f (void) #endif CONFIG_WRITE_BYTE(PCLSR, 0x8); /* set PCI cache line size */ - + CONFIG_WRITE_BYTE (PLTR, 0x40); /* set PCI latency timer */ /* * Note that although this bit is cleared after a hard reset, it * must be explicitly set and then cleared by software during -- 2.25.1