Commit fa8f6d06 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: lp87565: Set proper output level and direction for direction_output

The value argument of lp87565_gpio_direction_output() means output level
rather than gpio direction.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Reviewed-by: default avatarKeerthy <j-keerthy@ti.com>
Tested-by: default avatarKeerthy <j-keerthy@ti.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 727fd697
...@@ -26,6 +26,27 @@ struct lp87565_gpio { ...@@ -26,6 +26,27 @@ struct lp87565_gpio {
struct regmap *map; struct regmap *map;
}; };
static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct lp87565_gpio *gpio = gpiochip_get_data(chip);
int ret, val;
ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
if (ret < 0)
return ret;
return !!(val & BIT(offset));
}
static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct lp87565_gpio *gpio = gpiochip_get_data(chip);
regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
BIT(offset), value ? BIT(offset) : 0);
}
static int lp87565_gpio_get_direction(struct gpio_chip *chip, static int lp87565_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset) unsigned int offset)
{ {
...@@ -54,30 +75,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip, ...@@ -54,30 +75,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip,
{ {
struct lp87565_gpio *gpio = gpiochip_get_data(chip); struct lp87565_gpio *gpio = gpiochip_get_data(chip);
lp87565_gpio_set(chip, offset, value);
return regmap_update_bits(gpio->map, return regmap_update_bits(gpio->map,
LP87565_REG_GPIO_CONFIG, LP87565_REG_GPIO_CONFIG,
BIT(offset), !value ? BIT(offset) : 0); BIT(offset), BIT(offset));
}
static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct lp87565_gpio *gpio = gpiochip_get_data(chip);
int ret, val;
ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
if (ret < 0)
return ret;
return !!(val & BIT(offset));
}
static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct lp87565_gpio *gpio = gpiochip_get_data(chip);
regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
BIT(offset), value ? BIT(offset) : 0);
} }
static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset) static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment