[U-Boot-Users] PATCH] Add 8641reset commmand for mpc8641hpcn board

Jon Loeliger jdl at freescale.com
Thu Mar 22 19:31:54 CET 2007


From: Haiying Wang <haiying.wang at freescale.com>
Date: Mon, 22 Jan 2007 12:37:30 -0600
Subject: [PATCH] Add 8641reset commmand for mpc8641hpcn board
Also add brief introduction in README.mpc8641hpcn

Signed-off-by: Haiying Wang <haiying.wang at freescale.com>
Signed-off-by: Jon Loeliger <jdl at freescale.com>
---

Wolfgang,

Lo, these many moons ago, there was a bad patch to the 8641
tree that modified the reset command in an unaccepted way.
Here is a rewrite of a new reset command that has the extended
functionality needed for the 8641 HPCN board.  It only messes
with board-specific files in this form.

Does this look better/acceptable to you this way?

Thanks,
jdl



 board/mpc8641hpcn/mpc8641hpcn.c |   44 +++++++++++++++++++++++---------------
 cpu/mpc86xx/cpu.c               |    8 +------
 doc/README.mpc8641hpcn          |   19 ++++++++++++++++
 3 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/board/mpc8641hpcn/mpc8641hpcn.c b/board/mpc8641hpcn/mpc8641hpcn.c
index 47457d7..1d67365 100644
--- a/board/mpc8641hpcn/mpc8641hpcn.c
+++ b/board/mpc8641hpcn/mpc8641hpcn.c
@@ -282,11 +282,14 @@ mpc8641_reset_board(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		/* not reached */
 	}
 
-	cmd = argv[1][1];
+	cmd = argv[1][0];
 	switch (cmd) {
-	case 'f':		/* reset with frequency changed */
-		if (argc < 5)
-			goto my_usage;
+	case 'c':		/* reset with frequency changed */
+		if (argc < 5) {
+			puts("\nUsage: 8641reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLLratio>\n");
+			break;
+		}
+
 		read_from_px_regs(0);
 
 		val = set_px_sysclk(simple_strtoul(argv[2], NULL, 10));
@@ -304,8 +307,8 @@ mpc8641_reset_board(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 
 		while (1) ;	/* Not reached */
 
-	case 'l':
-		if (argv[2][1] == 'f') {
+	case 'a':
+		if (argv[2][0] == 'c') {
 			read_from_px_regs(0);
 			read_from_px_regs_altbank(0);
 			/* reset with frequency changed */
@@ -327,7 +330,7 @@ mpc8641_reset_board(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 
 			while (1) ;	/* Not reached */
 
-		} else if (argv[2][1] == 'd') {
+		} else if (argv[2][0] == 'w') {
 			/*
 			 * Reset from alternate bank without changing
 			 * frequencies but with watchdog timer enabled.
@@ -348,27 +351,34 @@ mpc8641_reset_board(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 			 */
 			read_from_px_regs(0);
 			read_from_px_regs_altbank(0);
-			if (argc > 2)
-				goto my_usage;
+			if (argc > 2) {
+				puts(" \nUsage: 8641reset altbank\n");
+				break;
+			}
 			puts("Setting registers VCFGNE1, VBOOT, and VCTL\n");
 			set_altbank();
 			read_from_px_regs_altbank(1);
 			puts("Resetting board to boot from the other bank....\n");
 			set_px_go();
 		}
-
+	case 'h':	/* help */
 	default:
-		goto my_usage;
+my_usage:
+		puts("\nUsage: 8641reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n");
+		puts("       8641reset altbank [cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>]\n");
+		puts("       8641reset altbank [wd]\n");
+		puts("For example:   8641reset cf 40 2.5 10\n");
+		puts("See MPC8641HPCN Design Workbook for valid values of command line parameters.\n");
+		break;
 	}
 
-my_usage:
-	puts("\nUsage: reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n");
-	puts("       reset altbank [cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>]\n");
-	puts("       reset altbank [wd]\n");
-	puts("For example:   reset cf 40 2.5 10\n");
-	puts("See MPC8641HPCN Design Workbook for valid values of command line parameters.\n");
 }
 
+U_BOOT_CMD(
+	8641reset, CFG_MAXARGS, 1, mpc8641_reset_board,
+	"8641reset 	- Reset the CPU to current bank or alternative bank\n",
+	NULL
+);
 
 /*
  * get_board_sys_clk
diff --git a/cpu/mpc86xx/cpu.c b/cpu/mpc86xx/cpu.c
index 551b243..84f5bef 100644
--- a/cpu/mpc86xx/cpu.c
+++ b/cpu/mpc86xx/cpu.c
@@ -32,12 +32,6 @@
 #include <ft_build.h>
 #endif
 
-#ifdef CONFIG_MPC8641HPCN
-extern void mpc8641_reset_board(cmd_tbl_t *cmdtp, int flag,
-				int argc, char *argv[]);
-#endif
-
-
 int
 checkcpu(void)
 {
@@ -185,7 +179,7 @@ do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 #else /* CONFIG_MPC8641HPCN */
 
-	mpc8641_reset_board(cmdtp, flag, argc, argv);
+	out8(PIXIS_BASE + PIXIS_RST, 0);
 
 #endif /* !CONFIG_MPC8641HPCN */
 
diff --git a/doc/README.mpc8641hpcn b/doc/README.mpc8641hpcn
index 4a650ce..09a4b89 100644
--- a/doc/README.mpc8641hpcn
+++ b/doc/README.mpc8641hpcn
@@ -121,3 +121,22 @@ To Flash U-boot into the alternative bank (0xFF800000 - 0xFFBFFFFF):
 	0xe300_0000	0xe3ff_ffff	PCI2/PEX2 IO	16M
 	0xfe00_0000	0xfeff_ffff	Flash(alternate)16M
 	0xff00_0000	0xffff_ffff	Flash(boot bank)16M
+
+5. 8641reset command
+--------------------
+A new command "8641reset" is introduced for reset mpc8641hpcn board to
+current bank or alternative bank, with/without wathdog timer enabled,
+with/without frequency changed. There are some example usage:
+	/* reset to current bank, like "reset" command */
+	8641reset
+
+	/* reset board to alternative bank */
+	8641reset altbank
+
+	/* reset board to alternative bank with watchdog timer enabled*/
+	8641reset altbank wd
+
+	/* reset board to alternative bank with frequency changed.
+	 * 40 is SYSCLK, 2.5 is COREPLL ratio, 10 is MPXPLL ratio
+	 */
+	8641reset altbank cf 40 2.5 10
-- 
1.5.0.3







More information about the U-Boot mailing list