Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/xilinx Inherit MAC address from Devicetree "loc...



details:   https://anonhg.NetBSD.org/src/rev/fe9511b60392
branches:  trunk
changeset: 372040:fe9511b60392
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Oct 26 11:31:11 2022 +0000

description:
Inherit MAC address from Devicetree "local-mac-address" property.

diffstat:

 sys/arch/arm/xilinx/zynq_cemac.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r f952b20a27a5 -r fe9511b60392 sys/arch/arm/xilinx/zynq_cemac.c
--- a/sys/arch/arm/xilinx/zynq_cemac.c  Wed Oct 26 10:55:23 2022 +0000
+++ b/sys/arch/arm/xilinx/zynq_cemac.c  Wed Oct 26 11:31:11 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $  */
+/*     $NetBSD: zynq_cemac.c,v 1.4 2022/10/26 11:31:11 jmcneill Exp $  */
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.4 2022/10/26 11:31:11 jmcneill Exp $");
 
 #include "opt_soc.h"
 
@@ -41,6 +41,8 @@
 #include <dev/cadence/cemacreg.h>
 #include <dev/cadence/if_cemacvar.h>
 
+#include <net/if_ether.h>
+
 #include <dev/fdt/fdtvar.h>
 
 static const struct device_compatible_entry compat_data[] = {
@@ -61,11 +63,13 @@
 {
        struct fdt_attach_args * const faa = aux;
        const int phandle = faa->faa_phandle;
+       prop_dictionary_t prop = device_properties(self);
        bus_space_handle_t ioh;
        char intrstr[128];
+       const char *macaddr;
        bus_addr_t addr;
        bus_size_t size;
-       int error;
+       int error, len;
 
        if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
                aprint_error(": couldn't get registers\n");
@@ -90,6 +94,11 @@
                return;
        }
 
+       macaddr = fdtbus_get_prop(phandle, "local-mac-address", &len);
+       if (macaddr != NULL && len == ETHER_ADDR_LEN) {
+               prop_dictionary_set_data(prop, "mac-address", macaddr, len);
+       }
+
        cemac_attach_common(self, faa->faa_bst, ioh, faa->faa_dmat, CEMAC_FLAG_GEM);
        aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 }



Home | Main Index | Thread Index | Old Index