source: rtems/bsps/mips/hurricane/start/usc.S

Last change on this file was 334d90e3, checked in by Joel Sherrill <joel@…>, on 07/11/22 at 22:22:48

bsps/mips/hurricane: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*  usc.S
4 *
5 *  COPYRIGHT (c) 1989-2010.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <bspopts.h>
31#include <rtems/asm.h>
32#include <rtems/mips/iregdef.h>
33#include <rtems/mips/idtcpu.h>
34#if BSP_HAS_USC320
35  #include <usc.h>
36#endif
37
38
39/***************************************************************************
40**
41**   The following code was added to support boards using V3 USC320
42**     system controller chip.
43**
44****************************************************************************/
45
46/*************************************************************
47*  init_hbt()
48*       Initialize the heartbeat timer
49*/
50FRAME(init_hbt,sp,0,ra)
51        .set noreorder
52        la      t0,SYSTEM       # Unlock USC registers
53        li      t1,0xA5
54        sb      t1,(t0)
55
56        la      t0,WD_HBI       # Initialize heatbeat and watchdog timers
57
58                                # (1 / 64 MHz) * 4000 * (63 + 1) = 4000.0 microseconds
59                                # Watchdog period is heartbeat period times watchdog timer constant (bits 7 - 0)
60                                # Watchdog period = 4000 * 5 = 20000 microseconds
61        li      t1,(WD_EN | HBI_4000_PS | 0x00003F00 | 0x5)
62
63                                # (1 / 64 MHz) * 4000 * (15 + 1) = 1000.0 microseconds
64                                # Watchdog period is heartbeat period times watchdog timer constant (bits 7 - 0)
65                                # Watchdog period = 1000 * 20 = 20000 microseconds
66        li      t1,(WD_EN | HBI_4000_PS | 0x00000F00 | 0x14)
67
68                                # (1 / 64 MHz) * 40000 * (15 + 1) = 10000.0 microseconds
69                                # Watchdog period is heartbeat period times watchdog timer constant (bits 7 - 0)
70                                # Watchdog period = 10000 * 20 = 200000 microseconds
71        li      t1,(WD_EN | HBI_4000_PS | 0x00009600 | 0x14)
72
73        sw      t1,(t0)
74
75        la      t0,SYSTEM       # Lock USC registers
76        li      t1,0x60
77        sb      t1,(t0)
78
79        .set reorder
80        j       ra
81        nop
82        .set reorder
83ENDFRAME(init_hbt)
84
85/*************************************************************
86*  reset_wdt()
87*       Reset the watchdog timer
88*/
89FRAME(reset_wdt,sp,0,ra)
90        .set noreorder
91
92        la      t0,WD_HBI+2     # Load address watchdog timer reset byte
93        li      t1,WD_INIT
94        sb      t1,(t0)
95
96        .set reorder
97        j       ra
98        nop
99        .set reorder
100ENDFRAME(reset_wdt)
101
102/*************************************************************
103*  disable_wdt()
104*       Disable watchdog timer
105*/
106FRAME(disable_wdt,sp,0,ra)
107        .set noreorder
108        la      t0,WD_HBI       # Clear watchdog enable bit in control register
109        lw      t1,(t0)
110        li      t2,~WD_EN
111        and     t1,t1,t2
112        sw      t1,(t0)
113
114        .set reorder
115        j       ra
116        nop
117        .set reorder
118ENDFRAME(disable_wdt)
119
120/*************************************************************
121*  enable_hbi(ints)
122*       Enable the heartbeat interrupt
123*/
124FRAME(enable_hbi,sp,0,ra)
125        .set noreorder
126
127        la      t0,INT_CFG3     # Enable heartbeat interrupt in USC320
128        lw      t1,(t0)
129        li      t2,(HBI_MASK | MODE_TOTEM_POLE)
130        or      t1,t1,t2
131        sw      t1,(t0)
132
133        .set reorder
134        j       ra
135        nop
136        .set reorder
137ENDFRAME(enable_hbi)
138
139/*************************************************************
140*  disable_hbi(ints)
141*       Disable the heartbeat interrupt
142*/
143FRAME(disable_hbi,sp,0,ra)
144        .set noreorder
145        la      t0,INT_CFG3     # Disable heartbeat interrupt in USC320
146        lw      t1,(t0)
147        li      t2,~HBI_MASK
148        and     t1,t1,t2
149        sw      t1,(t0)
150
151        .set reorder
152        j       ra
153        nop
154        .set reorder
155ENDFRAME(disable_hbi)
156
157
158/*************************************************************
159*  enable_wdi()
160*       Enable the watchdog interrupt
161*/
162FRAME(enable_wdi,sp,0,ra)
163        .set noreorder
164
165        la      t0,INT_CFG1     # Enable watchdog interrupt in USC320
166        lw      t1,(t0)
167        li      t2,(WDI_MASK | MODE_TOTEM_POLE)
168        or      t1,t1,t2
169        sw      t1,(t0)
170
171        .set reorder
172        j       ra
173        nop
174        .set reorder
175ENDFRAME(enable_wdi)
176
177/*************************************************************
178*  disable_wdi(ints)
179*       Disable the watchdog interrupt
180*/
181FRAME(disable_wdi,sp,0,ra)
182        .set noreorder
183
184        la      t0,INT_CFG1     # Disable watchdog interrupt in USC320
185        lw      t1,(t0)
186        li      t2,~(WDI_MASK | MODE_TOTEM_POLE)
187        and     t1,t1,t2
188        sw      t1,(t0)
189
190        la      t0,INT_STAT     # Clear watchdog interrupt status bit
191        li      t1,WDI_MASK
192        sw      t1,(t0)
193
194        .set reorder
195        j       ra
196        nop
197        .set reorder
198ENDFRAME(disable_wdi)
199
Note: See TracBrowser for help on using the repository browser.