1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2002-2010
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  */
6 
7 #ifndef	__ASM_GBL_DATA_H
8 #define __ASM_GBL_DATA_H
9 
10 /* Architecture-specific global data */
11 struct arch_global_data {
12 #if defined(CONFIG_FSL_ESDHC)
13 	u32 sdhc_clk;
14 #endif
15 
16 #if defined(CONFIG_U_QE)
17 	u32 qe_clk;
18 	u32 brg_clk;
19 	uint mp_alloc_base;
20 	uint mp_alloc_top;
21 #endif /* CONFIG_U_QE */
22 
23 #ifdef CONFIG_AT91FAMILY
24 	/* "static data" needed by at91's clock.c */
25 	unsigned long	cpu_clk_rate_hz;
26 	unsigned long	main_clk_rate_hz;
27 	unsigned long	mck_rate_hz;
28 	unsigned long	plla_rate_hz;
29 	unsigned long	pllb_rate_hz;
30 	unsigned long	at91_pllb_usb_init;
31 #endif
32 	/* "static data" needed by most of timer.c on ARM platforms */
33 	unsigned long timer_rate_hz;
34 	unsigned int tbu;
35 	unsigned int tbl;
36 	unsigned long lastinc;
37 	unsigned long long timer_reset_value;
38 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
39 	unsigned long tlb_addr;
40 	unsigned long tlb_size;
41 #if defined(CONFIG_ARM64)
42 	unsigned long tlb_fillptr;
43 	unsigned long tlb_emerg;
44 #endif
45 #endif
46 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
47 #define MEM_RESERVE_SECURE_SECURED	0x1
48 #define MEM_RESERVE_SECURE_MAINTAINED	0x2
49 #define MEM_RESERVE_SECURE_ADDR_MASK	(~0x3)
50 	/*
51 	 * Secure memory addr
52 	 * This variable needs maintenance if the RAM base is not zero,
53 	 * or if RAM splits into non-consecutive banks. It also has a
54 	 * flag indicating the secure memory is marked as secure by MMU.
55 	 * Flags used: 0x1 secured
56 	 *             0x2 maintained
57 	 */
58 	phys_addr_t secure_ram;
59 	unsigned long tlb_allocated;
60 #endif
61 #ifdef CONFIG_RESV_RAM
62 	/*
63 	 * Reserved RAM for memory resident, eg. Management Complex (MC)
64 	 * driver which continues to run after U-Boot exits.
65 	 */
66 	phys_addr_t resv_ram;
67 #endif
68 
69 #ifdef CONFIG_ARCH_OMAP2PLUS
70 	u32 omap_boot_device;
71 	u32 omap_boot_mode;
72 	u8 omap_ch_flags;
73 #endif
74 #if defined(CONFIG_FSL_LSCH3) && defined(CONFIG_SYS_FSL_HAS_DP_DDR)
75 	unsigned long mem2_clk;
76 #endif
77 };
78 
79 #include <asm-generic/global_data.h>
80 
81 #ifdef __clang__
82 
83 #define DECLARE_GLOBAL_DATA_PTR
84 #define gd	get_gd()
85 
86 static inline gd_t *get_gd(void)
87 {
88 	gd_t *gd_ptr;
89 
90 #ifdef CONFIG_ARM64
91 	/*
92 	 * Make will already error that reserving x18 is not supported at the
93 	 * time of writing, clang: error: unknown argument: '-ffixed-x18'
94 	 */
95 	__asm__ volatile("mov %0, x18\n" : "=r" (gd_ptr));
96 #else
97 	__asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
98 #endif
99 
100 	return gd_ptr;
101 }
102 
103 #else
104 
105 #ifdef CONFIG_ARM64
106 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("x18")
107 #else
108 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("r9")
109 #endif
110 #endif
111 
112 #endif /* __ASM_GBL_DATA_H */
113