mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
gpios: palmas: add .get_direction() op
commitdb4a79713eupstream. Accessing debug/gpio is quite noisy without a get_direction() implementation. To calm that down add an implementation. Fixes:3d50a27852("gpio: palmas: Add support for Palmas GPIO") Cc: stable@vger.kernel.org Reviewed-by: Linus Walleij <linusw@kernel.org> Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Link: https://patch.msgid.link/20260704-palmas-getdirection-v2-1-2fd85fee3832@kemnade.info Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0ea41686d7
commit
f916210f9d
@@ -117,6 +117,24 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int palmas_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
|
||||
{
|
||||
struct palmas_gpio *pg = gpiochip_get_data(gc);
|
||||
struct palmas *palmas = pg->palmas;
|
||||
unsigned int val;
|
||||
unsigned int reg;
|
||||
int ret;
|
||||
int gpio16 = (offset/8);
|
||||
|
||||
offset %= 8;
|
||||
reg = (gpio16) ? PALMAS_GPIO_DATA_DIR2 : PALMAS_GPIO_DATA_DIR;
|
||||
ret = palmas_read(palmas, PALMAS_GPIO_BASE, reg, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return (val & BIT(offset)) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
|
||||
}
|
||||
|
||||
static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
|
||||
{
|
||||
struct palmas_gpio *pg = gpiochip_get_data(gc);
|
||||
@@ -165,6 +183,7 @@ static int palmas_gpio_probe(struct platform_device *pdev)
|
||||
palmas_gpio->gpio_chip.can_sleep = true;
|
||||
palmas_gpio->gpio_chip.direction_input = palmas_gpio_input;
|
||||
palmas_gpio->gpio_chip.direction_output = palmas_gpio_output;
|
||||
palmas_gpio->gpio_chip.get_direction = palmas_gpio_get_direction;
|
||||
palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq;
|
||||
palmas_gpio->gpio_chip.set = palmas_gpio_set;
|
||||
palmas_gpio->gpio_chip.get = palmas_gpio_get;
|
||||
|
||||
Reference in New Issue
Block a user