All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [MIPS] Introduce machine_restart
Date: Wed, 19 Mar 2008 02:55:33 +0900	[thread overview]
Message-ID: <47E00215.5050007@ruby.dti.ne.jp> (raw)

Handles machine specific functions by using function pointers.

Signed-off-by: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
---

 board/incaip/incaip.c     |    8 ++++++++
 board/purple/purple.c     |   10 ++++++++++
 board/tb0229/tb0229.c     |   11 ++++++++++-
 cpu/mips/cpu.c            |   17 ++++++++++-------
 include/asm-mips/reboot.h |   15 +++++++++++++++
 5 files changed, 53 insertions(+), 8 deletions(-)
 create mode 100644 include/asm-mips/reboot.h


diff --git a/board/incaip/incaip.c b/board/incaip/incaip.c
index dbf0ecc..c2324bc 100644
--- a/board/incaip/incaip.c
+++ b/board/incaip/incaip.c
@@ -26,9 +26,15 @@
 #include <asm/addrspace.h>
 #include <asm/inca-ip.h>
 #include <asm/io.h>
+#include <asm/reboot.h>
 
 extern uint incaip_get_cpuclk(void);
 
+static void incaip_machine_restart(char *command)
+{
+	*INCA_IP_WDT_RST_REQ = 0x3f;
+}
+
 static ulong max_sdram_size(void)
 {
 	/* The only supported SDRAM data width is 16bit.
@@ -108,5 +114,7 @@ int checkboard (void)
 
 	set_io_port_base(0);
 
+	_machine_restart = incaip_machine_restart;
+
 	return 0;
 }
diff --git a/board/purple/purple.c b/board/purple/purple.c
index 74718af..2fa2e19 100644
--- a/board/purple/purple.c
+++ b/board/purple/purple.c
@@ -29,6 +29,7 @@
 #include <asm/io.h>
 #include <asm/addrspace.h>
 #include <asm/cacheops.h>
+#include <asm/reboot.h>
 
 #include "sconsole.h"
 
@@ -52,6 +53,13 @@ extern int	asc_serial_getc 	(void);
 extern int	asc_serial_tstc 	(void);
 extern void	asc_serial_setbrg 	(void);
 
+static void purple_machine_restart(char *command)
+{
+	void (*f)(void) = (void *) 0xbfc00000;
+
+	f();
+}
+
 static void sdram_timing_init (ulong size)
 {
 	register uint pass;
@@ -148,6 +156,8 @@ int checkboard (void)
 
 	set_io_port_base(0);
 
+	_machine_restart = purple_machine_restart;
+
 	return 0;
 }
 
diff --git a/board/tb0229/tb0229.c b/board/tb0229/tb0229.c
index 61c2e9b..c775069 100644
--- a/board/tb0229/tb0229.c
+++ b/board/tb0229/tb0229.c
@@ -12,9 +12,16 @@
 #include <common.h>
 #include <command.h>
 #include <asm/addrspace.h>
-#include <asm/inca-ip.h>
 #include <asm/io.h>
 #include <pci.h>
+#include <asm/reboot.h>
+
+static void tb0229_machine_restart(char *command)
+{
+	void (*f)(void) = (void *) 0xbfc00000;
+
+	f();
+}
 
 #if defined(CONFIG_PCI)
 static struct pci_controller hose;
@@ -37,5 +44,7 @@ int checkboard (void)
 
 	set_io_port_base(0);
 
+	_machine_restart = tb0229_machine_restart;
+
 	return 0;
 }
diff --git a/cpu/mips/cpu.c b/cpu/mips/cpu.c
index 71e5028..4c50829 100644
--- a/cpu/mips/cpu.c
+++ b/cpu/mips/cpu.c
@@ -23,9 +23,9 @@
 
 #include <common.h>
 #include <command.h>
-#include <asm/inca-ip.h>
 #include <asm/mipsregs.h>
 #include <asm/cacheops.h>
+#include <asm/reboot.h>
 
 #define cache_op(op,addr)						\
 	__asm__ __volatile__(						\
@@ -37,15 +37,18 @@
 	:								\
 	: "i" (op), "R" (*(unsigned char *)(addr)))
 
+/*
+ * Urgs ...  Too many MIPS machines to handle this in a generic way.
+ * So handle all using function pointers to machine specific
+ * functions.
+ */
+void (*_machine_restart)(char *command);
+
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-#if defined(CONFIG_INCA_IP)
-	*INCA_IP_WDT_RST_REQ = 0x3f;
-#elif defined(CONFIG_PURPLE) || defined(CONFIG_TB0229)
-	void (*f)(void) = (void *) 0xbfc00000;
+	if (_machine_restart)
+		_machine_restart(NULL);
 
-	f();
-#endif
 	fprintf(stderr, "*** reset failed ***\n");
 	return 0;
 }
diff --git a/include/asm-mips/reboot.h b/include/asm-mips/reboot.h
new file mode 100644
index 0000000..e48c0bf
--- /dev/null
+++ b/include/asm-mips/reboot.h
@@ -0,0 +1,15 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1997, 1999, 2001, 06 by Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
+ */
+#ifndef _ASM_REBOOT_H
+#define _ASM_REBOOT_H
+
+extern void (*_machine_restart)(char *command);
+extern void (*_machine_halt)(void);
+
+#endif /* _ASM_REBOOT_H */

             reply	other threads:[~2008-03-18 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-18 17:55 Shinya Kuribayashi [this message]
2008-03-18 18:43 ` [U-Boot-Users] [MIPS] Introduce machine_restart Jean-Christophe PLAGNIOL-VILLARD
2008-03-18 19:24   ` Wolfgang Denk
2008-03-18 19:37     ` Shinya Kuribayashi
2008-03-25  5:26       ` Shinya Kuribayashi
2008-03-18 22:23     ` Joakim Tjernlund
2008-03-19 10:47     ` Vlad Lungu
2008-03-18 18:45 ` Joakim Tjernlund

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=47E00215.5050007@ruby.dti.ne.jp \
    --to=skuribay@ruby.dti.ne.jp \
    --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.