aspeed_timer.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "hw/misc/aspeed_scu.h"
  26. #include "qom/object.h"
  27. #define TYPE_ASPEED_TIMER "aspeed.timer"
  28. OBJECT_DECLARE_TYPE(AspeedTimerCtrlState, AspeedTimerClass, ASPEED_TIMER)
  29. #define TYPE_ASPEED_2400_TIMER TYPE_ASPEED_TIMER "-ast2400"
  30. #define TYPE_ASPEED_2500_TIMER TYPE_ASPEED_TIMER "-ast2500"
  31. #define TYPE_ASPEED_2600_TIMER TYPE_ASPEED_TIMER "-ast2600"
  32. #define ASPEED_TIMER_NR_TIMERS 8
  33. typedef struct AspeedTimer {
  34. qemu_irq irq;
  35. uint8_t id;
  36. QEMUTimer timer;
  37. /**
  38. * Track the line level as the ASPEED timers implement edge triggered
  39. * interrupts, signalling with both the rising and falling edge.
  40. */
  41. int32_t level;
  42. uint32_t reload;
  43. uint32_t match[2];
  44. uint64_t start;
  45. } AspeedTimer;
  46. struct AspeedTimerCtrlState {
  47. /*< private >*/
  48. SysBusDevice parent;
  49. /*< public >*/
  50. MemoryRegion iomem;
  51. uint32_t ctrl;
  52. uint32_t ctrl2;
  53. uint32_t ctrl3;
  54. uint32_t irq_sts;
  55. AspeedTimer timers[ASPEED_TIMER_NR_TIMERS];
  56. AspeedSCUState *scu;
  57. };
  58. struct AspeedTimerClass {
  59. SysBusDeviceClass parent_class;
  60. uint64_t (*read)(AspeedTimerCtrlState *s, hwaddr offset);
  61. void (*write)(AspeedTimerCtrlState *s, hwaddr offset, uint64_t value);
  62. };
  63. #endif /* ASPEED_TIMER_H */