]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
ARM: OMAP2+: PRCM: create SoC-specific chip restart functions
authorPaul Walmsley <paul@pwsan.com>
Tue, 30 Oct 2012 02:56:07 +0000 (20:56 -0600)
committerPaul Walmsley <paul@pwsan.com>
Thu, 8 Nov 2012 19:33:08 +0000 (12:33 -0700)
Split omap_prcm_restart() from mach-omap2/prcm.c into SoC-specific
variants.  These functions need to be able to save the reboot reason
into the scratchpad RAM.  This implies a dependency on both the PRM
and SCM IP blocks, so they've been moved into their own file.  This
will eventually call functions in the PRM and SCM drivers, once those
are created.

Vaibhav Hiremath <hvaibhav@ti.com> identified an unused prototype in
the first version of this patch - now removed.  Tony Lindgren
<tony@atomide.com> noted a compile problem with some RMK Kconfigs;
resolved in this patch.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Tested-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/common.h
arch/arm/mach-omap2/omap2-restart.c [new file with mode: 0644]
arch/arm/mach-omap2/omap3-restart.c [new file with mode: 0644]
arch/arm/mach-omap2/omap4-common.c

index ae87a3ea53aefd4d2ff014cca295dfe2301aaf91..1988810c9de7040fbd10888a0d8637f4a3de2f39 100644 (file)
@@ -50,6 +50,11 @@ AFLAGS_sram242x.o                    :=-Wa,-march=armv6
 AFLAGS_sram243x.o                      :=-Wa,-march=armv6
 AFLAGS_sram34xx.o                      :=-Wa,-march=armv7-a
 
+# Restart code (OMAP4/5 currently in omap4-common.c)
+obj-$(CONFIG_SOC_OMAP2420)             += omap2-restart.o
+obj-$(CONFIG_SOC_OMAP2430)             += omap2-restart.o
+obj-$(CONFIG_ARCH_OMAP3)               += omap3-restart.o
+
 # Pin multiplexing
 obj-$(CONFIG_SOC_OMAP2420)             += mux2420.o
 obj-$(CONFIG_SOC_OMAP2430)             += mux2430.o
index ed21815edd4b433ba0bbb8436fd8b412f376e453..349d0153791b426750644a02d6029be8675908f5 100644 (file)
@@ -113,6 +113,30 @@ void omap4430_init_late(void);
 int omap2_common_pm_late_init(void);
 void omap_prcm_restart(char, const char *);
 
+#if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430)
+void omap2xxx_restart(char mode, const char *cmd);
+#else
+static inline void omap2xxx_restart(char mode, const char *cmd)
+{
+}
+#endif
+
+#ifdef CONFIG_ARCH_OMAP3
+void omap3xxx_restart(char mode, const char *cmd);
+#else
+static inline void omap3xxx_restart(char mode, const char *cmd)
+{
+}
+#endif
+
+#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
+void omap44xx_restart(char mode, const char *cmd);
+#else
+static inline void omap44xx_restart(char mode, const char *cmd)
+{
+}
+#endif
+
 /* This gets called from mach-omap2/io.c, do not call this */
 void __init omap2_set_globals_tap(u32 class, void __iomem *tap);
 
diff --git a/arch/arm/mach-omap2/omap2-restart.c b/arch/arm/mach-omap2/omap2-restart.c
new file mode 100644 (file)
index 0000000..be6bc89
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * omap2-restart.c - code common to all OMAP2xxx machines.
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Paul Walmsley
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include "common.h"
+#include "prm2xxx.h"
+
+/*
+ * reset_virt_prcm_set_ck, reset_sys_ck: pointers to the virt_prcm_set
+ * clock and the sys_ck.  Used during the reset process
+ */
+static struct clk *reset_virt_prcm_set_ck, *reset_sys_ck;
+
+/* Reboot handling */
+
+/**
+ * omap2xxx_restart - Set DPLL to bypass mode for reboot to work
+ *
+ * Set the DPLL to bypass so that reboot completes successfully.  No
+ * return value.
+ */
+void omap2xxx_restart(char mode, const char *cmd)
+{
+       u32 rate;
+
+       rate = clk_get_rate(reset_sys_ck);
+       clk_set_rate(reset_virt_prcm_set_ck, rate);
+
+       /* XXX Should save the cmd argument for use after the reboot */
+
+       omap2xxx_prm_dpll_reset(); /* never returns */
+       while (1);
+}
+
+/**
+ * omap2xxx_common_look_up_clks_for_reset - look up clocks needed for restart
+ *
+ * Some clocks need to be looked up in advance for the SoC restart
+ * operation to work - see omap2xxx_restart().  Returns -EINVAL upon
+ * error or 0 upon success.
+ */
+static int __init omap2xxx_common_look_up_clks_for_reset(void)
+{
+       reset_virt_prcm_set_ck = clk_get(NULL, "virt_prcm_set");
+       if (IS_ERR(reset_virt_prcm_set_ck))
+               return -EINVAL;
+
+       reset_sys_ck = clk_get(NULL, "sys_ck");
+       if (IS_ERR(reset_sys_ck))
+               return -EINVAL;
+
+       return 0;
+}
+core_initcall(omap2xxx_common_look_up_clks_for_reset);
diff --git a/arch/arm/mach-omap2/omap3-restart.c b/arch/arm/mach-omap2/omap3-restart.c
new file mode 100644 (file)
index 0000000..923c582
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * omap3-restart.c - Code common to all OMAP3xxx machines.
+ *
+ * Copyright (C) 2009, 2012 Texas Instruments
+ * Copyright (C) 2010 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ * Santosh Shilimkar <santosh.shilimkar@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include "iomap.h"
+#include "common.h"
+#include "control.h"
+#include "prm3xxx.h"
+
+/* Global address base setup code */
+
+/**
+ * omap3xxx_restart - trigger a software restart of the SoC
+ * @mode: the "reboot mode", see arch/arm/kernel/{setup,process}.c
+ * @cmd: passed from the userspace program rebooting the system (if provided)
+ *
+ * Resets the SoC.  For @cmd, see the 'reboot' syscall in
+ * kernel/sys.c.  No return value.
+ */
+void omap3xxx_restart(char mode, const char *cmd)
+{
+       omap3_ctrl_write_boot_mode((cmd ? (u8)*cmd : 0));
+       omap3xxx_prm_dpll3_reset(); /* never returns */
+       while (1);
+}
index 6cd7e877c8e5c476aa1ebfc2e9da3e8e3cbc2612..3b1398798b61106a6d8bf88ff6471ed5199fde58 100644 (file)
@@ -33,6 +33,7 @@
 #include "common.h"
 #include "mmc.h"
 #include "hsmmc.h"
+#include "prminst44xx.h"
 #include "omap4-sar-layout.h"
 #include "omap-secure.h"
 
@@ -281,3 +282,19 @@ int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
        return 0;
 }
 #endif
+
+/**
+ * omap44xx_restart - trigger a software restart of the SoC
+ * @mode: the "reboot mode", see arch/arm/kernel/{setup,process}.c
+ * @cmd: passed from the userspace program rebooting the system (if provided)
+ *
+ * Resets the SoC.  For @cmd, see the 'reboot' syscall in
+ * kernel/sys.c.  No return value.
+ */
+void omap44xx_restart(char mode, const char *cmd)
+{
+       /* XXX Should save 'cmd' into scratchpad for use after reboot */
+       omap4_prminst_global_warm_sw_reset(); /* never returns */
+       while (1);
+}
+