summaryrefslogtreecommitdiff
path: root/target/linux/lantiq/patches-3.0/0020-MIPS-lantiq-adds-falcon-VPE-softdog.patch
blob: 9f727cc1e7f45334435c1b44bf0e2fee7899cccf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From e3c377986855f820513edf2924a022a39c363908 Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Thu, 29 Sep 2011 21:29:14 +0200
Subject: [PATCH 20/24] MIPS: lantiq: adds falcon VPE softdog

---
 arch/mips/include/asm/mach-lantiq/falcon/vpe.h |   44 ++++++++++
 arch/mips/lantiq/falcon/softdog_vpe.c          |  109 ++++++++++++++++++++++++
 2 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-lantiq/falcon/vpe.h
 create mode 100644 arch/mips/lantiq/falcon/softdog_vpe.c

Index: linux-3.0.3/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-3.0.3/arch/mips/include/asm/mach-lantiq/falcon/vpe.h	2011-10-05 13:26:22.732981532 +0200
@@ -0,0 +1,44 @@
+/*
+ *   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.
+ *
+ *   Copyright (C) 2005 infineon
+ *   Copyright (C) 2007 John Crispin <blogic@openwrt.org>
+ *
+ */
+#ifndef _IFXMIPS_VPE_H__
+#define _IFXMIPS_VPE_H__
+
+/* For the explanation of the APIs please refer the section "MT APRP Kernel
+ * Programming" in AR9 SW Architecture Specification
+ */
+int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
+int32_t vpe1_sw_stop(uint32_t flags);
+uint32_t vpe1_get_load_addr (uint32_t flags);
+uint32_t vpe1_get_max_mem (uint32_t flags);
+
+int32_t vpe1_set_boot_param(char *field, char *value, char flags);
+int32_t vpe1_get_boot_param(char *field, char **value, char flags);
+
+/* Watchdog APIs */
+extern unsigned long vpe1_wdog_ctr;
+extern unsigned long vpe1_wdog_timeout;
+
+unsigned long vpe1_sw_wdog_start(unsigned long);
+unsigned long vpe1_sw_wdog_stop(unsigned long);
+
+typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
+int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
+
+#endif
Index: linux-3.0.3/arch/mips/lantiq/falcon/softdog_vpe.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-3.0.3/arch/mips/lantiq/falcon/softdog_vpe.c	2011-10-05 13:26:22.736981533 +0200
@@ -0,0 +1,109 @@
+/*
+** =============================================================================
+** FILE NAME     : softdog_vpe.c
+** MODULES       : LXDB
+** DATE          : 24-03-2008
+** AUTHOR        : LXDB Team
+** DESCRIPTION   : This header file contains the code for the watchdog
+**                 implentation on vpe1 side.
+** REFERENCES    :
+** COPYRIGHT     : Copyright (c) 2008
+**                 Am Campeon 1-12, 85579 Neubiberg, Germany
+** Any use of this software is subject to the conclusion of a respective
+** License agreement. Without such a License agreement no rights to the
+** software are granted
+**
+** HISTORY       :
+** $Date   $Author    $Comment
+** 24-03-2008   LXDB    Initial version
+** ============================================================================
+*/
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+
+#include <falcon/vpe.h>
+
+static unsigned long last_wdog_value;
+static unsigned long vpe1_wdog_cleared;
+
+static unsigned long vpe1_wdog_dead;
+static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
+static void keep_alive_vpe0(unsigned long);
+VPE_SW_WDOG_RESET reset_local_fn;
+
+
+static struct timer_list watchdog_vpe0_ticktock =
+                TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
+
+static void watchdog_vpe0_fire (unsigned long flags)
+{
+	volatile unsigned long *wdog_ctr_value;
+	wdog_ctr_value = (void*)vpe1_wdog_ctr;
+	if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
+		vpe1_sw_wdog_stop(flags);
+		vpe1_wdog_dead++;
+		printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
+	/* Call the reset handler function */
+		reset_local_fn(flags);
+	} else { /* Everything is OK on vpe1 side. Continue. */
+		last_wdog_value = *wdog_ctr_value;
+		vpe1_wdog_cleared++;
+		keep_alive_vpe0(flags);
+	}
+}
+
+int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
+{
+	reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
+	return 0;
+}
+
+static void keep_alive_vpe0(unsigned long flags)
+{
+	mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
+}
+
+unsigned long vpe1_sw_wdog_start(unsigned long flags)
+{
+	volatile unsigned long *wdog_ctr_value;
+	wdog_ctr_value = (void*)vpe1_wdog_ctr;
+	*wdog_ctr_value = 0;
+	last_wdog_value = 0;
+	keep_alive_vpe0(flags);
+	return 0;
+}
+
+unsigned long vpe1_sw_wdog_stop(unsigned long flags)
+{
+	del_timer(&watchdog_vpe0_ticktock);
+	return 0;
+}
+
+static int __init watchdog_vpe1_init(void)
+{
+	/* Nothing to be done here */
+	return 0;
+}
+
+static void __exit watchdog_vpe1_exit(void)
+{
+	unsigned long flags=0;
+	vpe1_sw_wdog_stop(flags);
+}
+
+module_init(watchdog_vpe1_init);
+module_exit(watchdog_vpe1_exit);
+
+EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
+EXPORT_SYMBOL(vpe1_sw_wdog_start);
+EXPORT_SYMBOL(vpe1_sw_wdog_stop);
+
+MODULE_AUTHOR("LXDB");
+MODULE_DESCRIPTION("Software Watchdog For VPE1");
+MODULE_LICENSE("GPL");
Index: linux-3.0.3/arch/mips/lantiq/falcon/Makefile
===================================================================
--- linux-3.0.3.orig/arch/mips/lantiq/falcon/Makefile	2011-10-05 13:38:41.801013127 +0200
+++ linux-3.0.3/arch/mips/lantiq/falcon/Makefile	2011-10-05 13:38:47.341013363 +0200
@@ -1,2 +1,2 @@
-obj-y := clk.o prom.o reset.o sysctrl.o devices.o gpio.o
+obj-y := clk.o prom.o reset.o sysctrl.o devices.o gpio.o softdog_vpe.o
 obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o