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