Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Diogo Ivo and committed by
Bartosz Golaszewski
4c4ff6e3 274ea0f1

+19
+19
drivers/gpio/gpio-max77620.c
··· 132 132 GPIOCHIP_IRQ_RESOURCE_HELPERS, 133 133 }; 134 134 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 + 135 153 static int max77620_gpio_dir_input(struct gpio_chip *gc, unsigned int offset) 136 154 { 137 155 struct max77620_gpio *mgpio = gpiochip_get_data(gc); ··· 326 308 327 309 mgpio->gpio_chip.label = pdev->name; 328 310 mgpio->gpio_chip.parent = pdev->dev.parent; 311 + mgpio->gpio_chip.get_direction = max77620_gpio_get_dir; 329 312 mgpio->gpio_chip.direction_input = max77620_gpio_dir_input; 330 313 mgpio->gpio_chip.get = max77620_gpio_get; 331 314 mgpio->gpio_chip.direction_output = max77620_gpio_dir_output;