openwrt/target/linux/bcm27xx/patches-5.15/950-0534-gpio-bcm-virt-Fix-the-get-method.patch
Álvaro Fernández Rojas 20ea6adbf1 bcm27xx: add support for linux v5.15
Build system: x86_64
Build-tested: bcm2708, bcm2709, bcm2710, bcm2711
Run-tested: bcm2708/RPiB+, bcm2709/RPi3B, bcm2710/RPi3B, bcm2711/RPi4B

Signed-off-by: Marty Jones <mj8263788@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2022-05-17 15:11:22 +02:00

30 lines
1.1 KiB
Diff

From 6e6d30ab723843fea8d9df368b35e89327f33c11 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Tue, 19 Oct 2021 11:23:43 +0100
Subject: [PATCH] gpio: bcm-virt: Fix the get() method
The get() method does not understand the on-the-wire encoding of the
remote GPIO states, thinking they are simple on/off bits when they are
really pairs of 16-bit counts. Rewrite the get() handler to return the
value last written, which will eventually match the actual GPIO state
if there are no other changes.
See: https://github.com/raspberrypi/linux/issues/4638
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
drivers/gpio/gpio-bcm-virt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpio/gpio-bcm-virt.c
+++ b/drivers/gpio/gpio-bcm-virt.c
@@ -49,7 +49,7 @@ static int brcmvirt_gpio_get(struct gpio
unsigned v;
gpio = container_of(gc, struct brcmvirt_gpio, gc);
v = readl(gpio->ts_base + off);
- return (v >> off) & 1;
+ return (s16)((v >> 16) - v) > 0;
}
static void brcmvirt_gpio_set(struct gpio_chip *gc, unsigned off, int val)