]> Zhao Yanbai Git Server - minix.git/commitdiff
kernel: implement reboot for am335x/dm37xx 00/700/2
authorThomas Cort <tcort@minix3.org>
Sat, 3 Aug 2013 12:40:59 +0000 (08:40 -0400)
committerThomas Cort <tcort@minix3.org>
Mon, 5 Aug 2013 14:23:00 +0000 (10:23 -0400)
Change-Id: Ied288326b9af8f31223b2dd76a064e32c9a03c45

kernel/arch/earm/Makefile.inc
kernel/arch/earm/arch_reset.c
kernel/arch/earm/arch_system.c
kernel/arch/earm/omap_reset.c [new file with mode: 0644]
kernel/arch/earm/omap_reset.h [new file with mode: 0644]

index 7d048fd85143579a327691e5d8096776d5514189..2ca8212cb5558fb48073de7fc54701dcae4824a1 100644 (file)
@@ -53,6 +53,7 @@ CPPFLAGS.findfp.c+= -I ${NETBSDSRCDIR}/lib/libc/include
 #
 .for unpaged_obj in head.o pre_init.o direct_tty_utils.o \
        pg_utils.o klib.o omap_serial.o omap_rtc.o utility.o arch_reset.o \
+       omap_reset.o \
        ${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}
 unpaged_${unpaged_obj}: ${unpaged_obj}
        ${OBJCOPY} --prefix-symbols=__k_unpaged_ ${.OBJDIR}/${unpaged_obj} $@
@@ -64,7 +65,7 @@ CLEANFILES+= ${ORIG_UNPAGED_OBJS}
 
 SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c \
        omap_serial.c omap_timer.c omap_padconf.c omap_intr.c omap_rtc.c \
-       exception.c klib.S memory.c \
+       omap_reset.c exception.c klib.S memory.c \
        protect.c direct_tty_utils.c arch_reset.c \
        pg_utils.c phys_copy.S phys_memset.S exc.S
 OBJS.kernel+=  ${UNPAGED_OBJS}
index fc0d3a623444d037dba6dec20607313a29ed0eaf..44d5dbe8fa5a6cc238f1c620ef71e10cd680350c 100644 (file)
@@ -34,7 +34,9 @@ halt_cpu(void)
 void
 reset(void)
 {
-    while (1);
+       omap3_reset();
+       direct_print("Reset not supported.");
+       while (1);
 }
 
 void
@@ -70,6 +72,10 @@ __dead void
 arch_shutdown(int how)
 {
        switch (how) {
+       case RBT_HALT:
+               /* Hang */
+               for (; ; ) halt_cpu();
+               NOT_REACHABLE;
 
        case RBT_POWEROFF:
                /* Power off if possible, hang otherwise */
@@ -77,7 +83,12 @@ arch_shutdown(int how)
                NOT_REACHABLE;
 
        default:
-               break;
+       case RBT_DEFAULT:
+       case RBT_REBOOT:
+       case RBT_RESET:
+               /* Reset the system */
+               reset();
+               NOT_REACHABLE;
        }
        while (1);
 }
index 0f0fc3a0bb8c1ba3a3ed67e2c168aa3319415d0b..5231b9d7b6b93150e576a8ab9ec49970417d35a2 100644 (file)
@@ -131,6 +131,9 @@ void arch_init(void)
 
        /* map memory for rtc */
        omap3_rtc_init();
+
+       /* map memory for reset control */
+       omap3_reset_init();
 }
 
 /*===========================================================================*
diff --git a/kernel/arch/earm/omap_reset.c b/kernel/arch/earm/omap_reset.c
new file mode 100644 (file)
index 0000000..9407b81
--- /dev/null
@@ -0,0 +1,60 @@
+#include <assert.h>
+#include <sys/types.h>
+#include <machine/cpu.h>
+#include <minix/type.h>
+#include <io.h>
+
+#include "kernel/kernel.h"
+#include "kernel/proc.h"
+#include "kernel/vm.h"
+#include "kernel/proto.h"
+#include "arch_proto.h"
+#include "omap_reset.h"
+
+#ifdef AM335X
+#define CM_BASE 0x44E00000
+#define CM_SIZE 0x1000
+#define PRM_DEVICE_OFFSET 0xf00
+#define PRM_RSTCTRL_REG 0x00
+#define RST_GLOBAL_WARM_SW_BIT 0 
+#elif DM37XX
+#define CM_BASE 0x48307000
+#define CM_SIZE 0x1000
+#define PRM_RSTCTRL_REG 0x250
+#define RST_DPLL3_BIT 2
+#else
+#define CM_BASE 0x00000000
+#define CM_SIZE 0x1000
+#endif
+
+struct omap_reset
+{
+       vir_bytes base;
+       vir_bytes size;
+};
+
+static struct omap_reset omap_reset = {
+       .base = CM_BASE,
+       .size = CM_SIZE
+};
+
+static kern_phys_map reset_phys_map;
+
+void
+omap3_reset_init(void)
+{
+#if defined(AM335X) || defined(DM37XX)
+       kern_phys_map_ptr(omap_reset.base, omap_reset.size, &reset_phys_map,
+           &omap_reset.base);
+#endif /* AM335X || DM37XX */
+}
+
+void
+omap3_reset(void)
+{
+#ifdef AM335X
+       mmio_set((omap_reset.base + PRM_DEVICE_OFFSET + PRM_RSTCTRL_REG), (1 << RST_GLOBAL_WARM_SW_BIT));
+#elif DM37XX
+       mmio_set((omap_reset.base + PRM_RSTCTRL_REG), (1 << RST_DPLL3_BIT));
+#endif
+}
diff --git a/kernel/arch/earm/omap_reset.h b/kernel/arch/earm/omap_reset.h
new file mode 100644 (file)
index 0000000..0f532fc
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __OMAP_RESET_H
+#define __OMAP_RESET_H
+
+void omap3_reset_init(void);
+void omap3_reset(void);
+
+#endif /* __OMAP_RESET_H */