Skip to contentSkip to conversation

net: emaclite: Support OF initialization

RFC PATCH New Michal Simek 2 participants 3 messages Jun 28, 2012 – Jul 4, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 net: emaclite: Support OF initialization

Support new CONFIG_OF_CONTROL option where device
probing is done based on device tree description.

---
 drivers/net/xilinx_emaclite.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/net/xilinx_emaclite.c +30 -0
index e1af42a..0f6807d 100644
@@ -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
Signature · 1 line
1.7.0.4
#1 lore raw

RFC PATCH 1/1 net: emaclite: Support OF initialization

Hi Michal,

Quoted 39 lines · Michal Simek

Support new CONFIG_OF_CONTROL option where device
probing is done based on device tree description.

---
 drivers/net/xilinx_emaclite.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/net/xilinx_emaclite.c +13 -0
index e1af42a..0f6807d 100644
@@ -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,

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 392

Quoted 2 lines
drivers/net/xilinx_emaclite.c +2 -0
+                                       "xlnx,xps-ethernetlite-1.00.a");
+               if (offset != -1) {

offset > 0 or >= 0

Quoted 14 lines
drivers/net/xilinx_emaclite.c +3 -0
+                       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);

drivers/net/xilinx_emaclite.c +2 -0
+                               ret |= xilinx_emaclite_initialize(bis, reg,
+                                                               txpp,

rxpp);

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 403

Quoted 3 lines
drivers/net/xilinx_emaclite.c +3 -0
+                       }
+               }
+       } while (offset != -1);

Just offset > 0 here I think.

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 407

Quoted 5 lines
drivers/net/xilinx_emaclite.c +4 -0
+
+       return ret;
+}
+#endif

This is fine I think. Do you want to impose an ordering on the interfaces, or are you happy with them being assigned randomly? If you want an ordering, see fdtdec_find_aliases_for_id().

Quoted 4 lines

--
1.7.0.4

Regards,
Simon

#2 lore raw

RFC PATCH 1/1 net: emaclite: Support OF initialization

2012/7/3 Simon Glass <[email protected]>:

Quoted 39 lines

Hi Michal,

Quoted 36 lines · Michal Simek

Support new CONFIG_OF_CONTROL option where device
probing is done based on device tree description.

---
 drivers/net/xilinx_emaclite.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/net/xilinx_emaclite.c +11 -0
index e1af42a..0f6807d 100644
@@ -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;
+
Quoted 8 lines

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 392

Quoted 5 lines
drivers/net/xilinx_emaclite.c +2 -0
+       do {
+               offset = fdt_node_offset_by_compatible(gd->fdt_blob,

offset,

drivers/net/xilinx_emaclite.c +2 -0
+                                       "xlnx,xps-ethernetlite-1.00.a");
+               if (offset != -1) {

offset > 0 or >= 0

ok, probably safer.

Quoted 14 lines
Quoted 14 lines

+ reg = fdtdec_get_addr(gd->fdt_blob, offset,
"reg");

drivers/net/xilinx_emaclite.c +2 -0
+                       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,

Quoted 8 lines

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 403

Quoted 5 lines

+ txpp,
rxpp);

drivers/net/xilinx_emaclite.c +3 -0
+                       }
+               }
+       } while (offset != -1);

Just offset > 0 here I think.

ok.

Quoted 11 lines

drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, · line 407

Quoted 6 lines
drivers/net/xilinx_emaclite.c +4 -0
+
+       return ret;
+}
+#endif

This is fine I think. Do you want to impose an ordering on the interfaces, or are you happy with them being assigned randomly? If you want an ordering, see fdtdec_find_aliases_for_id().

For now, not. for future probably yes.
I have changed uartlite and uart16550 drivers where this is very important.

Thanks,
Michal