bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore/*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * CDDL HEADER START
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * The contents of this file are subject to the terms of the
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Common Development and Distribution License (the "License").
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * You may not use this file except in compliance with the License.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * or http://www.opensolaris.org/os/licensing.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * See the License for the specific language governing permissions
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * and limitations under the License.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * If applicable, add the following below this CDDL HEADER, with the
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner]
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * CDDL HEADER END
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore/*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Use is subject to license terms.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore/*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * MII overrides for Intel PHYs.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/types.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/ddi.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/sunddi.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/cmn_err.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/note.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/mii.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/miiregs.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include "miipriv.h"
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#define MII_82555_SPCL_CONTROL MII_VENDOR(1)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#define I82555_AUTOPOL_DIS (1<<4)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore/*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * The older 82555 code in iprb had a bunch of workarounds to deal
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * with chip errata surrounding (I believe) autonegotiation problems
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * with the 82555 and long cables.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * I can't find any evidence in current Linux, NetBSD, or FreeBSD
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * sources for the same kinds of workarounds for this PHY, so I'm
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * going to operate on the belief that these workarounds are simply
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * not necessary. Without access to the errata for these parts, as
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * well as parts that exhibit the problems, I can't be certain that
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * such workarounds will work properly. So I'm leaving them out for
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * now. I believe that the errata were mostly problems for 10 Mbps
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * links which are very hard to find anymore, anyway.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorestatic int
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorei82555_start(phy_handle_t *ph)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore{
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore int rv;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore if ((rv = phy_start(ph)) != DDI_SUCCESS) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (rv);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Apparently some devices have problem with 10 Mbps polarity and
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * short cable lengths. However, these days everyone should be using
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * 100 Mbps, and rather than retain the extra legacy complexity
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * here, I'm going to simply offer the choice to disable auto polarity.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * If autopolarity doesn't work for you, you have several choices:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * 1) Find a longer cable.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * 2) Upgrade to 100Mbps.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * 3) Disable the polarity check by setting AutoPolarity to 0.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * We also believe that 10BASE-T autopolarity may be harmful (because
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * when used it can prevent use of a superior 100Mbps mode), so we
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * disable autopolarity by default.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore if (phy_get_prop(ph, "AutoPolarity", 0) == 0) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /* disable autopolarity */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore PHY_SET(ph, MII_82555_SPCL_CONTROL, I82555_AUTOPOL_DIS);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore } else {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /* enable basic autopolarity */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore PHY_CLR(ph, MII_82555_SPCL_CONTROL, I82555_AUTOPOL_DIS);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (rv);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore}
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amoreboolean_t
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorephy_intel_probe(phy_handle_t *ph)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore{
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore const char *model;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore if (MII_PHY_MFG(ph->phy_id) != MII_OUI_INTEL) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_FALSE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore switch (MII_PHY_MODEL(ph->phy_id)) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_INTEL_82553_CSTEP:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore model = "82553 C-step";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore break;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_INTEL_82555:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_start = i82555_start;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore model = "82555";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore break;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_INTEL_82562_EH:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore model = "Intel 82562 EH";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore break;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_INTEL_82562_ET:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore model = "Intel 82562 ET";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore break;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_INTEL_82562_EM:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore model = "Intel 82562 EM";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore break;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore default:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_FALSE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_vendor = "Intel";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_model = model;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_TRUE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore}