migration: move wait-unplug loop to its own function
[qemu/kevin.git] / hw / timer / aspeed_timer.c
blob42c47d2ce64aecc4833e18a7661dde5676e664f9
1 /*
2 * ASPEED AST2400 Timer
4 * Andrew Jeffery <andrew@aj.id.au>
6 * Copyright (C) 2016 IBM Corp.
8 * This code is licensed under the GPL version 2 or later. See
9 * the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "qapi/error.h"
14 #include "hw/irq.h"
15 #include "hw/sysbus.h"
16 #include "hw/timer/aspeed_timer.h"
17 #include "migration/vmstate.h"
18 #include "qemu/bitops.h"
19 #include "qemu/timer.h"
20 #include "qemu/log.h"
21 #include "qemu/module.h"
22 #include "hw/qdev-properties.h"
23 #include "trace.h"
25 #define TIMER_NR_REGS 4
27 #define TIMER_CTRL_BITS 4
28 #define TIMER_CTRL_MASK ((1 << TIMER_CTRL_BITS) - 1)
30 #define TIMER_CLOCK_USE_EXT true
31 #define TIMER_CLOCK_EXT_HZ 1000000
32 #define TIMER_CLOCK_USE_APB false
34 #define TIMER_REG_STATUS 0
35 #define TIMER_REG_RELOAD 1
36 #define TIMER_REG_MATCH_FIRST 2
37 #define TIMER_REG_MATCH_SECOND 3
39 #define TIMER_FIRST_CAP_PULSE 4
41 enum timer_ctrl_op {
42 op_enable = 0,
43 op_external_clock,
44 op_overflow_interrupt,
45 op_pulse_enable
49 * Minimum value of the reload register to filter out short period
50 * timers which have a noticeable impact in emulation. 5us should be
51 * enough, use 20us for "safety".
53 #define TIMER_MIN_NS (20 * SCALE_US)
55 /**
56 * Avoid mutual references between AspeedTimerCtrlState and AspeedTimer
57 * structs, as it's a waste of memory. The ptimer BH callback needs to know
58 * whether a specific AspeedTimer is enabled, but this information is held in
59 * AspeedTimerCtrlState. So, provide a helper to hoist ourselves from an
60 * arbitrary AspeedTimer to AspeedTimerCtrlState.
62 static inline AspeedTimerCtrlState *timer_to_ctrl(AspeedTimer *t)
64 const AspeedTimer (*timers)[] = (void *)t - (t->id * sizeof(*t));
65 return container_of(timers, AspeedTimerCtrlState, timers);
68 static inline bool timer_ctrl_status(AspeedTimer *t, enum timer_ctrl_op op)
70 return !!(timer_to_ctrl(t)->ctrl & BIT(t->id * TIMER_CTRL_BITS + op));
73 static inline bool timer_enabled(AspeedTimer *t)
75 return timer_ctrl_status(t, op_enable);
78 static inline bool timer_overflow_interrupt(AspeedTimer *t)
80 return timer_ctrl_status(t, op_overflow_interrupt);
83 static inline bool timer_can_pulse(AspeedTimer *t)
85 return t->id >= TIMER_FIRST_CAP_PULSE;
88 static inline bool timer_external_clock(AspeedTimer *t)
90 return timer_ctrl_status(t, op_external_clock);
93 static inline uint32_t calculate_rate(struct AspeedTimer *t)
95 AspeedTimerCtrlState *s = timer_to_ctrl(t);
97 return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ :
98 aspeed_scu_get_apb_freq(s->scu);
101 static inline uint32_t calculate_ticks(struct AspeedTimer *t, uint64_t now_ns)
103 uint64_t delta_ns = now_ns - MIN(now_ns, t->start);
104 uint32_t rate = calculate_rate(t);
105 uint64_t ticks = muldiv64(delta_ns, rate, NANOSECONDS_PER_SECOND);
107 return t->reload - MIN(t->reload, ticks);
110 static uint32_t calculate_min_ticks(AspeedTimer *t, uint32_t value)
112 uint32_t rate = calculate_rate(t);
113 uint32_t min_ticks = muldiv64(TIMER_MIN_NS, rate, NANOSECONDS_PER_SECOND);
115 return value < min_ticks ? min_ticks : value;
118 static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
120 uint64_t delta_ns;
121 uint64_t delta_ticks;
123 delta_ticks = t->reload - MIN(t->reload, ticks);
124 delta_ns = muldiv64(delta_ticks, NANOSECONDS_PER_SECOND, calculate_rate(t));
126 return t->start + delta_ns;
129 static inline uint32_t calculate_match(struct AspeedTimer *t, int i)
131 return t->match[i] < t->reload ? t->match[i] : 0;
134 static uint64_t calculate_next(struct AspeedTimer *t)
136 uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
137 uint64_t next;
140 * We don't know the relationship between the values in the match
141 * registers, so sort using MAX/MIN/zero. We sort in that order as
142 * the timer counts down to zero.
145 next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1)));
146 if (now < next) {
147 return next;
150 next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1)));
151 if (now < next) {
152 return next;
155 next = calculate_time(t, 0);
156 if (now < next) {
157 return next;
160 /* We've missed all deadlines, fire interrupt and try again */
161 timer_del(&t->timer);
163 if (timer_overflow_interrupt(t)) {
164 AspeedTimerCtrlState *s = timer_to_ctrl(t);
165 t->level = !t->level;
166 s->irq_sts |= BIT(t->id);
167 qemu_set_irq(t->irq, t->level);
170 next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
171 t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
173 return calculate_time(t, next);
176 static void aspeed_timer_mod(AspeedTimer *t)
178 uint64_t next = calculate_next(t);
179 if (next) {
180 timer_mod(&t->timer, next);
184 static void aspeed_timer_expire(void *opaque)
186 AspeedTimer *t = opaque;
187 bool interrupt = false;
188 uint32_t ticks;
190 if (!timer_enabled(t)) {
191 return;
194 ticks = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
196 if (!ticks) {
197 interrupt = timer_overflow_interrupt(t) || !t->match[0] || !t->match[1];
198 } else if (ticks <= MIN(t->match[0], t->match[1])) {
199 interrupt = true;
200 } else if (ticks <= MAX(t->match[0], t->match[1])) {
201 interrupt = true;
204 if (interrupt) {
205 AspeedTimerCtrlState *s = timer_to_ctrl(t);
206 t->level = !t->level;
207 s->irq_sts |= BIT(t->id);
208 qemu_set_irq(t->irq, t->level);
211 aspeed_timer_mod(t);
214 static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg)
216 uint64_t value;
218 switch (reg) {
219 case TIMER_REG_STATUS:
220 if (timer_enabled(t)) {
221 value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
222 } else {
223 value = t->reload;
225 break;
226 case TIMER_REG_RELOAD:
227 value = t->reload;
228 break;
229 case TIMER_REG_MATCH_FIRST:
230 case TIMER_REG_MATCH_SECOND:
231 value = t->match[reg - 2];
232 break;
233 default:
234 qemu_log_mask(LOG_UNIMP, "%s: Programming error: unexpected reg: %d\n",
235 __func__, reg);
236 value = 0;
237 break;
239 return value;
242 static uint64_t aspeed_timer_read(void *opaque, hwaddr offset, unsigned size)
244 AspeedTimerCtrlState *s = opaque;
245 const int reg = (offset & 0xf) / 4;
246 uint64_t value;
248 switch (offset) {
249 case 0x30: /* Control Register */
250 value = s->ctrl;
251 break;
252 case 0x00 ... 0x2c: /* Timers 1 - 4 */
253 value = aspeed_timer_get_value(&s->timers[(offset >> 4)], reg);
254 break;
255 case 0x40 ... 0x8c: /* Timers 5 - 8 */
256 value = aspeed_timer_get_value(&s->timers[(offset >> 4) - 1], reg);
257 break;
258 default:
259 value = ASPEED_TIMER_GET_CLASS(s)->read(s, offset);
260 break;
262 trace_aspeed_timer_read(offset, size, value);
263 return value;
266 static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
267 uint32_t value)
269 AspeedTimer *t;
270 uint32_t old_reload;
272 trace_aspeed_timer_set_value(timer, reg, value);
273 t = &s->timers[timer];
274 switch (reg) {
275 case TIMER_REG_RELOAD:
276 old_reload = t->reload;
277 t->reload = calculate_min_ticks(t, value);
279 /* If the reload value was not previously set, or zero, and
280 * the current value is valid, try to start the timer if it is
281 * enabled.
283 if (old_reload || !t->reload) {
284 break;
286 /* fall through to re-enable */
287 case TIMER_REG_STATUS:
288 if (timer_enabled(t)) {
289 uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
290 int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now);
291 uint32_t rate = calculate_rate(t);
293 if (delta >= 0) {
294 t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
295 } else {
296 t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate);
298 aspeed_timer_mod(t);
300 break;
301 case TIMER_REG_MATCH_FIRST:
302 case TIMER_REG_MATCH_SECOND:
303 t->match[reg - 2] = value;
304 if (timer_enabled(t)) {
305 aspeed_timer_mod(t);
307 break;
308 default:
309 qemu_log_mask(LOG_UNIMP, "%s: Programming error: unexpected reg: %d\n",
310 __func__, reg);
311 break;
315 /* Control register operations are broken out into helpers that can be
316 * explicitly called on aspeed_timer_reset(), but also from
317 * aspeed_timer_ctrl_op().
320 static void aspeed_timer_ctrl_enable(AspeedTimer *t, bool enable)
322 trace_aspeed_timer_ctrl_enable(t->id, enable);
323 if (enable) {
324 t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
325 aspeed_timer_mod(t);
326 } else {
327 timer_del(&t->timer);
331 static void aspeed_timer_ctrl_external_clock(AspeedTimer *t, bool enable)
333 trace_aspeed_timer_ctrl_external_clock(t->id, enable);
336 static void aspeed_timer_ctrl_overflow_interrupt(AspeedTimer *t, bool enable)
338 trace_aspeed_timer_ctrl_overflow_interrupt(t->id, enable);
341 static void aspeed_timer_ctrl_pulse_enable(AspeedTimer *t, bool enable)
343 if (timer_can_pulse(t)) {
344 trace_aspeed_timer_ctrl_pulse_enable(t->id, enable);
345 } else {
346 qemu_log_mask(LOG_GUEST_ERROR,
347 "%s: Timer does not support pulse mode\n", __func__);
352 * Given the actions are fixed in number and completely described in helper
353 * functions, dispatch with a lookup table rather than manage control flow with
354 * a switch statement.
356 static void (*const ctrl_ops[])(AspeedTimer *, bool) = {
357 [op_enable] = aspeed_timer_ctrl_enable,
358 [op_external_clock] = aspeed_timer_ctrl_external_clock,
359 [op_overflow_interrupt] = aspeed_timer_ctrl_overflow_interrupt,
360 [op_pulse_enable] = aspeed_timer_ctrl_pulse_enable,
364 * Conditionally affect changes chosen by a timer's control bit.
366 * The aspeed_timer_ctrl_op() interface is convenient for the
367 * aspeed_timer_set_ctrl() function as the "no change" early exit can be
368 * calculated for all operations, which cleans up the caller code. However the
369 * interface isn't convenient for the reset function where we want to enter a
370 * specific state without artificially constructing old and new values that
371 * will fall through the change guard (and motivates extracting the actions
372 * out to helper functions).
374 * @t: The timer to manipulate
375 * @op: The type of operation to be performed
376 * @old: The old state of the timer's control bits
377 * @new: The incoming state for the timer's control bits
379 static void aspeed_timer_ctrl_op(AspeedTimer *t, enum timer_ctrl_op op,
380 uint8_t old, uint8_t new)
382 const uint8_t mask = BIT(op);
383 const bool enable = !!(new & mask);
384 const bool changed = ((old ^ new) & mask);
385 if (!changed) {
386 return;
388 ctrl_ops[op](t, enable);
391 static void aspeed_timer_set_ctrl(AspeedTimerCtrlState *s, uint32_t reg)
393 int i;
394 int shift;
395 uint8_t t_old, t_new;
396 AspeedTimer *t;
397 const uint8_t enable_mask = BIT(op_enable);
399 /* Handle a dependency between the 'enable' and remaining three
400 * configuration bits - i.e. if more than one bit in the control set has
401 * changed, including the 'enable' bit, then we want either disable the
402 * timer and perform configuration, or perform configuration and then
403 * enable the timer
405 for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
406 t = &s->timers[i];
407 shift = (i * TIMER_CTRL_BITS);
408 t_old = (s->ctrl >> shift) & TIMER_CTRL_MASK;
409 t_new = (reg >> shift) & TIMER_CTRL_MASK;
411 /* If we are disabling, do so first */
412 if ((t_old & enable_mask) && !(t_new & enable_mask)) {
413 aspeed_timer_ctrl_enable(t, false);
415 aspeed_timer_ctrl_op(t, op_external_clock, t_old, t_new);
416 aspeed_timer_ctrl_op(t, op_overflow_interrupt, t_old, t_new);
417 aspeed_timer_ctrl_op(t, op_pulse_enable, t_old, t_new);
418 /* If we are enabling, do so last */
419 if (!(t_old & enable_mask) && (t_new & enable_mask)) {
420 aspeed_timer_ctrl_enable(t, true);
423 s->ctrl = reg;
426 static void aspeed_timer_set_ctrl2(AspeedTimerCtrlState *s, uint32_t value)
428 trace_aspeed_timer_set_ctrl2(value);
431 static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t value,
432 unsigned size)
434 const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
435 const int reg = (offset & 0xf) / 4;
436 AspeedTimerCtrlState *s = opaque;
438 switch (offset) {
439 /* Control Registers */
440 case 0x30:
441 aspeed_timer_set_ctrl(s, tv);
442 break;
443 /* Timer Registers */
444 case 0x00 ... 0x2c:
445 aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS), reg, tv);
446 break;
447 case 0x40 ... 0x8c:
448 aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS) - 1, reg, tv);
449 break;
450 default:
451 ASPEED_TIMER_GET_CLASS(s)->write(s, offset, value);
452 break;
456 static const MemoryRegionOps aspeed_timer_ops = {
457 .read = aspeed_timer_read,
458 .write = aspeed_timer_write,
459 .endianness = DEVICE_LITTLE_ENDIAN,
460 .valid.min_access_size = 4,
461 .valid.max_access_size = 4,
462 .valid.unaligned = false,
465 static uint64_t aspeed_2400_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
467 uint64_t value;
469 switch (offset) {
470 case 0x34:
471 value = s->ctrl2;
472 break;
473 case 0x38:
474 case 0x3C:
475 default:
476 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
477 __func__, offset);
478 value = 0;
479 break;
481 return value;
484 static void aspeed_2400_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
485 uint64_t value)
487 const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
489 switch (offset) {
490 case 0x34:
491 aspeed_timer_set_ctrl2(s, tv);
492 break;
493 case 0x38:
494 case 0x3C:
495 default:
496 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
497 __func__, offset);
498 break;
502 static uint64_t aspeed_2500_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
504 uint64_t value;
506 switch (offset) {
507 case 0x34:
508 value = s->ctrl2;
509 break;
510 case 0x38:
511 value = s->ctrl3 & BIT(0);
512 break;
513 case 0x3C:
514 default:
515 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
516 __func__, offset);
517 value = 0;
518 break;
520 return value;
523 static void aspeed_2500_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
524 uint64_t value)
526 const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
527 uint8_t command;
529 switch (offset) {
530 case 0x34:
531 aspeed_timer_set_ctrl2(s, tv);
532 break;
533 case 0x38:
534 command = (value >> 1) & 0xFF;
535 if (command == 0xAE) {
536 s->ctrl3 = 0x1;
537 } else if (command == 0xEA) {
538 s->ctrl3 = 0x0;
540 break;
541 case 0x3C:
542 if (s->ctrl3 & BIT(0)) {
543 aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
545 break;
547 default:
548 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
549 __func__, offset);
550 break;
554 static uint64_t aspeed_2600_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
556 uint64_t value;
558 switch (offset) {
559 case 0x34:
560 value = s->irq_sts;
561 break;
562 case 0x38:
563 case 0x3C:
564 default:
565 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
566 __func__, offset);
567 value = 0;
568 break;
570 return value;
573 static void aspeed_2600_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
574 uint64_t value)
576 const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
578 switch (offset) {
579 case 0x34:
580 s->irq_sts &= tv;
581 break;
582 case 0x3C:
583 aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
584 break;
586 case 0x38:
587 default:
588 qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
589 __func__, offset);
590 break;
594 static void aspeed_init_one_timer(AspeedTimerCtrlState *s, uint8_t id)
596 AspeedTimer *t = &s->timers[id];
598 t->id = id;
599 timer_init_ns(&t->timer, QEMU_CLOCK_VIRTUAL, aspeed_timer_expire, t);
602 static void aspeed_timer_realize(DeviceState *dev, Error **errp)
604 int i;
605 SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
606 AspeedTimerCtrlState *s = ASPEED_TIMER(dev);
608 assert(s->scu);
610 for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
611 aspeed_init_one_timer(s, i);
612 sysbus_init_irq(sbd, &s->timers[i].irq);
614 memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_timer_ops, s,
615 TYPE_ASPEED_TIMER, 0x1000);
616 sysbus_init_mmio(sbd, &s->iomem);
619 static void aspeed_timer_reset(DeviceState *dev)
621 int i;
622 AspeedTimerCtrlState *s = ASPEED_TIMER(dev);
624 for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
625 AspeedTimer *t = &s->timers[i];
626 /* Explicitly call helpers to avoid any conditional behaviour through
627 * aspeed_timer_set_ctrl().
629 aspeed_timer_ctrl_enable(t, false);
630 aspeed_timer_ctrl_external_clock(t, TIMER_CLOCK_USE_APB);
631 aspeed_timer_ctrl_overflow_interrupt(t, false);
632 aspeed_timer_ctrl_pulse_enable(t, false);
633 t->level = 0;
634 t->reload = 0;
635 t->match[0] = 0;
636 t->match[1] = 0;
638 s->ctrl = 0;
639 s->ctrl2 = 0;
640 s->ctrl3 = 0;
641 s->irq_sts = 0;
644 static const VMStateDescription vmstate_aspeed_timer = {
645 .name = "aspeed.timer",
646 .version_id = 2,
647 .minimum_version_id = 2,
648 .fields = (VMStateField[]) {
649 VMSTATE_UINT8(id, AspeedTimer),
650 VMSTATE_INT32(level, AspeedTimer),
651 VMSTATE_TIMER(timer, AspeedTimer),
652 VMSTATE_UINT32(reload, AspeedTimer),
653 VMSTATE_UINT32_ARRAY(match, AspeedTimer, 2),
654 VMSTATE_END_OF_LIST()
658 static const VMStateDescription vmstate_aspeed_timer_state = {
659 .name = "aspeed.timerctrl",
660 .version_id = 2,
661 .minimum_version_id = 2,
662 .fields = (VMStateField[]) {
663 VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
664 VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),
665 VMSTATE_UINT32(ctrl3, AspeedTimerCtrlState),
666 VMSTATE_UINT32(irq_sts, AspeedTimerCtrlState),
667 VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState,
668 ASPEED_TIMER_NR_TIMERS, 1, vmstate_aspeed_timer,
669 AspeedTimer),
670 VMSTATE_END_OF_LIST()
674 static Property aspeed_timer_properties[] = {
675 DEFINE_PROP_LINK("scu", AspeedTimerCtrlState, scu, TYPE_ASPEED_SCU,
676 AspeedSCUState *),
677 DEFINE_PROP_END_OF_LIST(),
680 static void timer_class_init(ObjectClass *klass, void *data)
682 DeviceClass *dc = DEVICE_CLASS(klass);
684 dc->realize = aspeed_timer_realize;
685 dc->reset = aspeed_timer_reset;
686 dc->desc = "ASPEED Timer";
687 dc->vmsd = &vmstate_aspeed_timer_state;
688 device_class_set_props(dc, aspeed_timer_properties);
691 static const TypeInfo aspeed_timer_info = {
692 .name = TYPE_ASPEED_TIMER,
693 .parent = TYPE_SYS_BUS_DEVICE,
694 .instance_size = sizeof(AspeedTimerCtrlState),
695 .class_init = timer_class_init,
696 .class_size = sizeof(AspeedTimerClass),
697 .abstract = true,
700 static void aspeed_2400_timer_class_init(ObjectClass *klass, void *data)
702 DeviceClass *dc = DEVICE_CLASS(klass);
703 AspeedTimerClass *awc = ASPEED_TIMER_CLASS(klass);
705 dc->desc = "ASPEED 2400 Timer";
706 awc->read = aspeed_2400_timer_read;
707 awc->write = aspeed_2400_timer_write;
710 static const TypeInfo aspeed_2400_timer_info = {
711 .name = TYPE_ASPEED_2400_TIMER,
712 .parent = TYPE_ASPEED_TIMER,
713 .class_init = aspeed_2400_timer_class_init,
716 static void aspeed_2500_timer_class_init(ObjectClass *klass, void *data)
718 DeviceClass *dc = DEVICE_CLASS(klass);
719 AspeedTimerClass *awc = ASPEED_TIMER_CLASS(klass);
721 dc->desc = "ASPEED 2500 Timer";
722 awc->read = aspeed_2500_timer_read;
723 awc->write = aspeed_2500_timer_write;
726 static const TypeInfo aspeed_2500_timer_info = {
727 .name = TYPE_ASPEED_2500_TIMER,
728 .parent = TYPE_ASPEED_TIMER,
729 .class_init = aspeed_2500_timer_class_init,
732 static void aspeed_2600_timer_class_init(ObjectClass *klass, void *data)
734 DeviceClass *dc = DEVICE_CLASS(klass);
735 AspeedTimerClass *awc = ASPEED_TIMER_CLASS(klass);
737 dc->desc = "ASPEED 2600 Timer";
738 awc->read = aspeed_2600_timer_read;
739 awc->write = aspeed_2600_timer_write;
742 static const TypeInfo aspeed_2600_timer_info = {
743 .name = TYPE_ASPEED_2600_TIMER,
744 .parent = TYPE_ASPEED_TIMER,
745 .class_init = aspeed_2600_timer_class_init,
748 static void aspeed_timer_register_types(void)
750 type_register_static(&aspeed_timer_info);
751 type_register_static(&aspeed_2400_timer_info);
752 type_register_static(&aspeed_2500_timer_info);
753 type_register_static(&aspeed_2600_timer_info);
756 type_init(aspeed_timer_register_types)