19860Sgdamore@opensolaris.org /* 29860Sgdamore@opensolaris.org * CDDL HEADER START 39860Sgdamore@opensolaris.org * 49860Sgdamore@opensolaris.org * The contents of this file are subject to the terms of the 59860Sgdamore@opensolaris.org * Common Development and Distribution License (the "License"). 69860Sgdamore@opensolaris.org * You may not use this file except in compliance with the License. 79860Sgdamore@opensolaris.org * 89860Sgdamore@opensolaris.org * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99860Sgdamore@opensolaris.org * or http://www.opensolaris.org/os/licensing. 109860Sgdamore@opensolaris.org * See the License for the specific language governing permissions 119860Sgdamore@opensolaris.org * and limitations under the License. 129860Sgdamore@opensolaris.org * 139860Sgdamore@opensolaris.org * When distributing Covered Code, include this CDDL HEADER in each 149860Sgdamore@opensolaris.org * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159860Sgdamore@opensolaris.org * If applicable, add the following below this CDDL HEADER, with the 169860Sgdamore@opensolaris.org * fields enclosed by brackets "[]" replaced with your own identifying 179860Sgdamore@opensolaris.org * information: Portions Copyright [yyyy] [name of copyright owner] 189860Sgdamore@opensolaris.org * 199860Sgdamore@opensolaris.org * CDDL HEADER END 209860Sgdamore@opensolaris.org */ 219860Sgdamore@opensolaris.org /* 22*11453Sgdamore@opensolaris.org * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 239860Sgdamore@opensolaris.org * Use is subject to license terms. 249860Sgdamore@opensolaris.org */ 259860Sgdamore@opensolaris.org 269860Sgdamore@opensolaris.org /* 279860Sgdamore@opensolaris.org * miipriv.h 289860Sgdamore@opensolaris.org * 299860Sgdamore@opensolaris.org * Private MII header file. 309860Sgdamore@opensolaris.org */ 319860Sgdamore@opensolaris.org 329860Sgdamore@opensolaris.org #ifndef _MIIPRIV_H 339860Sgdamore@opensolaris.org #define _MIIPRIV_H 349860Sgdamore@opensolaris.org 359860Sgdamore@opensolaris.org #define PHY_SET(phy, reg, bit) \ 369860Sgdamore@opensolaris.org phy_write(phy, reg, phy_read(phy, reg) | (bit)) 379860Sgdamore@opensolaris.org #define PHY_CLR(phy, reg, bit) \ 389860Sgdamore@opensolaris.org phy_write(phy, reg, phy_read(phy, reg) & ~(bit)) 399860Sgdamore@opensolaris.org 409860Sgdamore@opensolaris.org typedef struct phy_ops phy_ops_t; 419860Sgdamore@opensolaris.org typedef struct phy_handle phy_handle_t; 429860Sgdamore@opensolaris.org 439860Sgdamore@opensolaris.org struct phy_handle { 449860Sgdamore@opensolaris.org /* 459860Sgdamore@opensolaris.org * Read only fields for PHY implementations, used internally by 469860Sgdamore@opensolaris.org * the framework. 479860Sgdamore@opensolaris.org */ 489860Sgdamore@opensolaris.org mii_handle_t phy_mii; 499860Sgdamore@opensolaris.org boolean_t phy_present; 509860Sgdamore@opensolaris.org uint8_t phy_addr; 519860Sgdamore@opensolaris.org uint8_t phy_type; 529860Sgdamore@opensolaris.org uint32_t phy_id; 539860Sgdamore@opensolaris.org 549860Sgdamore@opensolaris.org /* 559860Sgdamore@opensolaris.org * Scratch storage available for PHY implementations. While 569860Sgdamore@opensolaris.org * perhaps not as "clean" as other solutions with dynamic memory, 579860Sgdamore@opensolaris.org * this avoids having to deal with potential concerns regarding the 589860Sgdamore@opensolaris.org * lifetime of the storage. It will be zeroed each time the MII 599860Sgdamore@opensolaris.org * bus is reprobed. 609860Sgdamore@opensolaris.org */ 619860Sgdamore@opensolaris.org uintptr_t phy_scratch[8]; 629860Sgdamore@opensolaris.org 639860Sgdamore@opensolaris.org /* 649860Sgdamore@opensolaris.org * These fields are intended to be overridden by PHY 659860Sgdamore@opensolaris.org * implementations. If left NULL, then default 669860Sgdamore@opensolaris.org * implementations will be supplied. 679860Sgdamore@opensolaris.org */ 689860Sgdamore@opensolaris.org const char *phy_vendor; 699860Sgdamore@opensolaris.org const char *phy_model; 709860Sgdamore@opensolaris.org int (*phy_reset)(phy_handle_t *); 719860Sgdamore@opensolaris.org int (*phy_start)(phy_handle_t *); 729860Sgdamore@opensolaris.org int (*phy_stop)(phy_handle_t *); 739860Sgdamore@opensolaris.org int (*phy_check)(phy_handle_t *); 7410359SGarrett.Damore@Sun.COM int (*phy_loop)(phy_handle_t *); 759860Sgdamore@opensolaris.org 769860Sgdamore@opensolaris.org /* 779860Sgdamore@opensolaris.org * Physical capabilities. PHY implementations may override 789860Sgdamore@opensolaris.org * the defaults if necessary. 799860Sgdamore@opensolaris.org */ 809860Sgdamore@opensolaris.org boolean_t phy_cap_aneg; 819860Sgdamore@opensolaris.org boolean_t phy_cap_10_hdx; 829860Sgdamore@opensolaris.org boolean_t phy_cap_10_fdx; 839860Sgdamore@opensolaris.org boolean_t phy_cap_100_t4; 849860Sgdamore@opensolaris.org boolean_t phy_cap_100_hdx; 859860Sgdamore@opensolaris.org boolean_t phy_cap_100_fdx; 869860Sgdamore@opensolaris.org boolean_t phy_cap_1000_hdx; 879860Sgdamore@opensolaris.org boolean_t phy_cap_1000_fdx; 889860Sgdamore@opensolaris.org boolean_t phy_cap_pause; 899860Sgdamore@opensolaris.org boolean_t phy_cap_asmpause; 909860Sgdamore@opensolaris.org 919860Sgdamore@opensolaris.org /* 929860Sgdamore@opensolaris.org * Local configured settings. PHY implementations should 939860Sgdamore@opensolaris.org * these as read only. The MII common layer will limit 949860Sgdamore@opensolaris.org * settings to only those that are sensible per the actual 959860Sgdamore@opensolaris.org * capabilities of the device. These represent administrator 969860Sgdamore@opensolaris.org * preferences. 979860Sgdamore@opensolaris.org */ 989860Sgdamore@opensolaris.org boolean_t phy_en_aneg; 999860Sgdamore@opensolaris.org boolean_t phy_en_10_hdx; 1009860Sgdamore@opensolaris.org boolean_t phy_en_10_fdx; 1019860Sgdamore@opensolaris.org boolean_t phy_en_100_t4; 1029860Sgdamore@opensolaris.org boolean_t phy_en_100_hdx; 1039860Sgdamore@opensolaris.org boolean_t phy_en_100_fdx; 1049860Sgdamore@opensolaris.org boolean_t phy_en_1000_hdx; 1059860Sgdamore@opensolaris.org boolean_t phy_en_1000_fdx; 1069860Sgdamore@opensolaris.org boolean_t phy_en_pause; 1079860Sgdamore@opensolaris.org boolean_t phy_en_asmpause; 1089860Sgdamore@opensolaris.org link_flowctrl_t phy_en_flowctrl; 1099860Sgdamore@opensolaris.org 1109860Sgdamore@opensolaris.org /* 1119860Sgdamore@opensolaris.org * Settings exposed on the hardware. MII common layer will 1129860Sgdamore@opensolaris.org * limit settings to only those that are sensible per the 1139860Sgdamore@opensolaris.org * actual capabilities of the device. 1149860Sgdamore@opensolaris.org */ 1159860Sgdamore@opensolaris.org boolean_t phy_adv_aneg; 1169860Sgdamore@opensolaris.org boolean_t phy_adv_10_hdx; 1179860Sgdamore@opensolaris.org boolean_t phy_adv_10_fdx; 1189860Sgdamore@opensolaris.org boolean_t phy_adv_100_t4; 1199860Sgdamore@opensolaris.org boolean_t phy_adv_100_hdx; 1209860Sgdamore@opensolaris.org boolean_t phy_adv_100_fdx; 1219860Sgdamore@opensolaris.org boolean_t phy_adv_1000_hdx; 1229860Sgdamore@opensolaris.org boolean_t phy_adv_1000_fdx; 1239860Sgdamore@opensolaris.org boolean_t phy_adv_pause; 1249860Sgdamore@opensolaris.org boolean_t phy_adv_asmpause; 1259860Sgdamore@opensolaris.org 1269860Sgdamore@opensolaris.org /* 1279860Sgdamore@opensolaris.org * Link partner settings. PHY implementations should 1289860Sgdamore@opensolaris.org * fill these in during phy_check. 1299860Sgdamore@opensolaris.org */ 1309860Sgdamore@opensolaris.org boolean_t phy_lp_aneg; 1319860Sgdamore@opensolaris.org boolean_t phy_lp_10_hdx; 1329860Sgdamore@opensolaris.org boolean_t phy_lp_10_fdx; 1339860Sgdamore@opensolaris.org boolean_t phy_lp_100_t4; 1349860Sgdamore@opensolaris.org boolean_t phy_lp_100_hdx; 1359860Sgdamore@opensolaris.org boolean_t phy_lp_100_fdx; 1369860Sgdamore@opensolaris.org boolean_t phy_lp_1000_hdx; 1379860Sgdamore@opensolaris.org boolean_t phy_lp_1000_fdx; 1389860Sgdamore@opensolaris.org boolean_t phy_lp_pause; 1399860Sgdamore@opensolaris.org boolean_t phy_lp_asmpause; 1409860Sgdamore@opensolaris.org 1419860Sgdamore@opensolaris.org /* 1429860Sgdamore@opensolaris.org * Loopback state. Loopback state overrides any other settings. 1439860Sgdamore@opensolaris.org */ 1449860Sgdamore@opensolaris.org int phy_loopback; 1459860Sgdamore@opensolaris.org #define PHY_LB_NONE 0 1469860Sgdamore@opensolaris.org #define PHY_LB_INT_PHY 1 1479860Sgdamore@opensolaris.org #define PHY_LB_EXT_10 2 1489860Sgdamore@opensolaris.org #define PHY_LB_EXT_100 3 1499860Sgdamore@opensolaris.org #define PHY_LB_EXT_1000 4 1509860Sgdamore@opensolaris.org 1519860Sgdamore@opensolaris.org /* 1529860Sgdamore@opensolaris.org * Resolved link status. PHY implementations should 1539860Sgdamore@opensolaris.org * fill these during phy_check. 1549860Sgdamore@opensolaris.org */ 1559860Sgdamore@opensolaris.org link_state_t phy_link; 1569860Sgdamore@opensolaris.org uint32_t phy_speed; 1579860Sgdamore@opensolaris.org link_duplex_t phy_duplex; 1589860Sgdamore@opensolaris.org link_flowctrl_t phy_flowctrl; 1599860Sgdamore@opensolaris.org }; 1609860Sgdamore@opensolaris.org 1619860Sgdamore@opensolaris.org /* 1629860Sgdamore@opensolaris.org * Routines intended to be accessed by PHY specific implementation code. 1639860Sgdamore@opensolaris.org * All of these routines assume that any relevant locks are held by the 1649860Sgdamore@opensolaris.org * famework (which would be true for all of the PHY functions. 1659860Sgdamore@opensolaris.org */ 1669860Sgdamore@opensolaris.org 1679860Sgdamore@opensolaris.org uint16_t phy_read(phy_handle_t *, uint8_t); 1689860Sgdamore@opensolaris.org void phy_write(phy_handle_t *, uint8_t, uint16_t); 1699860Sgdamore@opensolaris.org int phy_get_prop(phy_handle_t *, char *, int); 1709860Sgdamore@opensolaris.org const char *phy_get_name(phy_handle_t *); 1719860Sgdamore@opensolaris.org const char *phy_get_driver(phy_handle_t *); 1729860Sgdamore@opensolaris.org void phy_warn(phy_handle_t *, const char *, ...); 1739860Sgdamore@opensolaris.org 1749860Sgdamore@opensolaris.org /* 1759860Sgdamore@opensolaris.org * phy_reset is called when the PHY needs to be reset. The default 1769860Sgdamore@opensolaris.org * implementation just resets the PHY by toggling the BMCR bit, but it 1779860Sgdamore@opensolaris.org * also unisolates and powers up the PHY. 1789860Sgdamore@opensolaris.org */ 1799860Sgdamore@opensolaris.org int phy_reset(phy_handle_t *); 1809860Sgdamore@opensolaris.org 1819860Sgdamore@opensolaris.org /* 1829860Sgdamore@opensolaris.org * phy_start is used to start services on the PHY. Typically this is 1839860Sgdamore@opensolaris.org * called when autonegotiation should be started. phy_reset will 1849860Sgdamore@opensolaris.org * already have been called. 1859860Sgdamore@opensolaris.org */ 1869860Sgdamore@opensolaris.org int phy_start(phy_handle_t *); 1879860Sgdamore@opensolaris.org 1889860Sgdamore@opensolaris.org /* 1899860Sgdamore@opensolaris.org * phy_stop is used when the phy services should be stopped. This can 1909860Sgdamore@opensolaris.org * be done, for example, when a different PHY will be used. The default 1919860Sgdamore@opensolaris.org * implementation isolates the PHY, puts it into loopback, and then powers 1929860Sgdamore@opensolaris.org * it down. 1939860Sgdamore@opensolaris.org */ 1949860Sgdamore@opensolaris.org int phy_stop(phy_handle_t *); 1959860Sgdamore@opensolaris.org 1969860Sgdamore@opensolaris.org /* 1979860Sgdamore@opensolaris.org * phy_check is called to check the current state of the link. It 1989860Sgdamore@opensolaris.org * can be used from the implementations phy_check entry point. 1999860Sgdamore@opensolaris.org */ 2009860Sgdamore@opensolaris.org int phy_check(phy_handle_t *); 2019860Sgdamore@opensolaris.org 2029860Sgdamore@opensolaris.org /* 20310359SGarrett.Damore@Sun.COM * phy_ isoop called to establish loopback mode. The PHY must 20410359SGarrett.Damore@Sun.COM * examine the value of phy_loopback. 20510359SGarrett.Damore@Sun.COM */ 20610359SGarrett.Damore@Sun.COM int phy_loop(phy_handle_t *); 20710359SGarrett.Damore@Sun.COM 20810359SGarrett.Damore@Sun.COM /* 20910359SGarrett.Damore@Sun.COM * The following probes are PHY specific, and located here so that 2109860Sgdamore@opensolaris.org * the common PHY layer can find them. 2119860Sgdamore@opensolaris.org */ 2129860Sgdamore@opensolaris.org boolean_t phy_intel_probe(phy_handle_t *); 2139860Sgdamore@opensolaris.org boolean_t phy_natsemi_probe(phy_handle_t *); 2149860Sgdamore@opensolaris.org boolean_t phy_qualsemi_probe(phy_handle_t *); 2159860Sgdamore@opensolaris.org boolean_t phy_cicada_probe(phy_handle_t *); 21610359SGarrett.Damore@Sun.COM boolean_t phy_marvell_probe(phy_handle_t *); 217*11453Sgdamore@opensolaris.org boolean_t phy_realtek_probe(phy_handle_t *); 2189860Sgdamore@opensolaris.org boolean_t phy_other_probe(phy_handle_t *); 2199860Sgdamore@opensolaris.org 2209860Sgdamore@opensolaris.org #endif /* _MIIPRIV_H */ 221