Skip to content

Commit 5d50ed1

Browse files
Merge pull request #672 from spersvold/sp/devel_usb
Add USB-OHCI functionality similar to what is on the digilent_arty to the nexsys_video board
2 parents fd9a905 + ef91ec1 commit 5d50ed1

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

litex_boards/platforms/digilent_nexys_video.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@
180180
# Connectors ---------------------------------------------------------------------------------------
181181

182182
_connectors = [
183+
("pmoda", "AB22 AB21 AB20 AB18 Y21 AA21 AA20 AA18"),
184+
("pmodb", "V9 V8 V7 W7 W9 Y9 Y8 Y7"),
185+
("pmodc", "Y6 AA6 AA8 AB8 R6 T6 AB7 AB6"),
183186
("LPC", {
184187
"DP0_C2M_P" : "D7",
185188
"DP0_C2M_N" : "C7",
@@ -263,6 +266,22 @@
263266
)
264267
]
265268

269+
# PMODS --------------------------------------------------------------------------------------------
270+
271+
def raw_pmod_io(pmod):
272+
return [(pmod, 0, Pins(" ".join([f"{pmod}:{i:d}" for i in range(8)])), IOStandard("LVCMOS33"))]
273+
274+
def usb_pmod_io(pmod):
275+
return [
276+
# USB-UART PMOD: https://store.digilentinc.com/pmod-usbuart-usb-to-uart-interface/
277+
("usb_uart", 0,
278+
Subsignal("tx", Pins(f"{pmod}:1")),
279+
Subsignal("rx", Pins(f"{pmod}:2")),
280+
IOStandard("LVCMOS33")
281+
),
282+
]
283+
_usb_uart_pmod_io = usb_pmod_io("pmodb") # USB-UART PMOD on JB.
284+
266285
# Platform -----------------------------------------------------------------------------------------
267286

268287
class Platform(Xilinx7SeriesPlatform):

litex_boards/targets/digilent_nexys_video.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from litex_boards.platforms import digilent_nexys_video
1414

1515
from litex.soc.cores.clock import *
16+
from litex.soc.integration.soc import SoCRegion
1617
from litex.soc.integration.soc_core import *
1718
from litex.soc.integration.builder import *
1819
from litex.soc.cores.video import VideoS7HDMIPHY
@@ -73,6 +74,7 @@ def __init__(self, toolchain="vivado", sys_clk_freq=100e6,
7374
with_ethernet = False,
7475
with_led_chaser = True,
7576
with_sata = False, sata_gen="gen2",
77+
with_usb = False,
7678
vadj = "1.2V",
7779
with_video_terminal = False,
7880
with_video_framebuffer = False,
@@ -151,6 +153,32 @@ def __init__(self, toolchain="vivado", sys_clk_freq=100e6,
151153
if with_video_framebuffer:
152154
self.add_video_framebuffer(phy=self.videophy, timings="800x600@60Hz", clock_domain="hdmi")
153155

156+
# USB-OHCI ---------------------------------------------------------------------------------
157+
if with_usb:
158+
from litex.build.generic_platform import Subsignal, Pins, IOStandard
159+
from litex.soc.cores.usb_ohci import USBOHCI
160+
161+
# Use the Video PLL if available
162+
self.crg.cd_usb = ClockDomain()
163+
self.crg.pll.create_clkout(self.crg.cd_usb, 48e6, margin=0)
164+
165+
# Machdyne PMOD (https://github.com/machdyne/usb_host_dual_socket_pmod) on JB
166+
_usb_pmodb_dual_ios = [
167+
("usb_pmodb_dual", 0,
168+
Subsignal("dp", Pins("pmodb:0 pmodb:2")),
169+
Subsignal("dm", Pins("pmodb:1 pmodb:3")),
170+
IOStandard("LVCMOS33"),
171+
),
172+
]
173+
self.platform.add_extension(_usb_pmodb_dual_ios)
174+
175+
self.submodules.usb_ohci = USBOHCI(self.platform, self.platform.request("usb_pmodb_dual"), usb_clk_freq=int(48e6))
176+
self.mem_map["usb_ohci"] = 0x90000000
177+
self.bus.add_slave("usb_ohci_ctrl", self.usb_ohci.wb_ctrl, region=SoCRegion(origin=self.mem_map["usb_ohci"], size=0x1000, cached=False)) # FIXME: Mapping.
178+
self.dma_bus.add_master("usb_ohci_dma", master=self.usb_ohci.wb_dma)
179+
180+
self.comb += self.cpu.interrupt[16].eq(self.usb_ohci.interrupt)
181+
154182
# Leds -------------------------------------------------------------------------------------
155183
if with_led_chaser:
156184
self.leds = LedChaser(
@@ -167,6 +195,7 @@ def main():
167195
from litex.build.parser import LiteXArgumentParser
168196
parser = LiteXArgumentParser(platform=digilent_nexys_video.Platform, description="LiteX SoC on Nexys Video.")
169197
parser.add_target_argument("--sys-clk-freq", default=100e6, type=float, help="System clock frequency.")
198+
parser.add_target_argument("--with-usb", action="store_true", help="Enable USB Host.")
170199
parser.add_target_argument("--with-ethernet", action="store_true", help="Enable Ethernet support.")
171200
sdopts = parser.target_group.add_mutually_exclusive_group()
172201
sdopts.add_argument("--with-spi-sdcard", action="store_true", help="Enable SPI-mode SDCard support.")
@@ -183,6 +212,7 @@ def main():
183212
toolchain = args.toolchain,
184213
sys_clk_freq = args.sys_clk_freq,
185214
with_ethernet = args.with_ethernet,
215+
with_usb = args.with_usb,
186216
with_sata = args.with_sata,
187217
sata_gen = "gen" + args.sata_gen,
188218
vadj = args.vadj,

0 commit comments

Comments
 (0)