1 From e3c377986855f820513edf2924a022a39c363908 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 29 Sep 2011 21:29:14 +0200
4 Subject: [PATCH 20/24] MIPS: lantiq: adds falcon VPE softdog
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
14 +++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
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.
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.
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.
31 + * Copyright (C) 2005 infineon
32 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
35 +#ifndef _IFXMIPS_VPE_H__
36 +#define _IFXMIPS_VPE_H__
38 +/* For the explanation of the APIs please refer the section "MT APRP Kernel
39 + * Programming" in AR9 SW Architecture Specification
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);
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);
50 +extern unsigned long vpe1_wdog_ctr;
51 +extern unsigned long vpe1_wdog_timeout;
53 +unsigned long vpe1_sw_wdog_start(unsigned long);
54 +unsigned long vpe1_sw_wdog_stop(unsigned long);
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);
61 +++ b/arch/mips/lantiq/falcon/softdog_vpe.c
64 +** =============================================================================
65 +** FILE NAME : softdog_vpe.c
68 +** AUTHOR : LXDB Team
69 +** DESCRIPTION : This header file contains the code for the watchdog
70 +** implentation on vpe1 side.
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
79 +** $Date $Author $Comment
80 +** 24-03-2008 LXDB Initial version
81 +** ============================================================================
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>
92 +#include <falcon/vpe.h>
94 +static unsigned long last_wdog_value;
95 +static unsigned long vpe1_wdog_cleared;
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;
103 +static struct timer_list watchdog_vpe0_ticktock =
104 + TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
106 +static void watchdog_vpe0_fire (unsigned long flags)
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);
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);
123 +int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
125 + reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
129 +static void keep_alive_vpe0(unsigned long flags)
131 + mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
134 +unsigned long vpe1_sw_wdog_start(unsigned long flags)
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);
144 +unsigned long vpe1_sw_wdog_stop(unsigned long flags)
146 + del_timer(&watchdog_vpe0_ticktock);
150 +static int __init watchdog_vpe1_init(void)
152 + /* Nothing to be done here */
156 +static void __exit watchdog_vpe1_exit(void)
158 + unsigned long flags=0;
159 + vpe1_sw_wdog_stop(flags);
162 +module_init(watchdog_vpe1_init);
163 +module_exit(watchdog_vpe1_exit);
165 +EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
166 +EXPORT_SYMBOL(vpe1_sw_wdog_start);
167 +EXPORT_SYMBOL(vpe1_sw_wdog_stop);
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
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