diff options
author | Hongzhou Yang <hongzhou.yang@mediatek.com> | 2015-11-17 17:17:13 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-11-18 08:55:07 -0500 |
commit | f97c2309667b501c03fcc1c8b3595f5ca0a1ff01 (patch) | |
tree | a04629dfda33de8567da5c7210388d13be61e575 | |
parent | c3dd25cc78150d4db8c7a1842884553202d1fd43 (diff) |
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 <hongzhou.yang@mediatek.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index f307f1d27d64..5c717275a7fa 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c | |||
@@ -747,7 +747,7 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | |||
747 | reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dir_offset; | 747 | reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dir_offset; |
748 | bit = BIT(offset & 0xf); | 748 | bit = BIT(offset & 0xf); |
749 | regmap_read(pctl->regmap1, reg_addr, &read_val); | 749 | regmap_read(pctl->regmap1, reg_addr, &read_val); |
750 | return !!(read_val & bit); | 750 | return !(read_val & bit); |
751 | } | 751 | } |
752 | 752 | ||
753 | static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) | 753 | 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) | |||
757 | unsigned int read_val = 0; | 757 | unsigned int read_val = 0; |
758 | struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); | 758 | struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); |
759 | 759 | ||
760 | if (mtk_gpio_get_direction(chip, offset)) | 760 | reg_addr = mtk_get_port(pctl, offset) + |
761 | reg_addr = mtk_get_port(pctl, offset) + | 761 | pctl->devdata->din_offset; |
762 | pctl->devdata->dout_offset; | ||
763 | else | ||
764 | reg_addr = mtk_get_port(pctl, offset) + | ||
765 | pctl->devdata->din_offset; | ||
766 | 762 | ||
767 | bit = BIT(offset & 0xf); | 763 | bit = BIT(offset & 0xf); |
768 | regmap_read(pctl->regmap1, reg_addr, &read_val); | 764 | regmap_read(pctl->regmap1, reg_addr, &read_val); |
@@ -997,6 +993,7 @@ static struct gpio_chip mtk_gpio_chip = { | |||
997 | .owner = THIS_MODULE, | 993 | .owner = THIS_MODULE, |
998 | .request = gpiochip_generic_request, | 994 | .request = gpiochip_generic_request, |
999 | .free = gpiochip_generic_free, | 995 | .free = gpiochip_generic_free, |
996 | .get_direction = mtk_gpio_get_direction, | ||
1000 | .direction_input = mtk_gpio_direction_input, | 997 | .direction_input = mtk_gpio_direction_input, |
1001 | .direction_output = mtk_gpio_direction_output, | 998 | .direction_output = mtk_gpio_direction_output, |
1002 | .get = mtk_gpio_get, | 999 | .get = mtk_gpio_get, |