linux/drivers/gpio/gpio-mockup.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * GPIO Testing Device Driver
 *
 * Copyright (C) 2014  Kamlakant Patel <[email protected]>
 * Copyright (C) 2015-2016  Bamvor Jian Zhang <[email protected]>
 * Copyright (C) 2017 Bartosz Golaszewski <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irq_sim.h>
#include <linux/irqdomain.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/string_helpers.h>
#include <linux/uaccess.h>

#define GPIO_MOCKUP_MAX_GC
/*
 * We're storing two values per chip: the GPIO base and the number
 * of GPIO lines.
 */
#define GPIO_MOCKUP_MAX_RANGES
/* Maximum of four properties + the sentinel. */
#define GPIO_MOCKUP_MAX_PROP

/*
 * struct gpio_pin_status - structure describing a GPIO status
 * @dir:       Configures direction of gpio as "in" or "out"
 * @value:     Configures status of the gpio as 0(low) or 1(high)
 * @pull:      Configures the current pull of the GPIO as 0 (pull-down) or
 *             1 (pull-up)
 * @requested: Request status of this GPIO
 */
struct gpio_mockup_line_status {};

struct gpio_mockup_chip {};

struct gpio_mockup_dbgfs_private {};

static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_RANGES];
static int gpio_mockup_num_ranges;
module_param_array();

static bool gpio_mockup_named_lines;
module_param_named(gpio_mockup_named_lines,
		   gpio_mockup_named_lines, bool, 0400);

static struct dentry *gpio_mockup_dbg_dir;

static int gpio_mockup_range_base(unsigned int index)
{}

static int gpio_mockup_range_ngpio(unsigned int index)
{}

static int __gpio_mockup_get(struct gpio_mockup_chip *chip,
			     unsigned int offset)
{}

static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
{}

static int gpio_mockup_get_multiple(struct gpio_chip *gc,
				    unsigned long *mask, unsigned long *bits)
{}

static void __gpio_mockup_set(struct gpio_mockup_chip *chip,
			      unsigned int offset, int value)
{}

static void gpio_mockup_set(struct gpio_chip *gc,
			   unsigned int offset, int value)
{}

static void gpio_mockup_set_multiple(struct gpio_chip *gc,
				     unsigned long *mask, unsigned long *bits)
{}

static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip,
				  unsigned int offset, int value)
{}

static int gpio_mockup_set_config(struct gpio_chip *gc,
				  unsigned int offset, unsigned long config)
{}

static int gpio_mockup_dirout(struct gpio_chip *gc,
			      unsigned int offset, int value)
{}

static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
{}

static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
{}

static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
{}

static int gpio_mockup_request(struct gpio_chip *gc, unsigned int offset)
{}

static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset)
{}

static ssize_t gpio_mockup_debugfs_read(struct file *file,
					char __user *usr_buf,
					size_t size, loff_t *ppos)
{}

static ssize_t gpio_mockup_debugfs_write(struct file *file,
					 const char __user *usr_buf,
					 size_t size, loff_t *ppos)
{}

static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file)
{}

/*
 * Each mockup chip is represented by a directory named after the chip's device
 * name under /sys/kernel/debug/gpio-mockup/. Each line is represented by
 * a file using the line's offset as the name under the chip's directory.
 *
 * Reading from the line's file yields the current *value*, writing to the
 * line's file changes the current *pull*. Default pull for mockup lines is
 * down.
 *
 * Examples:
 * - when a line pulled down is requested in output mode and driven high, its
 *   value will return to 0 once it's released
 * - when the line is requested in output mode and driven high, writing 0 to
 *   the corresponding debugfs file will change the pull to down but the
 *   reported value will still be 1 until the line is released
 * - line requested in input mode always reports the same value as its pull
 *   configuration
 * - when the line is requested in input mode and monitored for events, writing
 *   the same value to the debugfs file will be a noop, while writing the
 *   opposite value will generate a dummy interrupt with an appropriate edge
 */
static const struct file_operations gpio_mockup_debugfs_ops =;

static void gpio_mockup_debugfs_setup(struct device *dev,
				      struct gpio_mockup_chip *chip)
{}

static void gpio_mockup_debugfs_cleanup(void *data)
{}

static void gpio_mockup_dispose_mappings(void *data)
{}

static int gpio_mockup_probe(struct platform_device *pdev)
{}

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

static struct platform_driver gpio_mockup_driver =;

static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC];

static void gpio_mockup_unregister_pdevs(void)
{}

static int __init gpio_mockup_register_chip(int idx)
{}

static int __init gpio_mockup_init(void)
{}

static void __exit gpio_mockup_exit(void)
{}

module_init();
module_exit(gpio_mockup_exit);

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