如何将现有的内核驱动程序初始化为PCI内存映射? [英] How existing kernel driver should be initialized as PCI memory-mapped?

查看:204
本文介绍了如何将现有的内核驱动程序初始化为PCI内存映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现有的内核驱动程序(例如xilinx)具有特定的注册方式(作为tty设备),如果它们直接映射到cpu内存映射(如设备树所示): https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842249/Uartlite + Driver

Existing kernel drivers such as xilinx have specific way to be registered (as tty device), if they are mapped directly to cpu memory map as done here with device tree: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842249/Uartlite+Driver

但是在其他情况下,有一个PCIe设备(例如具有xilinx uart IP的FPGA)与cpu连接.

But in other cases, there is a PCIe device (like FPGA which has the xilinx uart IPs) which is connected to and the cpu.

使用PCIe设备时如何使uart注册?

How should we make the uart get registered when using PCIe device ?

我尝试注册到PCIe的设备树是uartlite驱动程序: https://github.com/Xilinx/linux-xlnx/blob/master/drivers/tty/serial/uartlite.c

The device tree I try to register into PCIe is uartlite driver: https://github.com/Xilinx/linux-xlnx/blob/master/drivers/tty/serial/uartlite.c

我认为我可能需要做的是:

I think that what I probably need to do is:

  1. 编写自定义pci驱动程序.

  1. Write a custom pci driver.

需要准备platform_device结构,然后从pci驱动程序调用uart探测例程:

Need to prepare platform_device struct and then call the uart probe routine from pci driver:

ulite_probe(struct platform_device * pdev)

ulite_probe(struct platform_device *pdev)

我已经看到了使用连接了多个设备的FPGA与其他人相关的问题,但是似乎没有文档或说明如何执行此操作的教程.

I've seen related question with others using FPGA with multiple device connected, but seems that there is no docuemnt, or tutorial which describes how to do this.

任何评论,示例或文档都会受到赞赏.

Any comment, example or document is appreciated.

推荐答案

那么像ARM CPU这样通过PCIe连接到Artix FPGA的东西正确吗?

So something like a ARM CPU connected to an Artix FPGA over PCIe right?

是的,您需要自定义PCIe驱动程序. PCIe配置和数据空间必须被映射.看一下pci_resource_ {start,len}和pci_remap_bar函数.然后,您可以使用pci_get_device获取指向结构设备的指针,并检索PCIe配置空间的虚拟地址.然后,UART驱动程序可以使用结构设备指针,并且其寄存器映射应根据您的设计与PCIe配置空间的虚拟地址有一定偏移.您可以在自己的驱动程序中调用UARTlite IP驱动程序的探测调用.

Yes, you would need a custom PCIe driver. The PCIe configuration and data spaces would have to be mapped. Have a look at pci_resource_{start, len} and pci_remap_bar functions. You can then use pci_get_device to get a pointer to the struct device and retrieve the virtual address of the PCIe configuration space. The UART driver can then use the struct device pointer and it's register map should be at some offset to the virtual address of the PCIe configuration space as per your design. You can invoke the probe call of UARTlite IP driver in your own driver.

现有的内核驱动程序(如xilinx)具有特定的注册方式(作为tty设备),如果它们直接映射到cpu内存映射(如此处使用设备树所做的那样)".请注意,如果我们仅谈论tty设备,这是正确的. GPIO外设IP不会显示为tty,而是显示在/sys/class/gpio中.

"Existing kernel drivers such as xilinx have specific way to be registered (as tty device), if they are mapped directly to cpu memory map as done here with device tree". Note that this is true if we are only talking of tty devices. A GPIO peripheral IP won't be expose as tty but in /sys/class/gpio.

这篇关于如何将现有的内核驱动程序初始化为PCI内存映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆