1 /*
2  * (C) Copyright 2002-2010
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef	__ASM_GBL_DATA_H
9 #define __ASM_GBL_DATA_H
10 
11 /* Architecture-specific global data */
12 struct arch_global_data {
13 #if defined(CONFIG_FSL_ESDHC)
14 	u32 sdhc_clk;
15 #endif
16 
17 #if defined(CONFIG_U_QE)
18 	u32 qe_clk;
19 	u32 brg_clk;
20 	uint mp_alloc_base;
21 	uint mp_alloc_top;
22 #endif /* CONFIG_U_QE */
23 
24 #ifdef CONFIG_AT91FAMILY
25 	/* "static data" needed by at91's clock.c */
26 	unsigned long	cpu_clk_rate_hz;
27 	unsigned long	main_clk_rate_hz;
28 	unsigned long	mck_rate_hz;
29 	unsigned long	plla_rate_hz;
30 	unsigned long	pllb_rate_hz;
31 	unsigned long	at91_pllb_usb_init;
32 #endif
33 	/* "static data" needed by most of timer.c on ARM platforms */
34 	unsigned long timer_rate_hz;
35 	unsigned long tbu;
36 	unsigned long tbl;
37 	unsigned long lastinc;
38 	unsigned long long timer_reset_value;
39 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
40 	unsigned long tlb_addr;
41 	unsigned long tlb_size;
42 #endif
43 
44 #ifdef CONFIG_OMAP_COMMON
45 	u32 omap_boot_device;
46 	u32 omap_boot_mode;
47 	u8 omap_ch_flags;
48 #endif
49 #ifdef CONFIG_FSL_LSCH3
50 	unsigned long mem2_clk;
51 #endif
52 };
53 
54 #include <asm-generic/global_data.h>
55 
56 #ifdef __clang__
57 
58 #define DECLARE_GLOBAL_DATA_PTR
59 #define gd	get_gd()
60 
61 static inline gd_t *get_gd(void)
62 {
63 	gd_t *gd_ptr;
64 
65 #ifdef CONFIG_ARM64
66 	/*
67 	 * Make will already error that reserving x18 is not supported at the
68 	 * time of writing, clang: error: unknown argument: '-ffixed-x18'
69 	 */
70 	__asm__ volatile("mov %0, x18\n" : "=r" (gd_ptr));
71 #else
72 	__asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
73 #endif
74 
75 	return gd_ptr;
76 }
77 
78 #else
79 
80 #ifdef CONFIG_ARM64
81 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("x18")
82 #else
83 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("r9")
84 #endif
85 #endif
86 
87 #endif /* __ASM_GBL_DATA_H */
88