How existing kernel driver should be initialized as PCI memory-mapped?

允我心安 提交于 2019-12-23 06:03:32

问题


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

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

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

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. Write a custom pci driver.

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

    ulite_probe(struct platform_device *pdev)

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.


回答1:


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

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.

"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.



来源:https://stackoverflow.com/questions/54055736/how-existing-kernel-driver-should-be-initialized-as-pci-memory-mapped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!