bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0534-gpio-bcm-virt-Fix-the-get-method.patch
1 From 6e6d30ab723843fea8d9df368b35e89327f33c11 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Tue, 19 Oct 2021 11:23:43 +0100
4 Subject: [PATCH] gpio: bcm-virt: Fix the get() method
5
6 The get() method does not understand the on-the-wire encoding of the
7 remote GPIO states, thinking they are simple on/off bits when they are
8 really pairs of 16-bit counts. Rewrite the get() handler to return the
9 value last written, which will eventually match the actual GPIO state
10 if there are no other changes.
11
12 See: https://github.com/raspberrypi/linux/issues/4638
13
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
15 ---
16 drivers/gpio/gpio-bcm-virt.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19 --- a/drivers/gpio/gpio-bcm-virt.c
20 +++ b/drivers/gpio/gpio-bcm-virt.c
21 @@ -49,7 +49,7 @@ static int brcmvirt_gpio_get(struct gpio
22 unsigned v;
23 gpio = container_of(gc, struct brcmvirt_gpio, gc);
24 v = readl(gpio->ts_base + off);
25 - return (v >> off) & 1;
26 + return (s16)((v >> 16) - v) > 0;
27 }
28
29 static void brcmvirt_gpio_set(struct gpio_chip *gc, unsigned off, int val)