]> err.no Git - linux-2.6/blobdiff - arch/powerpc/boot/devtree.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6] / arch / powerpc / boot / devtree.c
index 549463bf5eec2dc978fe56fe702965037b6b221e..5d12336dc3609d9d0cb9df0089f273ffc7fabe77 100644 (file)
@@ -88,29 +88,46 @@ void dt_fixup_clock(const char *path, u32 freq)
        }
 }
 
+void dt_fixup_mac_address_by_alias(const char *alias, const u8 *addr)
+{
+       void *devp = find_node_by_alias(alias);
+
+       if (devp) {
+               printf("%s: local-mac-address <-"
+                      " %02x:%02x:%02x:%02x:%02x:%02x\n\r", alias,
+                      addr[0], addr[1], addr[2],
+                      addr[3], addr[4], addr[5]);
+
+               setprop(devp, "local-mac-address", addr, 6);
+       }
+}
+
+void dt_fixup_mac_address(u32 index, const u8 *addr)
+{
+       void *devp = find_node_by_prop_value(NULL, "linux,network-index",
+                                            (void*)&index, sizeof(index));
+
+       if (devp) {
+               printf("ENET%d: local-mac-address <-"
+                      " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
+                      addr[0], addr[1], addr[2],
+                      addr[3], addr[4], addr[5]);
+
+               setprop(devp, "local-mac-address", addr, 6);
+       }
+}
+
 void __dt_fixup_mac_addresses(u32 startindex, ...)
 {
        va_list ap;
        u32 index = startindex;
-       void *devp;
        const u8 *addr;
 
        va_start(ap, startindex);
-       while ((addr = va_arg(ap, const u8 *))) {
-               devp = find_node_by_prop_value(NULL, "linux,network-index",
-                                              (void*)&index, sizeof(index));
-
-               if (devp) {
-                       printf("ENET%d: local-mac-address <-"
-                              " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
-                              addr[0], addr[1], addr[2],
-                              addr[3], addr[4], addr[5]);
 
-                       setprop(devp, "local-mac-address", addr, 6);
-               }
+       while ((addr = va_arg(ap, const u8 *)))
+               dt_fixup_mac_address(index++, addr);
 
-               index++;
-       }
        va_end(ap);
 }
 
@@ -333,3 +350,23 @@ int dt_is_compatible(void *node, const char *compat)
 
        return 0;
 }
+
+int dt_get_virtual_reg(void *node, void **addr, int nres)
+{
+       unsigned long xaddr;
+       int n;
+
+       n = getprop(node, "virtual-reg", addr, nres * 4);
+       if (n > 0)
+               return n / 4;
+
+       for (n = 0; n < nres; n++) {
+               if (!dt_xlate_reg(node, n, &xaddr, NULL))
+                       break;
+
+               addr[n] = (void *)xaddr;
+       }
+
+       return n;
+}
+