0
votes

I am using Petalinux for a Xilinx Zynq application, and I am new to kernel driver development.

I created a kernel module for a platform driver for an AXI FIFO interface. The devices seems to be recognised from the device tree using the .of_match_table, since I can see the correct memory space reserved with cat /proc/iomem .

If I search for the driver name xxx I get

./lib/modules/4.4.0-xilinx/extra/xxx.ko
./sys/bus/platform/drivers/xxx
./sys/module/xxx
./sys/module/xxx/drivers/platform:xxx

I found the device under /sys/bus/platform/devices/43c00000.axi_xxxx but still can't access it or see it under /dev/.

  • How do I register device so that I can open it from my user space app?.

  • Do I need to allocate memory for it and then register a new device using platform_device_register(pdev)?

Thanks

1

1 Answers

1
votes

You need to register your device in a framework to get a device file created.

I would suggest registering a miscdevice in your case. It simply registers a character device.

static struct miscdevice miscdev;

static ssize_t myaxi_read(struct file *file, char __user *buf,
                 size_t sz, loff_t *ppos)
{
    // Do something

}

static ssize_t myaxi_write(struct file *file, const char __user *buf,
                  size_t sz, loff_t *ppos)
{
    // Do something
}

static const struct file_operations myaxi_fops = {
    .owner = THIS_MODULE,
    .write = myaxi_write,
    .read = myaxi_read,
};

In your probe:

miscdev.minor = MISC_DYNAMIC_MINOR;
miscdev.name = "myaxi";
miscdev.fops = &myaxi_fops;
misc_register(&miscdev);

You can read more about linux kernel driver development and the device model at http://free-electrons.com/doc/training/linux-kernel/linux-kernel-slides.pdf