Skip to content

Commit f97c230

Browse files
Hongzhou Yanglinusw
authored andcommitted
pinctrl: mediatek: Add get_direction support.
Since Linux gpio framework return 0 for output, 1 for input. But HW use 0 stands for input, and 1 stands for output. So use negative to correct it. And gpio_chip.get is used to get input value, no need to get output value, so removing it. Signed-off-by: Hongzhou Yang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent c3dd25c commit f97c230

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/pinctrl/mediatek/pinctrl-mtk-common.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
747747
reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dir_offset;
748748
bit = BIT(offset & 0xf);
749749
regmap_read(pctl->regmap1, reg_addr, &read_val);
750-
return !!(read_val & bit);
750+
return !(read_val & bit);
751751
}
752752

753753
static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -757,12 +757,8 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset)
757757
unsigned int read_val = 0;
758758
struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev);
759759

760-
if (mtk_gpio_get_direction(chip, offset))
761-
reg_addr = mtk_get_port(pctl, offset) +
762-
pctl->devdata->dout_offset;
763-
else
764-
reg_addr = mtk_get_port(pctl, offset) +
765-
pctl->devdata->din_offset;
760+
reg_addr = mtk_get_port(pctl, offset) +
761+
pctl->devdata->din_offset;
766762

767763
bit = BIT(offset & 0xf);
768764
regmap_read(pctl->regmap1, reg_addr, &read_val);
@@ -997,6 +993,7 @@ static struct gpio_chip mtk_gpio_chip = {
997993
.owner = THIS_MODULE,
998994
.request = gpiochip_generic_request,
999995
.free = gpiochip_generic_free,
996+
.get_direction = mtk_gpio_get_direction,
1000997
.direction_input = mtk_gpio_direction_input,
1001998
.direction_output = mtk_gpio_direction_output,
1002999
.get = mtk_gpio_get,

0 commit comments

Comments
 (0)