OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [devs/] [watchdog/] [arm/] [ebsa285/] [v2_0/] [src/] [watchdog_ebsa285.cxx] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      watchdog/ebsa285.cxx
4
//
5
//      Watchdog implementation for Intel EBSA-285 StronARM board
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):    jskov (based on the MN10300 watchdog code by nickg)
44
// Contributors: jskov, nickg
45
// Date:         1999-08-26
46
// Purpose:      Watchdog class implementation
47
// Description:  Contains an implementation of the Watchdog class for use
48
//               with the EBSA285/21285 hardware watchdog timer.
49
//
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
#include <pkgconf/system.h>             // system configuration file
55
#include <pkgconf/watchdog.h>           // configuration for this package
56
#include <pkgconf/kernel.h>             // kernel config
57
 
58
#include <cyg/infra/cyg_trac.h>         // tracing macros
59
#include <cyg/kernel/instrmnt.h>        // instrumentation
60
 
61
#include <cyg/hal/hal_io.h>             // IO register access
62
 
63
#include <cyg/io/watchdog.hxx>          // watchdog API
64
 
65
// -------------------------------------------------------------------------
66
// 21285 watchdog works by letting timer4 run; if it ever underflows,
67
// it resets the system. 
68
// Timer 4 is set to run at fclk_in/16 = 50MHz/16 = 3.125MHz
69
// The timer register is 24 bits, so it can easily hold a value that
70
// gives a 1s timeout.
71
#define WATCHDOG_TIMER_TICKS            3125000
72
#define WATCHDOG_RESOLUTION             (1000000000)
73
 
74
// -------------------------------------------------------------------------
75
// Constructor
76
 
77
void
78
Cyg_Watchdog::init_hw(void)
79
{
80
    CYG_REPORT_FUNCTION();
81
 
82
    // HW doesn't need init
83
 
84
    resolution          = WATCHDOG_RESOLUTION;
85
 
86
    CYG_REPORT_RETURN();
87
}
88
 
89
 
90
 
91
// -------------------------------------------------------------------------
92
// Start the watchdog running.
93
 
94
void
95
Cyg_Watchdog::start(void)
96
{
97
    CYG_REPORT_FUNCTION();
98
 
99
    // Init the watchdog timer.
100
    HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS);
101
    HAL_WRITE_UINT32(SA110_TIMER4_CLEAR, 0);
102
    HAL_WRITE_UINT32(SA110_TIMER4_CONTROL,
103
                     SA110_TIMER_CONTROL_ENABLE|SA110_TIMER_CONTROL_SCALE_16);
104
    // Enable the watchdog.
105
    cyg_uint32 ctrl;
106
    HAL_READ_UINT32(SA110_CONTROL, ctrl);
107
    ctrl |= SA110_CONTROL_WATCHDOG;
108
    HAL_WRITE_UINT32(SA110_CONTROL, ctrl);
109
 
110
    CYG_REPORT_RETURN();
111
}
112
 
113
// -------------------------------------------------------------------------
114
// Reset watchdog timer. This needs to be called regularly to prevent
115
// the watchdog firing.
116
 
117
void
118
Cyg_Watchdog::reset()
119
{
120
    CYG_REPORT_FUNCTION();
121
 
122
    HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS);
123
 
124
    CYG_REPORT_RETURN();
125
}
126
 
127
#if 0
128
// -------------------------------------------------------------------------
129
// Trigger the watchdog as if the timer had expired.
130
 
131
void
132
Cyg_Watchdog::reset_action(void)
133
{
134
    CYG_REPORT_FUNCTION();
135
 
136
    // Init the watchdog timer.
137
    HAL_WRITE_UINT32(SA110_TIMER4_LOAD, 1);
138
    HAL_WRITE_UINT32(SA110_TIMER4_CONTROL, SA110_TIMER_CONTROL_ENABLE);
139
    // Enable the watchdog.
140
    cyg_uint32 ctrl;
141
    HAL_READ_UINT32(SA110_CONTROL, ctrl);
142
    ctrl |= SA110_CONTROL_WATCHDOG;
143
    HAL_WRITE_UINT32(SA110_CONTROL, ctrl);
144
 
145
    CYG_REPORT_RETURN();
146
}
147
#endif
148
 
149
 
150
// -------------------------------------------------------------------------
151
// EOF watchdog_ebsa285.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.