]> git.proxmox.com Git - qemu.git/blame - hw/timer/pxa2xx_timer.c
Merge git://github.com/hw-claudio/qemu-aarch64-queue into tcg-next
[qemu.git] / hw / timer / pxa2xx_timer.c
CommitLineData
a171fe39
AZ
1/*
2 * Intel XScale PXA255/270 OS Timers.
3 *
4 * Copyright (c) 2006 Openedhand Ltd.
5 * Copyright (c) 2006 Thorsten Zitterell
6 *
8e31bf38 7 * This code is licensed under the GPL.
a171fe39
AZ
8 */
9
83c9f4ca 10#include "hw/hw.h"
1de7afc9 11#include "qemu/timer.h"
9c17d615 12#include "sysemu/sysemu.h"
0d09e41a 13#include "hw/arm/pxa.h"
83c9f4ca 14#include "hw/sysbus.h"
a171fe39
AZ
15
16#define OSMR0 0x00
17#define OSMR1 0x04
18#define OSMR2 0x08
19#define OSMR3 0x0c
20#define OSMR4 0x80
21#define OSMR5 0x84
22#define OSMR6 0x88
23#define OSMR7 0x8c
24#define OSMR8 0x90
25#define OSMR9 0x94
26#define OSMR10 0x98
27#define OSMR11 0x9c
28#define OSCR 0x10 /* OS Timer Count */
29#define OSCR4 0x40
30#define OSCR5 0x44
31#define OSCR6 0x48
32#define OSCR7 0x4c
33#define OSCR8 0x50
34#define OSCR9 0x54
35#define OSCR10 0x58
36#define OSCR11 0x5c
37#define OSSR 0x14 /* Timer status register */
38#define OWER 0x18
39#define OIER 0x1c /* Interrupt enable register 3-0 to E3-E0 */
40#define OMCR4 0xc0 /* OS Match Control registers */
41#define OMCR5 0xc4
42#define OMCR6 0xc8
43#define OMCR7 0xcc
44#define OMCR8 0xd0
45#define OMCR9 0xd4
46#define OMCR10 0xd8
47#define OMCR11 0xdc
48#define OSNR 0x20
49
50#define PXA25X_FREQ 3686400 /* 3.6864 MHz */
51#define PXA27X_FREQ 3250000 /* 3.25 MHz */
52
53static int pxa2xx_timer4_freq[8] = {
54 [0] = 0,
55 [1] = 32768,
56 [2] = 1000,
57 [3] = 1,
58 [4] = 1000000,
59 /* [5] is the "Externally supplied clock". Assign if necessary. */
60 [5 ... 7] = 0,
61};
62
797e9542
DES
63typedef struct PXA2xxTimerInfo PXA2xxTimerInfo;
64
bc24a225 65typedef struct {
a171fe39 66 uint32_t value;
5251d196 67 qemu_irq irq;
a171fe39
AZ
68 QEMUTimer *qtimer;
69 int num;
797e9542 70 PXA2xxTimerInfo *info;
bc24a225 71} PXA2xxTimer0;
a171fe39 72
bc24a225
PB
73typedef struct {
74 PXA2xxTimer0 tm;
a171fe39
AZ
75 int32_t oldclock;
76 int32_t clock;
77 uint64_t lastload;
78 uint32_t freq;
79 uint32_t control;
bc24a225 80} PXA2xxTimer4;
a171fe39 81
797e9542
DES
82struct PXA2xxTimerInfo {
83 SysBusDevice busdev;
b755bde3 84 MemoryRegion iomem;
797e9542
DES
85 uint32_t flags;
86
a171fe39
AZ
87 int32_t clock;
88 int32_t oldclock;
89 uint64_t lastload;
90 uint32_t freq;
bc24a225 91 PXA2xxTimer0 timer[4];
a171fe39
AZ
92 uint32_t events;
93 uint32_t irq_enabled;
94 uint32_t reset3;
a171fe39 95 uint32_t snapshot;
797e9542 96
4ff927cc 97 qemu_irq irq4;
797e9542 98 PXA2xxTimer4 tm4[8];
797e9542
DES
99};
100
101#define PXA2XX_TIMER_HAVE_TM4 0
102
103static inline int pxa2xx_timer_has_tm4(PXA2xxTimerInfo *s)
104{
105 return s->flags & (1 << PXA2XX_TIMER_HAVE_TM4);
106}
a171fe39
AZ
107
108static void pxa2xx_timer_update(void *opaque, uint64_t now_qemu)
109{
d353eb43 110 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
a171fe39
AZ
111 int i;
112 uint32_t now_vm;
113 uint64_t new_qemu;
114
115 now_vm = s->clock +
6ee093c9 116 muldiv64(now_qemu - s->lastload, s->freq, get_ticks_per_sec());
a171fe39
AZ
117
118 for (i = 0; i < 4; i ++) {
119 new_qemu = now_qemu + muldiv64((uint32_t) (s->timer[i].value - now_vm),
6ee093c9 120 get_ticks_per_sec(), s->freq);
a171fe39
AZ
121 qemu_mod_timer(s->timer[i].qtimer, new_qemu);
122 }
123}
124
125static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n)
126{
d353eb43 127 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
a171fe39
AZ
128 uint32_t now_vm;
129 uint64_t new_qemu;
130 static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 };
131 int counter;
132
133 if (s->tm4[n].control & (1 << 7))
134 counter = n;
135 else
136 counter = counters[n];
137
138 if (!s->tm4[counter].freq) {
3f582262 139 qemu_del_timer(s->tm4[n].tm.qtimer);
a171fe39
AZ
140 return;
141 }
142
143 now_vm = s->tm4[counter].clock + muldiv64(now_qemu -
144 s->tm4[counter].lastload,
6ee093c9 145 s->tm4[counter].freq, get_ticks_per_sec());
a171fe39 146
3bdd58a4 147 new_qemu = now_qemu + muldiv64((uint32_t) (s->tm4[n].tm.value - now_vm),
6ee093c9 148 get_ticks_per_sec(), s->tm4[counter].freq);
3f582262 149 qemu_mod_timer(s->tm4[n].tm.qtimer, new_qemu);
a171fe39
AZ
150}
151
a8170e5e 152static uint64_t pxa2xx_timer_read(void *opaque, hwaddr offset,
b755bde3 153 unsigned size)
a171fe39 154{
d353eb43 155 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
a171fe39
AZ
156 int tm = 0;
157
a171fe39
AZ
158 switch (offset) {
159 case OSMR3: tm ++;
de16017d 160 /* fall through */
a171fe39 161 case OSMR2: tm ++;
de16017d 162 /* fall through */
a171fe39 163 case OSMR1: tm ++;
de16017d 164 /* fall through */
a171fe39
AZ
165 case OSMR0:
166 return s->timer[tm].value;
167 case OSMR11: tm ++;
de16017d 168 /* fall through */
a171fe39 169 case OSMR10: tm ++;
de16017d 170 /* fall through */
a171fe39 171 case OSMR9: tm ++;
de16017d 172 /* fall through */
a171fe39 173 case OSMR8: tm ++;
de16017d 174 /* fall through */
a171fe39 175 case OSMR7: tm ++;
de16017d 176 /* fall through */
a171fe39 177 case OSMR6: tm ++;
de16017d 178 /* fall through */
a171fe39 179 case OSMR5: tm ++;
de16017d 180 /* fall through */
a171fe39 181 case OSMR4:
797e9542 182 if (!pxa2xx_timer_has_tm4(s))
a171fe39 183 goto badreg;
3bdd58a4 184 return s->tm4[tm].tm.value;
a171fe39 185 case OSCR:
74475455 186 return s->clock + muldiv64(qemu_get_clock_ns(vm_clock) -
6ee093c9 187 s->lastload, s->freq, get_ticks_per_sec());
a171fe39 188 case OSCR11: tm ++;
de16017d 189 /* fall through */
a171fe39 190 case OSCR10: tm ++;
de16017d 191 /* fall through */
a171fe39 192 case OSCR9: tm ++;
de16017d 193 /* fall through */
a171fe39 194 case OSCR8: tm ++;
de16017d 195 /* fall through */
a171fe39 196 case OSCR7: tm ++;
de16017d 197 /* fall through */
a171fe39 198 case OSCR6: tm ++;
de16017d 199 /* fall through */
a171fe39 200 case OSCR5: tm ++;
de16017d 201 /* fall through */
a171fe39 202 case OSCR4:
797e9542 203 if (!pxa2xx_timer_has_tm4(s))
a171fe39
AZ
204 goto badreg;
205
206 if ((tm == 9 - 4 || tm == 11 - 4) && (s->tm4[tm].control & (1 << 9))) {
207 if (s->tm4[tm - 1].freq)
208 s->snapshot = s->tm4[tm - 1].clock + muldiv64(
74475455 209 qemu_get_clock_ns(vm_clock) -
a171fe39 210 s->tm4[tm - 1].lastload,
6ee093c9 211 s->tm4[tm - 1].freq, get_ticks_per_sec());
a171fe39
AZ
212 else
213 s->snapshot = s->tm4[tm - 1].clock;
214 }
215
216 if (!s->tm4[tm].freq)
217 return s->tm4[tm].clock;
74475455 218 return s->tm4[tm].clock + muldiv64(qemu_get_clock_ns(vm_clock) -
6ee093c9 219 s->tm4[tm].lastload, s->tm4[tm].freq, get_ticks_per_sec());
a171fe39
AZ
220 case OIER:
221 return s->irq_enabled;
222 case OSSR: /* Status register */
223 return s->events;
224 case OWER:
225 return s->reset3;
226 case OMCR11: tm ++;
de16017d 227 /* fall through */
a171fe39 228 case OMCR10: tm ++;
de16017d 229 /* fall through */
a171fe39 230 case OMCR9: tm ++;
de16017d 231 /* fall through */
a171fe39 232 case OMCR8: tm ++;
de16017d 233 /* fall through */
a171fe39 234 case OMCR7: tm ++;
de16017d 235 /* fall through */
a171fe39 236 case OMCR6: tm ++;
de16017d 237 /* fall through */
a171fe39 238 case OMCR5: tm ++;
de16017d 239 /* fall through */
a171fe39 240 case OMCR4:
797e9542 241 if (!pxa2xx_timer_has_tm4(s))
a171fe39
AZ
242 goto badreg;
243 return s->tm4[tm].control;
244 case OSNR:
245 return s->snapshot;
246 default:
247 badreg:
2ac71179 248 hw_error("pxa2xx_timer_read: Bad offset " REG_FMT "\n", offset);
a171fe39
AZ
249 }
250
251 return 0;
252}
253
a8170e5e 254static void pxa2xx_timer_write(void *opaque, hwaddr offset,
b755bde3 255 uint64_t value, unsigned size)
a171fe39
AZ
256{
257 int i, tm = 0;
d353eb43 258 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
a171fe39 259
a171fe39
AZ
260 switch (offset) {
261 case OSMR3: tm ++;
de16017d 262 /* fall through */
a171fe39 263 case OSMR2: tm ++;
de16017d 264 /* fall through */
a171fe39 265 case OSMR1: tm ++;
de16017d 266 /* fall through */
a171fe39
AZ
267 case OSMR0:
268 s->timer[tm].value = value;
74475455 269 pxa2xx_timer_update(s, qemu_get_clock_ns(vm_clock));
a171fe39
AZ
270 break;
271 case OSMR11: tm ++;
de16017d 272 /* fall through */
a171fe39 273 case OSMR10: tm ++;
de16017d 274 /* fall through */
a171fe39 275 case OSMR9: tm ++;
de16017d 276 /* fall through */
a171fe39 277 case OSMR8: tm ++;
de16017d 278 /* fall through */
a171fe39 279 case OSMR7: tm ++;
de16017d 280 /* fall through */
a171fe39 281 case OSMR6: tm ++;
de16017d 282 /* fall through */
a171fe39 283 case OSMR5: tm ++;
de16017d 284 /* fall through */
a171fe39 285 case OSMR4:
797e9542 286 if (!pxa2xx_timer_has_tm4(s))
a171fe39 287 goto badreg;
3bdd58a4 288 s->tm4[tm].tm.value = value;
74475455 289 pxa2xx_timer_update4(s, qemu_get_clock_ns(vm_clock), tm);
a171fe39
AZ
290 break;
291 case OSCR:
292 s->oldclock = s->clock;
74475455 293 s->lastload = qemu_get_clock_ns(vm_clock);
a171fe39
AZ
294 s->clock = value;
295 pxa2xx_timer_update(s, s->lastload);
296 break;
297 case OSCR11: tm ++;
de16017d 298 /* fall through */
a171fe39 299 case OSCR10: tm ++;
de16017d 300 /* fall through */
a171fe39 301 case OSCR9: tm ++;
de16017d 302 /* fall through */
a171fe39 303 case OSCR8: tm ++;
de16017d 304 /* fall through */
a171fe39 305 case OSCR7: tm ++;
de16017d 306 /* fall through */
a171fe39 307 case OSCR6: tm ++;
de16017d 308 /* fall through */
a171fe39 309 case OSCR5: tm ++;
de16017d 310 /* fall through */
a171fe39 311 case OSCR4:
797e9542 312 if (!pxa2xx_timer_has_tm4(s))
a171fe39
AZ
313 goto badreg;
314 s->tm4[tm].oldclock = s->tm4[tm].clock;
74475455 315 s->tm4[tm].lastload = qemu_get_clock_ns(vm_clock);
a171fe39
AZ
316 s->tm4[tm].clock = value;
317 pxa2xx_timer_update4(s, s->tm4[tm].lastload, tm);
318 break;
319 case OIER:
320 s->irq_enabled = value & 0xfff;
321 break;
322 case OSSR: /* Status register */
8034ce7d 323 value &= s->events;
a171fe39 324 s->events &= ~value;
8034ce7d
AZ
325 for (i = 0; i < 4; i ++, value >>= 1)
326 if (value & 1)
5251d196 327 qemu_irq_lower(s->timer[i].irq);
8034ce7d
AZ
328 if (pxa2xx_timer_has_tm4(s) && !(s->events & 0xff0) && value)
329 qemu_irq_lower(s->irq4);
a171fe39
AZ
330 break;
331 case OWER: /* XXX: Reset on OSMR3 match? */
332 s->reset3 = value;
333 break;
334 case OMCR7: tm ++;
de16017d 335 /* fall through */
a171fe39 336 case OMCR6: tm ++;
de16017d 337 /* fall through */
a171fe39 338 case OMCR5: tm ++;
de16017d 339 /* fall through */
a171fe39 340 case OMCR4:
797e9542 341 if (!pxa2xx_timer_has_tm4(s))
a171fe39
AZ
342 goto badreg;
343 s->tm4[tm].control = value & 0x0ff;
344 /* XXX Stop if running (shouldn't happen) */
345 if ((value & (1 << 7)) || tm == 0)
346 s->tm4[tm].freq = pxa2xx_timer4_freq[value & 7];
347 else {
348 s->tm4[tm].freq = 0;
74475455 349 pxa2xx_timer_update4(s, qemu_get_clock_ns(vm_clock), tm);
a171fe39
AZ
350 }
351 break;
352 case OMCR11: tm ++;
de16017d 353 /* fall through */
a171fe39 354 case OMCR10: tm ++;
de16017d 355 /* fall through */
a171fe39 356 case OMCR9: tm ++;
de16017d 357 /* fall through */
a171fe39 358 case OMCR8: tm += 4;
797e9542 359 if (!pxa2xx_timer_has_tm4(s))
a171fe39
AZ
360 goto badreg;
361 s->tm4[tm].control = value & 0x3ff;
362 /* XXX Stop if running (shouldn't happen) */
363 if ((value & (1 << 7)) || !(tm & 1))
364 s->tm4[tm].freq =
365 pxa2xx_timer4_freq[(value & (1 << 8)) ? 0 : (value & 7)];
366 else {
367 s->tm4[tm].freq = 0;
74475455 368 pxa2xx_timer_update4(s, qemu_get_clock_ns(vm_clock), tm);
a171fe39
AZ
369 }
370 break;
371 default:
372 badreg:
2ac71179 373 hw_error("pxa2xx_timer_write: Bad offset " REG_FMT "\n", offset);
a171fe39
AZ
374 }
375}
376
b755bde3
BC
377static const MemoryRegionOps pxa2xx_timer_ops = {
378 .read = pxa2xx_timer_read,
379 .write = pxa2xx_timer_write,
380 .endianness = DEVICE_NATIVE_ENDIAN,
a171fe39
AZ
381};
382
383static void pxa2xx_timer_tick(void *opaque)
384{
bc24a225 385 PXA2xxTimer0 *t = (PXA2xxTimer0 *) opaque;
797e9542 386 PXA2xxTimerInfo *i = t->info;
a171fe39
AZ
387
388 if (i->irq_enabled & (1 << t->num)) {
a171fe39 389 i->events |= 1 << t->num;
5251d196 390 qemu_irq_raise(t->irq);
a171fe39
AZ
391 }
392
393 if (t->num == 3)
394 if (i->reset3 & 1) {
395 i->reset3 = 0;
3f582262 396 qemu_system_reset_request();
a171fe39
AZ
397 }
398}
399
400static void pxa2xx_timer_tick4(void *opaque)
401{
bc24a225 402 PXA2xxTimer4 *t = (PXA2xxTimer4 *) opaque;
d353eb43 403 PXA2xxTimerInfo *i = (PXA2xxTimerInfo *) t->tm.info;
a171fe39 404
3bdd58a4 405 pxa2xx_timer_tick(&t->tm);
a171fe39
AZ
406 if (t->control & (1 << 3))
407 t->clock = 0;
408 if (t->control & (1 << 6))
74475455 409 pxa2xx_timer_update4(i, qemu_get_clock_ns(vm_clock), t->tm.num - 4);
4ff927cc
DES
410 if (i->events & 0xff0)
411 qemu_irq_raise(i->irq4);
a171fe39
AZ
412}
413
797e9542 414static int pxa25x_timer_post_load(void *opaque, int version_id)
aa941b94 415{
d353eb43 416 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
aa941b94
AZ
417 int64_t now;
418 int i;
419
74475455 420 now = qemu_get_clock_ns(vm_clock);
aa941b94
AZ
421 pxa2xx_timer_update(s, now);
422
797e9542
DES
423 if (pxa2xx_timer_has_tm4(s))
424 for (i = 0; i < 8; i ++)
aa941b94 425 pxa2xx_timer_update4(s, now, i);
aa941b94
AZ
426
427 return 0;
428}
429
797e9542 430static int pxa2xx_timer_init(SysBusDevice *dev)
a171fe39
AZ
431{
432 int i;
d353eb43 433 PXA2xxTimerInfo *s;
a171fe39 434
797e9542 435 s = FROM_SYSBUS(PXA2xxTimerInfo, dev);
a171fe39
AZ
436 s->irq_enabled = 0;
437 s->oldclock = 0;
438 s->clock = 0;
74475455 439 s->lastload = qemu_get_clock_ns(vm_clock);
a171fe39 440 s->reset3 = 0;
a171fe39
AZ
441
442 for (i = 0; i < 4; i ++) {
443 s->timer[i].value = 0;
5251d196 444 sysbus_init_irq(dev, &s->timer[i].irq);
a171fe39
AZ
445 s->timer[i].info = s;
446 s->timer[i].num = i;
74475455 447 s->timer[i].qtimer = qemu_new_timer_ns(vm_clock,
a171fe39
AZ
448 pxa2xx_timer_tick, &s->timer[i]);
449 }
797e9542 450 if (s->flags & (1 << PXA2XX_TIMER_HAVE_TM4)) {
4ff927cc 451 sysbus_init_irq(dev, &s->irq4);
797e9542
DES
452
453 for (i = 0; i < 8; i ++) {
454 s->tm4[i].tm.value = 0;
455 s->tm4[i].tm.info = s;
456 s->tm4[i].tm.num = i + 4;
797e9542
DES
457 s->tm4[i].freq = 0;
458 s->tm4[i].control = 0x0;
74475455 459 s->tm4[i].tm.qtimer = qemu_new_timer_ns(vm_clock,
797e9542
DES
460 pxa2xx_timer_tick4, &s->tm4[i]);
461 }
462 }
a171fe39 463
853dca12 464 memory_region_init_io(&s->iomem, OBJECT(s), &pxa2xx_timer_ops, s,
b755bde3 465 "pxa2xx-timer", 0x00001000);
750ecd44 466 sysbus_init_mmio(dev, &s->iomem);
aa941b94 467
797e9542 468 return 0;
a171fe39
AZ
469}
470
797e9542
DES
471static const VMStateDescription vmstate_pxa2xx_timer0_regs = {
472 .name = "pxa2xx_timer0",
8034ce7d
AZ
473 .version_id = 2,
474 .minimum_version_id = 2,
475 .minimum_version_id_old = 2,
797e9542
DES
476 .fields = (VMStateField[]) {
477 VMSTATE_UINT32(value, PXA2xxTimer0),
797e9542
DES
478 VMSTATE_END_OF_LIST(),
479 },
480};
481
482static const VMStateDescription vmstate_pxa2xx_timer4_regs = {
483 .name = "pxa2xx_timer4",
484 .version_id = 1,
485 .minimum_version_id = 1,
486 .minimum_version_id_old = 1,
487 .fields = (VMStateField[]) {
488 VMSTATE_STRUCT(tm, PXA2xxTimer4, 1,
489 vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
490 VMSTATE_INT32(oldclock, PXA2xxTimer4),
491 VMSTATE_INT32(clock, PXA2xxTimer4),
492 VMSTATE_UINT64(lastload, PXA2xxTimer4),
493 VMSTATE_UINT32(freq, PXA2xxTimer4),
494 VMSTATE_UINT32(control, PXA2xxTimer4),
495 VMSTATE_END_OF_LIST(),
496 },
497};
498
499static bool pxa2xx_timer_has_tm4_test(void *opaque, int version_id)
a171fe39 500{
797e9542 501 return pxa2xx_timer_has_tm4(opaque);
a171fe39
AZ
502}
503
797e9542
DES
504static const VMStateDescription vmstate_pxa2xx_timer_regs = {
505 .name = "pxa2xx_timer",
506 .version_id = 1,
507 .minimum_version_id = 1,
508 .minimum_version_id_old = 1,
509 .post_load = pxa25x_timer_post_load,
510 .fields = (VMStateField[]) {
511 VMSTATE_INT32(clock, PXA2xxTimerInfo),
512 VMSTATE_INT32(oldclock, PXA2xxTimerInfo),
513 VMSTATE_UINT64(lastload, PXA2xxTimerInfo),
514 VMSTATE_STRUCT_ARRAY(timer, PXA2xxTimerInfo, 4, 1,
515 vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
516 VMSTATE_UINT32(events, PXA2xxTimerInfo),
517 VMSTATE_UINT32(irq_enabled, PXA2xxTimerInfo),
518 VMSTATE_UINT32(reset3, PXA2xxTimerInfo),
519 VMSTATE_UINT32(snapshot, PXA2xxTimerInfo),
520 VMSTATE_STRUCT_ARRAY_TEST(tm4, PXA2xxTimerInfo, 8,
521 pxa2xx_timer_has_tm4_test, 0,
522 vmstate_pxa2xx_timer4_regs, PXA2xxTimer4),
523 VMSTATE_END_OF_LIST(),
a171fe39 524 }
797e9542
DES
525};
526
999e12bb
AL
527static Property pxa25x_timer_dev_properties[] = {
528 DEFINE_PROP_UINT32("freq", PXA2xxTimerInfo, freq, PXA25X_FREQ),
529 DEFINE_PROP_BIT("tm4", PXA2xxTimerInfo, flags,
530 PXA2XX_TIMER_HAVE_TM4, false),
531 DEFINE_PROP_END_OF_LIST(),
797e9542
DES
532};
533
999e12bb
AL
534static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data)
535{
39bffca2 536 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb
AL
537 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
538
539 k->init = pxa2xx_timer_init;
39bffca2
AL
540 dc->desc = "PXA25x timer";
541 dc->vmsd = &vmstate_pxa2xx_timer_regs;
542 dc->props = pxa25x_timer_dev_properties;
999e12bb
AL
543}
544
8c43a6f0 545static const TypeInfo pxa25x_timer_dev_info = {
39bffca2
AL
546 .name = "pxa25x-timer",
547 .parent = TYPE_SYS_BUS_DEVICE,
548 .instance_size = sizeof(PXA2xxTimerInfo),
549 .class_init = pxa25x_timer_dev_class_init,
999e12bb
AL
550};
551
552static Property pxa27x_timer_dev_properties[] = {
553 DEFINE_PROP_UINT32("freq", PXA2xxTimerInfo, freq, PXA27X_FREQ),
554 DEFINE_PROP_BIT("tm4", PXA2xxTimerInfo, flags,
555 PXA2XX_TIMER_HAVE_TM4, true),
556 DEFINE_PROP_END_OF_LIST(),
557};
558
559static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data)
560{
39bffca2 561 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb
AL
562 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
563
564 k->init = pxa2xx_timer_init;
39bffca2
AL
565 dc->desc = "PXA27x timer";
566 dc->vmsd = &vmstate_pxa2xx_timer_regs;
567 dc->props = pxa27x_timer_dev_properties;
999e12bb
AL
568}
569
8c43a6f0 570static const TypeInfo pxa27x_timer_dev_info = {
39bffca2
AL
571 .name = "pxa27x-timer",
572 .parent = TYPE_SYS_BUS_DEVICE,
573 .instance_size = sizeof(PXA2xxTimerInfo),
574 .class_init = pxa27x_timer_dev_class_init,
797e9542
DES
575};
576
83f7d43a 577static void pxa2xx_timer_register_types(void)
797e9542 578{
39bffca2
AL
579 type_register_static(&pxa25x_timer_dev_info);
580 type_register_static(&pxa27x_timer_dev_info);
83f7d43a
AF
581}
582
583type_init(pxa2xx_timer_register_types)