linux/drivers/gpio/gpio-twl4030.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Access to GPIOs on TWL4030/TPS659x0 chips
 *
 * Copyright (C) 2006-2007 Texas Instruments, Inc.
 * Copyright (C) 2006 MontaVista Software, Inc.
 *
 * Code re-arranged and cleaned up by:
 *	Syed Mohammed Khasim <[email protected]>
 *
 * Initial Code:
 *	Andy Lowe / Nishanth Menon
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <linux/irq.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/irqdomain.h>

#include <linux/mfd/twl.h>

/*
 * The GPIO "subchip" supports 18 GPIOs which can be configured as
 * inputs or outputs, with pullups or pulldowns on each pin.  Each
 * GPIO can trigger interrupts on either or both edges.
 *
 * GPIO interrupts can be fed to either of two IRQ lines; this is
 * intended to support multiple hosts.
 *
 * There are also two LED pins used sometimes as output-only GPIOs.
 */

/* genirq interfaces are not available to modules */
#ifdef MODULE
#define is_module
#else
#define is_module()
#endif

/* GPIO_CTRL Fields */
#define MASK_GPIO_CTRL_GPIO0CD1
#define MASK_GPIO_CTRL_GPIO1CD2
#define MASK_GPIO_CTRL_GPIO_ON

/* Mask for GPIO registers when aggregated into a 32-bit integer */
#define GPIO_32_MASK

struct gpio_twl4030_priv {};

/*----------------------------------------------------------------------*/

/*
 * To configure TWL4030 GPIO module registers
 */
static inline int gpio_twl4030_write(u8 address, u8 data)
{}

/*----------------------------------------------------------------------*/

/*
 * LED register offsets from TWL_MODULE_LED base
 * PWMs A and B are dedicated to LEDs A and B, respectively.
 */

#define TWL4030_LED_LEDEN_REG
#define TWL4030_PWMAON_REG
#define TWL4030_PWMAOFF_REG
#define TWL4030_PWMBON_REG
#define TWL4030_PWMBOFF_REG

/* LEDEN bits */
#define LEDEN_LEDAON
#define LEDEN_LEDBON
#define LEDEN_LEDAEXT
#define LEDEN_LEDBEXT
#define LEDEN_LEDAPWM
#define LEDEN_LEDBPWM
#define LEDEN_PWM_LENGTHA
#define LEDEN_PWM_LENGTHB

#define PWMxON_LENGTH

/*----------------------------------------------------------------------*/

/*
 * To read a TWL4030 GPIO module register
 */
static inline int gpio_twl4030_read(u8 address)
{}

/*----------------------------------------------------------------------*/

static u8 cached_leden;

/* The LED lines are open drain outputs ... a FET pulls to GND, so an
 * external pullup is needed.  We could also expose the integrated PWM
 * as a LED brightness control; we initialize it as "always on".
 */
static void twl4030_led_set_value(int led, int value)
{}

static int twl4030_set_gpio_direction(int gpio, int is_input)
{}

static int twl4030_get_gpio_direction(int gpio)
{}

static int twl4030_set_gpio_dataout(int gpio, int enable)
{}

static int twl4030_get_gpio_datain(int gpio)
{}

/*----------------------------------------------------------------------*/

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

static void twl_free(struct gpio_chip *chip, unsigned offset)
{}

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

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

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

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

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

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

static const struct gpio_chip template_chip =;

/*----------------------------------------------------------------------*/

static int gpio_twl4030_pulls(u32 ups, u32 downs)
{}

static int gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
{}

static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev)
{}

/* Called from the registered devm action */
static void gpio_twl4030_power_off_action(void *data)
{}

static int gpio_twl4030_probe(struct platform_device *pdev)
{}

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

/* Note:  this hardware lives inside an I2C-based multi-function device. */
MODULE_ALIAS();

static struct platform_driver gpio_twl4030_driver =;

static int __init gpio_twl4030_init(void)
{}
subsys_initcall(gpio_twl4030_init);

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

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