Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/fdt Match smsc, lan9115 and honour local-mac-add...



details:   https://anonhg.NetBSD.org/src/rev/41054e7b16f9
branches:  trunk
changeset: 465057:41054e7b16f9
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Nov 03 12:06:32 2019 +0000

description:
Match smsc,lan9115 and honour local-mac-address/mac-address properties

diffstat:

 sys/arch/arm/fdt/smsh_fdt.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 1da690f9834b -r 41054e7b16f9 sys/arch/arm/fdt/smsh_fdt.c
--- a/sys/arch/arm/fdt/smsh_fdt.c       Sun Nov 03 12:03:35 2019 +0000
+++ b/sys/arch/arm/fdt/smsh_fdt.c       Sun Nov 03 12:06:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $ */
+/* $NetBSD: smsh_fdt.c,v 1.2 2019/11/03 12:06:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v 1.2 2019/11/03 12:06:32 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -49,7 +49,11 @@
 static int     smsh_fdt_match(device_t, cfdata_t, void *);
 static void    smsh_fdt_attach(device_t, device_t, void *);
 
-static const char * const compatible[] = { "smsc,lan9118", NULL };
+static const char * const compatible[] = {
+       "smsc,lan9118",
+       "smsc,lan9115",
+       NULL
+};
 
 CFATTACH_DECL_NEW(smsh_fdt, sizeof(struct lan9118_softc),
        smsh_fdt_match, smsh_fdt_attach, NULL, NULL);
@@ -67,10 +71,12 @@
 {
        struct lan9118_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
+       const int phandle = faa->faa_phandle;
+       const char *enaddr;
        char intrstr[128];
-       const int phandle = faa->faa_phandle;
        bus_addr_t addr;
        bus_size_t size;
+       int len;
        void *ih;
 
        if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
@@ -95,6 +101,14 @@
        if (of_hasprop(phandle, "smsc,irq-push-pull"))
                sc->sc_flags |= LAN9118_FLAGS_IRQ_PP;
 
+       enaddr = fdtbus_get_prop(phandle, "local-mac-address", &len);
+       if (enaddr == NULL || len != ETHER_ADDR_LEN)
+               enaddr = fdtbus_get_prop(phandle, "mac-address", &len);
+       if (enaddr != NULL && len == ETHER_ADDR_LEN) {
+               memcpy(sc->sc_enaddr, enaddr, ETHER_ADDR_LEN);
+               sc->sc_flags |= LAN9118_FLAGS_NO_EEPROM;
+       }
+
        if (lan9118_attach(sc) != 0)
                goto unmap;
 



Home | Main Index | Thread Index | Old Index