#include <linux/gpio/driver.h>
#include <linux/kernel.h>
#include <linux/mfd/tps6586x.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#define TPS6586X_GPIOSET1 0x5d
#define TPS6586X_GPIOSET2 0x5e
struct gpio_chip gpio_chip;
static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
ret = tps6586x_read(tps6586x_gpio->parent, TPS6586X_GPIOSET2, &val);
return !!(val & (1 << offset));
static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
value << offset, 1 << offset);
static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
tps6586x_gpio_set(gc, offset, value);
val = 0x1 << (offset * 2);
mask = 0x3 << (offset * 2);
return tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET1,