/* SPDX-License-Identifier: GPL-2.0-only */ /* * include/linux/uio_driver.h * * Copyright(C) 2005, Benedikt Spranger <[email protected]> * Copyright(C) 2005, Thomas Gleixner <[email protected]> * Copyright(C) 2006, Hans J. Koch <[email protected]> * Copyright(C) 2006, Greg Kroah-Hartman <[email protected]> * * Userspace IO driver. */ #ifndef _UIO_DRIVER_H_ #define _UIO_DRIVER_H_ #include <linux/device.h> #include <linux/fs.h> #include <linux/interrupt.h> struct module; struct uio_map; /** * struct uio_mem - description of a UIO memory region * @name: name of the memory region for identification * @addr: address of the device's memory rounded to page * size (phys_addr is used since addr can be * logical, virtual, or physical & phys_addr_t * should always be large enough to handle any of * the address types) * @dma_addr: DMA handle set by dma_alloc_coherent, used with * UIO_MEM_DMA_COHERENT only (@addr should be the * void * returned from the same dma_alloc_coherent call) * @offs: offset of device memory within the page * @size: size of IO (multiple of page size) * @memtype: type of memory addr points to * @internal_addr: ioremap-ped version of addr, for driver internal use * @dma_device: device struct that was passed to dma_alloc_coherent, * used with UIO_MEM_DMA_COHERENT only * @map: for use by the UIO core only. */ struct uio_mem { … }; #define MAX_UIO_MAPS … struct uio_portio; /** * struct uio_port - description of a UIO port region * @name: name of the port region for identification * @start: start of port region * @size: size of port region * @porttype: type of port (see UIO_PORT_* below) * @portio: for use by the UIO core only. */ struct uio_port { … }; #define MAX_UIO_PORT_REGIONS … struct uio_device { … }; /** * struct uio_info - UIO device capabilities * @uio_dev: the UIO device this info belongs to * @name: device name * @version: device driver version * @mem: list of mappable memory regions, size==0 for end of list * @port: list of port regions, size==0 for end of list * @irq: interrupt number or UIO_IRQ_CUSTOM * @irq_flags: flags for request_irq() * @priv: optional private data * @handler: the device's irq handler * @mmap: mmap operation for this uio device * @open: open operation for this uio device * @release: release operation for this uio device * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX */ struct uio_info { … }; extern int __must_check __uio_register_device(struct module *owner, struct device *parent, struct uio_info *info); /* use a define to avoid include chaining to get THIS_MODULE */ /** * uio_register_device - register a new userspace IO device * @parent: parent device * @info: UIO device capabilities * * returns zero on success or a negative error code. */ #define uio_register_device(parent, info) … extern void uio_unregister_device(struct uio_info *info); extern void uio_event_notify(struct uio_info *info); extern int __must_check __devm_uio_register_device(struct module *owner, struct device *parent, struct uio_info *info); /* use a define to avoid include chaining to get THIS_MODULE */ /** * devm_uio_register_device - Resource managed uio_register_device() * @parent: parent device * @info: UIO device capabilities * * returns zero on success or a negative error code. */ #define devm_uio_register_device(parent, info) … /* defines for uio_info->irq */ #define UIO_IRQ_CUSTOM … #define UIO_IRQ_NONE … /* defines for uio_mem->memtype */ #define UIO_MEM_NONE … #define UIO_MEM_PHYS … #define UIO_MEM_LOGICAL … #define UIO_MEM_VIRTUAL … #define UIO_MEM_IOVA … /* * UIO_MEM_DMA_COHERENT exists for legacy drivers that had been getting by with * improperly mapping DMA coherent allocations through the other modes. * Do not use in new drivers. */ #define UIO_MEM_DMA_COHERENT … /* defines for uio_port->porttype */ #define UIO_PORT_NONE … #define UIO_PORT_X86 … #define UIO_PORT_GPIO … #define UIO_PORT_OTHER … #endif /* _LINUX_UIO_DRIVER_H_ */