Mike Frysinger | 32ed1fe | 2011-05-10 16:22:25 -0400 | [diff] [blame] | 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 | |
| 9 | #include <common.h> |
| 10 | #include <config.h> |
| 11 | #include <post.h> |
| 12 | |
| 13 | #include <asm/gpio.h> |
| 14 | |
| 15 | #if CONFIG_POST & CONFIG_SYS_POST_BSPEC1 |
| 16 | int led_post_test(int flags) |
| 17 | { |
| 18 | unsigned leds[] = { CONFIG_POST_BSPEC1_GPIO_LEDS }; |
| 19 | int i; |
| 20 | |
| 21 | /* First turn them all off */ |
| 22 | for (i = 0; i < ARRAY_SIZE(leds); ++i) { |
| 23 | if (gpio_request(leds[i], "post")) { |
| 24 | printf("could not request gpio %u\n", leds[i]); |
| 25 | continue; |
| 26 | } |
| 27 | gpio_direction_output(leds[i], 0); |
| 28 | } |
| 29 | |
| 30 | /* Now turn them on one by one */ |
| 31 | for (i = 0; i < ARRAY_SIZE(leds); ++i) { |
| 32 | printf("LED%i on", i + 1); |
| 33 | gpio_set_value(leds[i], 1); |
| 34 | udelay(1000000); |
| 35 | printf("\b\b\b\b\b\b\b"); |
| 36 | gpio_free(leds[i]); |
| 37 | } |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | #if CONFIG_POST & CONFIG_SYS_POST_BSPEC2 |
| 44 | int button_post_test(int flags) |
| 45 | { |
| 46 | unsigned buttons[] = { CONFIG_POST_BSPEC2_GPIO_BUTTONS }; |
| 47 | unsigned int sws[] = { CONFIG_POST_BSPEC2_GPIO_NAMES }; |
| 48 | int i, delay = 5; |
| 49 | unsigned short value = 0; |
| 50 | int result = 0; |
| 51 | |
| 52 | for (i = 0; i < ARRAY_SIZE(buttons); ++i) { |
| 53 | if (gpio_request(buttons[i], "post")) { |
| 54 | printf("could not request gpio %u\n", buttons[i]); |
| 55 | continue; |
| 56 | } |
| 57 | gpio_direction_input(buttons[i]); |
| 58 | |
| 59 | delay = 5; |
| 60 | printf("\n--------Press SW%i: %2d ", sws[i], delay); |
| 61 | while (delay--) { |
| 62 | int j; |
| 63 | for (j = 0; j < 100; j++) { |
| 64 | value = gpio_get_value(buttons[i]); |
| 65 | if (value != 0) |
| 66 | break; |
| 67 | udelay(10000); |
| 68 | } |
| 69 | printf("\b\b\b%2d ", delay); |
| 70 | } |
| 71 | if (value != 0) |
| 72 | puts("\b\bOK"); |
| 73 | else { |
| 74 | result = -1; |
| 75 | puts("\b\bfailed"); |
| 76 | } |
| 77 | |
| 78 | gpio_free(buttons[i]); |
| 79 | } |
| 80 | |
| 81 | puts("\n"); |
| 82 | |
| 83 | return result; |
| 84 | } |
| 85 | #endif |