From: Rustam Adilov <adilov@disroot.org>
To: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Sander Vanheule <sander@svanheule.net>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Rustam Adilov <adilov@disroot.org>
Subject: [PATCH v2 2/2] gpio: realtek-otto: make bank_read/write overridable by endian property
Date: Sat, 15 Aug 2026 14:44:51 +0500 [thread overview]
Message-ID: <20260815094451.31792-3-adilov@disroot.org> (raw)
In-Reply-To: <20260815094451.31792-1-adilov@disroot.org>
In order to have a working gpio controller with SWAP_IO_SPACE,
the bank_read/bank_write functions and the gen_gc_flag used for
gpio_generic_chip_config must be able to be changed to their
respective counterparts.
To do that, introduce checks for the presence of endian property
under the device tree node and if so, override what has been
set by GPIO_PORTS_REVERSED quirk flag. This way, existing device
trees are kept working as they were originally.
Both big-endian and little-endian properties must be checked
because there are devices that have GPIO_PORTS_REVERSED flag
and the others that don't.
Signed-off-by: Rustam Adilov <adilov@disroot.org>
---
drivers/gpio/gpio-realtek-otto.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpio/gpio-realtek-otto.c b/drivers/gpio/gpio-realtek-otto.c
index 491fde846d46..e079b5180760 100644
--- a/drivers/gpio/gpio-realtek-otto.c
+++ b/drivers/gpio/gpio-realtek-otto.c
@@ -405,6 +405,16 @@ static int realtek_gpio_probe(struct platform_device *pdev)
ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
}
+ if (device_property_read_bool(dev, "little-endian")) {
+ gen_gc_flags = 0;
+ ctrl->bank_read = realtek_gpio_bank_read;
+ ctrl->bank_write = realtek_gpio_bank_write;
+ } else if (device_is_big_endian(dev)) {
+ gen_gc_flags = GPIO_GENERIC_BIG_ENDIAN_BYTE_ORDER;
+ ctrl->bank_read = realtek_gpio_bank_read_swapped;
+ ctrl->bank_write = realtek_gpio_bank_write_swapped;
+ }
+
config = (struct gpio_generic_chip_config) {
.dev = dev,
.sz = 4,
--
2.55.0
prev parent reply other threads:[~2026-08-15 9:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 9:44 [PATCH v2 0/2] gpio: realtek-otto: make the driver work with SWAP_IO_SPACE Rustam Adilov
2026-08-15 9:44 ` [PATCH v2 1/2] gpio: realtek-otto: use __raw_readl/writel in realtek_gpio_update_line_imr() Rustam Adilov
2026-08-15 9:44 ` Rustam Adilov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260815094451.31792-3-adilov@disroot.org \
--to=adilov@disroot.org \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sander@svanheule.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox