linux/drivers/staging/axis-fifo/axis-fifo.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Xilinx AXIS FIFO: interface to the Xilinx AXI-Stream FIFO IP core
 *
 * Copyright (C) 2018 Jacob Feder
 *
 * Authors:  Jacob Feder <[email protected]>
 *
 * See Xilinx PG080 document for IP details
 */

/* ----------------------------
 *           includes
 * ----------------------------
 */

#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/moduleparam.h>
#include <linux/interrupt.h>
#include <linux/param.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/jiffies.h>
#include <linux/miscdevice.h>

/* ----------------------------
 *       driver parameters
 * ----------------------------
 */

#define DRIVER_NAME

#define READ_BUF_SIZE
#define WRITE_BUF_SIZE

/* ----------------------------
 *     IP register offsets
 * ----------------------------
 */

#define XLLF_ISR_OFFSET
#define XLLF_IER_OFFSET

#define XLLF_TDFR_OFFSET
#define XLLF_TDFV_OFFSET
#define XLLF_TDFD_OFFSET
#define XLLF_TLR_OFFSET

#define XLLF_RDFR_OFFSET
#define XLLF_RDFO_OFFSET
#define XLLF_RDFD_OFFSET
#define XLLF_RLR_OFFSET
#define XLLF_SRR_OFFSET
#define XLLF_TDR_OFFSET
#define XLLF_RDR_OFFSET

/* ----------------------------
 *     reset register masks
 * ----------------------------
 */

#define XLLF_RDFR_RESET_MASK
#define XLLF_TDFR_RESET_MASK
#define XLLF_SRR_RESET_MASK

/* ----------------------------
 *       interrupt masks
 * ----------------------------
 */

#define XLLF_INT_RPURE_MASK
#define XLLF_INT_RPORE_MASK
#define XLLF_INT_RPUE_MASK
#define XLLF_INT_TPOE_MASK
#define XLLF_INT_TC_MASK
#define XLLF_INT_RC_MASK
#define XLLF_INT_TSE_MASK
#define XLLF_INT_TRC_MASK
#define XLLF_INT_RRC_MASK
#define XLLF_INT_TFPF_MASK
#define XLLF_INT_TFPE_MASK
#define XLLF_INT_RFPF_MASK
#define XLLF_INT_RFPE_MASK
#define XLLF_INT_ALL_MASK
#define XLLF_INT_ERROR_MASK
#define XLLF_INT_RXERROR_MASK
#define XLLF_INT_TXERROR_MASK

/* ----------------------------
 *           globals
 * ----------------------------
 */
static long read_timeout =; /* ms to wait before read() times out */
static long write_timeout =; /* ms to wait before write() times out */

/* ----------------------------
 * module command-line arguments
 * ----------------------------
 */

module_param(read_timeout, long, 0444);
MODULE_PARM_DESC();
module_param(write_timeout, long, 0444);
MODULE_PARM_DESC();

/* ----------------------------
 *            types
 * ----------------------------
 */

struct axis_fifo {};

/* ----------------------------
 *         sysfs entries
 * ----------------------------
 */

static ssize_t sysfs_write(struct device *dev, const char *buf,
			   size_t count, unsigned int addr_offset)
{}

static ssize_t sysfs_read(struct device *dev, char *buf,
			  unsigned int addr_offset)
{}

static ssize_t isr_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static ssize_t isr_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RW(isr);

static ssize_t ier_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static ssize_t ier_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RW(ier);

static ssize_t tdfr_store(struct device *dev, struct device_attribute *attr,
			  const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(tdfr);

static ssize_t tdfv_show(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(tdfv);

static ssize_t tdfd_store(struct device *dev, struct device_attribute *attr,
			  const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(tdfd);

static ssize_t tlr_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(tlr);

static ssize_t rdfr_store(struct device *dev, struct device_attribute *attr,
			  const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(rdfr);

static ssize_t rdfo_show(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(rdfo);

static ssize_t rdfd_show(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(rdfd);

static ssize_t rlr_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(rlr);

static ssize_t srr_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(srr);

static ssize_t tdr_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static DEVICE_ATTR_WO(tdr);

static ssize_t rdr_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(rdr);

static struct attribute *axis_fifo_attrs[] =;

static const struct attribute_group axis_fifo_attrs_group =;

static const struct attribute_group *axis_fifo_attrs_groups[] =;

/* ----------------------------
 *        implementation
 * ----------------------------
 */

static void reset_ip_core(struct axis_fifo *fifo)
{}

/**
 * axis_fifo_read() - Read a packet from AXIS-FIFO character device.
 * @f: Open file.
 * @buf: User space buffer to read to.
 * @len: User space buffer length.
 * @off: Buffer offset.
 *
 * As defined by the device's documentation, we need to check the device's
 * occupancy before reading the length register and then the data. All these
 * operations must be executed atomically, in order and one after the other
 * without missing any.
 *
 * Returns the number of bytes read from the device or negative error code
 *	on failure.
 */
static ssize_t axis_fifo_read(struct file *f, char __user *buf,
			      size_t len, loff_t *off)
{}

/**
 * axis_fifo_write() - Write buffer to AXIS-FIFO character device.
 * @f: Open file.
 * @buf: User space buffer to write to the device.
 * @len: User space buffer length.
 * @off: Buffer offset.
 *
 * As defined by the device's documentation, we need to write to the device's
 * data buffer then to the device's packet length register atomically. Also,
 * we need to lock before checking if the device has available space to avoid
 * any concurrency issue.
 *
 * Returns the number of bytes written to the device or negative error code
 *	on failure.
 */
static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
			       size_t len, loff_t *off)
{}

static irqreturn_t axis_fifo_irq(int irq, void *dw)
{}

static int axis_fifo_open(struct inode *inod, struct file *f)
{}

static int axis_fifo_close(struct inode *inod, struct file *f)
{}

static const struct file_operations fops =;

/* read named property from the device tree */
static int get_dts_property(struct axis_fifo *fifo,
			    char *name, unsigned int *var)
{}

static int axis_fifo_parse_dt(struct axis_fifo *fifo)
{}

static int axis_fifo_probe(struct platform_device *pdev)
{}

static void axis_fifo_remove(struct platform_device *pdev)
{}

static const struct of_device_id axis_fifo_of_match[] =;
MODULE_DEVICE_TABLE(of, axis_fifo_of_match);

static struct platform_driver axis_fifo_driver =;

static int __init axis_fifo_init(void)
{}

module_init();

static void __exit axis_fifo_exit(void)
{}

module_exit(axis_fifo_exit);

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();