miipriv.h revision cea606427170954e8cfcfa5417f3b60394180cb9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Private MII header file.
*/
#ifndef _MIIPRIV_H
#define _MIIPRIV_H
typedef struct phy_handle phy_handle_t;
struct phy_handle {
/*
* Read only fields for PHY implementations, used internally by
* the framework.
*/
/*
* Scratch storage available for PHY implementations. While
* perhaps not as "clean" as other solutions with dynamic memory,
* this avoids having to deal with potential concerns regarding the
* lifetime of the storage. It will be zeroed each time the MII
* bus is reprobed.
*/
/*
* These fields are intended to be overridden by PHY
* implementations. If left NULL, then default
* implementations will be supplied.
*/
const char *phy_vendor;
const char *phy_model;
int (*phy_reset)(phy_handle_t *);
int (*phy_start)(phy_handle_t *);
int (*phy_stop)(phy_handle_t *);
int (*phy_check)(phy_handle_t *);
int (*phy_loop)(phy_handle_t *);
/*
* Physical capabilities. PHY implementations may override
* the defaults if necessary.
*/
/*
* Local configured settings. PHY implementations should
* these as read only. The MII common layer will limit
* settings to only those that are sensible per the actual
* capabilities of the device. These represent administrator
* preferences.
*/
/*
* Settings exposed on the hardware. MII common layer will
* limit settings to only those that are sensible per the
* actual capabilities of the device.
*/
/*
* Link partner settings. PHY implementations should
* fill these in during phy_check.
*/
/*
* Loopback state. Loopback state overrides any other settings.
*/
int phy_loopback;
#define PHY_LB_NONE 0
#define PHY_LB_INT_PHY 1
#define PHY_LB_EXT_10 2
#define PHY_LB_EXT_100 3
#define PHY_LB_EXT_1000 4
/*
* Resolved link status. PHY implementations should
* fill these during phy_check.
*/
};
/*
* Routines intended to be accessed by PHY specific implementation code.
* All of these routines assume that any relevant locks are held by the
* famework (which would be true for all of the PHY functions.
*/
int phy_get_prop(phy_handle_t *, char *, int);
const char *phy_get_name(phy_handle_t *);
const char *phy_get_driver(phy_handle_t *);
void phy_warn(phy_handle_t *, const char *, ...);
/*
* phy_reset is called when the PHY needs to be reset. The default
* implementation just resets the PHY by toggling the BMCR bit, but it
* also unisolates and powers up the PHY.
*/
int phy_reset(phy_handle_t *);
/*
* phy_start is used to start services on the PHY. Typically this is
* called when autonegotiation should be started. phy_reset will
* already have been called.
*/
int phy_start(phy_handle_t *);
/*
* phy_stop is used when the phy services should be stopped. This can
* be done, for example, when a different PHY will be used. The default
* implementation isolates the PHY, puts it into loopback, and then powers
* it down.
*/
int phy_stop(phy_handle_t *);
/*
* phy_check is called to check the current state of the link. It
* can be used from the implementations phy_check entry point.
*/
int phy_check(phy_handle_t *);
/*
* phy_ isoop called to establish loopback mode. The PHY must
* examine the value of phy_loopback.
*/
int phy_loop(phy_handle_t *);
/*
* The following probes are PHY specific, and located here so that
* the common PHY layer can find them.
*/
#endif /* _MIIPRIV_H */