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