From: Gabriel Somlo Date: Fri, 27 Mar 2020 10:58:06 +0000 (-0400) Subject: software/bios: factor out busy_wait() function X-Git-Tag: 24jan2021_ls180~510^2~2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c6b6dee2e78fa16a81c54ad03dcaf45807fcb511;p=litex.git software/bios: factor out busy_wait() function Signed-off-by: Gabriel Somlo --- diff --git a/litex/soc/software/bios/sdcard.c b/litex/soc/software/bios/sdcard.c index c12b2db1..314b9e28 100644 --- a/litex/soc/software/bios/sdcard.c +++ b/litex/soc/software/bios/sdcard.c @@ -143,16 +143,6 @@ void sdclk_set_clk(unsigned int freq) { /* command utils */ -static void busy_wait(unsigned int ms) -{ - timer0_en_write(0); - timer0_reload_write(0); - timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000*ms); - timer0_en_write(1); - timer0_update_value_write(1); - while(timer0_value_read()) timer0_update_value_write(1); -} - static void sdtimer_init(void) { sdtimer_en_write(0); diff --git a/litex/soc/software/include/base/system.h b/litex/soc/software/include/base/system.h index 18753548..ef3bf45b 100644 --- a/litex/soc/software/include/base/system.h +++ b/litex/soc/software/include/base/system.h @@ -9,6 +9,8 @@ void flush_cpu_icache(void); void flush_cpu_dcache(void); void flush_l2_cache(void); +void busy_wait(unsigned int ms); + #ifdef __or1k__ #include static inline unsigned long mfspr(unsigned long add) diff --git a/litex/soc/software/libbase/system.c b/litex/soc/software/libbase/system.c index 83ecd408..e8b3e505 100644 --- a/litex/soc/software/libbase/system.c +++ b/litex/soc/software/libbase/system.c @@ -128,3 +128,13 @@ void flush_l2_cache(void) } } #endif + +void busy_wait(unsigned int ms) +{ + timer0_en_write(0); + timer0_reload_write(0); + timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000*ms); + timer0_en_write(1); + timer0_update_value_write(1); + while(timer0_value_read()) timer0_update_value_write(1); +} diff --git a/litex/soc/software/libnet/microudp.c b/litex/soc/software/libnet/microudp.c index 5d40e7f0..3199456e 100644 --- a/litex/soc/software/libnet/microudp.c +++ b/litex/soc/software/libnet/microudp.c @@ -448,24 +448,14 @@ void microudp_service(void) } } -static void busy_wait(unsigned int ds) -{ - timer0_en_write(0); - timer0_reload_write(0); - timer0_load_write(CONFIG_CLOCK_FREQUENCY/10*ds); - timer0_en_write(1); - timer0_update_value_write(1); - while(timer0_value_read()) timer0_update_value_write(1); -} - void eth_init(void) { printf("Ethernet init...\n"); #ifdef CSR_ETHPHY_CRG_RESET_ADDR ethphy_crg_reset_write(1); - busy_wait(2); + busy_wait(200); ethphy_crg_reset_write(0); - busy_wait(2); + busy_wait(200); #endif }