1bdb9230aSGarrett D'Amore /* 2bdb9230aSGarrett D'Amore * CDDL HEADER START 3bdb9230aSGarrett D'Amore * 4bdb9230aSGarrett D'Amore * The contents of this file are subject to the terms of the 5bdb9230aSGarrett D'Amore * Common Development and Distribution License (the "License"). 6bdb9230aSGarrett D'Amore * You may not use this file except in compliance with the License. 7bdb9230aSGarrett D'Amore * 8bdb9230aSGarrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9bdb9230aSGarrett D'Amore * or http://www.opensolaris.org/os/licensing. 10bdb9230aSGarrett D'Amore * See the License for the specific language governing permissions 11bdb9230aSGarrett D'Amore * and limitations under the License. 12bdb9230aSGarrett D'Amore * 13bdb9230aSGarrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each 14bdb9230aSGarrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15bdb9230aSGarrett D'Amore * If applicable, add the following below this CDDL HEADER, with the 16bdb9230aSGarrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying 17bdb9230aSGarrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner] 18bdb9230aSGarrett D'Amore * 19bdb9230aSGarrett D'Amore * CDDL HEADER END 20bdb9230aSGarrett D'Amore */ 21bdb9230aSGarrett D'Amore /* 22*bbb1277bSGarrett D'Amore * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23bdb9230aSGarrett D'Amore * Use is subject to license terms. 24bdb9230aSGarrett D'Amore */ 25bdb9230aSGarrett D'Amore 26bdb9230aSGarrett D'Amore /* 27bdb9230aSGarrett D'Amore * miipriv.h 28bdb9230aSGarrett D'Amore * 29bdb9230aSGarrett D'Amore * Private MII header file. 30bdb9230aSGarrett D'Amore */ 31bdb9230aSGarrett D'Amore 32bdb9230aSGarrett D'Amore #ifndef _MIIPRIV_H 33bdb9230aSGarrett D'Amore #define _MIIPRIV_H 34bdb9230aSGarrett D'Amore 35bdb9230aSGarrett D'Amore #define PHY_SET(phy, reg, bit) \ 36bdb9230aSGarrett D'Amore phy_write(phy, reg, phy_read(phy, reg) | (bit)) 37bdb9230aSGarrett D'Amore #define PHY_CLR(phy, reg, bit) \ 38bdb9230aSGarrett D'Amore phy_write(phy, reg, phy_read(phy, reg) & ~(bit)) 39bdb9230aSGarrett D'Amore 40bdb9230aSGarrett D'Amore typedef struct phy_ops phy_ops_t; 41bdb9230aSGarrett D'Amore typedef struct phy_handle phy_handle_t; 42bdb9230aSGarrett D'Amore 43bdb9230aSGarrett D'Amore struct phy_handle { 44bdb9230aSGarrett D'Amore /* 45bdb9230aSGarrett D'Amore * Read only fields for PHY implementations, used internally by 46bdb9230aSGarrett D'Amore * the framework. 47bdb9230aSGarrett D'Amore */ 48bdb9230aSGarrett D'Amore mii_handle_t phy_mii; 49bdb9230aSGarrett D'Amore boolean_t phy_present; 50bdb9230aSGarrett D'Amore uint8_t phy_addr; 51bdb9230aSGarrett D'Amore uint8_t phy_type; 52bdb9230aSGarrett D'Amore uint32_t phy_id; 53bdb9230aSGarrett D'Amore 54bdb9230aSGarrett D'Amore /* 55bdb9230aSGarrett D'Amore * Scratch storage available for PHY implementations. While 56bdb9230aSGarrett D'Amore * perhaps not as "clean" as other solutions with dynamic memory, 57bdb9230aSGarrett D'Amore * this avoids having to deal with potential concerns regarding the 58bdb9230aSGarrett D'Amore * lifetime of the storage. It will be zeroed each time the MII 59bdb9230aSGarrett D'Amore * bus is reprobed. 60bdb9230aSGarrett D'Amore */ 61bdb9230aSGarrett D'Amore uintptr_t phy_scratch[8]; 62bdb9230aSGarrett D'Amore 63bdb9230aSGarrett D'Amore /* 64bdb9230aSGarrett D'Amore * These fields are intended to be overridden by PHY 65bdb9230aSGarrett D'Amore * implementations. If left NULL, then default 66bdb9230aSGarrett D'Amore * implementations will be supplied. 67bdb9230aSGarrett D'Amore */ 68bdb9230aSGarrett D'Amore const char *phy_vendor; 69bdb9230aSGarrett D'Amore const char *phy_model; 70bdb9230aSGarrett D'Amore int (*phy_reset)(phy_handle_t *); 71bdb9230aSGarrett D'Amore int (*phy_start)(phy_handle_t *); 72bdb9230aSGarrett D'Amore int (*phy_stop)(phy_handle_t *); 73bdb9230aSGarrett D'Amore int (*phy_check)(phy_handle_t *); 74cea60642SGarrett D'Amore int (*phy_loop)(phy_handle_t *); 75bdb9230aSGarrett D'Amore 76bdb9230aSGarrett D'Amore /* 77bdb9230aSGarrett D'Amore * Physical capabilities. PHY implementations may override 78bdb9230aSGarrett D'Amore * the defaults if necessary. 79bdb9230aSGarrett D'Amore */ 80bdb9230aSGarrett D'Amore boolean_t phy_cap_aneg; 81bdb9230aSGarrett D'Amore boolean_t phy_cap_10_hdx; 82bdb9230aSGarrett D'Amore boolean_t phy_cap_10_fdx; 83bdb9230aSGarrett D'Amore boolean_t phy_cap_100_t4; 84bdb9230aSGarrett D'Amore boolean_t phy_cap_100_hdx; 85bdb9230aSGarrett D'Amore boolean_t phy_cap_100_fdx; 86bdb9230aSGarrett D'Amore boolean_t phy_cap_1000_hdx; 87bdb9230aSGarrett D'Amore boolean_t phy_cap_1000_fdx; 88bdb9230aSGarrett D'Amore boolean_t phy_cap_pause; 89bdb9230aSGarrett D'Amore boolean_t phy_cap_asmpause; 90bdb9230aSGarrett D'Amore 91bdb9230aSGarrett D'Amore /* 92bdb9230aSGarrett D'Amore * Local configured settings. PHY implementations should 93bdb9230aSGarrett D'Amore * these as read only. The MII common layer will limit 94bdb9230aSGarrett D'Amore * settings to only those that are sensible per the actual 95bdb9230aSGarrett D'Amore * capabilities of the device. These represent administrator 96bdb9230aSGarrett D'Amore * preferences. 97bdb9230aSGarrett D'Amore */ 98bdb9230aSGarrett D'Amore boolean_t phy_en_aneg; 99bdb9230aSGarrett D'Amore boolean_t phy_en_10_hdx; 100bdb9230aSGarrett D'Amore boolean_t phy_en_10_fdx; 101bdb9230aSGarrett D'Amore boolean_t phy_en_100_t4; 102bdb9230aSGarrett D'Amore boolean_t phy_en_100_hdx; 103bdb9230aSGarrett D'Amore boolean_t phy_en_100_fdx; 104bdb9230aSGarrett D'Amore boolean_t phy_en_1000_hdx; 105bdb9230aSGarrett D'Amore boolean_t phy_en_1000_fdx; 106bdb9230aSGarrett D'Amore boolean_t phy_en_pause; 107bdb9230aSGarrett D'Amore boolean_t phy_en_asmpause; 108bdb9230aSGarrett D'Amore link_flowctrl_t phy_en_flowctrl; 109bdb9230aSGarrett D'Amore 110bdb9230aSGarrett D'Amore /* 111bdb9230aSGarrett D'Amore * Settings exposed on the hardware. MII common layer will 112bdb9230aSGarrett D'Amore * limit settings to only those that are sensible per the 113bdb9230aSGarrett D'Amore * actual capabilities of the device. 114bdb9230aSGarrett D'Amore */ 115bdb9230aSGarrett D'Amore boolean_t phy_adv_aneg; 116bdb9230aSGarrett D'Amore boolean_t phy_adv_10_hdx; 117bdb9230aSGarrett D'Amore boolean_t phy_adv_10_fdx; 118bdb9230aSGarrett D'Amore boolean_t phy_adv_100_t4; 119bdb9230aSGarrett D'Amore boolean_t phy_adv_100_hdx; 120bdb9230aSGarrett D'Amore boolean_t phy_adv_100_fdx; 121bdb9230aSGarrett D'Amore boolean_t phy_adv_1000_hdx; 122bdb9230aSGarrett D'Amore boolean_t phy_adv_1000_fdx; 123bdb9230aSGarrett D'Amore boolean_t phy_adv_pause; 124bdb9230aSGarrett D'Amore boolean_t phy_adv_asmpause; 125bdb9230aSGarrett D'Amore 126bdb9230aSGarrett D'Amore /* 127bdb9230aSGarrett D'Amore * Link partner settings. PHY implementations should 128bdb9230aSGarrett D'Amore * fill these in during phy_check. 129bdb9230aSGarrett D'Amore */ 130bdb9230aSGarrett D'Amore boolean_t phy_lp_aneg; 131bdb9230aSGarrett D'Amore boolean_t phy_lp_10_hdx; 132bdb9230aSGarrett D'Amore boolean_t phy_lp_10_fdx; 133bdb9230aSGarrett D'Amore boolean_t phy_lp_100_t4; 134bdb9230aSGarrett D'Amore boolean_t phy_lp_100_hdx; 135bdb9230aSGarrett D'Amore boolean_t phy_lp_100_fdx; 136bdb9230aSGarrett D'Amore boolean_t phy_lp_1000_hdx; 137bdb9230aSGarrett D'Amore boolean_t phy_lp_1000_fdx; 138bdb9230aSGarrett D'Amore boolean_t phy_lp_pause; 139bdb9230aSGarrett D'Amore boolean_t phy_lp_asmpause; 140bdb9230aSGarrett D'Amore 141bdb9230aSGarrett D'Amore /* 142bdb9230aSGarrett D'Amore * Loopback state. Loopback state overrides any other settings. 143bdb9230aSGarrett D'Amore */ 144bdb9230aSGarrett D'Amore int phy_loopback; 145bdb9230aSGarrett D'Amore #define PHY_LB_NONE 0 146bdb9230aSGarrett D'Amore #define PHY_LB_INT_PHY 1 147bdb9230aSGarrett D'Amore #define PHY_LB_EXT_10 2 148bdb9230aSGarrett D'Amore #define PHY_LB_EXT_100 3 149bdb9230aSGarrett D'Amore #define PHY_LB_EXT_1000 4 150bdb9230aSGarrett D'Amore 151bdb9230aSGarrett D'Amore /* 152bdb9230aSGarrett D'Amore * Resolved link status. PHY implementations should 153bdb9230aSGarrett D'Amore * fill these during phy_check. 154bdb9230aSGarrett D'Amore */ 155bdb9230aSGarrett D'Amore link_state_t phy_link; 156bdb9230aSGarrett D'Amore uint32_t phy_speed; 157bdb9230aSGarrett D'Amore link_duplex_t phy_duplex; 158bdb9230aSGarrett D'Amore link_flowctrl_t phy_flowctrl; 159bdb9230aSGarrett D'Amore }; 160bdb9230aSGarrett D'Amore 161bdb9230aSGarrett D'Amore /* 162bdb9230aSGarrett D'Amore * Routines intended to be accessed by PHY specific implementation code. 163bdb9230aSGarrett D'Amore * All of these routines assume that any relevant locks are held by the 164bdb9230aSGarrett D'Amore * famework (which would be true for all of the PHY functions. 165bdb9230aSGarrett D'Amore */ 166bdb9230aSGarrett D'Amore 167bdb9230aSGarrett D'Amore uint16_t phy_read(phy_handle_t *, uint8_t); 168bdb9230aSGarrett D'Amore void phy_write(phy_handle_t *, uint8_t, uint16_t); 169bdb9230aSGarrett D'Amore int phy_get_prop(phy_handle_t *, char *, int); 170bdb9230aSGarrett D'Amore const char *phy_get_name(phy_handle_t *); 171bdb9230aSGarrett D'Amore const char *phy_get_driver(phy_handle_t *); 172bdb9230aSGarrett D'Amore void phy_warn(phy_handle_t *, const char *, ...); 173bdb9230aSGarrett D'Amore 174bdb9230aSGarrett D'Amore /* 175bdb9230aSGarrett D'Amore * phy_reset is called when the PHY needs to be reset. The default 176bdb9230aSGarrett D'Amore * implementation just resets the PHY by toggling the BMCR bit, but it 177bdb9230aSGarrett D'Amore * also unisolates and powers up the PHY. 178bdb9230aSGarrett D'Amore */ 179bdb9230aSGarrett D'Amore int phy_reset(phy_handle_t *); 180bdb9230aSGarrett D'Amore 181bdb9230aSGarrett D'Amore /* 182bdb9230aSGarrett D'Amore * phy_start is used to start services on the PHY. Typically this is 183bdb9230aSGarrett D'Amore * called when autonegotiation should be started. phy_reset will 184bdb9230aSGarrett D'Amore * already have been called. 185bdb9230aSGarrett D'Amore */ 186bdb9230aSGarrett D'Amore int phy_start(phy_handle_t *); 187bdb9230aSGarrett D'Amore 188bdb9230aSGarrett D'Amore /* 189bdb9230aSGarrett D'Amore * phy_stop is used when the phy services should be stopped. This can 190bdb9230aSGarrett D'Amore * be done, for example, when a different PHY will be used. The default 191bdb9230aSGarrett D'Amore * implementation isolates the PHY, puts it into loopback, and then powers 192bdb9230aSGarrett D'Amore * it down. 193bdb9230aSGarrett D'Amore */ 194bdb9230aSGarrett D'Amore int phy_stop(phy_handle_t *); 195bdb9230aSGarrett D'Amore 196bdb9230aSGarrett D'Amore /* 197bdb9230aSGarrett D'Amore * phy_check is called to check the current state of the link. It 198bdb9230aSGarrett D'Amore * can be used from the implementations phy_check entry point. 199bdb9230aSGarrett D'Amore */ 200bdb9230aSGarrett D'Amore int phy_check(phy_handle_t *); 201bdb9230aSGarrett D'Amore 202bdb9230aSGarrett D'Amore /* 203cea60642SGarrett D'Amore * phy_ isoop called to establish loopback mode. The PHY must 204cea60642SGarrett D'Amore * examine the value of phy_loopback. 205cea60642SGarrett D'Amore */ 206cea60642SGarrett D'Amore int phy_loop(phy_handle_t *); 207cea60642SGarrett D'Amore 208cea60642SGarrett D'Amore /* 209cea60642SGarrett D'Amore * The following probes are PHY specific, and located here so that 210bdb9230aSGarrett D'Amore * the common PHY layer can find them. 211bdb9230aSGarrett D'Amore */ 212bdb9230aSGarrett D'Amore boolean_t phy_intel_probe(phy_handle_t *); 213bdb9230aSGarrett D'Amore boolean_t phy_natsemi_probe(phy_handle_t *); 214bdb9230aSGarrett D'Amore boolean_t phy_qualsemi_probe(phy_handle_t *); 215bdb9230aSGarrett D'Amore boolean_t phy_cicada_probe(phy_handle_t *); 216cea60642SGarrett D'Amore boolean_t phy_marvell_probe(phy_handle_t *); 217*bbb1277bSGarrett D'Amore boolean_t phy_realtek_probe(phy_handle_t *); 218bdb9230aSGarrett D'Amore boolean_t phy_other_probe(phy_handle_t *); 219bdb9230aSGarrett D'Amore 220bdb9230aSGarrett D'Amore #endif /* _MIIPRIV_H */ 221