[PATCH v2 1/2] reset: socfpga: Add reset status callback function

Ley Foon Tan ley.foon.tan at intel.com
Tue Dec 24 09:23:44 CET 2019


Add .rst_status callback function.
Read reset status from register, return 0 if deasserted,
non-zero if asserted

Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com>
---
 drivers/reset/reset-socfpga.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 93ec9cfdb6..b77c893b76 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -99,11 +99,23 @@ static int socfpga_reset_free(struct reset_ctl *reset_ctl)
 	return 0;
 }
 
+static int socfpga_reset_status(struct reset_ctl *reset_ctl)
+{
+	struct socfpga_reset_data *data = dev_get_priv(reset_ctl->dev);
+	int id = reset_ctl->id;
+	int reg_width = sizeof(u32);
+	int bank = id / (reg_width * BITS_PER_BYTE);
+	int offset = id % (reg_width * BITS_PER_BYTE);
+
+	return readl(data->modrst_base + (bank * BANK_INCREMENT)) & BIT(offset);
+}
+
 static const struct reset_ops socfpga_reset_ops = {
 	.request = socfpga_reset_request,
 	.free = socfpga_reset_free,
 	.rst_assert = socfpga_reset_assert,
 	.rst_deassert = socfpga_reset_deassert,
+	.rst_status = socfpga_reset_status,
 };
 
 static int socfpga_reset_probe(struct udevice *dev)
-- 
2.19.0



More information about the U-Boot mailing list