public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: matthias.fuchs at esd-electronics.com <matthias.fuchs@esd-electronics.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/6] ppc4xx: Fix PMC440 BSP commands
Date: Wed,  8 Oct 2008 18:20:10 +0200	[thread overview]
Message-ID: <12234828132894-git-send-email-matthias.fuchs@esd-electronics.com> (raw)
In-Reply-To: <12234828131550-git-send-email-matthias.fuchs@esd-electronics.com>

From: Matthias Fuchs <matthias.fuchs@esd-electronics.com>

This patch fixes the PMC440 BSP commands painit and selfreset

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
---
 board/esd/pmc440/cmd_pmc440.c |   70 +++++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/board/esd/pmc440/cmd_pmc440.c b/board/esd/pmc440/cmd_pmc440.c
index 74cf4c3..78fbf8c 100644
--- a/board/esd/pmc440/cmd_pmc440.c
+++ b/board/esd/pmc440/cmd_pmc440.c
@@ -26,6 +26,9 @@
 #include <asm/io.h>
 #include <asm/cache.h>
 #include <asm/processor.h>
+#if defined(CONFIG_LOGBUFFER)
+#include <logbuff.h>
+#endif
 
 #include "pmc440.h"
 
@@ -343,14 +346,11 @@ extern env_t *env_ptr;
 
 int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	u32 memsize;
-	u32 pram, env_base;
+	u32 pram, nextbase, base;
 	char *v;
 	u32 param;
 	ulong *lptr;
 
-	memsize = gd->bd->bi_memsize;
-
 	v = getenv("pram");
 	if (v)
 		pram = simple_strtoul(v, NULL, 10);
@@ -359,21 +359,42 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	param = memsize - (pram << 10);
+ 	base = gd->bd->bi_memsize;
+#if defined(CONFIG_LOGBUFFER)
+ 	base -= LOGBUFF_LEN + LOGBUFF_OVERHEAD;
+#endif
+ 	/*
+ 	 * gd->bd->bi_memsize == physical ram size - CFG_MEM_TOP_HIDE
+ 	 */
+ 	param = base - (pram << 10);
 	printf("PARAM: @%08x\n", param);
+ 	debug("memsize=0x%08x, base=0x%08x\n", gd->bd->bi_memsize, base);
 
+ 	/* clear entire PA ram */
 	memset((void*)param, 0, (pram << 10));
-	env_base = memsize - 4096 - ((CONFIG_ENV_SIZE + 4096) & ~(4096-1));
-	memcpy((void*)env_base, env_ptr, CONFIG_ENV_SIZE);
 
-	lptr = (ulong*)memsize;
-	*(--lptr) = CONFIG_ENV_SIZE;
-	*(--lptr) = memsize - env_base;
-	*(--lptr) = crc32(0, (void*)(memsize - 0x08), 0x08);
-	*(--lptr) = 0;
+ 	/* reserve 4k for pointer field */
+         nextbase = base - 4096;
+ 	lptr = (ulong*)(base);
+
+ 	/*
+ 	 * *(--lptr) = item_size;
+ 	 * *(--lptr) = base - item_base = distance from field top;
+ 	 */
+
+ 	/* env is first (4k aligned) */
+ 	nextbase -= ((CONFIG_ENV_SIZE + 4096 - 1) & ~(4096 - 1));
+ 	memcpy((void*)nextbase, env_ptr, CONFIG_ENV_SIZE);
+ 	*(--lptr) = CONFIG_ENV_SIZE;     /* size */
+ 	*(--lptr) = base - nextbase;  /* offset | type=0 */
+
+ 	/* free section */
+ 	*(--lptr) = nextbase - param; /* size */
+ 	*(--lptr) = (base - param) | 126; /* offset | type=126 */
 
-	/* make sure data can be accessed through PCI */
-	flush_dcache_range(param, param + (pram << 10) - 1);
+ 	/* terminate pointer field */
+ 	*(--lptr) = crc32(0, (void*)(base - 0x10), 0x10);
+ 	*(--lptr) = 0;                /* offset=0 -> terminator */
 	return 0;
 }
 U_BOOT_CMD(
@@ -385,28 +406,11 @@ U_BOOT_CMD(
 
 int do_selfreset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	if (argc > 1) {
-		if (argv[1][0] == '0') {
-			/* assert */
-			printf("self-reset# asserted\n");
-			out_be32((void*)GPIO0_TCR,
-				 in_be32((void*)GPIO0_TCR) | GPIO0_SELF_RST);
-		} else {
-			/* deassert */
-			printf("self-reset# deasserted\n");
-			out_be32((void*)GPIO0_TCR,
-				 in_be32((void*)GPIO0_TCR) & ~GPIO0_SELF_RST);
-		}
-	} else {
-		printf("self-reset# is %s\n",
-		       in_be32((void*)GPIO0_TCR) & GPIO0_SELF_RST ?
-		       "active" : "inactive");
-	}
-
+	in_be32((void*)CFG_RESET_BASE);
 	return 0;
 }
 U_BOOT_CMD(
-	selfreset,	2,	1,	do_selfreset,
+	selfreset,	1,	1,	do_selfreset,
 	"selfreset- assert self-reset# signal\n",
 	NULL
 	);
-- 
1.5.3

  reply	other threads:[~2008-10-08 16:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08 16:20 [U-Boot] [PATCH 1/6] ppc4xx: Handle other board variant in PMC440 FPGA code matthias.fuchs at esd-electronics.com
2008-10-08 16:20 ` [U-Boot] [PATCH 2/6] ppc4xx: Clean up PMC440 header matthias.fuchs at esd-electronics.com
2008-10-08 16:20   ` [U-Boot] [PATCH 3/6] ppc4xx: Fix esd loadpci command matthias.fuchs at esd-electronics.com
2008-10-08 16:20     ` [U-Boot] [PATCH 4/6] ppc4xx: Update PMC440 board configuration matthias.fuchs at esd-electronics.com
2008-10-08 16:20       ` matthias.fuchs at esd-electronics.com [this message]
2008-10-08 16:20         ` [U-Boot] [PATCH 6/6] ppc4xx: Update PMC440 board support matthias.fuchs at esd-electronics.com
2008-10-10 15:30 ` [U-Boot] [PATCH 1/6] ppc4xx: Handle other board variant in PMC440 FPGA code Stefan Roese
2008-10-28 12:11   ` Matthias Fuchs
2008-10-31  9:40     ` Stefan Roese

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=12234828132894-git-send-email-matthias.fuchs@esd-electronics.com \
    --to=matthias.fuchs@esd-electronics.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox