diff options
| author | Diogo Ivo <diogo.ivo@bootlin.com> | 2026-06-20 15:50:58 +0200 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-06-29 19:41:07 +0100 |
| commit | 99e361b2a50424ffd923dc151fd605afa5b213ce (patch) | |
| tree | ebf3d2758a7d2e94c98ba24a3f847faca4040fb3 /sound/soc/codecs/rt5677.c | |
| parent | dc59e4fea9d83f03bad6bddf3fa2e52491777482 (diff) | |
| download | linux-next-99e361b2a50424ffd923dc151fd605afa5b213ce.tar.gz linux-next-99e361b2a50424ffd923dc151fd605afa5b213ce.zip | |
ASoC: rt5677: Add GPIO .get_direction() callback
Implement the get_direction callback for the GPIO controller to allow
consumers to query the direction of GPIO pins.
Signed-off-by: Diogo Ivo <diogo.ivo@bootlin.com>
Link: https://patch.msgid.link/20260620-smaug-audio-v1-1-e318acdf5abd@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt5677.c')
| -rw-r--r-- | sound/soc/codecs/rt5677.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index ac084ca008f3..73fc008d558a 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -6,6 +6,7 @@ * Author: Oder Chiou <oder_chiou@realtek.com> */ +#include <linux/bits.h> #include <linux/delay.h> #include <linux/firmware.h> #include <linux/fs.h> @@ -4767,6 +4768,21 @@ static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset) return rt5677_update_gpio_bits(rt5677, offset, m, v); } +static int rt5677_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); + unsigned int shift = RT5677_GPIOx_DIR_SFT + (offset % 5) * 3; + unsigned int bank = offset / 5; + unsigned int reg = bank ? RT5677_GPIO_CTRL3 : RT5677_GPIO_CTRL2; + int ret; + + ret = regmap_test_bits(rt5677->regmap, reg, BIT(shift)); + if (ret < 0) + return ret; + + return ret ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN; +} + /* * Configures the GPIO as * 0 - floating @@ -4834,6 +4850,7 @@ static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) static const struct gpio_chip rt5677_template_chip = { .label = RT5677_DRV_NAME, .owner = THIS_MODULE, + .get_direction = rt5677_gpio_get_direction, .direction_output = rt5677_gpio_direction_out, .set = rt5677_gpio_set, .direction_input = rt5677_gpio_direction_in, |
