cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
derrickg
Observer
Observer
132 Views
Registered: ‎05-04-2016

Device Tree for devices on XDMA AXI lite bus

Given the following simple PCIe design, how do I define device tree entries for the devices on my AXI-lite bus, so that the existing drivers get loaded with the correct base address?

I know that typically PCIe doesn't use the device tree, because the pcie subsystem does its own probing, and the driver typically knows what is attached.  However, in this case I don't want to have to rewrite the drivers for the UART and the SPI and I2C masters, nor do I want to re-write the drivers for the the devices that will connect to the I2C and SPI buses.  I am certain that I am not the first person to attach a device with an existing driver on the other side of a PCIe block, but I have not been able to find much useful information on how to tell the kernel about these devices, and more critically, tell the drivers the correct translated base address for the devices on my AXI-lite bus.

The closest I have found was this: https://stackoverflow.com/questions/54367498/creating-a-device-tree-for-the-hardware-on-a-pci-device, but when I tried to replicate that with a very simple "hello world" driver, I was unable to get Linux to acknowledge my driver, let alone do any address translation for me.  This is the Device tree I tried:

 

 

&{/pcie@141a0000} {
        pci@0,0 {
                #address-cells = <3>;
                #size-cells = <2>;
                device_type = "pci";
                ranges = <0x82000000 0x0 0x40000000   0x82000000 0x0 0x40000000   0x0 0xc0000000>;
                fpga@0 {
                        compatible = "hello_bus-1.0";
                        reg = <0 0 0 0 0>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = < 0    0x82000000 0x0 0x40000000   0x2000000>;

                        foo@1000 {
                                compatible = "hello_world-1.0";
                                reg = <0x1000  0x1000>;
                        };
                };
        };
};

 

 

In this case the kernel doesn't notify either my "hello-bus" driver or my "hello-world" driver that a device is present.  However, if I put my fpga node as a child of the root node, then my driver gets notified.  But as a child of the root node, I don't have a chance of getting the address translation to work correctly.  I could hard code my physical address, but I am sure that will end up causing a problem when the base address suddenly changes because the BAR got mapped some other place.

I can see these nodes under /proc/device-tree/, so I know that the kernel knows about them.  It just doesn't want to notify my driver.

pcie_design.png

0 Kudos
0 Replies