diff --git a/litex/soc/cores/cpu/blackparrot/system.h b/litex/soc/cores/cpu/blackparrot/system.h index 079c7cfd7..9165ec802 100644 --- a/litex/soc/cores/cpu/blackparrot/system.h +++ b/litex/soc/cores/cpu/blackparrot/system.h @@ -9,6 +9,7 @@ __attribute__((unused)) static void flush_cpu_icache(void){}; /* FIXME: do some __attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do something useful here! */ void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #include diff --git a/litex/soc/cores/cpu/cv32e40p/system.h b/litex/soc/cores/cpu/cv32e40p/system.h index b787320a2..fa134fc38 100644 --- a/litex/soc/cores/cpu/cv32e40p/system.h +++ b/litex/soc/cores/cpu/cv32e40p/system.h @@ -22,6 +22,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void) void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #define csrr(reg) ({ unsigned long __tmp; \ asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ diff --git a/litex/soc/cores/cpu/lm32/system.h b/litex/soc/cores/cpu/lm32/system.h index 1272cf1ae..6fe734551 100644 --- a/litex/soc/cores/cpu/lm32/system.h +++ b/litex/soc/cores/cpu/lm32/system.h @@ -27,6 +27,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void) void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #ifdef __cplusplus } diff --git a/litex/soc/cores/cpu/microwatt/system.h b/litex/soc/cores/cpu/microwatt/system.h index c8c4e41c2..4a53f0760 100644 --- a/litex/soc/cores/cpu/microwatt/system.h +++ b/litex/soc/cores/cpu/microwatt/system.h @@ -13,6 +13,7 @@ static inline void flush_cpu_dcache(void){}; /* FIXME: do something useful here! void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #ifdef __cplusplus } diff --git a/litex/soc/cores/cpu/minerva/system.h b/litex/soc/cores/cpu/minerva/system.h index 408ab3659..220d1fed1 100644 --- a/litex/soc/cores/cpu/minerva/system.h +++ b/litex/soc/cores/cpu/minerva/system.h @@ -9,6 +9,7 @@ __attribute__((unused)) static void flush_cpu_icache(void){}; /* FIXME: do somet __attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do something useful here! */ void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #include diff --git a/litex/soc/cores/cpu/mor1kx/system.h b/litex/soc/cores/cpu/mor1kx/system.h index 77366810a..554162278 100644 --- a/litex/soc/cores/cpu/mor1kx/system.h +++ b/litex/soc/cores/cpu/mor1kx/system.h @@ -62,6 +62,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void) void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #ifdef __cplusplus } diff --git a/litex/soc/cores/cpu/picorv32/system.h b/litex/soc/cores/cpu/picorv32/system.h index afa56d677..262446a62 100644 --- a/litex/soc/cores/cpu/picorv32/system.h +++ b/litex/soc/cores/cpu/picorv32/system.h @@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* No instruction void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #ifdef __cplusplus } diff --git a/litex/soc/cores/cpu/rocket/system.h b/litex/soc/cores/cpu/rocket/system.h index d3e98e1db..5ed09d2a5 100644 --- a/litex/soc/cores/cpu/rocket/system.h +++ b/litex/soc/cores/cpu/rocket/system.h @@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do somet void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #include diff --git a/litex/soc/cores/cpu/serv/system.h b/litex/soc/cores/cpu/serv/system.h index afa56d677..262446a62 100644 --- a/litex/soc/cores/cpu/serv/system.h +++ b/litex/soc/cores/cpu/serv/system.h @@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* No instruction void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #ifdef __cplusplus } diff --git a/litex/soc/cores/cpu/vexriscv/system.h b/litex/soc/cores/cpu/vexriscv/system.h index f441a197e..c1239889b 100644 --- a/litex/soc/cores/cpu/vexriscv/system.h +++ b/litex/soc/cores/cpu/vexriscv/system.h @@ -37,6 +37,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void) void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #define csrr(reg) ({ unsigned long __tmp; \ asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ diff --git a/litex/soc/cores/cpu/vexriscv_smp/system.h b/litex/soc/cores/cpu/vexriscv_smp/system.h index a3759aec6..15649f602 100644 --- a/litex/soc/cores/cpu/vexriscv_smp/system.h +++ b/litex/soc/cores/cpu/vexriscv_smp/system.h @@ -27,6 +27,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void) void flush_l2_cache(void); void busy_wait(unsigned int ms); +void busy_wait_us(unsigned int us); #include diff --git a/litex/soc/software/libbase/system.c b/litex/soc/software/libbase/system.c index ed4110dde..4e5318323 100644 --- a/litex/soc/software/libbase/system.c +++ b/litex/soc/software/libbase/system.c @@ -24,3 +24,13 @@ void busy_wait(unsigned int ms) timer0_update_value_write(1); while(timer0_value_read()) timer0_update_value_write(1); } + +void busy_wait_us(unsigned int us) +{ + timer0_en_write(0); + timer0_reload_write(0); + timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us); + timer0_en_write(1); + timer0_update_value_write(1); + while(timer0_value_read()) timer0_update_value_write(1); +} diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index fc9e3ff0a..52e87af6d 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -42,16 +42,6 @@ unsigned int sdcard_response[SD_CMD_RESPONSE_SIZE/4]; /* SDCard command helpers */ /*-----------------------------------------------------------------------*/ -static void busy_wait_us(unsigned int us) -{ - timer0_en_write(0); - timer0_reload_write(0); - timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us); - timer0_en_write(1); - timer0_update_value_write(1); - while(timer0_value_read()) timer0_update_value_write(1); -} - int sdcard_wait_cmd_done(void) { unsigned int cmdevt; while (1) { diff --git a/litex/soc/software/liblitesdcard/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c index 01c62d4cf..eeb8dee5d 100644 --- a/litex/soc/software/liblitesdcard/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -123,16 +123,6 @@ static void spisdcardread_bytes(uint8_t* buf, uint16_t n) { /* SPI SDCard blocks Xfer functions */ /*-----------------------------------------------------------------------*/ -static void busy_wait_us(unsigned int us) -{ - timer0_en_write(0); - timer0_reload_write(0); - timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us); - timer0_en_write(1); - timer0_update_value_write(1); - while(timer0_value_read()) timer0_update_value_write(1); -} - static uint8_t spisdcardreceive_block(uint8_t *buf) { uint16_t i; uint32_t timeout;