]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
gpio: spacemit-k1: Use PDR for pin direction, not SDR/CDR
authorVivian Wang <wangruikang@iscas.ac.cn>
Tue, 27 Jan 2026 02:58:49 +0000 (10:58 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Wed, 28 Jan 2026 09:41:29 +0000 (10:41 +0100)
commitaa7e37fd770bafaaf856ab77735296955b93e377
treef58805a3c54807b1fc4d0055e3b098e561779eed
parent4c4ff6e38768f2431ed153f110f2d1fcce848af8
gpio: spacemit-k1: Use PDR for pin direction, not SDR/CDR

On the SpacemiT GPIO controller, the direction control register PDR is
readable and writable [1]. Therefore, implement direction control by
using PDR as dirout, and don't mark it as unreadable.

The original implementation, using SDR as dirout and CDR as dirin, is
not actually a supported configuration by gpio-mmio. The hardware
supports changing the direction of some pins atomically by writing a
value with the corresponding bits set to SDR (set as output) or to CDR
(set as input). However, gpio-mmio does not actually handle this.

Using only PDR as dirout to match the expectations of gpio-mmio. This
also allows us to avoid clobbering potentially important GPIO direction
configurations set by pre-Linux boot stages.

Found while trying to add PCIe support to OrangePi RV2, where the
regulator (controlled by GPIO 116) turns off on boot while some other
GPIO pin in the same bank is touched, which is not desirable.

Link: https://developer.spacemit.com/documentation?token=Rn9Kw3iFHirAMgkIpTAcV2Arnkf#18.4-gpio
Fixes: d00553240ef8 ("gpio: spacemit: add support for K1 SoC")
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260127-gpio-spacemit-k1-pdr-v1-1-bb868a517dbc@iscas.ac.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpio-spacemit-k1.c