gpio: mpc8xxx: Preserve pre-init state of outputs
authorJ. Neuschäfer <j.ne@posteo.net>
Fri, 20 Dec 2024 10:37:54 +0000 (11:37 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 30 Dec 2024 21:55:27 +0000 (15:55 -0600)
commit880374542845c0f7cdc4e60a913a987e6ff06b54
treea54830ff906d65d9d7d336e1835daa4919320832
parentba26b1d0fb923c0b145f15d132dc7561267bb8a9
gpio: mpc8xxx: Preserve pre-init state of outputs

The mpc8xxx_gpio driver contains a workaround for certain chips
where the previously written state of outputs cannot be read back
from the GPIO data (GPDAT) register (MPC8572/MPC8536). This workaround
consists of tracking the state of GPDAT in a "shadow register" (i.e. a
software variable). The shadow register is initialized to zero.

This results in a problem w.r.t. outputs that are configured to a
high (1) state before U-Boot runs, but not touched by U-Boot itself:
Due to the zero-initialization, these GPIOs end up being set to zero,
the first time that any other output is set.

To avoid such issues initialize the GPDAT shadow register to the value
previously held by any outputs, if possible. On MPC8572/MPC8536 this
should make no difference, i.e. the shadow register should be
initialized to zero on these chips.

This patch has been tested on a MPC8314E-based board.

Reviewed-by: Sinan Akman <sinan@writeme.com>
Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
drivers/gpio/mpc8xxx_gpio.c