blob: da851e37fa2cd4738dd01bf24720c1249e3daa7a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk7133d4c2002-09-12 22:42:52 +00002/*
3 * (C) Copyright 2002
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Michael Zaidman800eb092010-09-20 08:51:53 +02006 * (C) Copyright 2010
7 * Michael Zaidman, Kodak, michael.zaidman@kodak.com
8 * post_word_{load|store} cleanup.
wdenk7133d4c2002-09-12 22:42:52 +00009 */
10#ifndef _POST_H
11#define _POST_H
12
13#ifndef __ASSEMBLY__
Michael Zaidman800eb092010-09-20 08:51:53 +020014#include <asm/io.h>
15
Simon Glassc5404b62017-12-04 13:48:23 -070016#if defined(CONFIG_POST)
Michael Zaidman800eb092010-09-20 08:51:53 +020017
Tom Rini9cebc4a2022-11-19 18:45:44 -050018#ifndef CFG_POST_EXTERNAL_WORD_FUNCS
Tom Rini1e019502022-12-04 10:14:17 -050019#ifdef CFG_SYS_POST_WORD_ADDR
20#define _POST_WORD_ADDR CFG_SYS_POST_WORD_ADDR
Michael Zaidman800eb092010-09-20 08:51:53 +020021#else
22
Mario Six61abced2019-01-21 09:17:28 +010023#if defined(CONFIG_ARCH_MPC8360)
Zhao Qiang38d67a4e2014-06-03 16:27:07 +080024#include <linux/immap_qe.h>
Michael Zaidman800eb092010-09-20 08:51:53 +020025#define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR)
26
27#elif defined (CONFIG_MPC85xx)
York Sun8790ac02010-09-28 15:20:35 -070028#include <asm/immap_85xx.h>
Tom Rini51552072022-10-28 20:27:12 -040029#define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CFG_SYS_MPC85xx_PIC_OFFSET + \
Kumar Gala9de0aa72010-12-01 06:42:04 -060030 offsetof(ccsr_pic_t, tfrr))
wdenk7133d4c2002-09-12 22:42:52 +000031#endif
32
Michael Zaidman800eb092010-09-20 08:51:53 +020033#ifndef _POST_WORD_ADDR
34#error "_POST_WORD_ADDR currently not implemented for this platform!"
35#endif
Tom Rini1e019502022-12-04 10:14:17 -050036#endif /* CFG_SYS_POST_WORD_ADDR */
Michael Zaidman800eb092010-09-20 08:51:53 +020037
38static inline ulong post_word_load (void)
39{
40 return in_le32((volatile void *)(_POST_WORD_ADDR));
41}
42
43static inline void post_word_store (ulong value)
44{
45 out_le32((volatile void *)(_POST_WORD_ADDR), value);
46}
Valentin Longchamp3e161ce2011-09-02 04:59:04 +000047
48#else
49
50extern ulong post_word_load(void);
51extern void post_word_store(ulong value);
52
Tom Rini9cebc4a2022-11-19 18:45:44 -050053#endif /* CFG_POST_EXTERNAL_WORD_FUNCS */
Simon Glassc5404b62017-12-04 13:48:23 -070054#endif /* defined (CONFIG_POST) */
Michael Zaidman800eb092010-09-20 08:51:53 +020055#endif /* __ASSEMBLY__ */
56
wdenk7133d4c2002-09-12 22:42:52 +000057#ifdef CONFIG_POST
58
59#define POST_POWERON 0x01 /* test runs on power-on booting */
wdenk8564acf2003-07-14 22:13:32 +000060#define POST_NORMAL 0x02 /* test runs on normal booting */
61#define POST_SLOWTEST 0x04 /* test is slow, enabled by key press */
wdenk7133d4c2002-09-12 22:42:52 +000062#define POST_POWERTEST 0x08 /* test runs after watchdog reset */
63
wdenk27b207f2003-07-24 23:38:38 +000064#define POST_COLDBOOT 0x80 /* first boot after power-on */
65
wdenk7133d4c2002-09-12 22:42:52 +000066#define POST_ROM 0x0100 /* test runs in ROM */
67#define POST_RAM 0x0200 /* test runs in RAM */
68#define POST_MANUAL 0x0400 /* test runs on diag command */
69#define POST_REBOOT 0x0800 /* test may cause rebooting */
Michael Zaidman800eb092010-09-20 08:51:53 +020070#define POST_PREREL 0x1000 /* test runs before relocation */
wdenk7133d4c2002-09-12 22:42:52 +000071
Yuri Tikhonovb428f6a2008-02-04 14:11:03 +010072#define POST_CRITICAL 0x2000 /* Use failbootcmd if test failed */
Yuri Tikhonov28a38502008-05-08 15:45:26 +020073#define POST_STOP 0x4000 /* Interrupt POST sequence on fail */
Yuri Tikhonovb428f6a2008-02-04 14:11:03 +010074
wdenk7133d4c2002-09-12 22:42:52 +000075#define POST_MEM (POST_RAM | POST_ROM)
wdenk8564acf2003-07-14 22:13:32 +000076#define POST_ALWAYS (POST_NORMAL | \
77 POST_SLOWTEST | \
78 POST_MANUAL | \
wdenk7133d4c2002-09-12 22:42:52 +000079 POST_POWERON )
80
Yuri Tikhonovb428f6a2008-02-04 14:11:03 +010081#define POST_FAIL_SAVE 0x80
82
Michael Zaidmane070a562010-03-01 11:47:36 +020083#define POST_BEFORE 1
84#define POST_AFTER 0
85#define POST_PASSED 1
86#define POST_FAILED 0
87
wdenk7133d4c2002-09-12 22:42:52 +000088#ifndef __ASSEMBLY__
89
90struct post_test {
91 char *name;
92 char *cmd;
93 char *desc;
94 int flags;
95 int (*test) (int flags);
wdenk4532cb62003-04-27 22:52:51 +000096 int (*init_f) (void);
97 void (*reloc) (void);
wdenk228f29a2002-12-08 09:53:23 +000098 unsigned long testid;
wdenk7133d4c2002-09-12 22:42:52 +000099};
wdenk4532cb62003-04-27 22:52:51 +0000100int post_init_f (void);
wdenk7133d4c2002-09-12 22:42:52 +0000101void post_bootmode_init (void);
102int post_bootmode_get (unsigned int * last_test);
103void post_bootmode_clear (void);
wdenk7133d4c2002-09-12 22:42:52 +0000104int post_run (char *name, int flags);
105int post_info (char *name);
106int post_log (char *format, ...);
wdenk4532cb62003-04-27 22:52:51 +0000107unsigned long post_time_ms (unsigned long base);
wdenk7133d4c2002-09-12 22:42:52 +0000108
Ovidiu Panait7addd3c2020-11-28 10:43:10 +0200109/**
110 * post_output_backlog() - Print POST results
111 *
112 * Print POST results during the generic board init sequence, after
113 * relocation.
114 *
115 * Return: 0 if OK
116 */
117int post_output_backlog(void);
118
wdenk7133d4c2002-09-12 22:42:52 +0000119extern struct post_test post_list[];
120extern unsigned int post_list_size;
wdenk27b207f2003-07-24 23:38:38 +0000121extern int post_hotkeys_pressed(void);
Heiko Schochereaf5e652011-07-26 20:31:08 +0000122extern int memory_post_test(int flags);
wdenk7133d4c2002-09-12 22:42:52 +0000123
Yuri Tikhonovce82ff02008-12-20 14:54:21 +0300124/*
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__ */
wdenk7133d4c2002-09-12 22:42:52 +0000137#endif /* __ASSEMBLY__ */
138
Tom Rini1e019502022-12-04 10:14:17 -0500139#define CFG_SYS_POST_RTC 0x00000001
140#define CFG_SYS_POST_WATCHDOG 0x00000002
Tom Rini65cc0e22022-11-16 13:10:41 -0500141#define CFG_SYS_POST_MEMORY 0x00000004
Tom Rini1e019502022-12-04 10:14:17 -0500142#define CFG_SYS_POST_CPU 0x00000008
143#define CFG_SYS_POST_I2C 0x00000010
144#define CFG_SYS_POST_CACHE 0x00000020
145#define CFG_SYS_POST_UART 0x00000040
146#define CFG_SYS_POST_ETHER 0x00000080
147#define CFG_SYS_POST_USB 0x00000200
148#define CFG_SYS_POST_SPR 0x00000400
149#define CFG_SYS_POST_SYSMON 0x00000800
150#define CFG_SYS_POST_DSP 0x00001000
151#define CFG_SYS_POST_OCM 0x00002000
152#define CFG_SYS_POST_FPU 0x00004000
153#define CFG_SYS_POST_ECC 0x00008000
154#define CFG_SYS_POST_BSPEC1 0x00010000
155#define CFG_SYS_POST_BSPEC2 0x00020000
156#define CFG_SYS_POST_BSPEC3 0x00040000
157#define CFG_SYS_POST_BSPEC4 0x00080000
158#define CFG_SYS_POST_BSPEC5 0x00100000
159#define CFG_SYS_POST_CODEC 0x00200000
160#define CFG_SYS_POST_COPROC 0x00400000
161#define CFG_SYS_POST_FLASH 0x00800000
Tom Rini65cc0e22022-11-16 13:10:41 -0500162#define CFG_SYS_POST_MEM_REGIONS 0x01000000
wdenk7133d4c2002-09-12 22:42:52 +0000163
wdenk7133d4c2002-09-12 22:42:52 +0000164#endif /* CONFIG_POST */
165
166#endif /* _POST_H */