Skip to content

Commit 2634475

Browse files
superna9999linusw
authored andcommitted
pinctrl: qcom: spmi-gpio: implement .get_direction()
GPIO controller driver should typically implement the .get_direction() callback as GPIOLIB internals may try to use it to determine the state of a pin. Since introduction of shared proxy, it prints a warning splat when using a shared spmi gpio. The implementation is not easy because the controller supports enabling the input and output logic at the same time, so we aligns on the behaviour of the .get() operation and return -EINVAL in other situations. Fixes: eadff30 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver") Fixes: d7b5f5c ("pinctrl: qcom: spmi-gpio: Add support for GPIO LV/MV subtype") Signed-off-by: Neil Armstrong <[email protected]> Reviewed-by: Konrad Dybcio <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 1f318b9 commit 2634475

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,21 @@ static const struct pinconf_ops pmic_gpio_pinconf_ops = {
723723
.pin_config_group_dbg_show = pmic_gpio_config_dbg_show,
724724
};
725725

726+
static int pmic_gpio_get_direction(struct gpio_chip *chip, unsigned pin)
727+
{
728+
struct pmic_gpio_state *state = gpiochip_get_data(chip);
729+
struct pmic_gpio_pad *pad;
730+
731+
pad = state->ctrl->desc->pins[pin].drv_data;
732+
733+
if (!pad->is_enabled || pad->analog_pass ||
734+
(!pad->input_enabled && !pad->output_enabled))
735+
return -EINVAL;
736+
737+
/* Make sure the state is aligned on what pmic_gpio_get() returns */
738+
return pad->input_enabled ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
739+
}
740+
726741
static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
727742
{
728743
struct pmic_gpio_state *state = gpiochip_get_data(chip);
@@ -801,6 +816,7 @@ static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
801816
}
802817

803818
static const struct gpio_chip pmic_gpio_gpio_template = {
819+
.get_direction = pmic_gpio_get_direction,
804820
.direction_input = pmic_gpio_direction_input,
805821
.direction_output = pmic_gpio_direction_output,
806822
.get = pmic_gpio_get,

0 commit comments

Comments
 (0)