Skip to contentSkip to conversation

sh: Add support SH3 and SH7720

PATCH New Yoshihiro Shimoda 2 participants 2 messages Dec 3, 2007 – Jan 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: Add support SH3 and SH7720

Add support Renesas SH3 and SH7720.

---
 cpu/sh3/Makefile            |   49 ++++++++
 cpu/sh3/cache.c             |  112 ++++++++++++++++++
 cpu/sh3/config.mk           |   31 +++++
 cpu/sh3/cpu.c               |   84 +++++++++++++
 cpu/sh3/interrupts.c        |   43 +++++++
 cpu/sh3/start.S             |   78 ++++++++++++
 cpu/sh3/time.c              |  103 ++++++++++++++++
 cpu/sh3/watchdog.c          |   34 +++++
 include/asm-sh/cpu_sh3.h    |   40 ++++++
 include/asm-sh/cpu_sh7720.h |  207 ++++++++++++++++++++++++++++++++++
 10 files changed, 781 insertions(+)
cpu/sh3/cache.c +112 -0
diff -uprN a/cpu/sh3/cache.c b/cpu/sh3/cache.c
@@ -0,0 +1,112 @@
+/*
+ * (C) Copyright 2007
+ * Yoshihiro Shimoda <[email protected]>
+ *
+ * (C) Copyright 2007
+ * Nobobuhiro Iwamatsu <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/processor.h>
+#include <asm/io.h>
+
+/*
+ * Jump to P2 area.
+ * When handling TLB or caches, we need to do it from P2 area.
+ */
+#define jump_to_P2()                    \
+  do {                                    \
+    unsigned long __dummy;		\
+    __asm__ __volatile__(			\
+		"mov.l  1f, %0\n\t"     \
+		"or     %1, %0\n\t"     \
+		"jmp    @%0\n\t"        \
+		" nop\n\t"              \
+		".balign 4\n"           \
+		"1:     .long 2f\n"     \
+		"2:"                    \
+		: "=&r" (__dummy)       \
+		: "r" (0x20000000));    \
+  } while (0)
+
+/*
+ * Back to P1 area.
+ */
+#define back_to_P1()                                    \
+  do {                                                    \
+    unsigned long __dummy;                          \
+    __asm__ __volatile__(                           \
+		"nop;nop;nop;nop;nop;nop;nop\n\t"       \
+		"mov.l  1f, %0\n\t"                     \
+		"jmp    @%0\n\t"                        \
+		" nop\n\t"                              \
+		".balign 4\n"                           \
+		"1:     .long 2f\n"                     \
+		"2:"                                    \
+		: "=&r" (__dummy));                     \
+  } while (0)
+
+#define CACHE_VALID       1
+#define CACHE_UPDATED     2
+
+static inline void cache_wback_all(void)
+{
+	unsigned long addr, data, i, j;
+
+	jump_to_P2();
+	for (i = 0; i < CACHE_OC_NUM_ENTRIES; i++) {
+		for (j = 0; j < CACHE_OC_NUM_WAYS; j++) {
+			addr = CACHE_OC_ADDRESS_ARRAY
+				| (j << CACHE_OC_WAY_SHIFT)
+				| (i << CACHE_OC_ENTRY_SHIFT);
+			data = inl(addr);
+			if (data & CACHE_UPDATED) {
+				data &= ~CACHE_UPDATED;
+				outl(data, addr);
+			}
+		}
+	}
+	back_to_P1();
+}
+
+
+#define CACHE_ENABLE      0
+#define CACHE_DISABLE     1
+
+int cache_control(unsigned int cmd)
+{
+	unsigned long ccr;
+
+	jump_to_P2();
+	ccr = inl(CCR);
+
+	if (ccr & CCR_CACHE_ENABLE)
+		cache_wback_all();
+
+	if (cmd == CACHE_DISABLE)
+		outl(CCR_CACHE_STOP, CCR);
+	else
+		outl(CCR_CACHE_INIT, CCR);
+	back_to_P1();
+
+	return 0;
+}
cpu/sh3/config.mk +31 -0
diff -uprN a/cpu/sh3/config.mk b/cpu/sh3/config.mk
@@ -0,0 +1,31 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2007
+# Nobuhiro Iwamatsu <[email protected]>
+#
+# (C) Copyright 2007
+# Yoshihiro Shimoda <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+PLATFORM_CPPFLAGS += -m3
+PLATFORM_RELFLAGS += -ffixed-r13
cpu/sh3/cpu.c +84 -0

84 lines not on this page · raw message

cpu/sh3/interrupts.c +43 -0

43 lines not on this page · raw message

cpu/sh3/Makefile +49 -0

49 lines not on this page · raw message

cpu/sh3/start.S +78 -0

78 lines not on this page · raw message

cpu/sh3/time.c +103 -0

103 lines not on this page · raw message

cpu/sh3/watchdog.c +34 -0
diff -uprN a/cpu/sh3/watchdog.c b/cpu/sh3/watchdog.c
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2007
+ * Yoshihiro Shimoda <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/processor.h>
+
+int watchdog_init(void)
+{
+	return 0;
+}
+
+void reset_cpu(unsigned long ignored)
+{
+	while (1)
+		;
+}
+
include/asm-sh/cpu_sh3.h +40 -0
diff -uprN a/include/asm-sh/cpu_sh3.h b/include/asm-sh/cpu_sh3.h
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2007 Nobuhiro Iwamatsu <[email protected]>
+ * (C) Copyright 2007 Yoshihiro Shimoda <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _ASM_CPU_SH3_H_
+#define _ASM_CPU_SH3_H_
+
+/* cache control */
+#define CCR_CACHE_STOP   0x00000008
+#define CCR_CACHE_ENABLE 0x00000005
+#define CCR_CACHE_ICI    0x00000008
+
+#define CACHE_OC_ADDRESS_ARRAY	0xf0000000
+#define CACHE_OC_WAY_SHIFT	13
+#define CACHE_OC_NUM_ENTRIES	256
+#define CACHE_OC_ENTRY_SHIFT	4
+
+#if defined(CONFIG_CPU_SH7720)
+#include <asm/cpu_sh7720.h>
+#else
+#error "Unknown SH3 variant"
+#endif
+
+#endif	/* _ASM_CPU_SH3_H_ */
include/asm-sh/cpu_sh7720.h +207 -0

207 lines not on this page · raw message

#1 lore raw

PATCH 1/1 sh: Add support SH3 and SH7720

Quoted 4 lines · On Mon, 03 Dec 2007 22:58:45 +0900 Yoshihiro Shimoda…

Add support Renesas SH3 and SH7720.

Quoted 12 lines
---
 cpu/sh3/Makefile            |   49 ++++++++
 cpu/sh3/cache.c             |  112 ++++++++++++++++++
 cpu/sh3/config.mk           |   31 +++++
 cpu/sh3/cpu.c               |   84 +++++++++++++
 cpu/sh3/interrupts.c        |   43 +++++++
 cpu/sh3/start.S             |   78 ++++++++++++
 cpu/sh3/time.c              |  103 ++++++++++++++++
 cpu/sh3/watchdog.c          |   34 +++++
 include/asm-sh/cpu_sh3.h    |   40 ++++++
 include/asm-sh/cpu_sh7720.h |  207 ++++++++++++++++++++++++++++++++++
 10 files changed, 781 insertions(+)

Applied, thanks.

Signature · 5 lines
Nobuhiro Iwamatsu
	hemamu at t-base.ne.jp
	iwamatsu at debian.or.jp

	GPG ID : 3170EBE9