software/bios: factor out busy_wait() function
authorGabriel Somlo <gsomlo@gmail.com>
Fri, 27 Mar 2020 10:58:06 +0000 (06:58 -0400)
committerGabriel Somlo <gsomlo@gmail.com>
Fri, 27 Mar 2020 19:24:09 +0000 (15:24 -0400)
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
litex/soc/software/bios/sdcard.c
litex/soc/software/include/base/system.h
litex/soc/software/libbase/system.c
litex/soc/software/libnet/microudp.c

index c12b2db17d672eaf742e0b005bf7e741621a54e9..314b9e28b3c64861f5fa33e24e1177905f8039cd 100644 (file)
@@ -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);
index 18753548e1f084d21a657a27e6b68146f0684f63..ef3bf45b0cefd63457f11f7542353d2f11d04681 100644 (file)
@@ -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 <spr-defs.h>
 static inline unsigned long mfspr(unsigned long add)
index 83ecd40866dbf9ecdeb73475831171422f67168c..e8b3e50553ed067f397690f1b612eafc34febdc9 100644 (file)
@@ -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);
+}
index 5d40e7f073008ee947cc9c8d045b5a48285ae3fa..3199456e7833402314cd1d6e75bf536ae1443436 100644 (file)
@@ -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
 }