From c3a03d0d9935db3081cd69fa8281c2b2911ee114 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 20 May 2020 09:32:45 +0200 Subject: [PATCH] software: create liblitespi and mode litespi code to it (with some parts commented out for now). --- litex/soc/integration/builder.py | 1 + litex/soc/software/bios/Makefile | 4 +++- litex/soc/software/bios/main.c | 8 +++---- litex/soc/software/liblitespi/Makefile | 23 +++++++++++++++++++ .../{bios/spi.c => liblitespi/spiflash.c} | 7 ++++-- .../{bios/spi.h => liblitespi/spiflash.h} | 6 ++--- 6 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 litex/soc/software/liblitespi/Makefile rename litex/soc/software/{bios/spi.c => liblitespi/spiflash.c} (97%) rename litex/soc/software/{bios/spi.h => liblitespi/spiflash.h} (77%) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 469f2110..2c3044d2 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -27,6 +27,7 @@ soc_software_packages = [ "libbase", "liblitedram", "libliteeth", + "liblitespi", "liblitesdcard", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index a04a17b3..9782d0e3 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -62,6 +62,7 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) ../libbase/libbase-nofloat.a \ ../liblitedram/liblitedram.a \ ../libliteeth/libliteeth.a \ + ../liblitespi/liblitespi.a \ ../liblitesdcard/liblitesdcard.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ @@ -70,9 +71,10 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -L../libbase \ -L../liblitedram \ -L../libliteeth \ + -L../liblitespi \ -L../liblitesdcard \ $(BP_LIBS) \ - -lcompiler_rt -llitedram -lliteeth -llitesdcard -lbase-nofloat \ + -lcompiler_rt -llitedram -lliteeth -llitespi -llitesdcard -lbase-nofloat \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index e6765a59..9d1dc85b 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -44,7 +44,7 @@ #include "sdram.h" #include "sdcard.h" -#include "spi.h" +//#include "spi.h" #include "boot.h" #include "readline.h" #include "helpers.h" @@ -135,9 +135,9 @@ int main(int i, char **c) printf("Memory initialization failed\n"); printf("\n"); #endif -#ifdef CSR_SPI_BASE - spi_autoconfig(); -#endif +//#ifdef CSR_SPI_BASE +// spi_autoconfig(); +//#endif if(sdr_ok) { printf("--============== \e[1mBoot\e[0m ==================--\n"); diff --git a/litex/soc/software/liblitespi/Makefile b/litex/soc/software/liblitespi/Makefile new file mode 100644 index 00000000..74f0b131 --- /dev/null +++ b/litex/soc/software/liblitespi/Makefile @@ -0,0 +1,23 @@ +include ../include/generated/variables.mak +include $(SOC_DIRECTORY)/software/common.mak + +OBJECTS=spiflash.o + +all: liblitespi.a + +liblitespi.a: $(OBJECTS) + $(AR) crs liblitespi.a $(OBJECTS) + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +%.o: $(LIBLITESPI_DIRECTORY)/%.c + $(compile) + +%.o: %.S + $(assemble) + +.PHONY: all clean + +clean: + $(RM) $(OBJECTS) liblitespi.a .*~ *~ diff --git a/litex/soc/software/bios/spi.c b/litex/soc/software/liblitespi/spiflash.c similarity index 97% rename from litex/soc/software/bios/spi.c rename to litex/soc/software/liblitespi/spiflash.c index 23b677c2..702c969d 100644 --- a/litex/soc/software/bios/spi.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -8,10 +8,11 @@ #include #include -#include #include -#include "spi.h" +#include "spiflash.h" + +#ifdef SPIXIP_BASE #define DEBUG 0 #define USER_DEFINED_DUMMY_BITS 0 @@ -60,6 +61,8 @@ int spi_frequency_test(void) return lowest_div; } +#endif + void spi_dummy_bits_setup(unsigned int dummy_bits) { spi_dummy_bits_write((uint32_t)dummy_bits); diff --git a/litex/soc/software/bios/spi.h b/litex/soc/software/liblitespi/spiflash.h similarity index 77% rename from litex/soc/software/bios/spi.h rename to litex/soc/software/liblitespi/spiflash.h index 961aef0c..b9d210c2 100644 --- a/litex/soc/software/bios/spi.h +++ b/litex/soc/software/liblitespi/spiflash.h @@ -1,5 +1,5 @@ -#ifndef __SPI_H -#define __SPI_H +#ifndef __LITESPI_FLASH_H +#define __LITESPI_FLASH_H #include @@ -15,4 +15,4 @@ int spi_frequency_test(void); void spi_dummy_bits_setup(unsigned int dummy_bits); void spi_autoconfig(void); -#endif /* __SPI_H */ +#endif /* __LITESPI_FLASH_H */ -- 2.30.2