diff options
Diffstat (limited to 'arch/powerpc/kernel/prom_parse.c')
-rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index 12c51e4ad2b4..ea6fd552c7ea 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/pci_regs.h> | 5 | #include <linux/pci_regs.h> |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/ioport.h> | 7 | #include <linux/ioport.h> |
8 | #include <linux/etherdevice.h> | ||
8 | #include <asm/prom.h> | 9 | #include <asm/prom.h> |
9 | #include <asm/pci-bridge.h> | 10 | #include <asm/pci-bridge.h> |
10 | 11 | ||
@@ -1003,3 +1004,42 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq | |||
1003 | return res; | 1004 | return res; |
1004 | } | 1005 | } |
1005 | EXPORT_SYMBOL_GPL(of_irq_map_one); | 1006 | EXPORT_SYMBOL_GPL(of_irq_map_one); |
1007 | |||
1008 | /** | ||
1009 | * Search the device tree for the best MAC address to use. 'mac-address' is | ||
1010 | * checked first, because that is supposed to contain to "most recent" MAC | ||
1011 | * address. If that isn't set, then 'local-mac-address' is checked next, | ||
1012 | * because that is the default address. If that isn't set, then the obsolete | ||
1013 | * 'address' is checked, just in case we're using an old device tree. | ||
1014 | * | ||
1015 | * Note that the 'address' property is supposed to contain a virtual address of | ||
1016 | * the register set, but some DTS files have redefined that property to be the | ||
1017 | * MAC address. | ||
1018 | * | ||
1019 | * All-zero MAC addresses are rejected, because those could be properties that | ||
1020 | * exist in the device tree, but were not set by U-Boot. For example, the | ||
1021 | * DTS could define 'mac-address' and 'local-mac-address', with zero MAC | ||
1022 | * addresses. Some older U-Boots only initialized 'local-mac-address'. In | ||
1023 | * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists | ||
1024 | * but is all zeros. | ||
1025 | */ | ||
1026 | const void *of_get_mac_address(struct device_node *np) | ||
1027 | { | ||
1028 | struct property *pp; | ||
1029 | |||
1030 | pp = of_find_property(np, "mac-address", NULL); | ||
1031 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
1032 | return pp->value; | ||
1033 | |||
1034 | pp = of_find_property(np, "local-mac-address", NULL); | ||
1035 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
1036 | return pp->value; | ||
1037 | |||
1038 | pp = of_find_property(np, "address", NULL); | ||
1039 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
1040 | return pp->value; | ||
1041 | |||
1042 | return NULL; | ||
1043 | } | ||
1044 | EXPORT_SYMBOL(of_get_mac_address); | ||
1045 | |||