Module Name: src
Committed By: martin
Date: Mon Sep 8 14:26:16 UTC 2014
Modified Files:
src/sys/arch/arm/allwinner: awin_gige.c files.awin
src/sys/conf: files
Log Message:
Config glue for the Designware GMAC core.
Switch allwinner specific awge driver over to use it.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_gige.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/files.awin
cvs rdiff -u -r1.1102 -r1.1103 src/sys/conf/files
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/allwinner/awin_gige.c
diff -u src/sys/arch/arm/allwinner/awin_gige.c:1.4 src/sys/arch/arm/allwinner/awin_gige.c:1.5
--- src/sys/arch/arm/allwinner/awin_gige.c:1.4 Wed Feb 26 00:29:23 2014
+++ src/sys/arch/arm/allwinner/awin_gige.c Mon Sep 8 14:26:16 2014
@@ -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 @@ __KERNEL_RCSID(1, "$NetBSD: awin_gige.c,
#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 @@ awin_gige_attach(device_t parent, device
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);
}
Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.11 src/sys/arch/arm/allwinner/files.awin:1.12
--- src/sys/arch/arm/allwinner/files.awin:1.11 Sun Sep 7 17:49:39 2014
+++ src/sys/arch/arm/allwinner/files.awin Mon Sep 8 14:26:16 2014
@@ -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 @@ attach awe at awinio with awin_eth
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
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1102 src/sys/conf/files:1.1103
--- src/sys/conf/files:1.1102 Sun Aug 24 20:23:38 2014
+++ src/sys/conf/files Mon Sep 8 14:26:16 2014
@@ -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 @@ file dev/ic/hme.c hme
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