I wrote a driver on a microzed xilinx embedded Linux to communicate wih FPGA
and receive and treat IRQ with an IRQ handler.
The device tree look like that for what we are interested in:
stef@dell00:~$ cat /tmp/devicetree.dts | grep -A 5 FPGA
FPGA_v1_0_2@43c00000 {
compatible = "xlnx,FPGA-v1-0-0";
interrupt-names = "interrupt";
interrupt-parent = <0x4>;
interrupts = <0x0 0x20 0x4>;
reg = <0x43c00000 0x10000>;
xlnx,data0-width = <0x10>;
--
FPGA_v1_0_2@43c10000 {
compatible = "xlnx,FPGA-v1-0-0";
interrupt-names = "interrupt";
interrupt-parent = <0x4>;
interrupts = <0x0 0x21 0x4>;
reg = <0x43c10000 0x10000>;
xlnx,data0-width = <0x10>;
So I have two instances of the same driver for treating in parallel FPGA registers and IRQs at the same time (that is the purpose).
The code on the INIT driver functions "could" look like and/or look like that:
static struct platform_driver my_driver = {
.driver = {
.name = "FPGA",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(my_dt_ids),
},
.probe = my_probe,
.remove = my_remove,
.shutdown = my_shutdown,
};
with the probe function :
static int my_probe(platform_device * pdev_p)
{
u32 baseAddr ;
void __iomem * devm_ior_res_p = NULL ;
struct resource * resource_p = NULL ;
typdef_struct_mydata * my_device_datas = NULL ;
my_device_datas = kzalloc( sizeof(typdef_struct_mydata), GFP_ATOMIC );
platform_set_drvdata( pdev_p, dev_p);
resource_p = platform_get_resource(pdev_p, IORESOURCE_MEM, 0);
devm_ior_res_p = devm_ioremap_resource(&pdev_p->dev, resource_p);
of_property_read_u32( pdev_p->dev.of_node, "xlnx,data0-width", &data-width ) ;
baseAddr = (u32)devm_ior_res_p;
// FIXME : do something else at init ....
}
and the compatible link:
static const struct of_device_id my_dt_ids[] = {
{ .compatible = "xlnx,FPGA-v1-0-0", },
{}
};
Since the probe function is called, we can work with the base address and related things like registers / irq / etc...
Since the DTB have 2 nodes with 2 different reg adresses and MMU space addresses,
we see as expected 2 instances on the /sys
FS for one driver loaded (insmod):
root@my_target:/sys/devices/soc0/amba_pl# ls -rlt | grep FPGA
drwxr-xr-x 4 root root 0 Jan 7 15:50 43c10000.FPGA
drwxr-xr-x 4 root root 0 Jan 7 15:50 43c00000.FPGA
My question is: How to distinguish platform device data information of one instance from the other;
For a trivial example, just do a prink of the base address of the 2nd instance from the 1st and vice-versa.
In a general view, how to communicate between the two instances without go on the sysfs userspace API?
I read those articles:
but have not found the solution.
question from:
https://stackoverflow.com/questions/65858417/communication-between-two-linux-kernel-driver-instances-based-on-two-separated-n