]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/bf537-stamp/post.c
POST cleanup.
[people/ms/u-boot.git] / board / bf537-stamp / post.c
1 /*
2 * BF537-STAMP POST code
3 *
4 * Enter bugs at http://blackfin.uclinux.org/
5 *
6 * Copyright (c) 2005-2009 Analog Devices Inc.
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11 #include <common.h>
12 #include <config.h>
13 #include <command.h>
14 #include <asm/blackfin.h>
15
16 /* Using sw10-PF5 as the hotkey */
17 int post_hotkeys_pressed(void)
18 {
19 int delay = 3;
20 int i;
21 unsigned short value;
22
23 *pPORTF_FER &= ~PF5;
24 *pPORTFIO_DIR &= ~PF5;
25 *pPORTFIO_INEN |= PF5;
26
27 printf("########Press SW10 to enter Memory POST########: %2d ", delay);
28 while (delay--) {
29 for (i = 0; i < 100; i++) {
30 value = *pPORTFIO & PF5;
31 if (value != 0) {
32 break;
33 }
34 udelay(10000);
35 }
36 printf("\b\b\b%2d ", delay);
37 }
38 printf("\b\b\b 0");
39 printf("\n");
40 if (value == 0)
41 return 0;
42 else {
43 printf("Hotkey has been pressed, Enter POST . . . . . .\n");
44 return 1;
45 }
46 }
47
48 int uart_post_test(int flags)
49 {
50 return 0;
51 }
52
53 #define BLOCK_SIZE 0x10000
54 #define VERIFY_ADDR 0x2000000
55 extern int erase_block_flash(int);
56 extern int write_data(long lStart, long lCount, uchar * pnData);
57 int flash_post_test(int flags)
58 {
59 unsigned short *pbuf, *temp;
60 int offset, n, i;
61 int value = 0;
62 int result = 0;
63 printf("\n");
64 pbuf = (unsigned short *)VERIFY_ADDR;
65 temp = pbuf;
66 for (n = FLASH_START_POST_BLOCK; n < FLASH_END_POST_BLOCK; n++) {
67 offset = (n - 7) * BLOCK_SIZE;
68 printf("--------Erase block:%2d..", n);
69 erase_block_flash(n);
70 printf("OK\r");
71 printf("--------Program block:%2d...", n);
72 write_data(CONFIG_SYS_FLASH_BASE + offset, BLOCK_SIZE, pbuf);
73 printf("OK\r");
74 printf("--------Verify block:%2d...", n);
75 for (i = 0; i < BLOCK_SIZE; i += 2) {
76 if (*(unsigned short *)(CONFIG_SYS_FLASH_BASE + offset + i) !=
77 *temp++) {
78 value = 1;
79 result = 1;
80 }
81 }
82 if (value)
83 printf("failed\n");
84 else
85 printf("OK %3d%%\r",
86 (int)(
87 (n + 1 -
88 FLASH_START_POST_BLOCK) *
89 100 / (FLASH_END_POST_BLOCK -
90 FLASH_START_POST_BLOCK)));
91
92 temp = pbuf;
93 value = 0;
94 }
95 printf("\n");
96 if (result)
97 return -1;
98 else
99 return 0;
100 }
101
102 /****************************************************
103 * LED1 ---- PF6 LED2 ---- PF7 *
104 * LED3 ---- PF8 LED4 ---- PF9 *
105 * LED5 ---- PF10 LED6 ---- PF11 *
106 ****************************************************/
107 int led_post_test(int flags)
108 {
109 *pPORTF_FER &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
110 *pPORTFIO_DIR |= PF6 | PF7 | PF8 | PF9 | PF10 | PF11;
111 *pPORTFIO_INEN &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
112 *pPORTFIO &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
113 udelay(1000000);
114 printf("LED1 on");
115 *pPORTFIO |= PF6;
116 udelay(1000000);
117 printf("\b\b\b\b\b\b\b");
118 printf("LED2 on");
119 *pPORTFIO |= PF7;
120 udelay(1000000);
121 printf("\b\b\b\b\b\b\b");
122 printf("LED3 on");
123 *pPORTFIO |= PF8;
124 udelay(1000000);
125 printf("\b\b\b\b\b\b\b");
126 printf("LED4 on");
127 *pPORTFIO |= PF9;
128 udelay(1000000);
129 printf("\b\b\b\b\b\b\b");
130 printf("LED5 on");
131 *pPORTFIO |= PF10;
132 udelay(1000000);
133 printf("\b\b\b\b\b\b\b");
134 printf("lED6 on");
135 *pPORTFIO |= PF11;
136 printf("\b\b\b\b\b\b\b ");
137 return 0;
138 }
139
140 /************************************************
141 * SW10 ---- PF5 SW11 ---- PF4 *
142 * SW12 ---- PF3 SW13 ---- PF2 *
143 ************************************************/
144 int button_post_test(int flags)
145 {
146 int i, delay = 5;
147 unsigned short value = 0;
148 int result = 0;
149
150 *pPORTF_FER &= ~(PF5 | PF4 | PF3 | PF2);
151 *pPORTFIO_DIR &= ~(PF5 | PF4 | PF3 | PF2);
152 *pPORTFIO_INEN |= (PF5 | PF4 | PF3 | PF2);
153
154 printf("\n--------Press SW10: %2d ", delay);
155 while (delay--) {
156 for (i = 0; i < 100; i++) {
157 value = *pPORTFIO & PF5;
158 if (value != 0) {
159 break;
160 }
161 udelay(10000);
162 }
163 printf("\b\b\b%2d ", delay);
164 }
165 if (value != 0)
166 printf("\b\bOK");
167 else {
168 result = -1;
169 printf("\b\bfailed");
170 }
171
172 delay = 5;
173 printf("\n--------Press SW11: %2d ", delay);
174 while (delay--) {
175 for (i = 0; i < 100; i++) {
176 value = *pPORTFIO & PF4;
177 if (value != 0) {
178 break;
179 }
180 udelay(10000);
181 }
182 printf("\b\b\b%2d ", delay);
183 }
184 if (value != 0)
185 printf("\b\bOK");
186 else {
187 result = -1;
188 printf("\b\bfailed");
189 }
190
191 delay = 5;
192 printf("\n--------Press SW12: %2d ", delay);
193 while (delay--) {
194 for (i = 0; i < 100; i++) {
195 value = *pPORTFIO & PF3;
196 if (value != 0) {
197 break;
198 }
199 udelay(10000);
200 }
201 printf("\b\b\b%2d ", delay);
202 }
203 if (value != 0)
204 printf("\b\bOK");
205 else {
206 result = -1;
207 printf("\b\bfailed");
208 }
209
210 delay = 5;
211 printf("\n--------Press SW13: %2d ", delay);
212 while (delay--) {
213 for (i = 0; i < 100; i++) {
214 value = *pPORTFIO & PF2;
215 if (value != 0) {
216 break;
217 }
218 udelay(10000);
219 }
220 printf("\b\b\b%2d ", delay);
221 }
222 if (value != 0)
223 printf("\b\bOK");
224 else {
225 result = -1;
226 printf("\b\bfailed");
227 }
228 printf("\n");
229 return result;
230 }