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

Archive Download this file



interactive