2
0

mps2-fpgaio.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * ARM MPS2 FPGAIO emulation
  3. *
  4. * Copyright (c) 2018 Linaro Limited
  5. * Written by Peter Maydell
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 or
  9. * (at your option) any later version.
  10. */
  11. /* This is a model of the FPGAIO register block in the AN505
  12. * FPGA image for the MPS2 dev board; it is documented in the
  13. * application note:
  14. * https://developer.arm.com/documentation/dai0505/latest/
  15. *
  16. * QEMU interface:
  17. * + sysbus MMIO region 0: the register bank
  18. */
  19. #ifndef MPS2_FPGAIO_H
  20. #define MPS2_FPGAIO_H
  21. #include "hw/sysbus.h"
  22. #include "hw/misc/led.h"
  23. #include "qom/object.h"
  24. #define TYPE_MPS2_FPGAIO "mps2-fpgaio"
  25. OBJECT_DECLARE_SIMPLE_TYPE(MPS2FPGAIO, MPS2_FPGAIO)
  26. #define MPS2FPGAIO_MAX_LEDS 32
  27. struct MPS2FPGAIO {
  28. /*< private >*/
  29. SysBusDevice parent_obj;
  30. /*< public >*/
  31. MemoryRegion iomem;
  32. LEDState *led[MPS2FPGAIO_MAX_LEDS];
  33. uint32_t num_leds;
  34. bool has_switches;
  35. uint32_t led0;
  36. uint32_t prescale;
  37. uint32_t misc;
  38. /* QEMU_CLOCK_VIRTUAL time at which counter and pscntr were last synced */
  39. int64_t pscntr_sync_ticks;
  40. /* Values of COUNTER and PSCNTR at time pscntr_sync_ticks */
  41. uint32_t counter;
  42. uint32_t pscntr;
  43. uint32_t prescale_clk;
  44. /* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
  45. int64_t clk1hz_tick_offset;
  46. int64_t clk100hz_tick_offset;
  47. };
  48. #endif