linux/drivers/pinctrl/pinctrl-aw9523.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Awinic AW9523B i2c pin controller driver
 * Copyright (c) 2020, AngeloGioacchino Del Regno <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>

#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>

#define AW9523_MAX_FUNCS
#define AW9523_NUM_PORTS
#define AW9523_PINS_PER_PORT

/*
 * HW needs at least 20uS for reset and at least 1-2uS to recover from
 * reset, but we have to account for eventual board quirks, if any:
 * for this reason, keep reset asserted for 50uS and wait for 20uS
 * to recover from the reset.
 */
#define AW9523_HW_RESET_US
#define AW9523_HW_RESET_RECOVERY_US

/* Port 0: P0_0...P0_7 - Port 1: P1_0...P1_7 */
#define AW9523_PIN_TO_PORT(pin)
#define AW9523_REG_IN_STATE(pin)
#define AW9523_REG_OUT_STATE(pin)
#define AW9523_REG_CONF_STATE(pin)
#define AW9523_REG_INTR_DIS(pin)
#define AW9523_REG_CHIPID
#define AW9523_VAL_EXPECTED_CHIPID

#define AW9523_REG_GCR
#define AW9523_GCR_ISEL_MASK
#define AW9523_GCR_GPOMD_MASK

#define AW9523_REG_PORT_MODE(pin)
#define AW9523_REG_SOFT_RESET
#define AW9523_VAL_RESET

/*
 * struct aw9523_irq - Interrupt controller structure
 * @lock: mutex locking for the irq bus
 * @cached_gpio: stores the previous gpio status for bit comparison
 */
struct aw9523_irq {};

/*
 * struct aw9523 - Main driver structure
 * @dev: device handle
 * @regmap: regmap handle for current device
 * @i2c_lock: Mutex lock for i2c operations
 * @reset_gpio: Hardware reset (RSTN) signal GPIO
 * @vio_vreg: VCC regulator (Optional)
 * @pctl: pinctrl handle for current device
 * @gpio: structure holding gpiochip params
 * @irq: Interrupt controller structure
 */
struct aw9523 {};

static const struct pinctrl_pin_desc aw9523_pins[] =;

static int aw9523_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
{}

static const char *aw9523_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
						 unsigned int selector)
{}

static int aw9523_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
					 unsigned int selector,
					 const unsigned int **pins,
					 unsigned int *num_pins)
{}

static const struct pinctrl_ops aw9523_pinctrl_ops =;

static const char * const gpio_pwm_groups[] =;

/* Warning: Do NOT reorder this array */
static const struct pinfunction aw9523_pmx[] =;

static int aw9523_pmx_get_funcs_count(struct pinctrl_dev *pctl)
{}

static const char *aw9523_pmx_get_fname(struct pinctrl_dev *pctl,
					unsigned int sel)
{}

static int aw9523_pmx_get_groups(struct pinctrl_dev *pctl, unsigned int sel,
				 const char * const **groups,
				 unsigned int * const ngroups)
{}

static int aw9523_pmx_set_mux(struct pinctrl_dev *pctl, unsigned int fsel,
			      unsigned int grp)
{}

static const struct pinmux_ops aw9523_pinmux_ops =;

static int aw9523_pcfg_param_to_reg(enum pin_config_param pcp, int pin, u8 *r)
{}

static int aw9523_pconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
			    unsigned long *config)
{}

static int aw9523_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
			    unsigned long *configs, unsigned int num_configs)
{}

static const struct pinconf_ops aw9523_pinconf_ops =;

/*
 * aw9523_get_pin_direction - Get pin direction
 * @regmap: Regmap structure
 * @pin: gpiolib pin number
 * @n:   pin index in port register
 *
 * Return: Pin direction for success or negative number for error
 */
static int aw9523_get_pin_direction(struct regmap *regmap, u8 pin, u8 n)
{}

/*
 * aw9523_get_port_state - Get input or output state for entire port
 * @regmap: Regmap structure
 * @pin:    gpiolib pin number
 * @regbit: hw pin index, used to retrieve port number
 * @state:  returned port state
 *
 * Return: Zero for success or negative number for error
 */
static int aw9523_get_port_state(struct regmap *regmap, u8 pin, u8 regbit,
				 unsigned int *state)
{}

static int aw9523_gpio_irq_type(struct irq_data *d, unsigned int type)
{}

/*
 * aw9523_irq_mask - Mask interrupt
 * @d: irq data
 *
 * Sets which interrupt to mask in the bitmap;
 * The interrupt will be masked when unlocking the irq bus.
 */
static void aw9523_irq_mask(struct irq_data *d)
{}

/*
 * aw9523_irq_unmask - Unmask interrupt
 * @d: irq data
 *
 * Sets which interrupt to unmask in the bitmap;
 * The interrupt will be masked when unlocking the irq bus.
 */
static void aw9523_irq_unmask(struct irq_data *d)
{}

static irqreturn_t aw9523_irq_thread_func(int irq, void *dev_id)
{}

/*
 * aw9523_irq_bus_lock - Grab lock for interrupt operation
 * @d: irq data
 */
static void aw9523_irq_bus_lock(struct irq_data *d)
{}

/*
 * aw9523_irq_bus_sync_unlock - Synchronize state and unlock
 * @d: irq data
 *
 * Writes the interrupt mask bits (found in the bit map) to the
 * hardware, then unlocks the bus.
 */
static void aw9523_irq_bus_sync_unlock(struct irq_data *d)
{}

static int aw9523_gpio_get_direction(struct gpio_chip *chip,
				     unsigned int offset)
{}

static int aw9523_gpio_get(struct gpio_chip *chip, unsigned int offset)
{}

/**
 * _aw9523_gpio_get_multiple - Get I/O state for an entire port
 * @regmap: Regmap structure
 * @pin: gpiolib pin number
 * @regbit: hw pin index, used to retrieve port number
 * @state: returned port I/O state
 *
 * Return: Zero for success or negative number for error
 */
static int _aw9523_gpio_get_multiple(struct aw9523 *awi, u8 regbit,
				     u8 *state, u8 mask)
{}

static int aw9523_gpio_get_multiple(struct gpio_chip *chip,
				    unsigned long *mask,
				    unsigned long *bits)
{}

static void aw9523_gpio_set_multiple(struct gpio_chip *chip,
				    unsigned long *mask,
				    unsigned long *bits)
{}

static void aw9523_gpio_set(struct gpio_chip *chip,
			    unsigned int offset, int value)
{}


static int aw9523_direction_input(struct gpio_chip *chip, unsigned int offset)
{}

static int aw9523_direction_output(struct gpio_chip *chip,
				   unsigned int offset, int value)
{}

static int aw9523_drive_reset_gpio(struct aw9523 *awi)
{}

static int aw9523_hw_reset(struct aw9523 *awi)
{}

static int aw9523_init_gpiochip(struct aw9523 *awi, unsigned int npins)
{}

static const struct irq_chip aw9523_irq_chip =;

static int aw9523_init_irq(struct aw9523 *awi, int irq)
{}

static bool aw9523_is_reg_hole(unsigned int reg)
{}

static bool aw9523_readable_reg(struct device *dev, unsigned int reg)
{}

static bool aw9523_volatile_reg(struct device *dev, unsigned int reg)
{}

static bool aw9523_writeable_reg(struct device *dev, unsigned int reg)
{}

static bool aw9523_precious_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config aw9523_regmap =;

static int aw9523_hw_init(struct aw9523 *awi)
{}

static int aw9523_probe(struct i2c_client *client)
{}

static void aw9523_remove(struct i2c_client *client)
{}

static const struct i2c_device_id aw9523_i2c_id_table[] =;
MODULE_DEVICE_TABLE(i2c, aw9523_i2c_id_table);

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

static struct i2c_driver aw9523_driver =;
module_i2c_driver();

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