From: Florent Kermarrec Date: Mon, 18 May 2020 20:19:02 +0000 (+0200) Subject: bios/software: rename cmd_dram/cmd_sdcard/cmd_spi_flash to cmd_litedram/cmd_litesdcar... X-Git-Tag: 24jan2021_ls180~328^2~6 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c95084e5c69bd57b894138cdfec5c360f13111e4;p=litex.git bios/software: rename cmd_dram/cmd_sdcard/cmd_spi_flash to cmd_litedram/cmd_litesdcard/cmd_spiflash. --- diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index fe809fe8..24d33a50 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -19,11 +19,11 @@ OBJECTS = isr.o \ helpers.o \ cmd_bios.o \ cmd_boot.o \ - cmd_dram.o \ + cmd_litedram.o \ cmd_liteeth.o \ cmd_mem.o \ - cmd_sdcard.o \ - cmd_spi_flash.o \ + cmd_litesdcard.o \ + cmd_spiflash.o \ ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" "" CFLAGS += -DTERM_NO_COMPLETE diff --git a/litex/soc/software/bios/commands/cmd_dram.c b/litex/soc/software/bios/commands/cmd_dram.c deleted file mode 100644 index 0d6fa1d4..00000000 --- a/litex/soc/software/bios/commands/cmd_dram.c +++ /dev/null @@ -1,222 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "../command.h" -#include "../helpers.h" -#include "../sdram.h" - -/** - * Command "sdrrow" - * - * Precharge/Activate row - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrow_handler(int nb_params, char **params) -{ - char *c; - unsigned int row; - - if (nb_params < 1) { - sdrrow(0); - printf("Precharged"); - } - - row = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect row"); - return; - } - - sdrrow(row); - printf("Activated row %d", row); -} -define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS); -#endif - -/** - * Command "sdrsw" - * - * Gives SDRAM control to SW - * - */ -#ifdef CSR_SDRAM_BASE -define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS); -#endif - -/** - * Command "sdrhw" - * - * Gives SDRAM control to HW - * - */ -#ifdef CSR_SDRAM_BASE -define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", DRAM_CMDS); -#endif - -/** - * Command "sdrrdbuf" - * - * Dump SDRAM read buffer - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrdbuf_handler(int nb_params, char **params) -{ - sdrrdbuf(-1); -} - -define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", DRAM_CMDS); -#endif - -/** - * Command "sdrrd" - * - * Read SDRAM data - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrd_handler(int nb_params, char **params) -{ - unsigned int addr; - int dq; - char *c; - - if (nb_params < 1) { - printf("sdrrd
"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - if (nb_params < 2) - dq = -1; - else { - dq = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect DQ"); - return; - } - } - - sdrrd(addr, dq); -} - -define_command(sdrrd, sdrrd_handler, "Read SDRAM data", DRAM_CMDS); -#endif - -/** - * Command "sdrrderr" - * - * Print SDRAM read errors - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrderr_handler(int nb_params, char **params) -{ - int count; - char *c; - - if (nb_params < 1) { - printf("sdrrderr "); - return; - } - - count = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect count"); - return; - } - - sdrrderr(count); -} - -define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", DRAM_CMDS); -#endif - -/** - * Command "sdrwr" - * - * Write SDRAM test data - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrwr_handler(int nb_params, char **params) -{ - unsigned int addr; - char *c; - - if (nb_params < 1) { - printf("sdrwr
"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - sdrwr(addr); -} - -define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS); -#endif - -/** - * Command "sdrinit" - * - * Start SDRAM initialisation - * - */ -#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE) -define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS); -#endif - -/** - * Command "sdrwlon" - * - * Write leveling ON - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS); -#endif - -/** - * Command "sdrwloff" - * - * Write leveling OFF - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS); -#endif - -/** - * Command "sdrlevel" - * - * Perform read/write leveling - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE) -define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS); -#endif - -/** - * Command "memtest" - * - * Run a memory test - * - */ -#ifdef CSR_SDRAM_BASE -define_command(memtest, memtest, "Run a memory test", DRAM_CMDS); -#endif diff --git a/litex/soc/software/bios/commands/cmd_litedram.c b/litex/soc/software/bios/commands/cmd_litedram.c new file mode 100644 index 00000000..dbca4129 --- /dev/null +++ b/litex/soc/software/bios/commands/cmd_litedram.c @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "../command.h" +#include "../helpers.h" +#include "../sdram.h" + +/** + * Command "sdrrow" + * + * Precharge/Activate row + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrow_handler(int nb_params, char **params) +{ + char *c; + unsigned int row; + + if (nb_params < 1) { + sdrrow(0); + printf("Precharged"); + } + + row = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect row"); + return; + } + + sdrrow(row); + printf("Activated row %d", row); +} +define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS); +#endif + +/** + * Command "sdrsw" + * + * Gives SDRAM control to SW + * + */ +#ifdef CSR_SDRAM_BASE +define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS); +#endif + +/** + * Command "sdrhw" + * + * Gives SDRAM control to HW + * + */ +#ifdef CSR_SDRAM_BASE +define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", DRAM_CMDS); +#endif + +/** + * Command "sdrrdbuf" + * + * Dump SDRAM read buffer + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrdbuf_handler(int nb_params, char **params) +{ + sdrrdbuf(-1); +} + +define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", DRAM_CMDS); +#endif + +/** + * Command "sdrrd" + * + * Read SDRAM data + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrd_handler(int nb_params, char **params) +{ + unsigned int addr; + int dq; + char *c; + + if (nb_params < 1) { + printf("sdrrd
"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + if (nb_params < 2) + dq = -1; + else { + dq = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect DQ"); + return; + } + } + + sdrrd(addr, dq); +} + +define_command(sdrrd, sdrrd_handler, "Read SDRAM data", DRAM_CMDS); +#endif + +/** + * Command "sdrrderr" + * + * Print SDRAM read errors + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrderr_handler(int nb_params, char **params) +{ + int count; + char *c; + + if (nb_params < 1) { + printf("sdrrderr "); + return; + } + + count = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect count"); + return; + } + + sdrrderr(count); +} + +define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", DRAM_CMDS); +#endif + +/** + * Command "sdrwr" + * + * Write SDRAM test data + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrwr_handler(int nb_params, char **params) +{ + unsigned int addr; + char *c; + + if (nb_params < 1) { + printf("sdrwr
"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + sdrwr(addr); +} + +define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS); +#endif + +/** + * Command "sdrinit" + * + * Start SDRAM initialisation + * + */ +#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE) +define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS); +#endif + +/** + * Command "sdrwlon" + * + * Write leveling ON + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) +define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS); +#endif + +/** + * Command "sdrwloff" + * + * Write leveling OFF + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) +define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS); +#endif + +/** + * Command "sdrlevel" + * + * Perform read/write leveling + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE) +define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS); +#endif + +/** + * Command "memtest" + * + * Run a memory test + * + */ +#ifdef CSR_SDRAM_BASE +define_command(memtest, memtest, "Run a memory test", DRAM_CMDS); +#endif diff --git a/litex/soc/software/bios/commands/cmd_litesdcard.c b/litex/soc/software/bios/commands/cmd_litesdcard.c new file mode 100644 index 00000000..d9545e07 --- /dev/null +++ b/litex/soc/software/bios/commands/cmd_litesdcard.c @@ -0,0 +1,143 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "../command.h" +#include "../helpers.h" +#include "../sdcard.h" + +/** + * Command "sdclk" + * + * Configure SDcard clock frequency + * + */ +#ifdef CSR_SDCORE_BASE +static void sdclk(int nb_params, char **params) +{ + unsigned int frequ; + char *c; + + if (nb_params < 1) { + printf("sdclk "); + return; + } + + frequ = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect frequency"); + return; + } + + sdclk_set_clk(frequ); +} + +struct command_struct cmd_sdclk = +{ + .func = sdclk, + .name = "sdclk", + .help = "SDCard set clk frequency (Mhz)", +}; + +define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS); +#endif + +/** + * Command "sdinit" + * + * Initialize SDcard + * + */ +#ifdef CSR_SDCORE_BASE +define_command(sdinit, sdcard_init, "SDCard initialization", SD_CMDS); +#endif + +/** + * Command "sdtest" + * + * Perform SDcard read/write tests + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtest(int nb_params, char **params) +{ + unsigned int blocks; + char *c; + + if (nb_params < 1) { + printf("sdtest "); + return; + } + + blocks = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of blocks to write"); + return; + } + + sdcard_test(blocks); +} + +define_command(sdtest, sdtest, "SDCard test", SD_CMDS); +#endif + +/** + * Command "sdtestread" + * + * Perform SDcard read test + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtestread(int nb_params, char **params) +{ + unsigned int block; + char *c; + + if (nb_params < 1) { + printf("sdtestread "); + return; + } + + block = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of block to read"); + return; + } + + sdcard_test_read(block); +} + +define_command(sdtestread, sdtestread, "SDCard test read", SD_CMDS); +#endif + +/** + * Command "sdtestwrite" + * + * Perform SDcard write test + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtestwrite(int nb_params, char **params) +{ + unsigned int block; + char *c; + + if (nb_params < 2) { + printf("sdtestread "); + return; + } + + block = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of block to write"); + return; + } + + sdcard_test_write(block, params[1]); +} + +define_command(sdtestwrite, sdtestwrite, "SDCard test write", SD_CMDS); +#endif diff --git a/litex/soc/software/bios/commands/cmd_sdcard.c b/litex/soc/software/bios/commands/cmd_sdcard.c deleted file mode 100644 index d9545e07..00000000 --- a/litex/soc/software/bios/commands/cmd_sdcard.c +++ /dev/null @@ -1,143 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "../command.h" -#include "../helpers.h" -#include "../sdcard.h" - -/** - * Command "sdclk" - * - * Configure SDcard clock frequency - * - */ -#ifdef CSR_SDCORE_BASE -static void sdclk(int nb_params, char **params) -{ - unsigned int frequ; - char *c; - - if (nb_params < 1) { - printf("sdclk "); - return; - } - - frequ = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect frequency"); - return; - } - - sdclk_set_clk(frequ); -} - -struct command_struct cmd_sdclk = -{ - .func = sdclk, - .name = "sdclk", - .help = "SDCard set clk frequency (Mhz)", -}; - -define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS); -#endif - -/** - * Command "sdinit" - * - * Initialize SDcard - * - */ -#ifdef CSR_SDCORE_BASE -define_command(sdinit, sdcard_init, "SDCard initialization", SD_CMDS); -#endif - -/** - * Command "sdtest" - * - * Perform SDcard read/write tests - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtest(int nb_params, char **params) -{ - unsigned int blocks; - char *c; - - if (nb_params < 1) { - printf("sdtest "); - return; - } - - blocks = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of blocks to write"); - return; - } - - sdcard_test(blocks); -} - -define_command(sdtest, sdtest, "SDCard test", SD_CMDS); -#endif - -/** - * Command "sdtestread" - * - * Perform SDcard read test - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtestread(int nb_params, char **params) -{ - unsigned int block; - char *c; - - if (nb_params < 1) { - printf("sdtestread "); - return; - } - - block = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of block to read"); - return; - } - - sdcard_test_read(block); -} - -define_command(sdtestread, sdtestread, "SDCard test read", SD_CMDS); -#endif - -/** - * Command "sdtestwrite" - * - * Perform SDcard write test - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtestwrite(int nb_params, char **params) -{ - unsigned int block; - char *c; - - if (nb_params < 2) { - printf("sdtestread "); - return; - } - - block = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of block to write"); - return; - } - - sdcard_test_write(block, params[1]); -} - -define_command(sdtestwrite, sdtestwrite, "SDCard test write", SD_CMDS); -#endif diff --git a/litex/soc/software/bios/commands/cmd_spi_flash.c b/litex/soc/software/bios/commands/cmd_spi_flash.c deleted file mode 100644 index 8ca18c87..00000000 --- a/litex/soc/software/bios/commands/cmd_spi_flash.c +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "fw" - * - * Write data from a memory buffer to SPI flash - * - */ -#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) -static void fw(int nb_params, char **params) -{ - char *c; - unsigned int addr; - unsigned int value; - unsigned int count; - unsigned int i; - - if (nb_params < 2) { - printf("fw [count]"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect offset"); - return; - } - - value = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect value"); - return; - } - - if (nb_params == 2) { - count = 1; - } else { - count = strtoul(params[2], &c, 0); - if (*c != 0) { - printf("Incorrect count"); - return; - } - } - - for (i = 0; i < count; i++) - write_to_flash(addr + i * 4, (unsigned char *)&value, 4); -} - -define_command(fw, fw, "Write to flash", SPIFLASH_CMDS); -#endif - -/** - * Command "fe" - * - * Flash erase - * - */ -#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) -static void fe(int nb_params, char **params) -{ - erase_flash(); - printf("Flash erased\n"); -} - -define_command(fe, fe, "Erase whole flash", SPIFLASH_CMDS); -#endif - diff --git a/litex/soc/software/bios/commands/cmd_spiflash.c b/litex/soc/software/bios/commands/cmd_spiflash.c new file mode 100644 index 00000000..8ca18c87 --- /dev/null +++ b/litex/soc/software/bios/commands/cmd_spiflash.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "fw" + * + * Write data from a memory buffer to SPI flash + * + */ +#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) +static void fw(int nb_params, char **params) +{ + char *c; + unsigned int addr; + unsigned int value; + unsigned int count; + unsigned int i; + + if (nb_params < 2) { + printf("fw [count]"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect offset"); + return; + } + + value = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect value"); + return; + } + + if (nb_params == 2) { + count = 1; + } else { + count = strtoul(params[2], &c, 0); + if (*c != 0) { + printf("Incorrect count"); + return; + } + } + + for (i = 0; i < count; i++) + write_to_flash(addr + i * 4, (unsigned char *)&value, 4); +} + +define_command(fw, fw, "Write to flash", SPIFLASH_CMDS); +#endif + +/** + * Command "fe" + * + * Flash erase + * + */ +#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) +static void fe(int nb_params, char **params) +{ + erase_flash(); + printf("Flash erased\n"); +} + +define_command(fe, fe, "Erase whole flash", SPIFLASH_CMDS); +#endif +