2016-06-26 15:22:25 +02:00
|
|
|
/** Timer related helper functions
|
|
|
|
*
|
|
|
|
* These functions present a simpler interface to Xilinx' Timer Counter driver (XTmrCtr_*)
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, Steffen Vogel
|
2016-06-26 15:22:25 +02:00
|
|
|
**********************************************************************************/
|
|
|
|
|
2016-07-18 15:09:49 +02:00
|
|
|
#include "config.h"
|
2017-02-12 14:35:05 -03:00
|
|
|
#include "plugin.h"
|
2016-06-26 15:22:25 +02:00
|
|
|
|
|
|
|
#include "fpga/ip.h"
|
2017-02-18 10:43:58 -05:00
|
|
|
#include "fpga/card.h"
|
|
|
|
#include "fpga/ips/timer.h"
|
2016-06-26 15:22:25 +02:00
|
|
|
|
2017-03-25 21:13:07 +01:00
|
|
|
int timer_start(struct fpga_ip *c)
|
2016-06-26 15:22:25 +02:00
|
|
|
{
|
2017-02-18 10:43:58 -05:00
|
|
|
struct fpga_card *f = c->card;
|
2017-03-27 12:58:40 +02:00
|
|
|
struct timer *tmr = c->_vd;
|
2016-06-26 15:22:25 +02:00
|
|
|
|
|
|
|
XTmrCtr *xtmr = &tmr->inst;
|
|
|
|
XTmrCtr_Config xtmr_cfg = {
|
|
|
|
.BaseAddress = (uintptr_t) f->map + c->baseaddr,
|
2016-07-18 15:09:49 +02:00
|
|
|
.SysClockFreqHz = FPGA_AXI_HZ
|
2016-06-26 15:22:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
XTmrCtr_CfgInitialize(xtmr, &xtmr_cfg, (uintptr_t) f->map + c->baseaddr);
|
|
|
|
XTmrCtr_InitHw(xtmr);
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2016-06-26 15:22:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-12 14:35:05 -03:00
|
|
|
static struct plugin p = {
|
|
|
|
.name = "Xilinx's programmable timer / counter",
|
|
|
|
.description = "",
|
|
|
|
.type = PLUGIN_TYPE_FPGA_IP,
|
|
|
|
.ip = {
|
2017-02-18 10:43:58 -05:00
|
|
|
.vlnv = { "xilinx.com", "ip", "axi_timer", NULL },
|
|
|
|
.type = FPGA_IP_TYPE_MISC,
|
2017-03-25 21:13:07 +01:00
|
|
|
.start = timer_start,
|
2017-03-25 21:10:25 +01:00
|
|
|
.size = sizeof(struct timer)
|
2017-02-12 14:35:05 -03:00
|
|
|
}
|
2016-06-26 15:22:25 +02:00
|
|
|
};
|
|
|
|
|
2017-02-12 14:35:05 -03:00
|
|
|
REGISTER_PLUGIN(&p)
|