Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * Copyright (c) 2017 Microsemi Corporation. |
| 7 | * Padmarao Begari, Microsemi Corporation <padmarao.begari@microsemi.com> |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __ASM_GBL_DATA_H |
| 11 | #define __ASM_GBL_DATA_H |
| 12 | |
Tom Rini | 10e6a37 | 2023-12-14 13:16:52 -0500 | [diff] [blame] | 13 | #include <linux/types.h> |
Lukas Auer | 83d573d | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 14 | #include <asm/smp.h> |
Sean Anderson | 5aa0074 | 2020-06-24 06:41:16 -0400 | [diff] [blame] | 15 | #include <asm/u-boot.h> |
| 16 | #include <compiler.h> |
Yao Zi | 73b4c2a | 2025-04-27 14:50:11 +0000 | [diff] [blame] | 17 | #include <config.h> |
Lukas Auer | 83d573d | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 18 | |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 19 | /* Architecture-specific global data */ |
| 20 | struct arch_global_data { |
Bin Meng | 89681a7 | 2018-12-12 06:12:45 -0800 | [diff] [blame] | 21 | long boot_hart; /* boot hart id */ |
Atish Patra | 111b804 | 2020-04-21 11:15:01 -0700 | [diff] [blame] | 22 | phys_addr_t firmware_fdt_addr; |
Bin Meng | b5f0372 | 2023-06-21 23:11:46 +0800 | [diff] [blame] | 23 | #if CONFIG_IS_ENABLED(RISCV_ACLINT) |
| 24 | void __iomem *aclint; /* aclint base address */ |
Bin Meng | b6ee5e1 | 2018-12-12 06:12:30 -0800 | [diff] [blame] | 25 | #endif |
Yu Chien Peter Lin | 739cd6f | 2022-10-25 23:03:50 +0800 | [diff] [blame] | 26 | #ifdef CONFIG_ANDES_PLICSW |
Yu Chien Peter Lin | 52d54e1 | 2023-02-06 10:06:29 +0800 | [diff] [blame] | 27 | void __iomem *plicsw; /* andes plicsw base address */ |
Rick Chen | 6df4ed0 | 2019-04-02 15:56:39 +0800 | [diff] [blame] | 28 | #endif |
Bin Meng | b161f90 | 2020-04-16 08:09:30 -0700 | [diff] [blame] | 29 | #if CONFIG_IS_ENABLED(SMP) |
Lukas Auer | 83d573d | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 30 | struct ipi_data ipi[CONFIG_NR_CPUS]; |
| 31 | #endif |
Nikita Shubin | 7e5e029 | 2022-09-02 11:47:39 +0300 | [diff] [blame] | 32 | #if !CONFIG_IS_ENABLED(XIP) |
Rick Chen | 9c4d5c1 | 2022-09-21 14:34:54 +0800 | [diff] [blame] | 33 | #ifdef CONFIG_AVAILABLE_HARTS |
Lukas Auer | 83d573d | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 34 | ulong available_harts; |
Rick Chen | e5e6c36 | 2019-04-30 13:49:33 +0800 | [diff] [blame] | 35 | #endif |
Rick Chen | 9c4d5c1 | 2022-09-21 14:34:54 +0800 | [diff] [blame] | 36 | #endif |
Heinrich Schuchardt | 565ac63 | 2023-12-19 16:04:03 +0100 | [diff] [blame] | 37 | #if CONFIG_IS_ENABLED(ACPI) |
| 38 | ulong table_start; /* Start address of ACPI tables */ |
| 39 | ulong table_end; /* End address of ACPI tables */ |
| 40 | ulong table_start_high; /* Start address of high ACPI tables */ |
| 41 | ulong table_end_high; /* End address of high ACPI tables */ |
| 42 | #endif |
Simon Glass | 9b38810 | 2023-09-19 21:00:15 -0600 | [diff] [blame] | 43 | #ifdef CONFIG_SMBIOS |
| 44 | ulong smbios_start; /* Start address of SMBIOS table */ |
| 45 | #endif |
Anton Blanchard | 4cf2337 | 2024-08-08 02:14:17 +0000 | [diff] [blame] | 46 | struct resume_data *resume; |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #include <asm-generic/global_data.h> |
| 50 | |
Yao Zi | 73b4c2a | 2025-04-27 14:50:11 +0000 | [diff] [blame] | 51 | #if defined(__clang__) || CONFIG_IS_ENABLED(LTO) |
| 52 | |
| 53 | #define DECLARE_GLOBAL_DATA_PTR |
| 54 | #define gd get_gd() |
| 55 | |
| 56 | static inline gd_t *get_gd(void) |
| 57 | { |
| 58 | gd_t *gd_ptr; |
| 59 | |
| 60 | __asm__ volatile ("mv %0, gp\n" : "=r" (gd_ptr)); |
| 61 | |
| 62 | return gd_ptr; |
| 63 | } |
| 64 | |
| 65 | #else |
| 66 | |
Rick Chen | b34b4b9 | 2018-02-12 11:10:04 +0800 | [diff] [blame] | 67 | #define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp") |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 68 | |
Yao Zi | 73b4c2a | 2025-04-27 14:50:11 +0000 | [diff] [blame] | 69 | #endif |
| 70 | |
Heinrich Schuchardt | 6e7eb46 | 2020-09-10 07:47:39 +0200 | [diff] [blame] | 71 | static inline void set_gd(volatile gd_t *gd_ptr) |
| 72 | { |
| 73 | #ifdef CONFIG_64BIT |
| 74 | asm volatile("ld gp, %0\n" : : "m"(gd_ptr)); |
| 75 | #else |
| 76 | asm volatile("lw gp, %0\n" : : "m"(gd_ptr)); |
| 77 | #endif |
| 78 | } |
| 79 | |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 80 | #endif /* __ASM_GBL_DATA_H */ |