mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
gpios: palmas: add .get_direction() op
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>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
8cdeaa50ea
commit
db4a79713e
@@ -116,6 +116,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