xref: /qemu/include/hw/misc/mps2-fpgaio.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
19a52d999SPeter Maydell /*
29a52d999SPeter Maydell  * ARM MPS2 FPGAIO emulation
39a52d999SPeter Maydell  *
49a52d999SPeter Maydell  * Copyright (c) 2018 Linaro Limited
59a52d999SPeter Maydell  * Written by Peter Maydell
69a52d999SPeter Maydell  *
79a52d999SPeter Maydell  *  This program is free software; you can redistribute it and/or modify
89a52d999SPeter Maydell  *  it under the terms of the GNU General Public License version 2 or
99a52d999SPeter Maydell  *  (at your option) any later version.
109a52d999SPeter Maydell  */
119a52d999SPeter Maydell 
129a52d999SPeter Maydell /* This is a model of the FPGAIO register block in the AN505
139a52d999SPeter Maydell  * FPGA image for the MPS2 dev board; it is documented in the
149a52d999SPeter Maydell  * application note:
159a52d999SPeter Maydell  * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html
169a52d999SPeter Maydell  *
179a52d999SPeter Maydell  * QEMU interface:
189a52d999SPeter Maydell  *  + sysbus MMIO region 0: the register bank
199a52d999SPeter Maydell  */
209a52d999SPeter Maydell 
219a52d999SPeter Maydell #ifndef MPS2_FPGAIO_H
229a52d999SPeter Maydell #define MPS2_FPGAIO_H
239a52d999SPeter Maydell 
249a52d999SPeter Maydell #include "hw/sysbus.h"
25*db1015e9SEduardo Habkost #include "qom/object.h"
269a52d999SPeter Maydell 
279a52d999SPeter Maydell #define TYPE_MPS2_FPGAIO "mps2-fpgaio"
28*db1015e9SEduardo Habkost typedef struct MPS2FPGAIO MPS2FPGAIO;
299a52d999SPeter Maydell #define MPS2_FPGAIO(obj) OBJECT_CHECK(MPS2FPGAIO, (obj), TYPE_MPS2_FPGAIO)
309a52d999SPeter Maydell 
31*db1015e9SEduardo Habkost struct MPS2FPGAIO {
329a52d999SPeter Maydell     /*< private >*/
339a52d999SPeter Maydell     SysBusDevice parent_obj;
349a52d999SPeter Maydell 
359a52d999SPeter Maydell     /*< public >*/
369a52d999SPeter Maydell     MemoryRegion iomem;
379a52d999SPeter Maydell 
389a52d999SPeter Maydell     uint32_t led0;
399a52d999SPeter Maydell     uint32_t prescale;
409a52d999SPeter Maydell     uint32_t misc;
419a52d999SPeter Maydell 
4293739075SPeter Maydell     /* QEMU_CLOCK_VIRTUAL time at which counter and pscntr were last synced */
4393739075SPeter Maydell     int64_t pscntr_sync_ticks;
4493739075SPeter Maydell     /* Values of COUNTER and PSCNTR at time pscntr_sync_ticks */
4593739075SPeter Maydell     uint32_t counter;
4693739075SPeter Maydell     uint32_t pscntr;
4793739075SPeter Maydell 
489a52d999SPeter Maydell     uint32_t prescale_clk;
49a1982f90SPeter Maydell 
50a1982f90SPeter Maydell     /* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
51a1982f90SPeter Maydell     int64_t clk1hz_tick_offset;
52a1982f90SPeter Maydell     int64_t clk100hz_tick_offset;
53*db1015e9SEduardo Habkost };
549a52d999SPeter Maydell 
559a52d999SPeter Maydell #endif
56