Skip to content

Commit 4c4ff6e

Browse files
diogoivoBartosz Golaszewski
authored andcommitted
gpio: max77620: Implement .get_direction() callback
Add support for reporting the current GPIO line direction by implementing the .get_direction() callback for the MAX77620 GPIO controller. Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260127-smaug-spi_flash-v1-1-5fd334415118@tecnico.ulisboa.pt Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 274ea0f commit 4c4ff6e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/gpio/gpio-max77620.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,24 @@ static const struct irq_chip max77620_gpio_irqchip = {
132132
GPIOCHIP_IRQ_RESOURCE_HELPERS,
133133
};
134134

135+
static int max77620_gpio_get_dir(struct gpio_chip *gc, unsigned int offset)
136+
{
137+
struct max77620_gpio *mgpio = gpiochip_get_data(gc);
138+
unsigned int val;
139+
int ret;
140+
141+
ret = regmap_read(mgpio->rmap, GPIO_REG_ADDR(offset), &val);
142+
if (ret < 0) {
143+
dev_err(mgpio->dev, "CNFG_GPIOx read failed: %d\n", ret);
144+
return ret;
145+
}
146+
147+
if (val & MAX77620_CNFG_GPIO_DIR_MASK)
148+
return GPIO_LINE_DIRECTION_IN;
149+
else
150+
return GPIO_LINE_DIRECTION_OUT;
151+
}
152+
135153
static int max77620_gpio_dir_input(struct gpio_chip *gc, unsigned int offset)
136154
{
137155
struct max77620_gpio *mgpio = gpiochip_get_data(gc);
@@ -308,6 +326,7 @@ static int max77620_gpio_probe(struct platform_device *pdev)
308326

309327
mgpio->gpio_chip.label = pdev->name;
310328
mgpio->gpio_chip.parent = pdev->dev.parent;
329+
mgpio->gpio_chip.get_direction = max77620_gpio_get_dir;
311330
mgpio->gpio_chip.direction_input = max77620_gpio_dir_input;
312331
mgpio->gpio_chip.get = max77620_gpio_get;
313332
mgpio->gpio_chip.direction_output = max77620_gpio_dir_output;

0 commit comments

Comments
 (0)