Skip to content

Commit 846d9b8

Browse files
Andrei Stefanesculinusw
authored andcommitted
pinctrl: s32cc: enable the input buffer for a GPIO
The IBE (input buffer enable) should be enabled for a GPIO. Reading the value will return the one from the input register, writing the value will return the one from the output register. This offers the flexibility to check if the value intended to be set matches the actual physical one. Signed-off-by: Florin Buica <[email protected]> Signed-off-by: Andrei Stefanescu <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 1441195 commit 846d9b8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/pinctrl/nxp/pinctrl-s32cc.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Core driver for the S32 CC (Common Chassis) pin controller
44
*
5-
* Copyright 2017-2022 NXP
5+
* Copyright 2017-2022,2024 NXP
66
* Copyright (C) 2022 SUSE LLC
77
* Copyright 2015-2016 Freescale Semiconductor, Inc.
88
*/
@@ -431,16 +431,15 @@ static int s32_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
431431
unsigned int offset,
432432
bool input)
433433
{
434-
unsigned int config;
434+
/* Always enable IBE for GPIOs. This allows us to read the
435+
* actual line value and compare it with the one set.
436+
*/
437+
unsigned int config = S32_MSCR_IBE;
435438
unsigned int mask = S32_MSCR_IBE | S32_MSCR_OBE;
436439

437-
if (input) {
438-
/* Disable output buffer and enable input buffer */
439-
config = S32_MSCR_IBE;
440-
} else {
441-
/* Disable input buffer and enable output buffer */
442-
config = S32_MSCR_OBE;
443-
}
440+
/* Enable output buffer */
441+
if (!input)
442+
config |= S32_MSCR_OBE;
444443

445444
return s32_regmap_update(pctldev, offset, mask, config);
446445
}

0 commit comments

Comments
 (0)