Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 2014 06:03:59 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262206 - head/sys/dev/etherswitch/arswitch
Message-ID:  <201402190603.s1J63xK3064155@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Feb 19 06:03:58 2014
New Revision: 262206
URL: http://svnweb.freebsd.org/changeset/base/262206

Log:
  Turn the port init function into a HAL method and initialise it to the
  default port init code.
  
  This needs to be overridden for the AR8327.

Modified:
  head/sys/dev/etherswitch/arswitch/arswitch.c

Modified: head/sys/dev/etherswitch/arswitch/arswitch.c
==============================================================================
--- head/sys/dev/etherswitch/arswitch/arswitch.c	Wed Feb 19 06:02:47 2014	(r262205)
+++ head/sys/dev/etherswitch/arswitch/arswitch.c	Wed Feb 19 06:03:58 2014	(r262206)
@@ -224,7 +224,7 @@ arswitch_set_vlan_mode(struct arswitch_s
 }
 
 static void
-arswitch_port_init(struct arswitch_softc *sc, int port)
+arswitch_port_init_8xxx(struct arswitch_softc *sc, int port)
 {
 
 	/* Port0 - CPU */
@@ -266,6 +266,9 @@ arswitch_attach(device_t dev)
 	strlcpy(sc->info.es_name, device_get_desc(dev),
 	    sizeof(sc->info.es_name));
 
+	/* Default HAL methods */
+	sc->hal.arswitch_port_init = arswitch_port_init_8xxx;
+
 	/*
 	 * Attach switch related functions
 	 */
@@ -320,7 +323,7 @@ arswitch_attach(device_t dev)
 
 	/* Initialize the switch ports. */
 	for (port = 0; port <= sc->numphys; port++) {
-		arswitch_port_init(sc, port);
+		sc->hal.arswitch_port_init(sc, port);
 	}
 
 	/*
@@ -459,8 +462,15 @@ arswitch_miipollstat(struct arswitch_sof
 		if (sc->miibus[i] == NULL)
 			continue;
 		mii = device_get_softc(sc->miibus[i]);
-		portstatus = arswitch_readreg(sc->sc_dev,
-		    AR8X16_REG_PORT_STS(arswitch_portforphy(i)));
+		/* XXX This would be nice to have abstracted out to be per-chip */
+		/* AR8327/AR8337 has a different register base */
+		if (AR8X16_IS_SWITCH(sc, AR8327))
+			portstatus = arswitch_readreg(sc->sc_dev,
+			    AR8327_REG_PORT_STATUS(arswitch_portforphy(i)));
+		else
+			portstatus = arswitch_readreg(sc->sc_dev,
+			    AR8X16_REG_PORT_STS(arswitch_portforphy(i)));
+
 #if 0
 		DPRINTF(sc->sc_dev, "p[%d]=%b\n",
 		    i,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402190603.s1J63xK3064155>