litex-hub / litex-boards

LiteX boards files
BSD 2-Clause "Simplified" License
365 stars 278 forks source link

qmtech_wukong: how do I add SPI? #511

Open e-yes opened 1 year ago

e-yes commented 1 year ago

I am trying to add SPI support to Qmtech Wukong (v2) gateware. I modified platform file as following:

--- a/litex_boards/platforms/qmtech_wukong.py
+++ b/litex_boards/platforms/qmtech_wukong.py
@@ -145,6 +145,13 @@ _io_common = [
         Subsignal("hdp",     Pins("A3"), IOStandard("LVCMOS33")),
         Subsignal("cec",     Pins("B1"), IOStandard("LVCMOS33")),
     ),
+
+    ("spi", 0,
+        Subsignal("miso", Pins("AB26"), IOStandard("LVCMOS33")),
+        Subsignal("mosi", Pins("AC26"), IOStandard("LVCMOS33")),
+        Subsignal("clk",  Pins("AB24"), IOStandard("LVCMOS33")),
+        Subsignal("cs_n", Pins("AC24"), IOStandard("LVCMOS33"))
+    )
 ]

 # Connectors ---------------------------------------------------------------------------------------
@@ -152,7 +159,7 @@ _io_common = [
 _connectors = [
     ("j10", "D5 G5 G7 G8 E5 E6 D6 G6"),
     ("j11", "H4 F4 A4 A5 J4 G4 B4 B5"),
-    ("j12", "AB26 AC26 AB24 AC24 AA24 AB25 AA22 AA23",
+    ("j12", "AA24 AB25 AA22 AA23",
             " Y25 AA25  W25  Y26  Y22  Y23  W21  Y21",
             " V26  W26  U25  U26  V24  W24  V23  W23",
             " V18  W18  U22  V22  U21  V21  T20  U20",

and I use this command for compilation:

python3 -m litex_boards.targets.qmtech_wukong --board-version 2 --cpu-type vexriscv_smp --cpu-variant linux --with-video-framebuffer --with-sdcard --with-ethernet --csr-json csr.json --build

I don't see anything related to spi in generated csr.json. Do I miss some command line flasgs or maybe I have to add some more modifications to platform/target files? I want to use spidev or psx_joypad drivers. In the worst case I can add dummy spi-flash or spi-sdcard, but I believe there should be the right way to achieve what I want.

e-yes commented 1 year ago

Well, --with-spi-sdcard works as a workaround (gateware), but litespi is not functional. What branch in litex-hub/linux I have to try?