post.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Blackfin POST code
  3. *
  4. * Copyright (c) 2005-2011 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <post.h>
  11. #include <asm/gpio.h>
  12. #if CONFIG_POST & CONFIG_SYS_POST_BSPEC1
  13. int led_post_test(int flags)
  14. {
  15. unsigned leds[] = { CONFIG_POST_BSPEC1_GPIO_LEDS };
  16. int i;
  17. /* First turn them all off */
  18. for (i = 0; i < ARRAY_SIZE(leds); ++i) {
  19. if (gpio_request(leds[i], "post")) {
  20. printf("could not request gpio %u\n", leds[i]);
  21. continue;
  22. }
  23. gpio_direction_output(leds[i], 0);
  24. }
  25. /* Now turn them on one by one */
  26. for (i = 0; i < ARRAY_SIZE(leds); ++i) {
  27. printf("LED%i on", i + 1);
  28. gpio_set_value(leds[i], 1);
  29. udelay(1000000);
  30. printf("\b\b\b\b\b\b\b");
  31. gpio_free(leds[i]);
  32. }
  33. return 0;
  34. }
  35. #endif
  36. #if CONFIG_POST & CONFIG_SYS_POST_BSPEC2
  37. int button_post_test(int flags)
  38. {
  39. unsigned buttons[] = { CONFIG_POST_BSPEC2_GPIO_BUTTONS };
  40. unsigned int sws[] = { CONFIG_POST_BSPEC2_GPIO_NAMES };
  41. int i, delay = 5;
  42. unsigned short value = 0;
  43. int result = 0;
  44. for (i = 0; i < ARRAY_SIZE(buttons); ++i) {
  45. if (gpio_request(buttons[i], "post")) {
  46. printf("could not request gpio %u\n", buttons[i]);
  47. continue;
  48. }
  49. gpio_direction_input(buttons[i]);
  50. delay = 5;
  51. printf("\n--------Press SW%i: %2d ", sws[i], delay);
  52. while (delay--) {
  53. int j;
  54. for (j = 0; j < 100; j++) {
  55. value = gpio_get_value(buttons[i]);
  56. if (value != 0)
  57. break;
  58. udelay(10000);
  59. }
  60. printf("\b\b\b%2d ", delay);
  61. }
  62. if (value != 0)
  63. puts("\b\bOK");
  64. else {
  65. result = -1;
  66. puts("\b\bfailed");
  67. }
  68. gpio_free(buttons[i]);
  69. }
  70. puts("\n");
  71. return result;
  72. }
  73. #endif