/*
* 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.
*/
#include "dmfe_impl.h"
/*
* The bit-twiddling required by the MII interface makes the functions
* in this file relatively slow, so they should probably only be called
* won't work at hi-pri, AFAIK; and 'relatively slow' only means that
* they have microsecond busy-waits all over the place.
*/
/*
* ======== Low-level SROM access ========
*/
/*
* EEPROM access is here because it shares register functionality with MII.
* NB: <romaddr> is a byte address but must be 16-bit aligned.
* <cnt> is a byte count, and must be a multiple of 2.
*/
void
{
/* only a whole number of words for now */
/* loop over multiple words... rom access in 16-bit increments */
while (cnt > 0) {
/* select the eeprom */
drv_usecwait(1);
drv_usecwait(1);
drv_usecwait(1);
drv_usecwait(1);
/* send 3 bit read command */
/* strobe the bit in */
READ_EEPROM_CS | value);
drv_usecwait(1);
drv_usecwait(1);
READ_EEPROM_CS | value);
drv_usecwait(1);
}
/* send 6 bit address */
/* strobe the bit in */
READ_EEPROM_CS | value);
drv_usecwait(1);
drv_usecwait(1);
READ_EEPROM_CS | value);
drv_usecwait(1);
}
/* shift out data */
value = 0;
drv_usecwait(1);
drv_usecwait(1);
drv_usecwait(1);
}
/* turn off EEPROM access */
drv_usecwait(1);
/* this makes it endian neutral */
cnt -= 2;
raddr++;
}
}
/*
* ======== Lowest-level bit-twiddling to drive MII interface ========
*/
/*
* Poke <nbits> (up to 32) bits from <mii_data> along the MII control lines.
* Note: the data is taken starting with the MSB of <mii_data> and working
* down through progressively less significant bits.
*/
static void
{
/*
* Extract the MSB of <mii_data> and shift it to the
* proper bit position in the MII-poking register
*/
/*
* Drive the bit across the wire ...
*/
}
}
/*
* Put the MDIO port in tri-state for the turn around bits
* in MII read and at end of MII management sequence.
*/
static void
{
}
/*
*/
static void
{
/* Write Preamble & Command & return to tristate */
}
static uint16_t
{
int i;
/* Check that the PHY generated a zero bit on the 2nd clock */
/* read data WORD */
for (data = 0, i = 0; i < mii_reg_size; ++i) {
data <<= 1;
}
/* leave the interface tristated */
}
/*
* ======== Next level: 16-bit PHY register access routines ========
*/
static void
{
/* Issue MII command */
command_word |= reg_dat;
}
static uint16_t
{
/* Issue MII command */
return (rv);
}
static void
{
if (link == LINK_STATE_UP) {
/*
* Configure DUPLEX setting on MAC.
*/
} else {
}
}
}
/*
* PHY initialisation, called only once
*/
NULL, /* mii_reset */
};
{
return (B_FALSE);
}
return (B_TRUE);
}