Source
/*
* Digital I/O driver for Technologic Systems I2C FPGA Core
*
* Copyright (C) 2015 Technologic Systems
* Copyright (C) 2016 Savoir-Faire Linux
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether expressed or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License version 2 for more details.
*/
/*
* Register bits used by the GPIO device
* Some boards, such as TS-7970 do not have a separate input bit
*/
struct ts4900_gpio_priv {
struct regmap *regmap;
struct gpio_chip gpio_chip;
unsigned int input_bit;
};
static int ts4900_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
unsigned int reg;
regmap_read(priv->regmap, offset, ®);
return !(reg & TS4900_GPIO_OE);
}
static int ts4900_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
/*
* This will clear the output enable bit, the other bits are
* dontcare when this is cleared
*/
return regmap_write(priv->regmap, offset, 0);
}
static int ts4900_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)