2009-02-22 21:26:35 +00:00
|
|
|
/*
|
2011-05-10 20:22:25 +00:00
|
|
|
* Blackfin POST code
|
2009-02-22 21:26:35 +00:00
|
|
|
*
|
2011-05-10 20:22:25 +00:00
|
|
|
* Copyright (c) 2005-2011 Analog Devices Inc.
|
2009-02-22 21:26:35 +00:00
|
|
|
*
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <config.h>
|
2011-05-10 20:22:25 +00:00
|
|
|
#include <post.h>
|
|
|
|
|
2010-07-25 21:16:50 +00:00
|
|
|
#include <asm/gpio.h>
|
2009-02-22 21:26:35 +00:00
|
|
|
|
2011-05-10 20:22:25 +00:00
|
|
|
#if CONFIG_POST & CONFIG_SYS_POST_BSPEC1
|
2009-02-22 21:26:35 +00:00
|
|
|
int led_post_test(int flags)
|
|
|
|
{
|
2011-05-10 20:22:25 +00:00
|
|
|
unsigned leds[] = { CONFIG_POST_BSPEC1_GPIO_LEDS };
|
2010-07-25 21:16:50 +00:00
|
|
|
int i;
|
|
|
|
|
2011-05-10 20:22:25 +00:00
|
|
|
/* First turn them all off */
|
2010-07-25 21:16:50 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(leds); ++i) {
|
2011-05-10 20:22:25 +00:00
|
|
|
if (gpio_request(leds[i], "post")) {
|
|
|
|
printf("could not request gpio %u\n", leds[i]);
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-25 21:16:50 +00:00
|
|
|
gpio_direction_output(leds[i], 0);
|
2011-05-10 20:22:25 +00:00
|
|
|
}
|
2010-07-25 21:16:50 +00:00
|
|
|
|
2011-05-10 20:22:25 +00:00
|
|
|
/* Now turn them on one by one */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(leds); ++i) {
|
2010-07-25 21:16:50 +00:00
|
|
|
printf("LED%i on", i + 1);
|
|
|
|
gpio_set_value(leds[i], 1);
|
|
|
|
udelay(1000000);
|
|
|
|
printf("\b\b\b\b\b\b\b");
|
|
|
|
gpio_free(leds[i]);
|
|
|
|
}
|
|
|
|
|
2009-02-22 21:26:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-10 20:22:25 +00:00
|
|
|
#endif
|
2009-02-22 21:26:35 +00:00
|
|
|
|
2011-05-10 20:22:25 +00:00
|
|
|
#if CONFIG_POST & CONFIG_SYS_POST_BSPEC2
|
2009-02-22 21:26:35 +00:00
|
|
|
int button_post_test(int flags)
|
|
|
|
{
|
2011-05-10 20:22:25 +00:00
|
|
|
unsigned buttons[] = { CONFIG_POST_BSPEC2_GPIO_BUTTONS };
|
|
|
|
unsigned int sws[] = { CONFIG_POST_BSPEC2_GPIO_NAMES };
|
2009-02-22 21:26:35 +00:00
|
|
|
int i, delay = 5;
|
|
|
|
unsigned short value = 0;
|
|
|
|
int result = 0;
|
|
|
|
|
2010-07-25 21:16:50 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(buttons); ++i) {
|
2011-05-10 20:22:25 +00:00
|
|
|
if (gpio_request(buttons[i], "post")) {
|
|
|
|
printf("could not request gpio %u\n", buttons[i]);
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-25 21:16:50 +00:00
|
|
|
gpio_direction_input(buttons[i]);
|
2009-02-22 21:26:35 +00:00
|
|
|
|
2010-07-25 21:16:50 +00:00
|
|
|
delay = 5;
|
|
|
|
printf("\n--------Press SW%i: %2d ", sws[i], delay);
|
|
|
|
while (delay--) {
|
2011-05-10 20:22:25 +00:00
|
|
|
int j;
|
|
|
|
for (j = 0; j < 100; j++) {
|
2010-07-25 21:16:50 +00:00
|
|
|
value = gpio_get_value(buttons[i]);
|
|
|
|
if (value != 0)
|
|
|
|
break;
|
|
|
|
udelay(10000);
|
2009-02-22 21:26:35 +00:00
|
|
|
}
|
2010-07-25 21:16:50 +00:00
|
|
|
printf("\b\b\b%2d ", delay);
|
2009-02-22 21:26:35 +00:00
|
|
|
}
|
2010-07-25 21:16:50 +00:00
|
|
|
if (value != 0)
|
|
|
|
puts("\b\bOK");
|
|
|
|
else {
|
|
|
|
result = -1;
|
|
|
|
puts("\b\bfailed");
|
2009-02-22 21:26:35 +00:00
|
|
|
}
|
|
|
|
|
2010-07-25 21:16:50 +00:00
|
|
|
gpio_free(buttons[i]);
|
2009-02-22 21:26:35 +00:00
|
|
|
}
|
|
|
|
|
2010-07-25 21:16:50 +00:00
|
|
|
puts("\n");
|
|
|
|
|
2009-02-22 21:26:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
2011-05-10 20:22:25 +00:00
|
|
|
#endif
|