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 <florin.buica@nxp.com>
Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com>
Link: https://lore.kernel.org/20240723131832.1171036-2-andrei.stefanescu@oss.nxp.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Andrei Stefanescu 2024-07-23 16:18:30 +03:00 committed by Linus Walleij
parent 1441195709
commit 846d9b8628

View File

@ -2,7 +2,7 @@
/*
* Core driver for the S32 CC (Common Chassis) pin controller
*
* Copyright 2017-2022 NXP
* Copyright 2017-2022,2024 NXP
* Copyright (C) 2022 SUSE LLC
* Copyright 2015-2016 Freescale Semiconductor, Inc.
*/
@ -431,16 +431,15 @@ static int s32_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
unsigned int offset,
bool input)
{
unsigned int config;
/* Always enable IBE for GPIOs. This allows us to read the
* actual line value and compare it with the one set.
*/
unsigned int config = S32_MSCR_IBE;
unsigned int mask = S32_MSCR_IBE | S32_MSCR_OBE;
if (input) {
/* Disable output buffer and enable input buffer */
config = S32_MSCR_IBE;
} else {
/* Disable input buffer and enable output buffer */
config = S32_MSCR_OBE;
}
/* Enable output buffer */
if (!input)
config |= S32_MSCR_OBE;
return s32_regmap_update(pctldev, offset, mask, config);
}