Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/marvell From Dave Mills: It would appear that the tw...
details: https://anonhg.NetBSD.org/src/rev/703a6d590287
branches: trunk
changeset: 762917:703a6d590287
user: christos <christos%NetBSD.org@localhost>
date: Sat Mar 05 18:28:13 2011 +0000
description:
>From Dave Mills: It would appear that the two PHYs can only be
accessed from the registers of controller0 (mvgbec0) hence why both
PHYs are being detected on controller0. I have made the assumption
that PHY0 => controller0 (mvgbec0), PHY1 => controller1(mvgbec1)
and developed a patch accordingly. Also the irq is 15 for controller1
not 14.
diffstat:
sys/dev/marvell/if_mvgbe.c | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diffs (116 lines):
diff -r cca39a6c621b -r 703a6d590287 sys/dev/marvell/if_mvgbe.c
--- a/sys/dev/marvell/if_mvgbe.c Sat Mar 05 18:14:55 2011 +0000
+++ b/sys/dev/marvell/if_mvgbe.c Sat Mar 05 18:28:13 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mvgbe.c,v 1.5 2011/02/01 23:40:12 jakllsch Exp $ */
+/* $NetBSD: if_mvgbe.c,v 1.6 2011/03/05 18:28:13 christos Exp $ */
/*
* Copyright (c) 2007, 2008 KIYOHARA Takashi
* All rights reserved.
@@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.5 2011/02/01 23:40:12 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.6 2011/03/05 18:28:13 christos Exp $");
#include "rnd.h"
@@ -184,6 +184,7 @@
struct mvgbec_softc {
device_t sc_dev;
+ int sc_unit;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@@ -277,6 +278,7 @@
CFATTACH_DECL_NEW(mvgbe, sizeof(struct mvgbe_softc),
mvgbe_match, mvgbe_attach, NULL, NULL);
+device_t mvgbec0 = NULL;
struct mvgbe_port {
int model;
@@ -305,7 +307,7 @@
{ MARVELL_KIRKWOOD_88F6192, 0, 1, { 11 }, FLAGS_FIX_TQTB },
{ MARVELL_KIRKWOOD_88F6192, 1, 1, { 14 }, FLAGS_FIX_TQTB },
{ MARVELL_KIRKWOOD_88F6281, 0, 1, { 11 }, FLAGS_FIX_TQTB },
- { MARVELL_KIRKWOOD_88F6281, 1, 1, { 14 }, FLAGS_FIX_TQTB },
+ { MARVELL_KIRKWOOD_88F6281, 1, 1, { 15 }, FLAGS_FIX_TQTB },
{ MARVELL_MV78XX0_MV78100, 0, 1, { 40 }, FLAGS_FIX_TQTB },
{ MARVELL_MV78XX0_MV78100, 1, 1, { 44 }, FLAGS_FIX_TQTB },
@@ -353,11 +355,17 @@
sc->sc_dev = self;
sc->sc_iot = mva->mva_iot;
+ sc->sc_unit = mva->mva_unit;
if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
mva->mva_size, &sc->sc_ioh)) {
aprint_error_dev(self, "Cannot map registers\n");
return;
}
+
+ if (sc->sc_unit == 0) {
+ mvgbec0 = self;
+ }
+
phyaddr = 0;
MVGBE_WRITE(sc, MVGBE_PHYADDR, phyaddr);
@@ -432,11 +440,17 @@
mvgbec_miibus_readreg(device_t dev, int phy, int reg)
{
struct mvgbe_softc *sc = device_private(dev);
- struct mvgbec_softc *csc = device_private(device_parent(dev));
+ struct mvgbec_softc *csc;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
uint32_t smi, val;
int i;
+ if (mvgbec0 == NULL) {
+ aprint_error_ifnet(ifp, "SMI mvgbec0 not found\n");
+ return -1;
+ }
+ csc = device_private(mvgbec0);
+
mutex_enter(&csc->sc_mtx);
for (i = 0; i < MVGBE_PHY_TIMEOUT; i++) {
@@ -478,11 +492,17 @@
mvgbec_miibus_writereg(device_t dev, int phy, int reg, int val)
{
struct mvgbe_softc *sc = device_private(dev);
- struct mvgbec_softc *csc = device_private(device_parent(dev));
+ struct mvgbec_softc *csc;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
uint32_t smi;
int i;
+ if (mvgbec0 == NULL) {
+ aprint_error_ifnet(ifp, "SMI mvgbec0 not found\n");
+ return;
+ }
+ csc = device_private(mvgbec0);
+
DPRINTFN(9, ("mvgbec_miibus_writereg phy=%d reg=%#x val=%#x\n",
phy, reg, val));
@@ -602,6 +622,7 @@
mvgbe_attach(device_t parent, device_t self, void *aux)
{
struct mvgbe_softc *sc = device_private(self);
+ struct mvgbec_softc *csc = device_private(parent);
struct marvell_attach_args *mva = aux;
struct mvgbe_txmap_entry *entry;
struct ifnet *ifp;
@@ -749,7 +770,7 @@
ifmedia_init(&sc->sc_mii.mii_media, 0,
mvgbe_mediachange, mvgbe_mediastatus);
mii_attach(self, &sc->sc_mii, 0xffffffff,
- MII_PHY_ANY, MII_OFFSET_ANY, 0);
+ csc->sc_unit, MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
aprint_error_dev(self, "no PHY found!\n");
ifmedia_add(&sc->sc_mii.mii_media,
Home |
Main Index |
Thread Index |
Old Index