Skip to contentSkip to conversation

gpio: aspeed: Fix incorrect offset of read back register.

PATCH In review Billy Tsai 3 participants 3 messages Apr 13, 2022 – Apr 20, 2022

Subsystems (2)
lore
Share & tools
lore

Billy Tsai

author reviewer
#0 lore raw

PATCH 1/1 gpio: aspeed: Fix incorrect offset of read back register.

The offset of the current read back register is the value of the gpio pin, not the value written for the gpio output.
This patch fix it to avoid the other gpio output value controlled by the same register being set incorrectly.

Fixes 7ad889b0f37a ("gpio: Add Aspeed GPIO driver")
---
 drivers/gpio/gpio-aspeed.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-aspeed.c +2 -2
index a8a2afcb5c..2c5415c671 100644
@@ -211,7 +211,7 @@ static int aspeed_gpio_direction_output(struct udevice *dev, unsigned int offset
 	struct aspeed_gpio_priv *priv = dev_get_priv(dev);
 	const struct aspeed_gpio_bank *bank = to_bank(offset);
 	u32 dir = readl(bank_reg(priv, bank, reg_dir));
-	u32 output = readl(bank_reg(priv, bank, reg_val));
+	u32 output = readl(bank_reg(priv, bank, reg_rdata));
 
 	dir |= GPIO_BIT(offset);
 	writel(dir, bank_reg(priv, bank, reg_dir));
@@ -239,7 +239,7 @@ aspeed_gpio_set_value(struct udevice *dev, unsigned int offset, int value)
 {
 	struct aspeed_gpio_priv *priv = dev_get_priv(dev);
 	const struct aspeed_gpio_bank *bank = to_bank(offset);
-	u32 data = readl(bank_reg(priv, bank, reg_val));
+	u32 data = readl(bank_reg(priv, bank, reg_rdata));
 
 	if (value)
 		data |= GPIO_BIT(offset);
Signature · 1 line
2.25.1
reviewer
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Billy Tsai <[email protected]>
Sent: Wednesday, April 13, 2022 1:35 PM
To: Ryan Chen <[email protected]>; ChiaWei Wang <[email protected]>; BMC-SW <[email protected]>; [email protected]; Billy Tsai <[email protected]>; [email protected]
Subject: [PATCH] gpio: aspeed: Fix incorrect offset of read back register.

Quoted 7 lines

The offset of the current read back register is the value of the gpio pin, not the value written for the gpio output.
This patch fix it to avoid the other gpio output value controlled by the same register being set incorrectly.

Fixes 7ad889b0f37a ("gpio: Add Aspeed GPIO driver")
Quoted 28 lines
---
 drivers/gpio/gpio-aspeed.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-aspeed.c index renamed from drivers/gpio/gpio-aspeed.c +0 -0

a8a2afcb5c..2c5415c671 100644

drivers/gpio/gpio-aspeed.c +1 -1
@@ -211,7 +211,7 @@ static int aspeed_gpio_direction_output(struct udevice
 *dev, unsigned int offset
 	struct aspeed_gpio_priv *priv = dev_get_priv(dev);
 	const struct aspeed_gpio_bank *bank = to_bank(offset);
 	u32 dir = readl(bank_reg(priv, bank, reg_dir));
-	u32 output = readl(bank_reg(priv, bank, reg_val));
+	u32 output = readl(bank_reg(priv, bank, reg_rdata));
 
 	dir |= GPIO_BIT(offset);

writel(dir, bank_reg(priv, bank, reg_dir)); @@ -239,7 +239,7 @@
aspeed_gpio_set_value(struct udevice *dev, unsigned int offset, int value) {

drivers/gpio/gpio-aspeed.c +1 -2
 	struct aspeed_gpio_priv *priv = dev_get_priv(dev);
 	const struct aspeed_gpio_bank *bank = to_bank(offset);
-	u32 data = readl(bank_reg(priv, bank, reg_val));
+	u32 data = readl(bank_reg(priv, bank, reg_rdata));
 
 	if (value)
 		data |= GPIO_BIT(offset);
--

2.25.1

#2 lore raw
In reply to Billy Tsai
Quoted 7 lines · Billy Tsai

The offset of the current read back register is the value of the gpio pin, not the value written for the gpio output.
This patch fix it to avoid the other gpio output value controlled by the same register being set incorrectly.

Fixes 7ad889b0f37a ("gpio: Add Aspeed GPIO driver")

Applied to u-boot/master, thanks!

Signature · 1 line
Tom