From b073ebadf6db467d575f841902c1a5f518fa045a Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Sat, 11 Jan 2020 19:38:15 -0500 Subject: [PATCH] bios/sdram: switch to updated CSR accessors, and misc. cleanup Revert to treating SDRAM_DFII_PIX_[RD|WR]DATA CSRs as arrays of bytes, but use the new uintX_t array accessors for improved legibility, and to avoid unnecessary byteswapping. Signed-off-by: Gabriel Somlo --- litex/soc/software/bios/sdram.c | 144 +++++++++++++------------------- 1 file changed, 59 insertions(+), 85 deletions(-) diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index 6907041a..f7d8458c 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -20,8 +20,6 @@ #include #include -#include // for hton/ntoh (byteswap) functions - #include "sdram.h" // FIXME(hack): If we don't have main ram, just target the sram instead. @@ -63,22 +61,6 @@ __attribute__((unused)) static void cdelay(int i) #define DFII_PIX_DATA_BYTES DFII_PIX_DATA_SIZE*CSR_DATA_BYTES -#if CSR_DATA_BYTES == 1 - typedef uint8_t csr_dw_t; - #define csr_dw_hton(x) (x) - #define csr_dw_ntoh(x) (x) -#elif CSR_DATA_BYTES == 2 - typedef uint16_t csr_dw_t; - #define csr_dw_hton(x) htons(x) - #define csr_dw_ntoh(x) ntohs(x) -#elif CSR_DATA_BYTES == 4 - typedef uint32_t csr_dw_t; - #define csr_dw_hton(x) htonl(x) - #define csr_dw_ntoh(x) ntohl(x) -#else -#error Unsupported CSR data width -#endif - void sdrsw(void) { sdram_dfii_control_write(DFII_CONTROL_CKE|DFII_CONTROL_ODT|DFII_CONTROL_RESET_N); @@ -120,8 +102,7 @@ void sdrrdbuf(int dq) { int i, p; int first_byte, step; - csr_dw_t buf[DFII_PIX_DATA_SIZE]; - unsigned char *buf_bytes = (unsigned char *)&(buf[0]); + unsigned char buf[DFII_PIX_DATA_BYTES]; if(dq < 0) { first_byte = 0; @@ -132,10 +113,10 @@ void sdrrdbuf(int dq) } for(p=0;p\n"); @@ -193,32 +174,35 @@ void sdrrderr(char *count) } for(p=0;p\n"); @@ -246,9 +229,9 @@ void sdrwr(char *startaddr) for(p=0;p