Source-Changes-HG archive

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

[src/trunk]: src/sys Config glue for the Designware GMAC core.



details:   https://anonhg.NetBSD.org/src/rev/dfb2523c196e
branches:  trunk
changeset: 332135:dfb2523c196e
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Sep 08 14:26:16 2014 +0000

description:
Config glue for the Designware GMAC core.
Switch allwinner specific awge driver over to use it.

diffstat:

 sys/arch/arm/allwinner/awin_gige.c |  66 +++++++++++++++++++++++++++++++------
 sys/arch/arm/allwinner/files.awin  |   3 +-
 sys/conf/files                     |   7 +++-
 3 files changed, 61 insertions(+), 15 deletions(-)

diffs (145 lines):

diff -r 87bda593fac9 -r dfb2523c196e sys/arch/arm/allwinner/awin_gige.c
--- a/sys/arch/arm/allwinner/awin_gige.c        Mon Sep 08 14:24:32 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_gige.c        Mon Sep 08 14:26:16 2014 +0000
@@ -1,9 +1,9 @@
 /*-
- * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Matt Thomas of 3am Software Foundry.
+ * by Matt Thomas of 3am Software Foundry and Martin Husemann.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: awin_gige.c,v 1.4 2014/02/26 00:29:23 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_gige.c,v 1.5 2014/09/08 14:26:16 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -42,14 +42,21 @@
 #include <arm/allwinner/awin_reg.h>
 #include <arm/allwinner/awin_var.h>
 
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <dev/mii/miivar.h>
+
+#include <dev/ic/dwc_gmac_var.h>
+
 static int awin_gige_match(device_t, cfdata_t, void *);
 static void awin_gige_attach(device_t, device_t, void *);
+static int awin_gige_intr(void*);
 
 struct awin_gige_softc {
-       device_t sc_dev;
-       bus_space_tag_t sc_bst;
-       bus_space_handle_t sc_bsh;
-       bus_dma_tag_t sc_dmat;
+       struct dwc_gmac_softc sc_core;
+       void *sc_ih;
 };
 
 static const struct awin_gpio_pinset awin_gige_gpio_pinset = {
@@ -85,16 +92,51 @@
        struct awin_gige_softc * const sc = device_private(self);
        struct awinio_attach_args * const aio = aux;
        const struct awin_locators * const loc = &aio->aio_loc;
+       prop_dictionary_t dict;
+       uint8_t enaddr[ETHER_ADDR_LEN], *ep = NULL;
 
-       sc->sc_dev = self;
+       sc->sc_core.sc_dev = self;
+       dict = device_properties(sc->sc_core.sc_dev);
 
        awin_gpio_pinset_acquire(&awin_gige_gpio_pinset);
 
-       sc->sc_bst = aio->aio_core_bst;
-       sc->sc_dmat = aio->aio_dmat;
-       bus_space_subregion(sc->sc_bst, aio->aio_core_bsh,
-           loc->loc_offset, loc->loc_size, &sc->sc_bsh);
+       sc->sc_core.sc_bst = aio->aio_core_bst;
+       sc->sc_core.sc_dmat = aio->aio_dmat;
+       bus_space_subregion(sc->sc_core.sc_bst, aio->aio_core_bsh,
+           loc->loc_offset, loc->loc_size, &sc->sc_core.sc_bsh);
 
        aprint_naive("\n");
        aprint_normal(": Gigabit Ethernet Controller\n");
+       
+       prop_data_t ea = dict ? prop_dictionary_get(dict, "mac-address") : NULL;
+       if (ea != NULL) {
+               KASSERT(prop_object_type(ea) == PROP_TYPE_DATA);
+               KASSERT(prop_data_size(ea) == ETHER_ADDR_LEN);
+               memcpy(enaddr, prop_data_data_nocopy(ea), ETHER_ADDR_LEN);
+               ep = enaddr;
+       }
+
+       /*
+        * Interrupt handler
+        */
+       sc->sc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL|IST_MPSAFE,
+           awin_gige_intr, sc);
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "failed to establish interrupt %d\n",
+                    loc->loc_intr);
+               return;
+       }
+       aprint_normal_dev(self, "interrupting on irq %d\n",
+            loc->loc_intr);
+
+       dwc_gmac_attach(&sc->sc_core, ep);
 }
+
+
+static int
+awin_gige_intr(void *arg)
+{
+       struct awin_gige_softc *sc = arg;
+
+       return dwc_gmac_intr(&sc->sc_core);
+}
diff -r 87bda593fac9 -r dfb2523c196e sys/arch/arm/allwinner/files.awin
--- a/sys/arch/arm/allwinner/files.awin Mon Sep 08 14:24:32 2014 +0000
+++ b/sys/arch/arm/allwinner/files.awin Mon Sep 08 14:26:16 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.awin,v 1.11 2014/09/07 17:49:39 jmcneill Exp $
+#      $NetBSD: files.awin,v 1.12 2014/09/08 14:26:16 martin Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -88,7 +88,6 @@
 file   arch/arm/allwinner/awin_eth.c           awin_eth
 
 # A20 GMAC
-device awge { } : ether, ifnet, arp, mii
 attach awge at awinio with awin_gige
 file   arch/arm/allwinner/awin_gige.c          awin_gige
 
diff -r 87bda593fac9 -r dfb2523c196e sys/conf/files
--- a/sys/conf/files    Mon Sep 08 14:24:32 2014 +0000
+++ b/sys/conf/files    Mon Sep 08 14:26:16 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1102 2014/08/24 20:23:38 joerg Exp $
+#      $NetBSD: files,v 1.1103 2014/09/08 14:26:16 martin Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20140824
@@ -705,6 +705,11 @@
 device gem: arp, ether, ifnet, mii
 file   dev/ic/gem.c                    gem
 
+# Synopsis Designware GMAC core, as found on allwinner a20
+# and other SoCs
+device awge: arp, ether, ifnet, mii
+file   dev/ic/dwc_gmac.c               awge
+
 # 8390-family Ethernet controllers
 #
 defflag        opt_ipkdb.h             IPKDB_DP8390



Home | Main Index | Thread Index | Old Index