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 National Semiconductor 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/mii.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include <sys/miiregs.h>
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore#include "miipriv.h"
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorestatic int
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorens83840_reset(phy_handle_t *ph)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore{
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /* first do an ordinary reset */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore if (phy_reset(ph) != DDI_SUCCESS) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (DDI_FAILURE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /*
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * As per INTEL "PRO/100B Adapter Software Technical Reference
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Manual", set bit 10 of MII register 23. National
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * Semiconductor documentation shows this as "reserved, write
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * to as zero". We also set the "CIM_DIS" bit, also as
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * requested by the PRO/100B doc, to disable the carrier
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * integrity monitor. (That should only ever be used by
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * repeaters.)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore *
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * NetBSD also sets bit 8, without any explanation, so we'll
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore * follow suit.
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore PHY_SET(ph, MII_VENDOR(7), (1<<10) | (1<<8) | (1<<5));
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (DDI_SUCCESS);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore}
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amoreboolean_t
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amorephy_natsemi_probe(phy_handle_t *ph)
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore{
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore /* We could even look at revA vs revC, etc. but there is no need. */
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore if ((MII_PHY_MFG(ph->phy_id) != MII_OUI_NATIONAL_SEMI) &&
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore (MII_PHY_MFG(ph->phy_id) != MII_OUI_NATIONAL_SEMI_2)) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_FALSE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_vendor = "National Semiconductor";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore switch (MII_PHY_MODEL(ph->phy_id)) {
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_NATIONAL_SEMI_DP83840:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_model = "DP83840";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_reset = ns83840_reset;
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_TRUE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_NATIONAL_SEMI_DP83843:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_model = "DP83843";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_TRUE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_NATIONAL_SEMI_DP83847:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_model = "DP83847";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_TRUE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore case MII_MODEL_NATIONAL_SEMI_DP83815:
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore ph->phy_model = "DP83815";
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_TRUE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore }
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore return (B_FALSE);
bdb9230ac765cb7af3fc1f4119caf2c5720dceb3Garrett D'Amore}