blob: 5695e2b5334fb7f7db460a2c21bccbd3975f72ae [file] [log] [blame]
Tom Rini10e47792018-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 Zaidmanf969a682010-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__
14#include <common.h>
Michael Zaidmanf969a682010-09-20 08:51:53 +020015#include <asm/io.h>
16
Simon Glass49badb92017-12-04 13:48:23 -070017#if defined(CONFIG_POST)
Michael Zaidmanf969a682010-09-20 08:51:53 +020018
Valentin Longchampb2596e02011-09-02 04:59:04 +000019#ifndef CONFIG_POST_EXTERNAL_WORD_FUNCS
Michael Zaidmanf969a682010-09-20 08:51:53 +020020#ifdef CONFIG_SYS_POST_WORD_ADDR
21#define _POST_WORD_ADDR CONFIG_SYS_POST_WORD_ADDR
22#else
23
Mario Six84eb4312019-01-21 09:17:28 +010024#if defined(CONFIG_ARCH_MPC8360)
Zhao Qiang978679d2014-06-03 16:27:07 +080025#include <linux/immap_qe.h>
Michael Zaidmanf969a682010-09-20 08:51:53 +020026#define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR)
27
28#elif defined (CONFIG_MPC85xx)
York Sunf7541b42010-09-28 15:20:35 -070029#include <asm/immap_85xx.h>
Kumar Galae3a5d372010-12-01 06:42:04 -060030#define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PIC_OFFSET + \
31 offsetof(ccsr_pic_t, tfrr))
Michael Zaidmanf969a682010-09-20 08:51:53 +020032
Peter Tyser04ce2a82010-10-22 00:20:32 -050033#elif defined (CONFIG_MPC86xx)
34#include <asm/immap_86xx.h>
Kumar Galae3a5d372010-12-01 06:42:04 -060035#define _POST_WORD_ADDR (CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_PIC_OFFSET + \
36 offsetof(ccsr_pic_t, tfrr))
wdenk7133d4c2002-09-12 22:42:52 +000037#endif
38
Michael Zaidmanf969a682010-09-20 08:51:53 +020039#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
44static inline ulong post_word_load (void)
45{
46 return in_le32((volatile void *)(_POST_WORD_ADDR));
47}
48
49static inline void post_word_store (ulong value)
50{
51 out_le32((volatile void *)(_POST_WORD_ADDR), value);
52}
Valentin Longchampb2596e02011-09-02 04:59:04 +000053
54#else
55
56extern ulong post_word_load(void);
57extern void post_word_store(ulong value);
58
59#endif /* CONFIG_POST_EXTERNAL_WORD_FUNCS */
Simon Glass49badb92017-12-04 13:48:23 -070060#endif /* defined (CONFIG_POST) */
Michael Zaidmanf969a682010-09-20 08:51:53 +020061#endif /* __ASSEMBLY__ */
62
wdenk7133d4c2002-09-12 22:42:52 +000063#ifdef CONFIG_POST
64
65#define POST_POWERON 0x01 /* test runs on power-on booting */
wdenkdccbda02003-07-14 22:13:32 +000066#define POST_NORMAL 0x02 /* test runs on normal booting */
67#define POST_SLOWTEST 0x04 /* test is slow, enabled by key press */
wdenk7133d4c2002-09-12 22:42:52 +000068#define POST_POWERTEST 0x08 /* test runs after watchdog reset */
69
wdenk874ac262003-07-24 23:38:38 +000070#define POST_COLDBOOT 0x80 /* first boot after power-on */
71
wdenk7133d4c2002-09-12 22:42:52 +000072#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 Zaidmanf969a682010-09-20 08:51:53 +020076#define POST_PREREL 0x1000 /* test runs before relocation */
wdenk7133d4c2002-09-12 22:42:52 +000077
Yuri Tikhonovd773efb2008-02-04 14:11:03 +010078#define POST_CRITICAL 0x2000 /* Use failbootcmd if test failed */
Yuri Tikhonovbc439b02008-05-08 15:45:26 +020079#define POST_STOP 0x4000 /* Interrupt POST sequence on fail */
Yuri Tikhonovd773efb2008-02-04 14:11:03 +010080
wdenk7133d4c2002-09-12 22:42:52 +000081#define POST_MEM (POST_RAM | POST_ROM)
wdenkdccbda02003-07-14 22:13:32 +000082#define POST_ALWAYS (POST_NORMAL | \
83 POST_SLOWTEST | \
84 POST_MANUAL | \
wdenk7133d4c2002-09-12 22:42:52 +000085 POST_POWERON )
86
Yuri Tikhonovd773efb2008-02-04 14:11:03 +010087#define POST_FAIL_SAVE 0x80
88
Michael Zaidmane3ac2b92010-03-01 11:47:36 +020089#define POST_BEFORE 1
90#define POST_AFTER 0
91#define POST_PASSED 1
92#define POST_FAILED 0
93
wdenk7133d4c2002-09-12 22:42:52 +000094#ifndef __ASSEMBLY__
95
96struct post_test {
97 char *name;
98 char *cmd;
99 char *desc;
100 int flags;
101 int (*test) (int flags);
wdenkc08f1582003-04-27 22:52:51 +0000102 int (*init_f) (void);
103 void (*reloc) (void);
wdenk9dfa8d12002-12-08 09:53:23 +0000104 unsigned long testid;
wdenk7133d4c2002-09-12 22:42:52 +0000105};
wdenkc08f1582003-04-27 22:52:51 +0000106int post_init_f (void);
wdenk7133d4c2002-09-12 22:42:52 +0000107void post_bootmode_init (void);
108int post_bootmode_get (unsigned int * last_test);
109void post_bootmode_clear (void);
wdenk7133d4c2002-09-12 22:42:52 +0000110int post_run (char *name, int flags);
111int post_info (char *name);
112int post_log (char *format, ...);
Wolfgang Denkd0813e52010-10-28 20:00:11 +0200113#ifdef CONFIG_NEEDS_MANUAL_RELOC
wdenk7133d4c2002-09-12 22:42:52 +0000114void post_reloc (void);
Peter Tyser9057cbf2009-09-21 11:20:36 -0500115#endif
wdenkc08f1582003-04-27 22:52:51 +0000116unsigned long post_time_ms (unsigned long base);
wdenk7133d4c2002-09-12 22:42:52 +0000117
Ovidiu Panaitdc8b6242020-11-28 10:43:10 +0200118/**
119 * post_output_backlog() - Print POST results
120 *
121 * Print POST results during the generic board init sequence, after
122 * relocation.
123 *
124 * Return: 0 if OK
125 */
126int post_output_backlog(void);
127
wdenk7133d4c2002-09-12 22:42:52 +0000128extern struct post_test post_list[];
129extern unsigned int post_list_size;
wdenk874ac262003-07-24 23:38:38 +0000130extern int post_hotkeys_pressed(void);
Heiko Schocher4f151d92011-07-26 20:31:08 +0000131extern int memory_post_test(int flags);
wdenk7133d4c2002-09-12 22:42:52 +0000132
Yuri Tikhonov7ed66f72008-12-20 14:54:21 +0300133/*
134 * If GCC is configured to use a version of GAS that supports
135 * the .gnu_attribute directive, it will use that directive to
136 * record certain properties of the output code.
137 * This feature is new to GCC 4.3.0.
138 * .gnu_attribute is new to GAS 2.18.
139 */
140#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
141/* Tag_GNU_Power_ABI_FP/soft-float */
142#define GNU_FPOST_ATTR asm(".gnu_attribute 4, 2");
143#else
144#define GNU_FPOST_ATTR
145#endif /* __GNUC__ */
wdenk7133d4c2002-09-12 22:42:52 +0000146#endif /* __ASSEMBLY__ */
147
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200148#define CONFIG_SYS_POST_RTC 0x00000001
149#define CONFIG_SYS_POST_WATCHDOG 0x00000002
150#define CONFIG_SYS_POST_MEMORY 0x00000004
151#define CONFIG_SYS_POST_CPU 0x00000008
152#define CONFIG_SYS_POST_I2C 0x00000010
153#define CONFIG_SYS_POST_CACHE 0x00000020
154#define CONFIG_SYS_POST_UART 0x00000040
155#define CONFIG_SYS_POST_ETHER 0x00000080
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200156#define CONFIG_SYS_POST_USB 0x00000200
157#define CONFIG_SYS_POST_SPR 0x00000400
158#define CONFIG_SYS_POST_SYSMON 0x00000800
159#define CONFIG_SYS_POST_DSP 0x00001000
160#define CONFIG_SYS_POST_OCM 0x00002000
161#define CONFIG_SYS_POST_FPU 0x00004000
162#define CONFIG_SYS_POST_ECC 0x00008000
163#define CONFIG_SYS_POST_BSPEC1 0x00010000
164#define CONFIG_SYS_POST_BSPEC2 0x00020000
165#define CONFIG_SYS_POST_BSPEC3 0x00040000
166#define CONFIG_SYS_POST_BSPEC4 0x00080000
167#define CONFIG_SYS_POST_BSPEC5 0x00100000
168#define CONFIG_SYS_POST_CODEC 0x00200000
Anatolij Gustschin810b2072010-04-24 19:27:11 +0200169#define CONFIG_SYS_POST_COPROC 0x00400000
Mike Frysinger813531f2011-05-10 13:35:40 +0000170#define CONFIG_SYS_POST_FLASH 0x00800000
Valentin Longchamp24db42a2011-09-12 04:18:40 +0000171#define CONFIG_SYS_POST_MEM_REGIONS 0x01000000
wdenk7133d4c2002-09-12 22:42:52 +0000172
wdenk7133d4c2002-09-12 22:42:52 +0000173#endif /* CONFIG_POST */
174
175#endif /* _POST_H */