linux/drivers/gpio/gpio-max732x.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  MAX732x I2C Port Expander with 8/16 I/O
 *
 *  Copyright (C) 2007 Marvell International Ltd.
 *  Copyright (C) 2008 Jack Ren <[email protected]>
 *  Copyright (C) 2008 Eric Miao <[email protected]>
 *  Copyright (C) 2015 Linus Walleij <[email protected]>
 *
 *  Derived from drivers/gpio/pca953x.c
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/platform_data/max732x.h>

/*
 * Each port of MAX732x (including MAX7319) falls into one of the
 * following three types:
 *
 *   - Push Pull Output
 *   - Input
 *   - Open Drain I/O
 *
 * designated by 'O', 'I' and 'P' individually according to MAXIM's
 * datasheets. 'I' and 'P' ports are interrupt capables, some with
 * a dedicated interrupt mask.
 *
 * There are two groups of I/O ports, each group usually includes
 * up to 8 I/O ports, and is accessed by a specific I2C address:
 *
 *   - Group A : by I2C address 0b'110xxxx
 *   - Group B : by I2C address 0b'101xxxx
 *
 * where 'xxxx' is decided by the connections of pin AD2/AD0.  The
 * address used also affects the initial state of output signals.
 *
 * Within each group of ports, there are five known combinations of
 * I/O ports: 4I4O, 4P4O, 8I, 8P, 8O, see the definitions below for
 * the detailed organization of these ports. Only Goup A is interrupt
 * capable.
 *
 * GPIO numbers start from 'gpio_base + 0' to 'gpio_base + 8/16',
 * and GPIOs from GROUP_A are numbered before those from GROUP_B
 * (if there are two groups).
 *
 * NOTE: MAX7328/MAX7329 are drop-in replacements for PCF8574/a, so
 * they are not supported by this driver.
 */

#define PORT_NONE
#define PORT_OUTPUT
#define PORT_INPUT
#define PORT_OPENDRAIN

#define IO_4I4O
#define IO_4P4O
#define IO_8I
#define IO_8P
#define IO_8O

#define GROUP_A(x)
#define GROUP_B(x)

#define INT_NONE
#define INT_NO_MASK
#define INT_INDEP_MASK
#define INT_MERGED_MASK

#define INT_CAPS(x)

enum {};

static uint64_t max732x_features[] =;

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

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

struct max732x_chip {};

static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val)
{}

static int max732x_readb(struct max732x_chip *chip, int group_a, uint8_t *val)
{}

static inline int is_group_a(struct max732x_chip *chip, unsigned off)
{}

static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off)
{}

static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask,
				  int val)
{}

static void max732x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
{}

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

static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
{}

static int max732x_gpio_direction_output(struct gpio_chip *gc,
		unsigned off, int val)
{}

#ifdef CONFIG_GPIO_MAX732X_IRQ
static int max732x_writew(struct max732x_chip *chip, uint16_t val)
{}

static int max732x_readw(struct max732x_chip *chip, uint16_t *val)
{}

static void max732x_irq_update_mask(struct max732x_chip *chip)
{}

static void max732x_irq_mask(struct irq_data *d)
{}

static void max732x_irq_unmask(struct irq_data *d)
{}

static void max732x_irq_bus_lock(struct irq_data *d)
{}

static void max732x_irq_bus_sync_unlock(struct irq_data *d)
{}

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

static int max732x_irq_set_wake(struct irq_data *data, unsigned int on)
{}

static const struct irq_chip max732x_irq_chip =;

static uint8_t max732x_irq_pending(struct max732x_chip *chip)
{}

static irqreturn_t max732x_irq_handler(int irq, void *devid)
{}

static int max732x_irq_setup(struct max732x_chip *chip,
			     const struct i2c_device_id *id)
{}

#else /* CONFIG_GPIO_MAX732X_IRQ */
static int max732x_irq_setup(struct max732x_chip *chip,
			     const struct i2c_device_id *id)
{
	struct i2c_client *client = chip->client;
	int has_irq = max732x_features[id->driver_data] >> 32;

	if (client->irq && has_irq != INT_NONE)
		dev_warn(&client->dev, "interrupt support not compiled in\n");

	return 0;
}
#endif

static int max732x_setup_gpio(struct max732x_chip *chip,
					const struct i2c_device_id *id,
					unsigned gpio_start)
{}

static struct max732x_platform_data *of_gpio_max732x(struct device *dev)
{}

static int max732x_probe(struct i2c_client *client)
{}

static struct i2c_driver max732x_driver =;

static int __init max732x_init(void)
{}
/* register after i2c postcore initcall and before
 * subsys initcalls that may rely on these GPIOs
 */
subsys_initcall(max732x_init);

static void __exit max732x_exit(void)
{}
module_exit(max732x_exit);

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