Skip to content

ni: lci: Add LCI (VirtualBench) support to kernel v6.18 - #311

Open
jhershbe wants to merge 6 commits into
ni:nilrt/master/6.18from
jhershbe:virtualbench/master/6.18
Open

jhershbe wants to merge 6 commits into
ni:nilrt/master/6.18from
jhershbe:virtualbench/master/6.18

Conversation

@jhershbe

Copy link
Copy Markdown
Contributor

Port of the VirtualBench support merged for 4.14 in #303 to 6.18.

  • Add device trees for the VB-8012, VB-8034, VB-8054, ADP5250, ADP5470, and ADP5490
  • Add the g_lci composite gadget and its hid_bulk function
  • Add the uio_lci FPGA driver and the LCI FPGA node
  • Set ChipIdea Zynq OTG termination in device mode
  • Reset the board on an SWDT timeout

Tested on VB-8034 via NILE.
Build-tested: the NILE VB-8034 image (nati_zynq_defconfig plus the LCI options), and all six device trees.

Add device trees for the NI VB-8012, VB-8034, and VB-8054 and the
Digilent ADP5250, ADP5470, and ADP5490. ni-lci.dtsi describes the board
they share: gem0 with the Marvell 88E1512 PHY, the uart0 console, usb0
in peripheral mode with its ULPI pinmux for the g_lci gadget, the PL
fabric clocks FCLK0-3 for the FPGA design, and the raw-NAND
fsbl/u-boot/boot-config/root partitions. The VB-8034, VB-8054, ADP5470,
and ADP5490 enable Ethernet.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add the National Instruments LCI (VirtualBench) USB gadget.

f_hidbulk is a HID/bulk-switchable function registered as 'hid_bulk':
alt0 is a HID interrupt interface, and the first instance's alt1 exposes
8 bulk endpoints for high throughput. g_lci composes 4 hid_bulk
interfaces plus an optional mass-storage CD-ROM, configured by the
g_lci.* module parameters. The composite source is lci.c so the g_lci
module name does not collide with its only object.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Set OTGSC.OT (OTG Termination) from the Zynq controller reset notifier,
as the Zynq-7000 TRM requires when the controller operates as a device.
The OTGSC interrupt status bits are write-1-to-clear, so write them as
zero.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add a UIO driver for the LCI FPGA on NI VirtualBench devices. It exposes
the FPGA registers and DMA memory as maps 0 and 1, and the FPGA
interrupt, which the handler masks and irqcontrol unmasks.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add the LCI FPGA node for uio_lci: FPGA registers at 0x40000000, the DMA
buffer region at 0x0d600000, and PL interrupt 29, level high.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Set reset-on-timeout on the SWDT so the board resets when the LCI daemon
stops petting /dev/watchdog.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
@chaitu236
chaitu236 requested review from a team and a balanced review from Copilot November 19, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Open HID/bulk descriptors can access freed memory after unbind, and USB_G_LCI’s missing BLOCK dependency causes build failures with CONFIG_BLOCK=n.

8 open issues
What changed in this PR

Ports the VirtualBench support introduced for kernel 4.14 in #303 to kernel 6.18, integrating LCI devices with the existing NI Zynq platform support.

Changes:

  • Adds shared LCI hardware definitions and device trees for six VirtualBench and Digilent boards.
  • Introduces the FPGA UIO driver and a HID/bulk composite USB gadget with optional CD-ROM storage.
  • Configures Zynq USB OTG termination and watchdog timeout resets.
File Description
drivers/​usb/​gadget/​legacy/​Makefile Adds the g_lci build target.
drivers/​usb/​gadget/​legacy/​lci.c Composes four HID/bulk interfaces and optional storage.
drivers/​usb/​gadget/​legacy/​Kconfig Adds the LCI gadget option.
drivers/​usb/​gadget/​Kconfig Adds the HID/bulk function symbol.
drivers/​usb/​gadget/​function/​u_hidbulk.h Defines shared HID/bulk instance options.
drivers/​usb/​gadget/​function/​Makefile Builds the HID/bulk function.
drivers/​usb/​gadget/​function/​f_hidbulk.c Implements switchable HID/bulk transport and character devices.
drivers/​usb/​chipidea/​ci_hdrc_usb2.c Sets OTG termination during Zynq controller reset.
drivers/​usb/​chipidea/​bits.h Defines the OTG termination register bit.
drivers/​uio/​uio_lci.c Exposes FPGA registers, DMA memory, and interrupts.
drivers/​uio/​Makefile Builds the LCI UIO driver.
drivers/​uio/​Kconfig Adds the LCI FPGA driver option.
arch/​arm/​boot/​dts/​xilinx/​ni-lci.dtsi Defines shared peripherals, FPGA resources, and watchdog behavior.
arch/​arm/​boot/​dts/​xilinx/​ni-7ABB.dts Adds the Digilent ADP5490 board definition.
arch/​arm/​boot/​dts/​xilinx/​ni-7ABA.dts Adds the Digilent ADP5470 board definition.
arch/​arm/​boot/​dts/​xilinx/​ni-7AB9.dts Adds the Digilent ADP5250 board definition.
arch/​arm/​boot/​dts/​xilinx/​ni-78B4.dts Adds the NI VB-8054 board definition.
arch/​arm/​boot/​dts/​xilinx/​ni-77DE.dts Adds the NI VB-8034 board definition.
arch/​arm/​boot/​dts/​xilinx/​ni-76F6.dts Adds the NI VB-8012 board definition.
arch/​arm/​boot/​dts/​xilinx/​Makefile Registers all six new device-tree build targets.

Review effort: Balanced

Comment on lines +1631 to +1633
kfree(hidg->report_desc);
kfree(hidg->set_report_buff);
kfree(hidg);
dynamically linked module called "g_hid".

config USB_G_LCI
tristate "National Instruments LCI (VirtualBench) Gadget"
Comment on lines +318 to +319
if (wait_event_interruptible(hidg->read_queue, READ_COND))
return -ERESTARTSYS;
Comment on lines +812 to +813
ep_desc->wMaxPacketSize =
min_t(short, hidg->report_length, 512);
unsigned long flags;
#endif

VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt);
if (status)
goto fail;

device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
Comment on lines +1319 to +1320
usb_free_descriptors(f->hs_descriptors);
usb_free_descriptors(f->fs_descriptors);
opts->report_desc_length,
GFP_KERNEL);
if (!hidg->report_desc) {
kfree(hidg);

@chaitu236 chaitu236 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a quick pass - don't have any major concerns but we need to look into what copilot flagged.

There are also several checkpatch errors that we should also consider fixing (DT compatible string .. appears un-documented ones can be ignored`).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants