aspeed_timer.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * ASPEED AST2400 Timer
  3. *
  4. * Andrew Jeffery <andrew@aj.id.au>
  5. *
  6. * Copyright (C) 2016 IBM Corp.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef ASPEED_TIMER_H
  23. #define ASPEED_TIMER_H
  24. #include "qemu/timer.h"
  25. typedef struct AspeedSCUState AspeedSCUState;
  26. #define ASPEED_TIMER(obj) \
  27. OBJECT_CHECK(AspeedTimerCtrlState, (obj), TYPE_ASPEED_TIMER);
  28. #define TYPE_ASPEED_TIMER "aspeed.timer"
  29. #define ASPEED_TIMER_NR_TIMERS 8
  30. typedef struct AspeedTimer {
  31. qemu_irq irq;
  32. uint8_t id;
  33. QEMUTimer timer;
  34. /**
  35. * Track the line level as the ASPEED timers implement edge triggered
  36. * interrupts, signalling with both the rising and falling edge.
  37. */
  38. int32_t level;
  39. uint32_t reload;
  40. uint32_t match[2];
  41. uint64_t start;
  42. } AspeedTimer;
  43. typedef struct AspeedTimerCtrlState {
  44. /*< private >*/
  45. SysBusDevice parent;
  46. /*< public >*/
  47. MemoryRegion iomem;
  48. uint32_t ctrl;
  49. uint32_t ctrl2;
  50. AspeedTimer timers[ASPEED_TIMER_NR_TIMERS];
  51. AspeedSCUState *scu;
  52. } AspeedTimerCtrlState;
  53. #endif /* ASPEED_TIMER_H */