@@ -215,9 +215,11 @@ static int xilinx_timer_init(SysBusDevice *dev)
return 0;
}
+#define QDEV_NAME "xilinx,timer"
+
static SysBusDeviceInfo xilinx_timer_info = {
.init = xilinx_timer_init,
- .qdev.name = "xilinx,timer",
+ .qdev.name = QDEV_NAME,
.qdev.size = sizeof(struct timerblock),
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("frequency", struct timerblock, freq_hz, 0),
@@ -232,3 +234,38 @@ static void xilinx_timer_register(void)
}
device_init(xilinx_timer_register)
+
+#ifdef CONFIG_FDT
+
+#include "fdt_generic_qdev.h"
+
+#define FREQ_HZ (62 * 1000000)
+
+static FDTQDevPropMapping *
+xilinx_timer_fdt_qdev_map(char *node_path, FDTMachineInfo *fdti)
+{
+ FDTQDevPropMapping *ret = g_malloc0(sizeof(*ret) * 3);
+ struct FDTQDevPropMapping sprops [] = {
+ {
+ .name = "frequency",
+ .src.u32 = FREQ_HZ
+ },{
+ .name = "nr-timers",
+ .src.u32 = 2 - qemu_devtree_getprop(fdti->fdt, NULL, node_path,
+ "xlnx,one-timer-only", 0, 0)
+ },{
+ .name = NULL
+ }
+ };
+ return memcpy(ret, sprops, sizeof(*ret) * 3);
+}
+
+FDTQDevOps xilinx_timer_fdt_qdev_ops = {
+ .dev_name = QDEV_NAME,
+ .map = xilinx_timer_fdt_qdev_map,
+};
+
+fdt_qdev_register_compatibility(&xilinx_timer_fdt_qdev_ops,
+ "xlnx,xps-timer-1.00.a");
+
+#endif /* CONFIG_FDT */
Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com> --- hw/xilinx_timer.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-)