Merge git://www.denx.de/git/u-boot-imx
[oweals/u-boot.git] / include / post.h
1 /*
2  * (C) Copyright 2002
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * (C) Copyright 2010
6  * Michael Zaidman, Kodak, michael.zaidman@kodak.com
7  * post_word_{load|store} cleanup.
8  *
9  * SPDX-License-Identifier:     GPL-2.0+
10  */
11 #ifndef _POST_H
12 #define _POST_H
13
14 #ifndef __ASSEMBLY__
15 #include <common.h>
16 #include <asm/io.h>
17
18 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
19
20 #ifndef CONFIG_POST_EXTERNAL_WORD_FUNCS
21 #ifdef CONFIG_SYS_POST_WORD_ADDR
22 #define _POST_WORD_ADDR CONFIG_SYS_POST_WORD_ADDR
23 #else
24
25 #if defined(CONFIG_MPC8360)
26 #include <linux/immap_qe.h>
27 #define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR)
28
29 #elif defined (CONFIG_MPC85xx)
30 #include <asm/immap_85xx.h>
31 #define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PIC_OFFSET + \
32                                 offsetof(ccsr_pic_t, tfrr))
33
34 #elif defined (CONFIG_MPC86xx)
35 #include <asm/immap_86xx.h>
36 #define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_PIC_OFFSET + \
37                                 offsetof(ccsr_pic_t, tfrr))
38
39 #elif defined (CONFIG_4xx)
40 #define _POST_WORD_ADDR \
41         (CONFIG_SYS_OCM_DATA_ADDR + CONFIG_SYS_GBL_DATA_OFFSET - 0x4)
42 #endif
43
44 #ifndef _POST_WORD_ADDR
45 #error "_POST_WORD_ADDR currently not implemented for this platform!"
46 #endif
47 #endif /* CONFIG_SYS_POST_WORD_ADDR */
48
49 static inline ulong post_word_load (void)
50 {
51         return in_le32((volatile void *)(_POST_WORD_ADDR));
52 }
53
54 static inline void post_word_store (ulong value)
55 {
56         out_le32((volatile void *)(_POST_WORD_ADDR), value);
57 }
58
59 #else
60
61 extern ulong post_word_load(void);
62 extern void post_word_store(ulong value);
63
64 #endif /* CONFIG_POST_EXTERNAL_WORD_FUNCS */
65 #endif /* defined (CONFIG_POST) || defined(CONFIG_LOGBUFFER) */
66 #endif /* __ASSEMBLY__ */
67
68 #ifdef CONFIG_POST
69
70 #define POST_POWERON            0x01    /* test runs on power-on booting */
71 #define POST_NORMAL             0x02    /* test runs on normal booting */
72 #define POST_SLOWTEST           0x04    /* test is slow, enabled by key press */
73 #define POST_POWERTEST          0x08    /* test runs after watchdog reset */
74
75 #define POST_COLDBOOT           0x80    /* first boot after power-on */
76
77 #define POST_ROM                0x0100  /* test runs in ROM */
78 #define POST_RAM                0x0200  /* test runs in RAM */
79 #define POST_MANUAL             0x0400  /* test runs on diag command */
80 #define POST_REBOOT             0x0800  /* test may cause rebooting */
81 #define POST_PREREL             0x1000  /* test runs before relocation */
82
83 #define POST_CRITICAL           0x2000  /* Use failbootcmd if test failed */
84 #define POST_STOP               0x4000  /* Interrupt POST sequence on fail */
85
86 #define POST_MEM                (POST_RAM | POST_ROM)
87 #define POST_ALWAYS             (POST_NORMAL    | \
88                                  POST_SLOWTEST  | \
89                                  POST_MANUAL    | \
90                                  POST_POWERON   )
91
92 #define POST_FAIL_SAVE          0x80
93
94 #define POST_BEFORE             1
95 #define POST_AFTER              0
96 #define POST_PASSED             1
97 #define POST_FAILED             0
98
99 #ifndef __ASSEMBLY__
100
101 struct post_test {
102         char *name;
103         char *cmd;
104         char *desc;
105         int flags;
106         int (*test) (int flags);
107         int (*init_f) (void);
108         void (*reloc) (void);
109         unsigned long testid;
110 };
111 int post_init_f (void);
112 void post_bootmode_init (void);
113 int post_bootmode_get (unsigned int * last_test);
114 void post_bootmode_clear (void);
115 void post_output_backlog ( void );
116 int post_run (char *name, int flags);
117 int post_info (char *name);
118 int post_log (char *format, ...);
119 #ifdef CONFIG_NEEDS_MANUAL_RELOC
120 void post_reloc (void);
121 #endif
122 unsigned long post_time_ms (unsigned long base);
123
124 extern struct post_test post_list[];
125 extern unsigned int post_list_size;
126 extern int post_hotkeys_pressed(void);
127 extern int memory_post_test(int flags);
128
129 /*
130  *  If GCC is configured to use a version of GAS that supports
131  * the .gnu_attribute directive, it will use that directive to
132  * record certain properties of the output code.
133  *  This feature is new to GCC 4.3.0.
134  *  .gnu_attribute is new to GAS 2.18.
135  */
136 #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
137 /* Tag_GNU_Power_ABI_FP/soft-float */
138 #define GNU_FPOST_ATTR  asm(".gnu_attribute     4, 2");
139 #else
140 #define GNU_FPOST_ATTR
141 #endif /* __GNUC__ */
142 #endif /* __ASSEMBLY__ */
143
144 #define CONFIG_SYS_POST_RTC             0x00000001
145 #define CONFIG_SYS_POST_WATCHDOG        0x00000002
146 #define CONFIG_SYS_POST_MEMORY          0x00000004
147 #define CONFIG_SYS_POST_CPU             0x00000008
148 #define CONFIG_SYS_POST_I2C             0x00000010
149 #define CONFIG_SYS_POST_CACHE           0x00000020
150 #define CONFIG_SYS_POST_UART            0x00000040
151 #define CONFIG_SYS_POST_ETHER           0x00000080
152 #define CONFIG_SYS_POST_USB             0x00000200
153 #define CONFIG_SYS_POST_SPR             0x00000400
154 #define CONFIG_SYS_POST_SYSMON          0x00000800
155 #define CONFIG_SYS_POST_DSP             0x00001000
156 #define CONFIG_SYS_POST_OCM             0x00002000
157 #define CONFIG_SYS_POST_FPU             0x00004000
158 #define CONFIG_SYS_POST_ECC             0x00008000
159 #define CONFIG_SYS_POST_BSPEC1          0x00010000
160 #define CONFIG_SYS_POST_BSPEC2          0x00020000
161 #define CONFIG_SYS_POST_BSPEC3          0x00040000
162 #define CONFIG_SYS_POST_BSPEC4          0x00080000
163 #define CONFIG_SYS_POST_BSPEC5          0x00100000
164 #define CONFIG_SYS_POST_CODEC           0x00200000
165 #define CONFIG_SYS_POST_COPROC          0x00400000
166 #define CONFIG_SYS_POST_FLASH           0x00800000
167 #define CONFIG_SYS_POST_MEM_REGIONS     0x01000000
168
169 #endif /* CONFIG_POST */
170
171 #endif /* _POST_H */