[U-Boot] sysreset: dm: Support manual relocation for sysreset

Message ID af3890c3d6edd70f899778c7336e2fe146129fa5.1531395310.git.michal.simek@xilinx.com
State Accepted
Commit 758de97bb8be091e0b1ab25af6bb9965d54fa839
Delegated to: Simon Glass
Headers show
Series
  • [U-Boot] sysreset: dm: Support manual relocation for sysreset
Related show

Commit Message

Michal Simek July 12, 2018, 11:35 a.m.
Relocate sysreset ops as was done by:
"dm: Add support for all targets which requires MANUAL_RELOC"
(sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/sysreset/sysreset-uclass.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Simon Glass July 15, 2018, 9:21 p.m. | #1
On 12 July 2018 at 05:35, Michal Simek <michal.simek@xilinx.com> wrote:
> Relocate sysreset ops as was done by:
> "dm: Add support for all targets which requires MANUAL_RELOC"
> (sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  drivers/sysreset/sysreset-uclass.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Patch

diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 7e06c3c90a71..840eab6b5703 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -74,7 +74,23 @@  int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+static int sysreset_post_bind(struct udevice *dev)
+{
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+	struct sysreset_ops *ops = sysreset_get_ops(dev);
+	static int reloc_done;
+
+	if (!reloc_done) {
+		if (ops->request)
+			ops->request += gd->reloc_off;
+		reloc_done++;
+	}
+#endif
+	return 0;
+}
+
 UCLASS_DRIVER(sysreset) = {
 	.id		= UCLASS_SYSRESET,
 	.name		= "sysreset",
+	.post_bind	= sysreset_post_bind,
 };