Skip to contentSkip to conversation

m68k: add support for mcf5307 cpu

PATCH New Angelo Dureghello 1 participant 1 message Jan 22, 2013 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 m68k: add support for mcf5307 cpu

Add support for freescale coldfire mcf5307 cpu.

---
Changes for v2:
- Add MAINTAINERS entry
- Add boards.cfg entry
Changes for v3:
- Fix code format issues
Changes for v4:
- Removed MAINTAINERS file / entry
- Fixed macroes adding do {} while(0)
- Removed volatile
- Accessing cpu registers through structures/pointers

---
 arch/m68k/cpu/mcf530x/Makefile     |   48 +++++++
 arch/m68k/cpu/mcf530x/config.mk    |   30 ++++
 arch/m68k/cpu/mcf530x/cpu.c        |   53 +++++++
 arch/m68k/cpu/mcf530x/cpu.h        |   33 +++++
 arch/m68k/cpu/mcf530x/cpu_init.c   |  175 +++++++++++++++++++++++
 arch/m68k/cpu/mcf530x/interrupts.c |   44 ++++++
 arch/m68k/cpu/mcf530x/speed.c      |   38 +++++
 arch/m68k/cpu/mcf530x/start.S      |  271 ++++++++++++++++++++++++++++++++++++
 arch/m68k/include/asm/cache.h      |    3 +-
 arch/m68k/include/asm/immap.h      |   23 +++
 arch/m68k/include/asm/immap_5307.h |  135 ++++++++++++++++++
 arch/m68k/include/asm/m5307.h      |   87 ++++++++++++
 arch/m68k/include/asm/timer.h      |    3 +-
 arch/m68k/lib/time.c               |    1 +
 14 files changed, 942 insertions(+), 2 deletions(-)
arch/m68k/cpu/mcf530x/Makefile new file +48 -0
new file mode 100644
index 0000000..3c5a1c2
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2011 Angelo Dureghello <[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 $(TOPDIR)/config.mk
+
+# CFLAGS += -DET_DEBUG
+
+LIB	= $(obj)lib$(CPU).o
+
+START	= start.o
+COBJS	= interrupts.o cpu.o speed.o cpu_init.o
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/m68k/cpu/mcf530x/config.mk new file +30 -0
new file mode 100644
index 0000000..924cd7f
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2012 Angelo Dureghello <[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_RELFLAGS += -ffixed-d7 -msep-data
+
+cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
+is5307:=$(shell grep CONFIG_M5307 $(TOPDIR)/include/$(cfg))
+
+ifneq (,$(findstring CONFIG_M5307,$(is5307)))
+PLATFORM_CPPFLAGS += -mcpu=5307
+endif
arch/m68k/cpu/mcf530x/cpu.c new file +53 -0

53 lines not on this page · raw message

arch/m68k/cpu/mcf530x/cpu.h new file +33 -0
new file mode 100644
index 0000000..fd47f9a
@@ -0,0 +1,33 @@
+/*
+ *  cpu.h
+ *
+ *  Copyright (c) 2012 Angelo Dureghello <[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., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CPU_H_
+#define _CPU_H_
+
+#include <command.h>
+
+/* Use this to create board specific reset functions */
+void board_reset(void) __attribute__((__weak__));
+
+#endif /* _CPU_H_ */
arch/m68k/cpu/mcf530x/cpu_init.c new file +175 -0

175 lines not on this page · raw message

arch/m68k/cpu/mcf530x/interrupts.c new file +44 -0

44 lines not on this page · raw message

arch/m68k/cpu/mcf530x/speed.c new file +38 -0
new file mode 100644
index 0000000..94a8116
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 Angelo Dureghello <[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 <asm/processor.h>
+#include <asm/immap.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* get_clocks() fills in gd->cpu_clock and gd->bus_clk */
+int get_clocks(void)
+{
+#if defined(CONFIG_M5307)
+	gd->bus_clk = CONFIG_SYS_CLK;
+	gd->cpu_clk = CONFIG_SYS_CPU_CLK;
+#endif
+
+	return 0;
+}
arch/m68k/cpu/mcf530x/start.S new file +271 -0

271 lines not on this page · raw message

arch/m68k/include/asm/cache.h +2 -1
index f9e2d15..dd932c3 100644
@@ -31,7 +31,8 @@
 #define CONFIG_CF_V2
 #endif
 
-#if defined(CONFIG_MCF532x) || defined(CONFIG_MCF5301x)
+#if defined(CONFIG_MCF530x) || defined(CONFIG_MCF532x) || \
+    defined(CONFIG_MCF5301x)
 #define CONFIG_CF_V3
 #endif
 
arch/m68k/include/asm/immap.h +23 -0
index 2aab463..e9bd1e6 100644
@@ -256,6 +256,29 @@
 #endif
 #endif				/* CONFIG_M5282 */
 
+#ifdef CONFIG_M5307
+#include <asm/immap_5307.h>
+#include <asm/m5307.h>
+
+#define CONFIG_SYS_UART_BASE            (MMAP_UART0 + \
+					(CONFIG_SYS_UART_PORT * 0x40))
+#define CONFIG_SYS_INTR_BASE            (MMAP_INTC)
+#define CONFIG_SYS_NUM_IRQS             (64)
+
+/* Timer */
+#ifdef CONFIG_MCFTMR
+#define CONFIG_SYS_UDELAY_BASE          (MMAP_DTMR0)
+#define CONFIG_SYS_TMR_BASE             (MMAP_DTMR1)
+#define CONFIG_SYS_TMRPND_REG		(in_be32(MMAP_INTC))
+#define CONFIG_SYS_TMRINTR_NO           (31)
+#define CONFIG_SYS_TMRINTR_MASK		(0x00000400)
+#define CONFIG_SYS_TMRINTR_PEND		(CONFIG_SYS_TMRINTR_MASK)
+#define CONFIG_SYS_TMRINTR_PRI          (MCFSIM_ICR_AUTOVEC | \
+					MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3)
+#define CONFIG_SYS_TIMER_PRESCALER      (((gd->bus_clk / 1000000) - 1) << 8)
+#endif
+#endif                          /* CONFIG_M5307 */
+
 #if defined(CONFIG_MCF5301x)
 #include <asm/immap_5301x.h>
 #include <asm/m5301x.h>
arch/m68k/include/asm/immap_5307.h new file +134 -0

134 lines not on this page · raw message

arch/m68k/include/asm/m5307.h new file +86 -0

86 lines not on this page · raw message

arch/m68k/include/asm/timer.h +2 -1
index 1a5de05..528bce3 100644
@@ -33,7 +33,8 @@
 /****************************************************************************/
 /* DMA Timer module registers */
 typedef struct dtimer_ctrl {
-#if defined(CONFIG_M5249) || defined(CONFIG_M5253) || defined(CONFIG_M5272)
+#if defined(CONFIG_M5249) || defined(CONFIG_M5253) || \
+    defined(CONFIG_M5272) || defined(CONFIG_M5307)
 	u16 tmr;		/* 0x00 Mode register */
 	u16 res1;		/* 0x02 */
 	u16 trr;		/* 0x04 Reference register */
arch/m68k/lib/time.c +1 -0
index a0e2441..7476970 100644
@@ -27,6 +27,7 @@
 
 #include <asm/timer.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 #include <watchdog.h>
 
 DECLARE_GLOBAL_DATA_PTR;