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