Root/target/linux/lantiq/patches/0020-MIPS-lantiq-adds-falcon-VPE-softdog.patch

1From e3c377986855f820513edf2924a022a39c363908 Mon Sep 17 00:00:00 2001
2From: John Crispin <blogic@openwrt.org>
3Date: Thu, 29 Sep 2011 21:29:14 +0200
4Subject: [PATCH 20/24] MIPS: lantiq: adds falcon VPE softdog
5
6---
7 arch/mips/include/asm/mach-lantiq/falcon/vpe.h | 44 ++++++++++
8 arch/mips/lantiq/falcon/softdog_vpe.c | 109 ++++++++++++++++++++++++
9 2 files changed, 153 insertions(+), 0 deletions(-)
10 create mode 100644 arch/mips/include/asm/mach-lantiq/falcon/vpe.h
11 create mode 100644 arch/mips/lantiq/falcon/softdog_vpe.c
12
13--- /dev/null
14+++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
15@@ -0,0 +1,44 @@
16+/*
17+ * This program is free software; you can redistribute it and/or modify
18+ * it under the terms of the GNU General Public License as published by
19+ * the Free Software Foundation; either version 2 of the License, or
20+ * (at your option) any later version.
21+ *
22+ * This program is distributed in the hope that it will be useful,
23+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+ * GNU General Public License for more details.
26+ *
27+ * You should have received a copy of the GNU General Public License
28+ * along with this program; if not, write to the Free Software
29+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
30+ *
31+ * Copyright (C) 2005 infineon
32+ * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
33+ *
34+ */
35+#ifndef _IFXMIPS_VPE_H__
36+#define _IFXMIPS_VPE_H__
37+
38+/* For the explanation of the APIs please refer the section "MT APRP Kernel
39+ * Programming" in AR9 SW Architecture Specification
40+ */
41+int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
42+int32_t vpe1_sw_stop(uint32_t flags);
43+uint32_t vpe1_get_load_addr (uint32_t flags);
44+uint32_t vpe1_get_max_mem (uint32_t flags);
45+
46+int32_t vpe1_set_boot_param(char *field, char *value, char flags);
47+int32_t vpe1_get_boot_param(char *field, char **value, char flags);
48+
49+/* Watchdog APIs */
50+extern unsigned long vpe1_wdog_ctr;
51+extern unsigned long vpe1_wdog_timeout;
52+
53+unsigned long vpe1_sw_wdog_start(unsigned long);
54+unsigned long vpe1_sw_wdog_stop(unsigned long);
55+
56+typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
57+int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
58+
59+#endif
60--- /dev/null
61+++ b/arch/mips/lantiq/falcon/softdog_vpe.c
62@@ -0,0 +1,109 @@
63+/*
64+** =============================================================================
65+** FILE NAME : softdog_vpe.c
66+** MODULES : LXDB
67+** DATE : 24-03-2008
68+** AUTHOR : LXDB Team
69+** DESCRIPTION : This header file contains the code for the watchdog
70+** implentation on vpe1 side.
71+** REFERENCES :
72+** COPYRIGHT : Copyright (c) 2008
73+** Am Campeon 1-12, 85579 Neubiberg, Germany
74+** Any use of this software is subject to the conclusion of a respective
75+** License agreement. Without such a License agreement no rights to the
76+** software are granted
77+**
78+** HISTORY :
79+** $Date $Author $Comment
80+** 24-03-2008 LXDB Initial version
81+** ============================================================================
82+*/
83+
84+#include <linux/module.h>
85+#include <linux/moduleparam.h>
86+#include <linux/types.h>
87+#include <linux/timer.h>
88+#include <linux/reboot.h>
89+#include <linux/init.h>
90+#include <linux/jiffies.h>
91+
92+#include <falcon/vpe.h>
93+
94+static unsigned long last_wdog_value;
95+static unsigned long vpe1_wdog_cleared;
96+
97+static unsigned long vpe1_wdog_dead;
98+static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
99+static void keep_alive_vpe0(unsigned long);
100+VPE_SW_WDOG_RESET reset_local_fn;
101+
102+
103+static struct timer_list watchdog_vpe0_ticktock =
104+ TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
105+
106+static void watchdog_vpe0_fire (unsigned long flags)
107+{
108+ volatile unsigned long *wdog_ctr_value;
109+ wdog_ctr_value = (void*)vpe1_wdog_ctr;
110+ if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
111+ vpe1_sw_wdog_stop(flags);
112+ vpe1_wdog_dead++;
113+ printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
114+ /* Call the reset handler function */
115+ reset_local_fn(flags);
116+ } else { /* Everything is OK on vpe1 side. Continue. */
117+ last_wdog_value = *wdog_ctr_value;
118+ vpe1_wdog_cleared++;
119+ keep_alive_vpe0(flags);
120+ }
121+}
122+
123+int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
124+{
125+ reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
126+ return 0;
127+}
128+
129+static void keep_alive_vpe0(unsigned long flags)
130+{
131+ mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
132+}
133+
134+unsigned long vpe1_sw_wdog_start(unsigned long flags)
135+{
136+ volatile unsigned long *wdog_ctr_value;
137+ wdog_ctr_value = (void*)vpe1_wdog_ctr;
138+ *wdog_ctr_value = 0;
139+ last_wdog_value = 0;
140+ keep_alive_vpe0(flags);
141+ return 0;
142+}
143+
144+unsigned long vpe1_sw_wdog_stop(unsigned long flags)
145+{
146+ del_timer(&watchdog_vpe0_ticktock);
147+ return 0;
148+}
149+
150+static int __init watchdog_vpe1_init(void)
151+{
152+ /* Nothing to be done here */
153+ return 0;
154+}
155+
156+static void __exit watchdog_vpe1_exit(void)
157+{
158+ unsigned long flags=0;
159+ vpe1_sw_wdog_stop(flags);
160+}
161+
162+module_init(watchdog_vpe1_init);
163+module_exit(watchdog_vpe1_exit);
164+
165+EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
166+EXPORT_SYMBOL(vpe1_sw_wdog_start);
167+EXPORT_SYMBOL(vpe1_sw_wdog_stop);
168+
169+MODULE_AUTHOR("LXDB");
170+MODULE_DESCRIPTION("Software Watchdog For VPE1");
171+MODULE_LICENSE("GPL");
172--- a/arch/mips/lantiq/falcon/Makefile
173+++ b/arch/mips/lantiq/falcon/Makefile
174@@ -1,2 +1,2 @@
175-obj-y := clk.o prom.o reset.o sysctrl.o devices.o gpio.o
176+obj-y := clk.o prom.o reset.o sysctrl.o devices.o gpio.o softdog_vpe.o
177 obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
178

Archive Download this file



interactive