root / hw / etraxfs_timer.c @ 1455084e
History | View | Annotate | Download (8.4 kB)
1 | 83fa1010 | ths | /*
|
---|---|---|---|
2 | e62b5b13 | edgar_igl | * QEMU ETRAX Timers
|
3 | 83fa1010 | ths | *
|
4 | 83fa1010 | ths | * Copyright (c) 2007 Edgar E. Iglesias, Axis Communications AB.
|
5 | 83fa1010 | ths | *
|
6 | 83fa1010 | ths | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 83fa1010 | ths | * of this software and associated documentation files (the "Software"), to deal
|
8 | 83fa1010 | ths | * in the Software without restriction, including without limitation the rights
|
9 | 83fa1010 | ths | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 83fa1010 | ths | * copies of the Software, and to permit persons to whom the Software is
|
11 | 83fa1010 | ths | * furnished to do so, subject to the following conditions:
|
12 | 83fa1010 | ths | *
|
13 | 83fa1010 | ths | * The above copyright notice and this permission notice shall be included in
|
14 | 83fa1010 | ths | * all copies or substantial portions of the Software.
|
15 | 83fa1010 | ths | *
|
16 | 83fa1010 | ths | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 83fa1010 | ths | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 83fa1010 | ths | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 83fa1010 | ths | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 83fa1010 | ths | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 83fa1010 | ths | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 83fa1010 | ths | * THE SOFTWARE.
|
23 | 83fa1010 | ths | */
|
24 | 3b1fd90e | Edgar E. Iglesias | #include "sysbus.h" |
25 | 5439779e | edgar_igl | #include "sysemu.h" |
26 | 87ecb68b | pbrook | #include "qemu-timer.h" |
27 | 83fa1010 | ths | |
28 | bbaf29c7 | edgar_igl | #define D(x)
|
29 | bbaf29c7 | edgar_igl | |
30 | ca87d03b | edgar_igl | #define RW_TMR0_DIV 0x00 |
31 | ca87d03b | edgar_igl | #define R_TMR0_DATA 0x04 |
32 | ca87d03b | edgar_igl | #define RW_TMR0_CTRL 0x08 |
33 | ca87d03b | edgar_igl | #define RW_TMR1_DIV 0x10 |
34 | ca87d03b | edgar_igl | #define R_TMR1_DATA 0x14 |
35 | ca87d03b | edgar_igl | #define RW_TMR1_CTRL 0x18 |
36 | ca87d03b | edgar_igl | #define R_TIME 0x38 |
37 | ca87d03b | edgar_igl | #define RW_WD_CTRL 0x40 |
38 | 5439779e | edgar_igl | #define R_WD_STAT 0x44 |
39 | ca87d03b | edgar_igl | #define RW_INTR_MASK 0x48 |
40 | ca87d03b | edgar_igl | #define RW_ACK_INTR 0x4c |
41 | ca87d03b | edgar_igl | #define R_INTR 0x50 |
42 | ca87d03b | edgar_igl | #define R_MASKED_INTR 0x54 |
43 | 83fa1010 | ths | |
44 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer {
|
45 | 3b1fd90e | Edgar E. Iglesias | SysBusDevice busdev; |
46 | 3b1fd90e | Edgar E. Iglesias | qemu_irq irq; |
47 | 3b1fd90e | Edgar E. Iglesias | qemu_irq nmi; |
48 | 84ceea57 | Edgar E. Iglesias | |
49 | 84ceea57 | Edgar E. Iglesias | QEMUBH *bh_t0; |
50 | 84ceea57 | Edgar E. Iglesias | QEMUBH *bh_t1; |
51 | 84ceea57 | Edgar E. Iglesias | QEMUBH *bh_wd; |
52 | 84ceea57 | Edgar E. Iglesias | ptimer_state *ptimer_t0; |
53 | 84ceea57 | Edgar E. Iglesias | ptimer_state *ptimer_t1; |
54 | 84ceea57 | Edgar E. Iglesias | ptimer_state *ptimer_wd; |
55 | 84ceea57 | Edgar E. Iglesias | |
56 | 84ceea57 | Edgar E. Iglesias | int wd_hits;
|
57 | 84ceea57 | Edgar E. Iglesias | |
58 | 84ceea57 | Edgar E. Iglesias | /* Control registers. */
|
59 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_tmr0_div; |
60 | 84ceea57 | Edgar E. Iglesias | uint32_t r_tmr0_data; |
61 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_tmr0_ctrl; |
62 | 84ceea57 | Edgar E. Iglesias | |
63 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_tmr1_div; |
64 | 84ceea57 | Edgar E. Iglesias | uint32_t r_tmr1_data; |
65 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_tmr1_ctrl; |
66 | 84ceea57 | Edgar E. Iglesias | |
67 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_wd_ctrl; |
68 | 84ceea57 | Edgar E. Iglesias | |
69 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_intr_mask; |
70 | 84ceea57 | Edgar E. Iglesias | uint32_t rw_ack_intr; |
71 | 84ceea57 | Edgar E. Iglesias | uint32_t r_intr; |
72 | 84ceea57 | Edgar E. Iglesias | uint32_t r_masked_intr; |
73 | 83fa1010 | ths | }; |
74 | 83fa1010 | ths | |
75 | c227f099 | Anthony Liguori | static uint32_t timer_readl (void *opaque, target_phys_addr_t addr) |
76 | 83fa1010 | ths | { |
77 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
78 | 84ceea57 | Edgar E. Iglesias | uint32_t r = 0;
|
79 | 84ceea57 | Edgar E. Iglesias | |
80 | 84ceea57 | Edgar E. Iglesias | switch (addr) {
|
81 | 84ceea57 | Edgar E. Iglesias | case R_TMR0_DATA:
|
82 | 84ceea57 | Edgar E. Iglesias | r = ptimer_get_count(t->ptimer_t0); |
83 | 84ceea57 | Edgar E. Iglesias | break;
|
84 | 84ceea57 | Edgar E. Iglesias | case R_TMR1_DATA:
|
85 | 84ceea57 | Edgar E. Iglesias | r = ptimer_get_count(t->ptimer_t1); |
86 | 84ceea57 | Edgar E. Iglesias | break;
|
87 | 84ceea57 | Edgar E. Iglesias | case R_TIME:
|
88 | 74475455 | Paolo Bonzini | r = qemu_get_clock_ns(vm_clock) / 10;
|
89 | 84ceea57 | Edgar E. Iglesias | break;
|
90 | 84ceea57 | Edgar E. Iglesias | case RW_INTR_MASK:
|
91 | 84ceea57 | Edgar E. Iglesias | r = t->rw_intr_mask; |
92 | 84ceea57 | Edgar E. Iglesias | break;
|
93 | 84ceea57 | Edgar E. Iglesias | case R_MASKED_INTR:
|
94 | 84ceea57 | Edgar E. Iglesias | r = t->r_intr & t->rw_intr_mask; |
95 | 84ceea57 | Edgar E. Iglesias | break;
|
96 | 84ceea57 | Edgar E. Iglesias | default:
|
97 | 84ceea57 | Edgar E. Iglesias | D(printf ("%s %x\n", __func__, addr));
|
98 | 84ceea57 | Edgar E. Iglesias | break;
|
99 | 84ceea57 | Edgar E. Iglesias | } |
100 | 84ceea57 | Edgar E. Iglesias | return r;
|
101 | 83fa1010 | ths | } |
102 | 83fa1010 | ths | |
103 | 3b1fd90e | Edgar E. Iglesias | static void update_ctrl(struct etrax_timer *t, int tnum) |
104 | 83fa1010 | ths | { |
105 | 84ceea57 | Edgar E. Iglesias | unsigned int op; |
106 | 84ceea57 | Edgar E. Iglesias | unsigned int freq; |
107 | 84ceea57 | Edgar E. Iglesias | unsigned int freq_hz; |
108 | 84ceea57 | Edgar E. Iglesias | unsigned int div; |
109 | 84ceea57 | Edgar E. Iglesias | uint32_t ctrl; |
110 | 84ceea57 | Edgar E. Iglesias | |
111 | 84ceea57 | Edgar E. Iglesias | ptimer_state *timer; |
112 | 84ceea57 | Edgar E. Iglesias | |
113 | 84ceea57 | Edgar E. Iglesias | if (tnum == 0) { |
114 | 84ceea57 | Edgar E. Iglesias | ctrl = t->rw_tmr0_ctrl; |
115 | 84ceea57 | Edgar E. Iglesias | div = t->rw_tmr0_div; |
116 | 84ceea57 | Edgar E. Iglesias | timer = t->ptimer_t0; |
117 | 84ceea57 | Edgar E. Iglesias | } else {
|
118 | 84ceea57 | Edgar E. Iglesias | ctrl = t->rw_tmr1_ctrl; |
119 | 84ceea57 | Edgar E. Iglesias | div = t->rw_tmr1_div; |
120 | 84ceea57 | Edgar E. Iglesias | timer = t->ptimer_t1; |
121 | 84ceea57 | Edgar E. Iglesias | } |
122 | 84ceea57 | Edgar E. Iglesias | |
123 | 84ceea57 | Edgar E. Iglesias | |
124 | 84ceea57 | Edgar E. Iglesias | op = ctrl & 3;
|
125 | 84ceea57 | Edgar E. Iglesias | freq = ctrl >> 2;
|
126 | 84ceea57 | Edgar E. Iglesias | freq_hz = 32000000;
|
127 | 84ceea57 | Edgar E. Iglesias | |
128 | 84ceea57 | Edgar E. Iglesias | switch (freq)
|
129 | 84ceea57 | Edgar E. Iglesias | { |
130 | 84ceea57 | Edgar E. Iglesias | case 0: |
131 | 84ceea57 | Edgar E. Iglesias | case 1: |
132 | 84ceea57 | Edgar E. Iglesias | D(printf ("extern or disabled timer clock?\n"));
|
133 | 84ceea57 | Edgar E. Iglesias | break;
|
134 | 84ceea57 | Edgar E. Iglesias | case 4: freq_hz = 29493000; break; |
135 | 84ceea57 | Edgar E. Iglesias | case 5: freq_hz = 32000000; break; |
136 | 84ceea57 | Edgar E. Iglesias | case 6: freq_hz = 32768000; break; |
137 | 84ceea57 | Edgar E. Iglesias | case 7: freq_hz = 100000000; break; |
138 | 84ceea57 | Edgar E. Iglesias | default:
|
139 | 84ceea57 | Edgar E. Iglesias | abort(); |
140 | 84ceea57 | Edgar E. Iglesias | break;
|
141 | 84ceea57 | Edgar E. Iglesias | } |
142 | 84ceea57 | Edgar E. Iglesias | |
143 | 84ceea57 | Edgar E. Iglesias | D(printf ("freq_hz=%d div=%d\n", freq_hz, div));
|
144 | 84ceea57 | Edgar E. Iglesias | ptimer_set_freq(timer, freq_hz); |
145 | 84ceea57 | Edgar E. Iglesias | ptimer_set_limit(timer, div, 0);
|
146 | 84ceea57 | Edgar E. Iglesias | |
147 | 84ceea57 | Edgar E. Iglesias | switch (op)
|
148 | 84ceea57 | Edgar E. Iglesias | { |
149 | 84ceea57 | Edgar E. Iglesias | case 0: |
150 | 84ceea57 | Edgar E. Iglesias | /* Load. */
|
151 | 84ceea57 | Edgar E. Iglesias | ptimer_set_limit(timer, div, 1);
|
152 | 84ceea57 | Edgar E. Iglesias | break;
|
153 | 84ceea57 | Edgar E. Iglesias | case 1: |
154 | 84ceea57 | Edgar E. Iglesias | /* Hold. */
|
155 | 84ceea57 | Edgar E. Iglesias | ptimer_stop(timer); |
156 | 84ceea57 | Edgar E. Iglesias | break;
|
157 | 84ceea57 | Edgar E. Iglesias | case 2: |
158 | 84ceea57 | Edgar E. Iglesias | /* Run. */
|
159 | 84ceea57 | Edgar E. Iglesias | ptimer_run(timer, 0);
|
160 | 84ceea57 | Edgar E. Iglesias | break;
|
161 | 84ceea57 | Edgar E. Iglesias | default:
|
162 | 84ceea57 | Edgar E. Iglesias | abort(); |
163 | 84ceea57 | Edgar E. Iglesias | break;
|
164 | 84ceea57 | Edgar E. Iglesias | } |
165 | 83fa1010 | ths | } |
166 | 83fa1010 | ths | |
167 | 3b1fd90e | Edgar E. Iglesias | static void timer_update_irq(struct etrax_timer *t) |
168 | 83fa1010 | ths | { |
169 | 84ceea57 | Edgar E. Iglesias | t->r_intr &= ~(t->rw_ack_intr); |
170 | 84ceea57 | Edgar E. Iglesias | t->r_masked_intr = t->r_intr & t->rw_intr_mask; |
171 | 60237223 | edgar_igl | |
172 | 84ceea57 | Edgar E. Iglesias | D(printf("%s: masked_intr=%x\n", __func__, t->r_masked_intr));
|
173 | 3b1fd90e | Edgar E. Iglesias | qemu_set_irq(t->irq, !!t->r_masked_intr); |
174 | 83fa1010 | ths | } |
175 | 83fa1010 | ths | |
176 | 5439779e | edgar_igl | static void timer0_hit(void *opaque) |
177 | 60237223 | edgar_igl | { |
178 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
179 | 84ceea57 | Edgar E. Iglesias | t->r_intr |= 1;
|
180 | 84ceea57 | Edgar E. Iglesias | timer_update_irq(t); |
181 | 60237223 | edgar_igl | } |
182 | 60237223 | edgar_igl | |
183 | 5439779e | edgar_igl | static void timer1_hit(void *opaque) |
184 | 5439779e | edgar_igl | { |
185 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
186 | 84ceea57 | Edgar E. Iglesias | t->r_intr |= 2;
|
187 | 84ceea57 | Edgar E. Iglesias | timer_update_irq(t); |
188 | 5439779e | edgar_igl | } |
189 | 5439779e | edgar_igl | |
190 | 5439779e | edgar_igl | static void watchdog_hit(void *opaque) |
191 | 5439779e | edgar_igl | { |
192 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
193 | 84ceea57 | Edgar E. Iglesias | if (t->wd_hits == 0) { |
194 | 84ceea57 | Edgar E. Iglesias | /* real hw gives a single tick before reseting but we are
|
195 | 84ceea57 | Edgar E. Iglesias | a bit friendlier to compensate for our slower execution. */
|
196 | 84ceea57 | Edgar E. Iglesias | ptimer_set_count(t->ptimer_wd, 10);
|
197 | 84ceea57 | Edgar E. Iglesias | ptimer_run(t->ptimer_wd, 1);
|
198 | 3b1fd90e | Edgar E. Iglesias | qemu_irq_raise(t->nmi); |
199 | 84ceea57 | Edgar E. Iglesias | } |
200 | 84ceea57 | Edgar E. Iglesias | else
|
201 | 84ceea57 | Edgar E. Iglesias | qemu_system_reset_request(); |
202 | 84ceea57 | Edgar E. Iglesias | |
203 | 84ceea57 | Edgar E. Iglesias | t->wd_hits++; |
204 | 5439779e | edgar_igl | } |
205 | 5439779e | edgar_igl | |
206 | 3b1fd90e | Edgar E. Iglesias | static inline void timer_watchdog_update(struct etrax_timer *t, uint32_t value) |
207 | 5439779e | edgar_igl | { |
208 | 84ceea57 | Edgar E. Iglesias | unsigned int wd_en = t->rw_wd_ctrl & (1 << 8); |
209 | 84ceea57 | Edgar E. Iglesias | unsigned int wd_key = t->rw_wd_ctrl >> 9; |
210 | 84ceea57 | Edgar E. Iglesias | unsigned int wd_cnt = t->rw_wd_ctrl & 511; |
211 | 84ceea57 | Edgar E. Iglesias | unsigned int new_key = value >> 9 & ((1 << 7) - 1); |
212 | 84ceea57 | Edgar E. Iglesias | unsigned int new_cmd = (value >> 8) & 1; |
213 | 5439779e | edgar_igl | |
214 | 84ceea57 | Edgar E. Iglesias | /* If the watchdog is enabled, they written key must match the
|
215 | 84ceea57 | Edgar E. Iglesias | complement of the previous. */
|
216 | 84ceea57 | Edgar E. Iglesias | wd_key = ~wd_key & ((1 << 7) - 1); |
217 | 5439779e | edgar_igl | |
218 | 84ceea57 | Edgar E. Iglesias | if (wd_en && wd_key != new_key)
|
219 | 84ceea57 | Edgar E. Iglesias | return;
|
220 | 5439779e | edgar_igl | |
221 | 84ceea57 | Edgar E. Iglesias | D(printf("en=%d new_key=%x oldkey=%x cmd=%d cnt=%d\n",
|
222 | 84ceea57 | Edgar E. Iglesias | wd_en, new_key, wd_key, new_cmd, wd_cnt)); |
223 | 5439779e | edgar_igl | |
224 | 84ceea57 | Edgar E. Iglesias | if (t->wd_hits)
|
225 | 3b1fd90e | Edgar E. Iglesias | qemu_irq_lower(t->nmi); |
226 | 5ef98b47 | edgar_igl | |
227 | 84ceea57 | Edgar E. Iglesias | t->wd_hits = 0;
|
228 | 5ef98b47 | edgar_igl | |
229 | 84ceea57 | Edgar E. Iglesias | ptimer_set_freq(t->ptimer_wd, 760);
|
230 | 84ceea57 | Edgar E. Iglesias | if (wd_cnt == 0) |
231 | 84ceea57 | Edgar E. Iglesias | wd_cnt = 256;
|
232 | 84ceea57 | Edgar E. Iglesias | ptimer_set_count(t->ptimer_wd, wd_cnt); |
233 | 84ceea57 | Edgar E. Iglesias | if (new_cmd)
|
234 | 84ceea57 | Edgar E. Iglesias | ptimer_run(t->ptimer_wd, 1);
|
235 | 84ceea57 | Edgar E. Iglesias | else
|
236 | 84ceea57 | Edgar E. Iglesias | ptimer_stop(t->ptimer_wd); |
237 | 5439779e | edgar_igl | |
238 | 84ceea57 | Edgar E. Iglesias | t->rw_wd_ctrl = value; |
239 | 5439779e | edgar_igl | } |
240 | 5439779e | edgar_igl | |
241 | 83fa1010 | ths | static void |
242 | c227f099 | Anthony Liguori | timer_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
|
243 | 83fa1010 | ths | { |
244 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
245 | 84ceea57 | Edgar E. Iglesias | |
246 | 84ceea57 | Edgar E. Iglesias | switch (addr)
|
247 | 84ceea57 | Edgar E. Iglesias | { |
248 | 84ceea57 | Edgar E. Iglesias | case RW_TMR0_DIV:
|
249 | 84ceea57 | Edgar E. Iglesias | t->rw_tmr0_div = value; |
250 | 84ceea57 | Edgar E. Iglesias | break;
|
251 | 84ceea57 | Edgar E. Iglesias | case RW_TMR0_CTRL:
|
252 | 84ceea57 | Edgar E. Iglesias | D(printf ("RW_TMR0_CTRL=%x\n", value));
|
253 | 84ceea57 | Edgar E. Iglesias | t->rw_tmr0_ctrl = value; |
254 | 84ceea57 | Edgar E. Iglesias | update_ctrl(t, 0);
|
255 | 84ceea57 | Edgar E. Iglesias | break;
|
256 | 84ceea57 | Edgar E. Iglesias | case RW_TMR1_DIV:
|
257 | 84ceea57 | Edgar E. Iglesias | t->rw_tmr1_div = value; |
258 | 84ceea57 | Edgar E. Iglesias | break;
|
259 | 84ceea57 | Edgar E. Iglesias | case RW_TMR1_CTRL:
|
260 | 84ceea57 | Edgar E. Iglesias | D(printf ("RW_TMR1_CTRL=%x\n", value));
|
261 | 84ceea57 | Edgar E. Iglesias | t->rw_tmr1_ctrl = value; |
262 | 84ceea57 | Edgar E. Iglesias | update_ctrl(t, 1);
|
263 | 84ceea57 | Edgar E. Iglesias | break;
|
264 | 84ceea57 | Edgar E. Iglesias | case RW_INTR_MASK:
|
265 | 84ceea57 | Edgar E. Iglesias | D(printf ("RW_INTR_MASK=%x\n", value));
|
266 | 84ceea57 | Edgar E. Iglesias | t->rw_intr_mask = value; |
267 | 84ceea57 | Edgar E. Iglesias | timer_update_irq(t); |
268 | 84ceea57 | Edgar E. Iglesias | break;
|
269 | 84ceea57 | Edgar E. Iglesias | case RW_WD_CTRL:
|
270 | 84ceea57 | Edgar E. Iglesias | timer_watchdog_update(t, value); |
271 | 84ceea57 | Edgar E. Iglesias | break;
|
272 | 84ceea57 | Edgar E. Iglesias | case RW_ACK_INTR:
|
273 | 84ceea57 | Edgar E. Iglesias | t->rw_ack_intr = value; |
274 | 84ceea57 | Edgar E. Iglesias | timer_update_irq(t); |
275 | 84ceea57 | Edgar E. Iglesias | t->rw_ack_intr = 0;
|
276 | 84ceea57 | Edgar E. Iglesias | break;
|
277 | 84ceea57 | Edgar E. Iglesias | default:
|
278 | 84ceea57 | Edgar E. Iglesias | printf ("%s " TARGET_FMT_plx " %x\n", |
279 | 84ceea57 | Edgar E. Iglesias | __func__, addr, value); |
280 | 84ceea57 | Edgar E. Iglesias | break;
|
281 | 84ceea57 | Edgar E. Iglesias | } |
282 | 83fa1010 | ths | } |
283 | 83fa1010 | ths | |
284 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const timer_read[] = { |
285 | 84ceea57 | Edgar E. Iglesias | NULL, NULL, |
286 | 84ceea57 | Edgar E. Iglesias | &timer_readl, |
287 | 83fa1010 | ths | }; |
288 | 83fa1010 | ths | |
289 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const timer_write[] = { |
290 | 84ceea57 | Edgar E. Iglesias | NULL, NULL, |
291 | 84ceea57 | Edgar E. Iglesias | &timer_writel, |
292 | 83fa1010 | ths | }; |
293 | 83fa1010 | ths | |
294 | 5439779e | edgar_igl | static void etraxfs_timer_reset(void *opaque) |
295 | 5439779e | edgar_igl | { |
296 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = opaque;
|
297 | 84ceea57 | Edgar E. Iglesias | |
298 | 84ceea57 | Edgar E. Iglesias | ptimer_stop(t->ptimer_t0); |
299 | 84ceea57 | Edgar E. Iglesias | ptimer_stop(t->ptimer_t1); |
300 | 84ceea57 | Edgar E. Iglesias | ptimer_stop(t->ptimer_wd); |
301 | 84ceea57 | Edgar E. Iglesias | t->rw_wd_ctrl = 0;
|
302 | 84ceea57 | Edgar E. Iglesias | t->r_intr = 0;
|
303 | 84ceea57 | Edgar E. Iglesias | t->rw_intr_mask = 0;
|
304 | 3b1fd90e | Edgar E. Iglesias | qemu_irq_lower(t->irq); |
305 | 5439779e | edgar_igl | } |
306 | 5439779e | edgar_igl | |
307 | 81a322d4 | Gerd Hoffmann | static int etraxfs_timer_init(SysBusDevice *dev) |
308 | 83fa1010 | ths | { |
309 | 3b1fd90e | Edgar E. Iglesias | struct etrax_timer *t = FROM_SYSBUS(typeof (*t), dev);
|
310 | 84ceea57 | Edgar E. Iglesias | int timer_regs;
|
311 | 83fa1010 | ths | |
312 | 84ceea57 | Edgar E. Iglesias | t->bh_t0 = qemu_bh_new(timer0_hit, t); |
313 | 84ceea57 | Edgar E. Iglesias | t->bh_t1 = qemu_bh_new(timer1_hit, t); |
314 | 84ceea57 | Edgar E. Iglesias | t->bh_wd = qemu_bh_new(watchdog_hit, t); |
315 | 84ceea57 | Edgar E. Iglesias | t->ptimer_t0 = ptimer_init(t->bh_t0); |
316 | 84ceea57 | Edgar E. Iglesias | t->ptimer_t1 = ptimer_init(t->bh_t1); |
317 | 84ceea57 | Edgar E. Iglesias | t->ptimer_wd = ptimer_init(t->bh_wd); |
318 | 3b1fd90e | Edgar E. Iglesias | |
319 | 3b1fd90e | Edgar E. Iglesias | sysbus_init_irq(dev, &t->irq); |
320 | 3b1fd90e | Edgar E. Iglesias | sysbus_init_irq(dev, &t->nmi); |
321 | 83fa1010 | ths | |
322 | 2507c12a | Alexander Graf | timer_regs = cpu_register_io_memory(timer_read, timer_write, t, |
323 | 2507c12a | Alexander Graf | DEVICE_NATIVE_ENDIAN); |
324 | 3b1fd90e | Edgar E. Iglesias | sysbus_init_mmio(dev, 0x5c, timer_regs);
|
325 | 5439779e | edgar_igl | |
326 | a08d4367 | Jan Kiszka | qemu_register_reset(etraxfs_timer_reset, t); |
327 | 81a322d4 | Gerd Hoffmann | return 0; |
328 | 83fa1010 | ths | } |
329 | 3b1fd90e | Edgar E. Iglesias | |
330 | 3b1fd90e | Edgar E. Iglesias | static void etraxfs_timer_register(void) |
331 | 3b1fd90e | Edgar E. Iglesias | { |
332 | 3b1fd90e | Edgar E. Iglesias | sysbus_register_dev("etraxfs,timer", sizeof (struct etrax_timer), |
333 | 3b1fd90e | Edgar E. Iglesias | etraxfs_timer_init); |
334 | 3b1fd90e | Edgar E. Iglesias | } |
335 | 3b1fd90e | Edgar E. Iglesias | |
336 | 3b1fd90e | Edgar E. Iglesias | device_init(etraxfs_timer_register) |