Skip to content

Commit 022689f

Browse files
pelwellpopcornmix
authored andcommitted
pinctrl: bcm2835: Only return non-GPIOs to inputs
Allowing GPIO state to persist allows the use of gpioset to control GPIO levels without having to use the --mode=wait feature. Signed-off-by: Phil Elwell <[email protected]>
1 parent c4163ba commit 022689f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/pinctrl/bcm/pinctrl-bcm2835.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,12 @@ static int bcm2835_pmx_free(struct pinctrl_dev *pctldev,
918918
unsigned offset)
919919
{
920920
struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
921+
enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
922+
923+
/* Return non-GPIOs to GPIO_IN */
924+
if (fsel != BCM2835_FSEL_GPIO_IN && fsel != BCM2835_FSEL_GPIO_OUT)
925+
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
921926

922-
/* disable by setting to GPIO_IN */
923-
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
924927
return 0;
925928
}
926929

@@ -962,10 +965,7 @@ static void bcm2835_pmx_gpio_disable_free(struct pinctrl_dev *pctldev,
962965
struct pinctrl_gpio_range *range,
963966
unsigned offset)
964967
{
965-
struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
966-
967-
/* disable by setting to GPIO_IN */
968-
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
968+
(void)bcm2835_pmx_free(pctldev, offset);
969969
}
970970

971971
static int bcm2835_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,

0 commit comments

Comments
 (0)