[U-Boot-Users] [PATCH 4/8] [SH] SuperH support

Nobuhiro Iwamatsu iwamatsu at nigauri.org
Sun May 6 22:14:33 CEST 2007


Hi, all.

I wrote the code in which u-boot was supported for SH [0]. 
I am maintaining SH-IPL+g[1] that is the boot loader only for SH now. 
However, I think that I will maintain u-boot in the future.

Now,
0. SDRAM controler
1. Internal serial device
2. Flash
3. Timer
working.

I plan to adopt it as a boot loader of the main in the future though 
only several boards are supported now. 

Please apply this patch .

regards,
 Nobuhiro

[0] : http://america.renesas.com/fmwk.jsp?cnt=superh_family_landing.jsp&fp=/products/mpumcu/superh_family
[1] : http://git.nigauri.org

-- 
Nobuhiro Iwamatsu
	E-Mail : iwamatsu at nigauri.org
	GPG ID : 3170EBE9 

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>

diff --git a/examples/stubs.c b/examples/stubs.c
index 26df6e0..263dd8c 100644
--- a/examples/stubs.c
+++ b/examples/stubs.c
@@ -151,6 +151,22 @@ gd_t *global_data;
 		:					\
 		: "i"(offsetof(gd_t, jt)), "i"(XF_ ##x)	\
 		: "r8");
+#elif defined(CONFIG_SH)
+/*
+ * r13 holds the pointer to the global_data. r1 is a call clobbered.
+ */
+#define EXPORT_FUNC(x)                  \
+        asm volatile (                  \
+		"       .align  2\n"                    \
+		"       .globl " #x "\n"                \
+		#x ":\n"                                \
+		"       mov     r13, r1\n"              \
+		"       add     %0, r1\n"               \
+		"       add     %1, r1\n"               \
+		"       jmp     @r1\n"                  \
+		"       nop\n"                          \
+		"       nop\n"                          \
+		: : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r1");
 #else
 #error stubs definition missing for this architecture
 #endif
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
new file mode 100644
index 0000000..44dca9f
--- /dev/null
+++ b/include/asm-sh/bitops.h
@@ -0,0 +1,13 @@
+#ifndef __ASM_SH_BITOPS_H_
+#define __ASM_SH_BITOPS_H_
+
+extern void set_bit(int nr, volatile void * a);
+extern void clear_bit(int nr, volatile void * a);
+extern int test_and_clear_bit(int nr, volatile void * a);
+extern void change_bit(unsigned long nr, volatile void *addr);
+extern int test_and_set_bit(int nr, volatile void * a);
+extern int test_and_change_bit(int nr, volatile void * addr);
+extern int test_bit(int nr, volatile void * a);
+extern int ffs(int i);
+
+#endif
diff --git a/include/asm-sh/byteorder.h b/include/asm-sh/byteorder.h
new file mode 100644
index 0000000..8836e65
--- /dev/null
+++ b/include/asm-sh/byteorder.h
@@ -0,0 +1,31 @@
+/*
+ * 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_SH_BYTEORDER_H_
+#define __ASM_SH_BYTEORDER_H_
+
+#include <config.h>
+#include <asm/types.h>
+
+#ifdef __LITTLE_ENDIAN__
+#include <linux/byteorder/little_endian.h>
+#else
+#include <linux/byteorder/big_endian.h>
+#endif
+
+#endif
+
diff --git a/include/asm-sh/cpu_sh4.h b/include/asm-sh/cpu_sh4.h
new file mode 100644
index 0000000..e0275f3
--- /dev/null
+++ b/include/asm-sh/cpu_sh4.h
@@ -0,0 +1,10 @@
+#ifndef _ASM_CPU_SH4_H_
+#define _ASM_CPU_SH4_H_
+#if defined (CONFIG_CPU_SH7750)
+#include <asm/cpu_sh7750.h>
+#elif defined (CONFIG_CPU_SH7780)
+#include <asm/cpu_sh7780.h>
+#else
+#error "Unknown SH4 variant"
+#endif
+#endif
diff --git a/include/asm-sh/cpu_sh7750.h b/include/asm-sh/cpu_sh7750.h
new file mode 100644
index 0000000..eb4f1af
--- /dev/null
+++ b/include/asm-sh/cpu_sh7750.h
@@ -0,0 +1,145 @@
+#ifndef _ASM_CPU_SH7750_H_
+#define _ASM_CPU_SH7750_H_
+
+#define PTEH 	0xFF000000 
+#define PTEL 	0xFF000004 
+#define TTB 	0xFF000008 
+#define TEA 	0xFF00000C 
+#define MMUCR 	0xFF000010 
+#define BASRA 	0xFF000014 
+#define BASRB	0xFF000018 
+#define CCR	0xFF00001C
+#define TRA 	0xFF000020
+#define EXPEVT 	0xFF000024
+#define INTEVT 	0xFF000028
+#define PTEA 	0xFF000034
+#define QACR0 	0xFF000038
+#define QACR1 	0xFF00003C
+#define BARA 	0xFF200000
+#define BAMRA 	0xFF200004
+#define BBRA 	0xFF200008
+#define BARB 	0xFF20000C
+#define BAMRB 	0xFF200010
+#define BBRB 	0xFF200014
+#define BDRB 	0xFF200018
+#define BDMRB 	0xFF20001C
+#define BRCR 	0xFF200020
+
+#define BCR1	0xFF800000
+#define BCR2	0xFF800004 
+#define BCR3 	0xFF800050 
+#define BCR4	0xFE0A00F0 
+#define WCR1 	0xFF800008 
+#define WCR2 	0xFF80000C 
+#define WCR3 	0xFF800010 
+#define MCR 	0xFF800014 
+#define PCR 	0xFF800018 
+#define RTCSR 	0xFF80001C 
+#define RTCNT 	0xFF800020 
+#define RTCOR 	0xFF800024 
+#define RFCR 	0xFF800028 
+#define PCTRA 	0xFF80002C 
+#define PDTRA 	0xFF800030 
+#define PCTRB 	0xFF800040 
+#define PDTRB 	0xFF800044 
+#define GPIOIC 	0xFF800048 
+#define SAR0 	0xFFA00000 
+#define DAR0 	0xFFA00004 
+#define DMATCR0 0xFFA00008 
+#define CHCR0	0xFFA0000C 
+#define SAR1 	0xFFA00010 
+#define DAR1 	0xFFA00014 
+#define DMATCR1 0xFFA00018 
+#define CHCR1 	0xFFA0001C 
+#define SAR2 	0xFFA00020 
+#define DAR2 	0xFFA00024 
+#define DMATCR2 0xFFA00028 
+#define CHCR2 	0xFFA0002C 
+#define SAR3 	0xFFA00030 
+#define DAR3 	0xFFA00034 
+#define DMATCR3 0xFFA00038 
+#define CHCR3 	0xFFA0003C 
+#define DMAOR 	0xFFA00040 
+#define SAR4	0xFFA00050 
+#define DAR4 	0xFFA00054 
+#define DMATCR4 0xFFA00058 
+
+#define FRQCR 	0xFFC00000 
+#define STBCR 	0xFFC00004 
+#define WTCNT 	0xFFC00008 
+#define WTCSR 	0xFFC0000C 
+#define STBCR2 	0xFFC00010 
+#define R64CNT	0xFFC80000 
+#define RSECCNT 0xFFC80004 
+#define RMINCNT 0xFFC80008 
+#define RHRCNT 	0xFFC8000C 
+#define RWKCNT 	0xFFC80010 
+#define RDAYCNT 0xFFC80014 
+#define RMONCNT 0xFFC80018 
+#define RYRCNT 	0xFFC8001C 
+#define RSECAR 	0xFFC80020 
+#define RMINAR 	0xFFC80024 
+#define RHRAR 	0xFFC80028 
+#define RWKAR 	0xFFC8002C 
+#define RDAYAR 	0xFFC80030 
+#define RMONAR 	0xFFC80034 
+#define RCR1 	0xFFC80038 
+#define RCR2 	0xFFC8003C 
+#define RCR3 	0xFFC80050 
+#define RYRAR 	0xFFC80054 
+#define ICR 	0xFFD00000 
+#define IPRA 	0xFFD00004 
+#define IPRB 	0xFFD00008 
+#define IPRC	0xFFD0000C 
+#define IPRD 	0xFFD00010 
+#define INTPRI 	0xFE080000 
+#define INTREQ	0xFE080020 
+#define INTMSK	0xFE080040 
+#define INTMSKCL	0xFE080060 
+#define CLKSTP		0xFE0A0000
+#define CLKSTPCLR	0xFE0A0008
+#define TSTR2 	0xFE100004 
+#define TCOR3 	0xFE100008 
+#define TCNT3 	0xFE10000C 
+#define TCR3 	0xFE100010 
+#define TCOR4 	0xFE100014 
+#define TCNT4 	0xFE100018 
+#define TCR4 	0xFE10001C 
+#define TOCR 	0xFFD80000 
+#define TSTR0 	0xFFD80004 
+#define TCOR0	0xFFD80008 
+#define TCNT0 	0xFFD8000C 
+#define TCR0 	0xFFD80010 
+#define TCOR1 	0xFFD80014 
+#define TCNT1 	0xFFD80018 
+#define TCR1 	0xFFD8001C 
+#define TCOR2 	0xFFD80020 
+#define TCNT2 	0xFFD80024 
+#define TCR2 	0xFFD80028 
+#define TCPR2 	0xFFD8002C
+#define SCSMR1 	0xFFE00000 
+#define SCBRR1 	0xFFE00004 
+#define SCSCR1 	0xFFE00008 
+#define SCTDR1 	0xFFE0000C 
+#define SCSSR1 	0xFFE00010 
+#define SCRDR1 	0xFFE00014 
+#define SCSCMR1 0xFFE00018 
+#define SCSPTR1 0xFFE0001C 
+#define SCF0_BASE	SCSMR1
+#define SCSMR2 	0xFFE80000
+#define SCBRR2 	0xFFE80004 
+#define SCSCR2 	0xFFE80008 
+#define SCFTDR2 0xFFE8000C 
+#define SCFSR2 	0xFFE80010 
+#define SCFRDR2	0xFFE80014 
+#define SCFCR2 	0xFFE80018 
+#define SCFDR2 	0xFFE8001C 
+#define SCSPTR2	0xFFE80020 
+#define SCLSR2 	0xFFE80024 
+#define SCIF1_BASE	SCSMR2
+#define SDIR 	0xFFF00000 
+#define SDDR 	0xFFF00008 
+#define SDINT 	0xFFF00014 
+
+#endif	/* _ASM_CPU_SH7750_H_ */
+
diff --git a/include/asm-sh/global_data.h b/include/asm-sh/global_data.h
new file mode 100644
index 0000000..0a44a34
--- /dev/null
+++ b/include/asm-sh/global_data.h
@@ -0,0 +1,50 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * (C) Copyright 2007
+ * Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
+ *
+ * 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
+ */
+
+#ifndef	__ASM_SH_GLOBALDATA_H_
+#define __ASM_SH_GLOBALDATA_H_
+
+typedef	struct global_data
+{
+	bd_t		*bd;
+	unsigned long	flags;
+	unsigned long	baudrate;
+	unsigned long	cpu_clk;	/* CPU clock in Hz! */
+	unsigned long	have_console;	/* serial_init() was called */
+	unsigned long	ram_size;	/* RAM size */
+	unsigned long	reloc_off;	/* Relocation Offset */
+	unsigned long	env_addr;	/* Address  of Environment struct */
+	unsigned long	env_valid;	/* Checksum of Environment valid */
+	void		**jt;		/* Standalone app jump table */
+}gd_t;
+
+#define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/
+#define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/
+#define	GD_FLG_SILENT	0x00004		/* Silent mode				*/
+
+#define DECLARE_GLOBAL_DATA_PTR	register gd_t *gd asm ("r13")
+
+#endif /* __ASM_SH_GLOBALDATA_H_ */




More information about the U-Boot mailing list