xref: /titanic_51/usr/src/uts/common/io/mii/mii_natsemi.c (revision 491f61a1e1c1fc54a47bbcf53dbbbe1293b93b27)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * MII overrides for National Semiconductor PHYs.
28  */
29 
30 #include <sys/types.h>
31 #include <sys/ddi.h>
32 #include <sys/sunddi.h>
33 #include <sys/mii.h>
34 #include <sys/miiregs.h>
35 #include "miipriv.h"
36 
37 static int
38 ns83840_reset(phy_handle_t *ph)
39 {
40 	/* first do an ordinary reset */
41 	if (phy_reset(ph) != DDI_SUCCESS) {
42 		return (DDI_FAILURE);
43 	}
44 
45 	/*
46 	 * As per INTEL "PRO/100B Adapter Software Technical Reference
47 	 * Manual", set bit 10 of MII register 23.  National
48 	 * Semiconductor documentation shows this as "reserved, write
49 	 * to as zero". We also set the "CIM_DIS" bit, also as
50 	 * requested by the PRO/100B doc, to disable the carrier
51 	 * integrity monitor.  (That should only ever be used by
52 	 * repeaters.)
53 	 *
54 	 * NetBSD also sets bit 8, without any explanation, so we'll
55 	 * follow suit.
56 	 */
57 	PHY_SET(ph, MII_VENDOR(7), (1<<10) | (1<<8) | (1<<5));
58 	return (DDI_SUCCESS);
59 }
60 
61 boolean_t
62 phy_natsemi_probe(phy_handle_t *ph)
63 {
64 	/* We could even look at revA vs revC, etc. but there is no need. */
65 	if ((MII_PHY_MFG(ph->phy_id) != MII_OUI_NATIONAL_SEMI) &&
66 	    (MII_PHY_MFG(ph->phy_id) != MII_OUI_NATIONAL_SEMI_2)) {
67 		return (B_FALSE);
68 	}
69 	ph->phy_vendor = "National Semiconductor";
70 
71 	switch (MII_PHY_MODEL(ph->phy_id)) {
72 	case MII_MODEL_NATIONAL_SEMI_DP83840:
73 		ph->phy_model = "DP83840";
74 		ph->phy_reset = ns83840_reset;
75 		return (B_TRUE);
76 
77 	case MII_MODEL_NATIONAL_SEMI_DP83843:
78 		ph->phy_model = "DP83843";
79 		return (B_TRUE);
80 
81 	case MII_MODEL_NATIONAL_SEMI_DP83847:
82 		ph->phy_model = "DP83847";
83 		return (B_TRUE);
84 
85 	case MII_MODEL_NATIONAL_SEMI_DP83815:
86 		ph->phy_model = "DP83815";
87 		return (B_TRUE);
88 	}
89 	return (B_FALSE);
90 }
91