Patchwork [RFC,V1,08/14] xilinx_timer: Added fdt_generic platform support

login
register
mail settings
Submitter Peter A. G. Crosthwaite
Date Aug. 25, 2011, 6:41 a.m.
Message ID <1314254480-22438-9-git-send-email-peter.crosthwaite@petalogix.com>
Download mbox | patch
Permalink /patch/111479/
State New
Headers show

Comments

Peter A. G. Crosthwaite - Aug. 25, 2011, 6:41 a.m.
Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 hw/xilinx_timer.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c
index f1c7abc..8fe32f6 100644
--- a/hw/xilinx_timer.c
+++ b/hw/xilinx_timer.c
@@ -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 */