Skip to content

Commit c6ee931

Browse files
committed
pinctrl: bcm2835: Add strict_gpiod module parameter
Setting strict_gpiod to Y makes libgpiod and the gpiod utilities behave as documented, i.e. pins are returned to being GPIO inputs when they are released. drivers/pinctrl/bcm/pinctrl-bcm2835.c Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent f07cc57 commit c6ee931

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pinctrl/bcm/pinctrl-bcm2835.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ static const char * const irq_type_names[] = {
244244
[IRQ_TYPE_LEVEL_LOW] = "level-low",
245245
};
246246

247+
static bool strict_gpiod;
248+
module_param(strict_gpiod, bool, 0644);
249+
MODULE_PARM_DESC(strict_gpiod, "unless true, outputs remain outputs when freed");
250+
247251
static inline u32 bcm2835_gpio_rd(struct bcm2835_pinctrl *pc, unsigned reg)
248252
{
249253
return readl(pc->base + reg);
@@ -941,8 +945,8 @@ static int bcm2835_pmx_free(struct pinctrl_dev *pctldev,
941945
struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
942946
enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
943947

944-
/* Return non-GPIOs to GPIO_IN */
945-
if (fsel != BCM2835_FSEL_GPIO_IN && fsel != BCM2835_FSEL_GPIO_OUT)
948+
/* Return non-GPIOs to GPIO_IN, unless strict_gpiod is set */
949+
if (strict_gpiod || (fsel != BCM2835_FSEL_GPIO_IN && fsel != BCM2835_FSEL_GPIO_OUT))
946950
bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
947951

948952
return 0;

0 commit comments

Comments
 (0)