Skip to contentSkip to conversation

reset: socfpga: Poll for reset status after deassert reset

PATCH Superseded Ley Foon Tan 3 participants 3 messages Jan 8, 2020 – Jan 10, 2020 Reset controller framework

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 reset: socfpga: Poll for reset status after deassert reset

In Cyclone 5 SoC platform, the first USB probing is failed but second probing is success. DWC2 USB driver read gsnpsid register right after de-assert reset, but controller is not ready yet and it returns gsnpsid 0. Polling reset status after de-assert reset to solve the issue.

Retry with this fix more than 10 times without issue.

---
v4:
- Change to use get_timer() for timeout.

v3:
- Remove _status callback and poll reset status after deassert reset
- https://patchwork.ozlabs.org/patch/1218026/

v2:
- https://patchwork.ozlabs.org/cover/1215174/

v1:
- https://patchwork.ozlabs.org/patch/1214841/

---
 drivers/reset/reset-socfpga.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/reset/reset-socfpga.c +13 -1
index 93ec9cfdb6..a08967b648 100644
@@ -78,9 +78,21 @@ static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)
 	int reg_width = sizeof(u32);
 	int bank = id / (reg_width * BITS_PER_BYTE);
 	int offset = id % (reg_width * BITS_PER_BYTE);
+	ulong start;
+	u32 status;
 
 	clrbits_le32(data->modrst_base + (bank * BANK_INCREMENT), BIT(offset));
-	return 0;
+
+	/* Poll until reset is completed. */
+	start = get_timer(0);
+	do {
+		status = readl(data->modrst_base + (bank * BANK_INCREMENT)) &
+			       BIT(offset);
+		if (!status)
+			return 0;
+	} while (get_timer(start) < 200);
+
+	return -ETIMEDOUT;
 }
 
 static int socfpga_reset_request(struct reset_ctl *reset_ctl)
Signature · 1 line
2.19.0
#1 lore raw

PATCH v4 1/1 reset: socfpga: Poll for reset status after deassert reset

Quoted 40 lines · Ley Foon Tan

In Cyclone 5 SoC platform, the first USB probing is failed but second probing is success. DWC2 USB driver read gsnpsid register right after de-assert reset, but controller is not ready yet and it returns gsnpsid 0. Polling reset status after de-assert reset to solve the issue.

Retry with this fix more than 10 times without issue.

---
v4:
- Change to use get_timer() for timeout.

v3:
- Remove _status callback and poll reset status after deassert reset
- https://patchwork.ozlabs.org/patch/1218026/

v2:
- https://patchwork.ozlabs.org/cover/1215174/

v1:
- https://patchwork.ozlabs.org/patch/1214841/

---
 drivers/reset/reset-socfpga.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/reset/reset-socfpga.c +3 -1
index 93ec9cfdb6..a08967b648 100644
@@ -78,9 +78,21 @@ static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)
 	int reg_width = sizeof(u32);
 	int bank = id / (reg_width * BITS_PER_BYTE);
 	int offset = id % (reg_width * BITS_PER_BYTE);
+	ulong start;
+	u32 status;
 
 	clrbits_le32(data->modrst_base + (bank * BANK_INCREMENT), BIT(offset));
-	return 0;
+

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_ctl *reset_ctl) · line 95

Quoted 10 lines
drivers/reset/reset-socfpga.c +10 -0
+	/* Poll until reset is completed. */
+	start = get_timer(0);
+	do {
+		status = readl(data->modrst_base + (bank * BANK_INCREMENT)) &
+			       BIT(offset);
+		if (!status)
+			return 0;
+	} while (get_timer(start) < 200);
+
+	return -ETIMEDOUT;

Isn't this like open-coded wait_for_bit...() ?

#2 lore raw

PATCH v4 1/1 reset: socfpga: Poll for reset status after deassert reset

Quoted 61 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Thursday, January 9, 2020 10:44 PM
To: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de
Cc: Simon Goldschmidt <[email protected]>; Simon Glass <[email protected]>; Joe Hershberger <[email protected]>; Ley Foon Tan <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH v4] reset: socfpga: Poll for reset status after deassert reset

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_ctl

Quoted 31 lines · Ley Foon Tan

In Cyclone 5 SoC platform, the first USB probing is failed but second probing is success. DWC2 USB driver read gsnpsid register right after de-assert reset, but controller is not ready yet and it returns gsnpsid 0. Polling reset status after de-assert reset to solve the issue.

Retry with this fix more than 10 times without issue.

---
v4:
- Change to use get_timer() for timeout.

v3:
- Remove _status callback and poll reset status after deassert reset
- https://patchwork.ozlabs.org/patch/1218026/

v2:
- https://patchwork.ozlabs.org/cover/1215174/

v1:
- https://patchwork.ozlabs.org/patch/1214841/

---
 drivers/reset/reset-socfpga.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/reset/reset-socfpga.c index 93ec9cfdb6..a08967b648 100644

drivers/reset/reset-socfpga.c +0 -0
@@ -78,9 +78,21 @@ static int socfpga_reset_deassert(struct reset_ctl

*reset_ctl)

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)

Quoted 7 lines
drivers/reset/reset-socfpga.c +2 -0
 	int reg_width = sizeof(u32);
 	int bank = id / (reg_width * BITS_PER_BYTE);
 	int offset = id % (reg_width * BITS_PER_BYTE);
+	ulong start;
+	u32 status;
 
 	clrbits_le32(data->modrst_base + (bank * BANK_INCREMENT),

BIT(offset));

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)

Quoted 6 lines
drivers/reset/reset-socfpga.c +5 -1
-	return 0;
+
+	/* Poll until reset is completed. */
+	start = get_timer(0);
+	do {
+		status = readl(data->modrst_base + (bank *

BANK_INCREMENT)) &

Quoted 8 lines

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_ctl *reset_ctl) · line 95

Quoted 6 lines
drivers/reset/reset-socfpga.c +6 -0
+			       BIT(offset);
+		if (!status)
+			return 0;
+	} while (get_timer(start) < 200);
+
+	return -ETIMEDOUT;

Isn't this like open-coded wait_for_bit...() ?

Yes, you are right. Will change to it.

Thanks.

Regards
Ley Foon