Skip to contentSkip to conversation

m68k: add support for Freescale Coldfire mcf5307 cpu

PATCH New angelo at sysam.it 1 participant 1 message Aug 20, 2014 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 m68k: add support for Freescale Coldfire mcf5307 cpu

From: Angelo Dureghello <[email protected]>

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
Changes for v5:
- updated for Kconfig / defconfig

---
 arch/m68k/Kconfig                  |   4 +
 arch/m68k/cpu/mcf530x/Makefile     |   9 ++
 arch/m68k/cpu/mcf530x/config.mk    |  12 ++
 arch/m68k/cpu/mcf530x/cpu.c        |  36 ++++++
 arch/m68k/cpu/mcf530x/cpu_init.c   | 160 +++++++++++++++++++++++
 arch/m68k/cpu/mcf530x/interrupts.c |  29 +++++
 arch/m68k/cpu/mcf530x/speed.c      |  23 ++++
 arch/m68k/cpu/mcf530x/start.S      | 256 +++++++++++++++++++++++++++++++++++++
 arch/m68k/include/asm/cache.h      |   3 +-
 arch/m68k/include/asm/immap.h      |  23 ++++
 arch/m68k/include/asm/immap_5307.h | 118 +++++++++++++++++
 arch/m68k/include/asm/m5307.h      |  70 ++++++++++
 arch/m68k/include/asm/timer.h      |   3 +-
 13 files changed, 744 insertions(+), 2 deletions(-)
 create mode 100644 arch/m68k/cpu/mcf530x/Makefile
 create mode 100644 arch/m68k/cpu/mcf530x/config.mk
 create mode 100644 arch/m68k/cpu/mcf530x/cpu.c
 create mode 100644 arch/m68k/cpu/mcf530x/cpu_init.c
 create mode 100644 arch/m68k/cpu/mcf530x/interrupts.c
 create mode 100644 arch/m68k/cpu/mcf530x/speed.c
 create mode 100644 arch/m68k/cpu/mcf530x/start.S
 create mode 100644 arch/m68k/include/asm/immap_5307.h
 create mode 100644 arch/m68k/include/asm/m5307.h
arch/m68k/Kconfig +4 -0
index 6cda7db..b361c48 100644
@@ -71,6 +71,9 @@ config TARGET_M5475EVB
 config TARGET_M5485EVB
 	bool "Support M5485EVB"
 
+config TARGET_AMCORE
+	bool "Support AMCORE"
+
 endchoice
 
 source "board/BuS/eb_cpu5282/Kconfig"
@@ -94,5 +97,6 @@ source "board/freescale/m54451evb/Kconfig"
 source "board/freescale/m54455evb/Kconfig"
 source "board/freescale/m547xevb/Kconfig"
 source "board/freescale/m548xevb/Kconfig"
+source "board/sysam/amcore/Kconfig"
 
 endmenu
arch/m68k/cpu/mcf530x/Makefile new file +9 -0
new file mode 100644
index 0000000..9492bde
@@ -0,0 +1,9 @@
+#
+# (C) Copyright 2014  Angelo Dureghello <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+extra-y	= start.o
+obj-y	= interrupts.o cpu.o speed.o cpu_init.o
+
arch/m68k/cpu/mcf530x/config.mk new file +12 -0
new file mode 100644
index 0000000..aef72d7
@@ -0,0 +1,12 @@
+#
+# (C) Copyright 2014  Angelo Dureghello <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
+is5307:=$(shell grep CONFIG_M5307 $(cfg))
+
+ifneq (,$(findstring CONFIG_M5307,$(is5307)))
+PLATFORM_CPPFLAGS += -mcpu=5307
+endif
arch/m68k/cpu/mcf530x/cpu.c new file +36 -0
new file mode 100644
index 0000000..78f4385
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2014  Angelo Dureghello <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <asm/immap.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_M5307
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	sim_t *sim = (sim_t *)(MMAP_SIM);
+
+	/* enable watchdog/reset, set timeout to 0 and wait */
+	out_8(&sim->sypcr, SYPCR_SWE | SYPCR_SWRI);
+
+	/* wait for watchdog reset */
+	for (;;)
+		;
+
+	/* we don't return! */
+	return 0;
+}
+
+int checkcpu(void)
+{
+	char buf[32];
+
+	printf("CPU:   Freescale Coldfire MCF5307 at %s MHz\n",
+	       strmhz(buf, CONFIG_SYS_CPU_CLK));
+	return 0;
+}
+#endif
arch/m68k/cpu/mcf530x/cpu_init.c new file +160 -0

160 lines not on this page · raw message

arch/m68k/cpu/mcf530x/interrupts.c new file +29 -0
new file mode 100644
index 0000000..bf4038d
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright 2014  Angelo Dureghello <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <asm/immap.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_M5307
+int interrupt_init(void)
+{
+	enable_interrupts();
+
+	return 0;
+}
+
+void dtimer_intr_setup(void)
+{
+	intctrl_t *icr = (intctrl_t *)(MMAP_INTC);
+
+	/* clearing TIMER2 mask, so enabling the related interrupt */
+	out_be32(&icr->imr, in_be32(&icr->imr) & ~0x00000400);
+	/* set TIMER2 interrupt priority */
+	out_8(&icr->icr2, CONFIG_SYS_TMRINTR_PRI);
+}
+#endif
arch/m68k/cpu/mcf530x/speed.c new file +23 -0
new file mode 100644
index 0000000..3cf1986
@@ -0,0 +1,23 @@
+/*
+ * (C) Copyright 2014  Angelo Dureghello <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#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 +256 -0

256 lines not on this page · raw message

arch/m68k/include/asm/cache.h +2 -1
index 59fa33b..812f25c 100644
@@ -15,7 +15,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 f0a76f4..1c6bfce 100644
@@ -240,6 +240,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		(((volatile intctrl_t *)(CONFIG_SYS_INTR_BASE))->ipr)
+#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 +118 -0

118 lines not on this page · raw message

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

70 lines not on this page · raw message

arch/m68k/include/asm/timer.h +2 -1
index 2bdaddc..8fb3216 100644
@@ -17,7 +17,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 */
Signature · 1 line
2.1.0.rc1