Patchwork [RFC,V1,10/14] xilinx_ethlite: 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-11-git-send-email-peter.crosthwaite@petalogix.com>
Download mbox | patch
Permalink /patch/111478/
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_ethlite.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c
index f35ba84..c06b015 100644
--- a/hw/xilinx_ethlite.c
+++ b/hw/xilinx_ethlite.c
@@ -221,9 +221,11 @@  static int xilinx_ethlite_init(SysBusDevice *dev)
     return 0;
 }
 
+#define QDEV_NAME "xilinx,ethlite"
+
 static SysBusDeviceInfo xilinx_ethlite_info = {
     .init = xilinx_ethlite_init,
-    .qdev.name  = "xilinx,ethlite",
+    .qdev.name  = QDEV_NAME,
     .qdev.size  = sizeof(struct xlx_ethlite),
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("txpingpong", struct xlx_ethlite, c_tx_pingpong, 1),
@@ -239,3 +241,38 @@  static void xilinx_ethlite_register(void)
 }
 
 device_init(xilinx_ethlite_register)
+
+#ifdef CONFIG_FDT
+
+#include "fdt_generic_qdev.h"
+
+static FDTQDevPropMapping *
+xilinx_ethlite_fdt_qdev_map(char *node_path, FDTMachineInfo *fdti)
+{
+    FDTQDevPropMapping *ret = g_malloc0(sizeof(*ret) * 3);
+    struct FDTQDevPropMapping sprops [] = {
+        {
+            .name = "txpingpong",
+            .src.u32 = qemu_devtree_getprop(fdti->fdt, NULL, node_path,
+                                        "xlnx,tx-ping-pong", 0, 0)
+        },{
+            .name = "rxpingpong",
+            .src.u32 = qemu_devtree_getprop(fdti->fdt, NULL, node_path,
+                                        "xlnx,rx-ping-pong", 0, 0)
+        },{
+           .name = NULL
+        }
+    };
+    return memcpy(ret, sprops, sizeof(*ret) * 3);
+}
+
+FDTQDevOps xilinx_ethlite_fdt_qdev_ops = {
+    .dev_name = QDEV_NAME,
+    .is_nic = 1,
+    .map = xilinx_ethlite_fdt_qdev_map,
+};
+
+fdt_qdev_register_compatibility(&xilinx_ethlite_fdt_qdev_ops,
+    "xlnx,xps-ethernetlite-1.00.a");
+
+#endif /*CONFIG_FDT */