Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Andreas Bießmann | 2542986 | 2015-02-06 23:06:45 +0100 | [diff] [blame] | 2 | /* |
Andreas Bießmann | 07dafdb | 2016-05-01 03:46:16 +0200 | [diff] [blame] | 3 | * Copyright (c) 2015 Andreas Bießmann <andreas@biessmann.org> |
Andreas Bießmann | 2542986 | 2015-02-06 23:06:45 +0100 | [diff] [blame] | 4 | * |
| 5 | * Copyright (c) 2011 The Chromium OS Authors. |
| 6 | * (C) Copyright 2002-2006 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Marius Groeger <mgroeger@sysgo.de> |
Andreas Bießmann | 2542986 | 2015-02-06 23:06:45 +0100 | [diff] [blame] | 12 | */ |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 13 | #include <init.h> |
Marek Vasut | 964beff | 2021-09-10 22:47:07 +0200 | [diff] [blame] | 14 | #include <lmb.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Andreas Bießmann | 2542986 | 2015-02-06 23:06:45 +0100 | [diff] [blame] | 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | int arch_reserve_stacks(void) |
| 20 | { |
| 21 | #ifdef CONFIG_SPL_BUILD |
| 22 | gd->start_addr_sp -= 128; /* leave 32 words for abort-stack */ |
| 23 | gd->irq_sp = gd->start_addr_sp; |
| 24 | #else |
| 25 | /* setup stack pointer for exceptions */ |
| 26 | gd->irq_sp = gd->start_addr_sp; |
| 27 | |
| 28 | # if !defined(CONFIG_ARM64) |
Andreas Bießmann | 2542986 | 2015-02-06 23:06:45 +0100 | [diff] [blame] | 29 | /* leave 3 words for abort-stack, plus 1 for alignment */ |
| 30 | gd->start_addr_sp -= 16; |
| 31 | # endif |
| 32 | #endif |
| 33 | |
| 34 | return 0; |
| 35 | } |
Marek Vasut | 964beff | 2021-09-10 22:47:07 +0200 | [diff] [blame] | 36 | |
| 37 | static ulong get_sp(void) |
| 38 | { |
| 39 | ulong ret; |
| 40 | |
| 41 | asm("mov %0, sp" : "=r"(ret) : ); |
| 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | void arch_lmb_reserve(struct lmb *lmb) |
| 46 | { |
Marek Vasut | e2afcf4 | 2021-09-10 22:47:11 +0200 | [diff] [blame] | 47 | arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384); |
Marek Vasut | 964beff | 2021-09-10 22:47:07 +0200 | [diff] [blame] | 48 | } |