diff mbox

[U-Boot,4/5] net: emaclite: Support OF initialization

Message ID 1340955478-22251-4-git-send-email-monstr@monstr.eu
State Accepted
Delegated to: Joe Hershberger
Headers show

Commit Message

Michal Simek June 29, 2012, 7:37 a.m. UTC
Support new CONFIG_OF_CONTROL option where device
probing is done based on device tree description.

Signed-off-by: Michal Simek <monstr@monstr.eu>
CC: Joe Hershberger <joe.hershberger@gmail.com>
---
 drivers/net/xilinx_emaclite.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

Comments

Joe Hershberger Sept. 28, 2012, 3:52 p.m. UTC | #1
Hi Michal,

On Fri, Jun 29, 2012 at 2:37 AM, Michal Simek <monstr@monstr.eu> wrote:
> Support new CONFIG_OF_CONTROL option where device
> probing is done based on device tree description.
>
> Signed-off-by: Michal Simek <monstr@monstr.eu>
> CC: Joe Hershberger <joe.hershberger@gmail.com>
> ---

Applied, thanks.

-Joe
diff mbox

Patch

diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index d5bd737..d890d60 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -28,6 +28,9 @@ 
 #include <config.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <fdtdec.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 #undef DEBUG
 
@@ -375,3 +378,30 @@  int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr,
 
 	return 1;
 }
+
+#ifdef CONFIG_OF_CONTROL
+int xilinx_emaclite_init(bd_t *bis)
+{
+	int offset = 0;
+	u32 ret = 0;
+	u32 reg;
+
+	do {
+		offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
+					"xlnx,xps-ethernetlite-1.00.a");
+		if (offset != -1) {
+			reg = fdtdec_get_addr(gd->fdt_blob, offset, "reg");
+			if (reg != FDT_ADDR_T_NONE) {
+				u32 rxpp = fdtdec_get_int(gd->fdt_blob, offset,
+							"xlnx,rx-ping-pong", 0);
+				u32 txpp = fdtdec_get_int(gd->fdt_blob, offset,
+							"xlnx,tx-ping-pong", 0);
+				ret |= xilinx_emaclite_initialize(bis, reg,
+								txpp, rxpp);
+			}
+		}
+	} while (offset != -1);
+
+	return ret;
+}
+#endif