summaryrefslogtreecommitdiff
path: root/board/bf537-stamp/post.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-07-25 17:16:50 -0400
committerMike Frysinger <vapier@gentoo.org>2010-10-02 16:00:37 -0400
commit0049053ff3475cc438eb27c5f147b9f9be2e20b2 (patch)
treed2d70fd461bfa2b6a81da5338a17bce713d92f9c /board/bf537-stamp/post.c
parent0c7148170b996b2c843c363cc33f8e00a5e9ab1d (diff)
downloadu-boot-imx-0049053ff3475cc438eb27c5f147b9f9be2e20b2.zip
u-boot-imx-0049053ff3475cc438eb27c5f147b9f9be2e20b2.tar.gz
u-boot-imx-0049053ff3475cc438eb27c5f147b9f9be2e20b2.tar.bz2
Blackfin: bf537-stamp: post: update old MMR style macros
The old MMR defines are being scrubbed, so convert the driver to use the new standard helper macros. For the GPIO MMR usage, convert to the new GPIO framework. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'board/bf537-stamp/post.c')
-rw-r--r--board/bf537-stamp/post.c152
1 files changed, 48 insertions, 104 deletions
diff --git a/board/bf537-stamp/post.c b/board/bf537-stamp/post.c
index c546ab6..60eed5f 100644
--- a/board/bf537-stamp/post.c
+++ b/board/bf537-stamp/post.c
@@ -12,6 +12,7 @@
#include <config.h>
#include <command.h>
#include <asm/blackfin.h>
+#include <asm/gpio.h>
/* Using sw10-PF5 as the hotkey */
int post_hotkeys_pressed(void)
@@ -20,14 +21,13 @@ int post_hotkeys_pressed(void)
int i;
unsigned short value;
- *pPORTF_FER &= ~PF5;
- *pPORTFIO_DIR &= ~PF5;
- *pPORTFIO_INEN |= PF5;
+ gpio_request(GPIO_PF5, "post");
+ gpio_direction_input(GPIO_PF5);
printf("########Press SW10 to enter Memory POST########: %2d ", delay);
while (delay--) {
for (i = 0; i < 100; i++) {
- value = *pPORTFIO & PF5;
+ value = gpio_get_value(GPIO_PF5);
if (value != 0) {
break;
}
@@ -43,6 +43,8 @@ int post_hotkeys_pressed(void)
printf("Hotkey has been pressed, Enter POST . . . . . .\n");
return 1;
}
+
+ gpio_free(GPIO_PF5);
}
int uart_post_test(int flags)
@@ -106,34 +108,24 @@ int flash_post_test(int flags)
****************************************************/
int led_post_test(int flags)
{
- *pPORTF_FER &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
- *pPORTFIO_DIR |= PF6 | PF7 | PF8 | PF9 | PF10 | PF11;
- *pPORTFIO_INEN &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
- *pPORTFIO &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
- udelay(1000000);
- printf("LED1 on");
- *pPORTFIO |= PF6;
- udelay(1000000);
- printf("\b\b\b\b\b\b\b");
- printf("LED2 on");
- *pPORTFIO |= PF7;
- udelay(1000000);
- printf("\b\b\b\b\b\b\b");
- printf("LED3 on");
- *pPORTFIO |= PF8;
- udelay(1000000);
- printf("\b\b\b\b\b\b\b");
- printf("LED4 on");
- *pPORTFIO |= PF9;
- udelay(1000000);
- printf("\b\b\b\b\b\b\b");
- printf("LED5 on");
- *pPORTFIO |= PF10;
- udelay(1000000);
- printf("\b\b\b\b\b\b\b");
- printf("lED6 on");
- *pPORTFIO |= PF11;
- printf("\b\b\b\b\b\b\b ");
+ unsigned int leds[] = {
+ GPIO_PF6, GPIO_PF7, GPIO_PF8,
+ GPIO_PF9, GPIO_PF10, GPIO_PF11,
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(leds); ++i) {
+ gpio_request(leds[i], "post");
+ gpio_direction_output(leds[i], 0);
+
+ 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]);
+ }
+
return 0;
}
@@ -143,88 +135,40 @@ int led_post_test(int flags)
************************************************/
int button_post_test(int flags)
{
+ unsigned int buttons[] = {
+ GPIO_PF2, GPIO_PF3, GPIO_PF4, GPIO_PF5,
+ };
+ unsigned int sws[] = { 13, 12, 11, 10, };
int i, delay = 5;
unsigned short value = 0;
int result = 0;
- *pPORTF_FER &= ~(PF5 | PF4 | PF3 | PF2);
- *pPORTFIO_DIR &= ~(PF5 | PF4 | PF3 | PF2);
- *pPORTFIO_INEN |= (PF5 | PF4 | PF3 | PF2);
+ for (i = 0; i < ARRAY_SIZE(buttons); ++i) {
+ gpio_request(buttons[i], "post");
+ gpio_direction_input(buttons[i]);
- printf("\n--------Press SW10: %2d ", delay);
- while (delay--) {
- for (i = 0; i < 100; i++) {
- value = *pPORTFIO & PF5;
- if (value != 0) {
- break;
+ delay = 5;
+ printf("\n--------Press SW%i: %2d ", sws[i], delay);
+ while (delay--) {
+ for (i = 0; i < 100; i++) {
+ value = gpio_get_value(buttons[i]);
+ if (value != 0)
+ break;
+ udelay(10000);
}
- udelay(10000);
+ printf("\b\b\b%2d ", delay);
}
- printf("\b\b\b%2d ", delay);
- }
- if (value != 0)
- printf("\b\bOK");
- else {
- result = -1;
- printf("\b\bfailed");
- }
-
- delay = 5;
- printf("\n--------Press SW11: %2d ", delay);
- while (delay--) {
- for (i = 0; i < 100; i++) {
- value = *pPORTFIO & PF4;
- if (value != 0) {
- break;
- }
- udelay(10000);
+ if (value != 0)
+ puts("\b\bOK");
+ else {
+ result = -1;
+ puts("\b\bfailed");
}
- printf("\b\b\b%2d ", delay);
- }
- if (value != 0)
- printf("\b\bOK");
- else {
- result = -1;
- printf("\b\bfailed");
- }
- delay = 5;
- printf("\n--------Press SW12: %2d ", delay);
- while (delay--) {
- for (i = 0; i < 100; i++) {
- value = *pPORTFIO & PF3;
- if (value != 0) {
- break;
- }
- udelay(10000);
- }
- printf("\b\b\b%2d ", delay);
- }
- if (value != 0)
- printf("\b\bOK");
- else {
- result = -1;
- printf("\b\bfailed");
+ gpio_free(buttons[i]);
}
- delay = 5;
- printf("\n--------Press SW13: %2d ", delay);
- while (delay--) {
- for (i = 0; i < 100; i++) {
- value = *pPORTFIO & PF2;
- if (value != 0) {
- break;
- }
- udelay(10000);
- }
- printf("\b\b\b%2d ", delay);
- }
- if (value != 0)
- printf("\b\bOK");
- else {
- result = -1;
- printf("\b\bfailed");
- }
- printf("\n");
+ puts("\n");
+
return result;
}