June 4, 2022

U-Boot for Xilinx FPGA devices - source code

So I found the Github repository with the Xilinx U-Boot source and cloned it:
git clone https://github.com/Xilinx/u-boot-xlnx.git
Interesting things have already turned up, even undocumented registers in the devcfg.
drivers/fpga/zynqpl.c
arch/arm/mach-zynq/include/mach/hardware.h
Prior to this discovery I had been looking at sources in the Vivado SDK, such as:
Vivado/2019.1/data/embeddedsw/XilinxProcessorIPLib/drivers/devcfg_v3_5/src/xdevcfg.c
Vivado/2019.1/data/embeddedsw/XilinxProcessorIPLib/drivers/devcfg_v3_5/examples/xdevcfg_polled_example.c
But the code in U-boot is both more readable and looks as though it addresses issues that are ignored by the Vivado code.

Ctags

This is all but essential dealing with the u-boot code. As a fellow I know used to say, the files are scattered "from hell to breakfast". You can either make yourself crazy using grep and cd or let ctags find things.
cd u-boot-xlnx
ctags -R .

zynq_load()

This is the critical function in zynqpl.c, where and how is it called? A simple grep won't answer the question because this is just one of many FPGA drivers (apparently) and the call is placed into a table via:
struct xilinx_fpga_op zynq_op = {
        .load = zynq_load,
};
The call is in "drivers/fpga/xilinx.c" in xilinx_load(). This has other interesting code, such as fpga_loadbitstream(), which is quite familiar, calling fpga_load() with the bin file it extracts. This is in "drivers/fpga/fpga.c" and is just a switch that will end up calling back to xilinx_load();

All of this seems to start back in "cmd/fpga.c". The relevant top level calls look like:

fpga_loadbitstream(dev, (void *)fpga_data, data_size, BIT_FULL);
fpga_loadbitstream(dev, (void *)fpga_data, data_size, BIT_PARTIAL);
fpga_load(dev, (void *)fpga_data, data_size, BIT_FULL);
fpga_load(dev, (void *)fpga_data, data_size, BIT_PARTIAL);
Here "dev" is a Xilinx device descriptor, which seems to be ignored once we get to the zynq driver level.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org