soc/software: move helpers to hw/common.h

Fixes warning:
liblitespi/spiflash.c: In function 'spiflash_erase_range':
liblitespi/spiflash.c:202:4: warning: implicit declaration of function 'cdelay' [-Wimplicit-function-declaration]
    cdelay(CONFIG_CLOCK_FREQUENCY/25);
    ^~~~~~

Fixes link failure with spiflash and without liblitedram after commit: 118dd6ed08

ld: ../liblitespi/liblitespi.a(spiflash.o): in function `spiflash_erase_range':
../liblitespi/spiflash.c:209: undefined reference to `cdelay'
This commit is contained in:
Andrew Dennison 2023-05-31 17:17:04 +10:00 committed by Florent Kermarrec
parent d8ba2e8f65
commit 200a1a18ee
6 changed files with 16 additions and 40 deletions

View file

@ -36,13 +36,6 @@
#include <liblitesata/sata.h>
#include <libfatfs/ff.h>
/*-----------------------------------------------------------------------*/
/* Helpers */
/*-----------------------------------------------------------------------*/
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
/*-----------------------------------------------------------------------*/
/* Boot */
/*-----------------------------------------------------------------------*/

View file

@ -4,6 +4,22 @@
#include <stdint.h>
#include <system.h>
/*-----------------------------------------------------------------------*/
/* Helpers */
/*-----------------------------------------------------------------------*/
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
static inline void cdelay(int i) {
#ifndef CONFIG_BIOS_NO_DELAYS
while(i > 0) {
__asm__ volatile(CONFIG_CPU_NOP);
i--;
}
#endif // CONFIG_BIOS_NO_DELAYS
}
/* To overwrite CSR subregister accessors, define extern, non-inlined versions
* of csr_[read|write]_simple(), and define CSR_ACCESSORS_DEFINED.
*/

View file

@ -10,9 +10,6 @@ extern "C" {
#include <generated/csr.h>
#include <generated/soc.h>
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
#ifndef MEMTEST_DATA_SIZE
#define MEMTEST_DATA_SIZE (2*1024*1024)
#endif

View file

@ -50,22 +50,6 @@
#define MODULO (1)
#endif // SDRAM_PHY_DELAYS > 32
/*-----------------------------------------------------------------------*/
/* Helpers */
/*-----------------------------------------------------------------------*/
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
__attribute__((unused)) void cdelay(int i) {
#ifndef CONFIG_BIOS_NO_DELAYS
while(i > 0) {
__asm__ volatile(CONFIG_CPU_NOP);
i--;
}
#endif // CONFIG_BIOS_NO_DELAYS
}
/*-----------------------------------------------------------------------*/
/* Constants */
/*-----------------------------------------------------------------------*/

View file

@ -33,13 +33,6 @@
#define SDCARD_CLK_FREQ 25000000
#endif
/*-----------------------------------------------------------------------*/
/* Helpers */
/*-----------------------------------------------------------------------*/
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
/*-----------------------------------------------------------------------*/
/* SDCard command helpers */
/*-----------------------------------------------------------------------*/

View file

@ -28,13 +28,6 @@
#define SPISDCARD_CLK_FREQ 20000000
#endif
/*-----------------------------------------------------------------------*/
/* Helpers */
/*-----------------------------------------------------------------------*/
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
/*-----------------------------------------------------------------------*/
/* SPI SDCard clocker functions */
/*-----------------------------------------------------------------------*/