Commit de1d0d16 authored by Artur Weber's avatar Artur Weber Committed by Bartosz Golaszewski
Browse files

gpio: bcm-kona: Fix GPIO lock/unlock for banks above bank 0



The GPIO lock/unlock functions clear/write a bit to the relevant
register for each bank. However, due to an oversight the bit that
was being written was based on the total GPIO number, not the index
of the GPIO within the relevant bank, causing it to fail for any
GPIO above 32 (thus any GPIO for banks above bank 0).

Fix lock/unlock for these banks by using the correct bit.

Fixes: bdb93c03 ("gpio: bcm281xx: Centralize register locking")
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarMarkus Mayer <mmayer@broadcom.com>
Signed-off-by: default avatarArtur Weber <aweber.kernel@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250206-kona-gpio-fixes-v2-1-409135eab780@gmail.com


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent a64dcfb4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -86,11 +86,12 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio,
	u32 val;
	unsigned long flags;
	int bank_id = GPIO_BANK(gpio);
	int bit = GPIO_BIT(gpio);

	raw_spin_lock_irqsave(&kona_gpio->lock, flags);

	val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id));
	val |= BIT(gpio);
	val |= BIT(bit);
	bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val);

	raw_spin_unlock_irqrestore(&kona_gpio->lock, flags);
@@ -102,11 +103,12 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio,
	u32 val;
	unsigned long flags;
	int bank_id = GPIO_BANK(gpio);
	int bit = GPIO_BIT(gpio);

	raw_spin_lock_irqsave(&kona_gpio->lock, flags);

	val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id));
	val &= ~BIT(gpio);
	val &= ~BIT(bit);
	bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val);

	raw_spin_unlock_irqrestore(&kona_gpio->lock, flags);