Skip to content

Commit 2f8da7f

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 <phil@raspberrypi.com>
1 parent 7b14f34 commit 2f8da7f

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
@@ -926,9 +926,12 @@ static int bcm2835_pmx_free(struct pinctrl_dev *pctldev,
926926
unsigned offset)
927927
{
928928
struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
929+
enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
930+
931+
/* Return non-GPIOs to GPIO_IN */
932+
if (fsel != BCM2835_FSEL_GPIO_IN && fsel != BCM2835_FSEL_GPIO_OUT)
933+
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
929934

930-
/* disable by setting to GPIO_IN */
931-
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
932935
return 0;
933936
}
934937

@@ -970,10 +973,7 @@ static void bcm2835_pmx_gpio_disable_free(struct pinctrl_dev *pctldev,
970973
struct pinctrl_gpio_range *range,
971974
unsigned offset)
972975
{
973-
struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
974-
975-
/* disable by setting to GPIO_IN */
976-
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
976+
(void)bcm2835_pmx_free(pctldev, offset);
977977
}
978978

979979
static int bcm2835_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,

0 commit comments

Comments
 (0)