1 |
27 |
unneback |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// mod_regs_cpg.h
|
4 |
|
|
//
|
5 |
|
|
// CPG (clock pulse generator) Module register definitions
|
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
|
44 |
|
|
// Contributors:jskov
|
45 |
|
|
// Date: 2000-10-30
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
//=============================================================================
|
50 |
|
|
|
51 |
|
|
//--------------------------------------------------------------------------
|
52 |
|
|
// Oscillator control registers
|
53 |
|
|
#define CYGARC_REG_FRQCR 0xffffff80
|
54 |
|
|
#define CYGARC_REG_WTCNT 0xffffff84 // read 8bit, write 16bit
|
55 |
|
|
#define CYGARC_REG_WTCSR 0xffffff86 // read 8bit, write 16bit
|
56 |
|
|
|
57 |
|
|
#define CYGARC_REG_WTCNT_WRITE 0x5a00 // top 8bit value for write
|
58 |
|
|
|
59 |
|
|
#define CYGARC_REG_WTCSR_WRITE 0xa500 // top 8bit value for write
|
60 |
|
|
#define CYGARC_REG_WTCSR_TME 0x80 // timer enable
|
61 |
|
|
#define CYGARC_REG_WTCSR_WT_IT 0x40 // watchdog(1)/interval(0)
|
62 |
|
|
#define CYGARC_REG_WTCSR_RSTS 0x20 // manual(1)/poweron(0)
|
63 |
|
|
#define CYGARC_REG_WTCSR_WOVF 0x10 // watchdog overflow
|
64 |
|
|
#define CYGARC_REG_WTCSR_IOVF 0x08 // interval overflow
|
65 |
|
|
#define CYGARC_REG_WTCSR_CKS2 0x04 // clock select 2
|
66 |
|
|
#define CYGARC_REG_WTCSR_CKS1 0x02 // clock select 1
|
67 |
|
|
#define CYGARC_REG_WTCSR_CKS0 0x01 // clock select 0
|
68 |
|
|
#define CYGARC_REG_WTCSR_CKSx_MASK 0x07 // clock select mask
|
69 |
|
|
// This is the period (in us) between watchdog reset and overflow.
|
70 |
|
|
// Note: We use max timeout delay for now.
|
71 |
|
|
#define CYGARC_REG_WTCSR_CKSx_SETTING 0x07 // max delay
|
72 |
|
|
|
73 |
|
|
#define CYGARC_REG_WTCSR_PERIOD ((1000000000/(CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED/4096))*256)
|
74 |
|
|
|
75 |
|
|
// Translate various CDL clock configurations to register equivalents
|
76 |
|
|
// for the various CPG versions
|
77 |
|
|
#if (CYGARC_SH_MOD_CPG == 1) // ---------------------------- V1
|
78 |
|
|
|
79 |
|
|
// PLL1
|
80 |
|
|
#if (CYGHWR_HAL_SH_OOC_PLL_1 == 0) || (CYGHWR_HAL_SH_OOC_PLL_1 == 1)
|
81 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0000
|
82 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 2)
|
83 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0010
|
84 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 4)
|
85 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0020
|
86 |
|
|
#else
|
87 |
|
|
# error "Unsupported PLL1 setting"
|
88 |
|
|
#endif
|
89 |
|
|
|
90 |
|
|
// Divider1
|
91 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 1)
|
92 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0000
|
93 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 2)
|
94 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0004
|
95 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 4)
|
96 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0008
|
97 |
|
|
#else
|
98 |
|
|
# error "Unsupported Divider1 setting"
|
99 |
|
|
#endif
|
100 |
|
|
|
101 |
|
|
// Divider2
|
102 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 1)
|
103 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0000
|
104 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 2)
|
105 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0001
|
106 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 4)
|
107 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0002
|
108 |
|
|
#else
|
109 |
|
|
# error "Unsupported Divider1 setting"
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
// CKOEN - set in all modes but 7
|
113 |
|
|
#if (CYGHWR_HAL_SH_OOC_CLOCK_MODE != 7)
|
114 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0100
|
115 |
|
|
#else
|
116 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0000
|
117 |
|
|
#endif
|
118 |
|
|
|
119 |
|
|
#elif (CYGARC_SH_MOD_CPG == 2) // ---------------------------- V2
|
120 |
|
|
|
121 |
|
|
// PLL1
|
122 |
|
|
#if (CYGHWR_HAL_SH_OOC_PLL_1 == 0) || (CYGHWR_HAL_SH_OOC_PLL_1 == 1)
|
123 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0000
|
124 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 2)
|
125 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0010
|
126 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 4)
|
127 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0020
|
128 |
|
|
#else
|
129 |
|
|
# error "Unsupported PLL1 setting"
|
130 |
|
|
#endif
|
131 |
|
|
|
132 |
|
|
// Divider1
|
133 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 1)
|
134 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0000
|
135 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 2)
|
136 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0004
|
137 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 4)
|
138 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0008
|
139 |
|
|
#else
|
140 |
|
|
# error "Unsupported Divider1 setting"
|
141 |
|
|
#endif
|
142 |
|
|
|
143 |
|
|
// Divider2
|
144 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 1)
|
145 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0000
|
146 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 2)
|
147 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0001
|
148 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 4)
|
149 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0002
|
150 |
|
|
#else
|
151 |
|
|
# error "Unsupported Divider1 setting"
|
152 |
|
|
#endif
|
153 |
|
|
|
154 |
|
|
// CKOEN - set in all modes but 2
|
155 |
|
|
#if (CYGHWR_HAL_SH_OOC_CLOCK_MODE != 2)
|
156 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0100
|
157 |
|
|
#else
|
158 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0000
|
159 |
|
|
#endif
|
160 |
|
|
|
161 |
|
|
#elif (CYGARC_SH_MOD_CPG == 3) // ---------------------------- V3
|
162 |
|
|
|
163 |
|
|
// PLL1
|
164 |
|
|
#if (CYGHWR_HAL_SH_OOC_PLL_1 == 0) || (CYGHWR_HAL_SH_OOC_PLL_1 == 1)
|
165 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0000
|
166 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 2)
|
167 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0010
|
168 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 3)
|
169 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x8000
|
170 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 4)
|
171 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0020
|
172 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 6)
|
173 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x8010
|
174 |
|
|
#elif (CYGHWR_HAL_SH_OOC_PLL_1 == 8)
|
175 |
|
|
# define CYGARC_REG_FRQCR_INIT_PLL1 0x0030
|
176 |
|
|
#else
|
177 |
|
|
# error "Unsupported PLL1 setting"
|
178 |
|
|
#endif
|
179 |
|
|
|
180 |
|
|
// Divider1
|
181 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 1)
|
182 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0000
|
183 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 2)
|
184 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0004
|
185 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 3)
|
186 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x4000
|
187 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_1 == 4)
|
188 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER1 0x0008
|
189 |
|
|
#else
|
190 |
|
|
# error "Unsupported Divider1 setting"
|
191 |
|
|
#endif
|
192 |
|
|
|
193 |
|
|
// Divider2
|
194 |
|
|
#if (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 1)
|
195 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0000
|
196 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 2)
|
197 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0001
|
198 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 3)
|
199 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x2000
|
200 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 4)
|
201 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x0002
|
202 |
|
|
#elif (CYGHWR_HAL_SH_OOC_DIVIDER_2 == 6)
|
203 |
|
|
# define CYGARC_REG_FRQCR_INIT_DIVIDER2 0x2002
|
204 |
|
|
#else
|
205 |
|
|
# error "Unsupported Divider2 setting"
|
206 |
|
|
#endif
|
207 |
|
|
|
208 |
|
|
// CKOEN - set in modes 0-2
|
209 |
|
|
#if (CYGHWR_HAL_SH_OOC_CLOCK_MODE <= 2)
|
210 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0100
|
211 |
|
|
#else
|
212 |
|
|
# define CYGARC_REG_FRQCR_INIT_CKOEN 0x0000
|
213 |
|
|
#endif
|
214 |
|
|
|
215 |
|
|
#else
|
216 |
|
|
|
217 |
|
|
# error "Unsupported CPG version"
|
218 |
|
|
|
219 |
|
|
#endif
|
220 |
|
|
|
221 |
|
|
// Init value
|
222 |
|
|
#define CYGARC_REG_FRQCR_INIT (CYGARC_REG_FRQCR_INIT_PLL1|CYGARC_REG_FRQCR_INIT_DIVIDER1|CYGARC_REG_FRQCR_INIT_DIVIDER2|CYGARC_REG_FRQCR_INIT_CKOEN)
|