All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 08/37] Blackfin: bf537-stamp: post: update old MMR style macros
Date: Sat,  2 Oct 2010 16:05:34 -0400	[thread overview]
Message-ID: <1286049958-4125-7-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1286049958-4125-1-git-send-email-vapier@gentoo.org>

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>
---
 board/bf537-stamp/post-memory.c |   54 +++++++-------
 board/bf537-stamp/post.c        |  152 ++++++++++++--------------------------
 2 files changed, 75 insertions(+), 131 deletions(-)

diff --git a/board/bf537-stamp/post-memory.c b/board/bf537-stamp/post-memory.c
index 4daea62..49022dc 100644
--- a/board/bf537-stamp/post-memory.c
+++ b/board/bf537-stamp/post-memory.c
@@ -97,19 +97,19 @@ void post_init_uart(int sclk)
 	for (divisor = 0; sclk > 0; divisor++)
 		sclk -= 57600 * 16;
 
-	*pPORTF_FER = 0x000F;
-	*pPORTH_FER = 0xFFFF;
+	bfin_write_PORTF_FER(0x000F);
+	bfin_write_PORTH_FER(0xFFFF);
 
-	*pUART_GCTL = 0x00;
-	*pUART_LCR = 0x83;
+	bfin_write_UART_GCTL(0x00);
+	bfin_write_UART_LCR(0x83);
 	SSYNC();
-	*pUART_DLL = (divisor & 0xFF);
+	bfin_write_UART_DLL(divisor & 0xFF);
 	SSYNC();
-	*pUART_DLH = ((divisor >> 8) & 0xFF);
+	bfin_write_UART_DLH((divisor >> 8) & 0xFF);
 	SSYNC();
-	*pUART_LCR = 0x03;
+	bfin_write_UART_LCR(0x03);
 	SSYNC();
-	*pUART_GCTL = 0x01;
+	bfin_write_UART_GCTL(0x01);
 	SSYNC();
 }
 
@@ -121,8 +121,8 @@ void post_out_buff(char *buff)
 		;
 	i = 0;
 	while ((buff[i] != '\0') && (i != 100)) {
-		while (!(*pUART_LSR & 0x20)) ;
-		*pUART_THR = buff[i];
+		while (!(bfin_read_pUART_LSR() & 0x20)) ;
+		bfin_write_UART_THR(buff[i]);
 		SSYNC();
 		i++;
 	}
@@ -138,15 +138,15 @@ int post_key_pressed(void)
 	int i, n;
 	unsigned short value;
 
-	*pPORTF_FER &= ~PF5;
-	*pPORTFIO_DIR &= ~PF5;
-	*pPORTFIO_INEN |= PF5;
+	bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~PF5);
+	bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() & ~PF5);
+	bfin_write_PORTFIO_INEN(bfin_read_PORTFIO_INEN() | PF5);
 	SSYNC();
 
 	post_out_buff("########Press SW10 to enter Memory POST########: 3\0");
 	for (i = 0; i < KEY_LOOP; i++) {
-		value = *pPORTFIO & PF5;
-		if (*pUART0_RBR == 0x0D) {
+		value = bfin_read_PORTFIO() & PF5;
+		if (bfin_read_UART0_RBR() == 0x0D) {
 			value = 0;
 			goto key_pressed;
 		}
@@ -158,8 +158,8 @@ int post_key_pressed(void)
 	post_out_buff("\b2\0");
 
 	for (i = 0; i < KEY_LOOP; i++) {
-		value = *pPORTFIO & PF5;
-		if (*pUART0_RBR == 0x0D) {
+		value = bfin_read_PORTFIO() & PF5;
+		if (bfin_read_UART0_RBR() == 0x0D) {
 			value = 0;
 			goto key_pressed;
 		}
@@ -171,8 +171,8 @@ int post_key_pressed(void)
 	post_out_buff("\b1\0");
 
 	for (i = 0; i < KEY_LOOP; i++) {
-		value = *pPORTFIO & PF5;
-		if (*pUART0_RBR == 0x0D) {
+		value = bfin_read_PORTFIO() & PF5;
+		if (bfin_read_UART0_RBR() == 0x0D) {
 			value = 0;
 			goto key_pressed;
 		}
@@ -193,13 +193,13 @@ int post_key_pressed(void)
 void post_init_pll(int mult, int div)
 {
 
-	*pSIC_IWR = 0x01;
-	*pPLL_CTL = (mult << 9);
-	*pPLL_DIV = div;
+	bfin_write_SIC_IWR(0x01);
+	bfin_write_PLL_CTL((mult << 9));
+	bfin_write_PLL_DIV(div);
 	asm("CLI R2;");
 	asm("IDLE;");
 	asm("STI R2;");
-	while (!(*pPLL_STAT & 0x20)) ;
+	while (!(bfin_read_PLL_STAT() & 0x20)) ;
 }
 
 int post_init_sdram(int sclk)
@@ -302,15 +302,15 @@ int post_init_sdram(int sclk)
 
 	SSYNC();
 
-	*pEBIU_SDGCTL |= 0x1000000;
+	bfin_write_EBIU_SDGCTL(bfin_write_EBIU_SDGCTL() | 0x1000000);
 	/* Set the SDRAM Refresh Rate control register based on SSCLK value */
-	*pEBIU_SDRRC = mem_SDRRC;
+	bfin_write_EBIU_SDRRC(mem_SDRRC);
 
 	/* SDRAM Memory Bank Control Register */
-	*pEBIU_SDBCTL = mem_SDBCTL;
+	bfin_write_EBIU_SDBCTL(mem_SDBCTL);
 
 	/* SDRAM Memory Global Control Register */
-	*pEBIU_SDGCTL = mem_SDGCTL;
+	bfin_write_EBIU_SDGCTL(mem_SDGCTL);
 	SSYNC();
 	return mem_SDRRC;
 }
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;
 }
-- 
1.7.3.1

  parent reply	other threads:[~2010-10-02 20:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-02 20:05 [U-Boot] [PATCH 00/37] Blackfin updates for v2010.12-rc1 Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 03/37] Blackfin: bfin_spi: add optional DMA support Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 04/37] Blackfin: bfin_sdh: clean up send_cmd Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 05/37] Blackfin: unify gpio cfi implementations Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 06/37] Blackfin: punt headers for non-existent BF541 Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 07/37] Blackfin: bfin_mac: convert from old style MMR macros Mike Frysinger
2010-10-02 20:05 ` Mike Frysinger [this message]
2010-10-02 20:05 ` [U-Boot] [PATCH 09/37] Blackfin: bf527-ezkit: video: " Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 10/37] Blackfin: bf548-ezkit: " Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 11/37] Blackfin: cm-bf548: " Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 12/37] Blackfin: bf527-ad7160-eval: " Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 14/37] Blackfin: bf537: unify arch header duplication Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 19/37] Blackfin: move CONFIG_BFIN_CPU to board config.mk Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 20/37] Blackfin: cmd_gpio: document/extend input sub-option Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 21/37] Blackfin: support a 3rd gpio cfi pin Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 22/37] Blackfin: adi config: add an "all spi flashes" option to unify board lists Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 23/37] Blackfin: adi config: add a hook for boards to append the env Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 24/37] Blackfin: bf527-sdp: new board port Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 25/37] Blackfin: cmd_gpio: return gpio value to caller Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 26/37] Blackfin: adi config: allow boards to tweak a little more Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 27/37] Blackfin: bct-brettl2: new board port Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 28/37] Blackfin: adi config: enable nand lock/unlock support Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 29/37] Blackfin: bf526-ezbrd: enable BootROM-OOB layout when booting from NAND Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 30/37] Blackfin: cmd_gpio: accept upper case pin names Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 31/37] Blackfin: propagate target cpu defines when building embedded env Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 32/37] Blackfin: blackvme: new board port Mike Frysinger
2010-10-03  1:52   ` Wojtek Skulski
2010-10-02 20:05 ` [U-Boot] [PATCH 33/37] Blackfin: fix MMC init output alignment Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 34/37] Blackfin: bf548-ezkit: bump SPI flash size up Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 35/37] Blackfin: bf527-ad7160-eval: fix GPIO CS define Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 36/37] Blackfin: bf537-pnav: increase monitor len Mike Frysinger
2010-10-02 20:05 ` [U-Boot] [PATCH 37/37] Blackfin: otp: fix build after constification of args[] Mike Frysinger
2010-10-04 17:33 ` [U-Boot] Pull request u-boot-blackfin.git Mike Frysinger
2010-10-05 12:43   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1286049958-4125-7-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.