/*
* 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 (c) 2012 Gary Mills
*
*/
/*
* Copyright (c) 2008, Pyun YongHyeon <yongari@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "atge.h"
#include "atge_cmn_reg.h"
#include "atge_l1c_reg.h"
#include "atge_l1e_reg.h"
#include "atge_l1_reg.h"
{
uint32_t v;
int i;
for (i = PHY_TIMEOUT; i > 0; i--) {
drv_usecwait(5);
if ((v & (MDIO_OP_EXECUTE | MDIO_OP_BUSY)) == 0)
break;
}
if (i == 0) {
return (0xffff);
}
/*
* Some fast ethernet chips may not be able to auto-nego with
* switches even though they have 1000T based PHY. Hence we mask
* 1000T based capabilities.
*/
if (reg == MII_STATUS)
v &= ~MII_STATUS_EXTSTAT;
else if (reg == MII_EXTSTATUS)
v = 0;
}
return ((v & MDIO_DATA_MASK) >> MDIO_DATA_SHIFT);
}
void
{
uint32_t v;
int i;
for (i = PHY_TIMEOUT; i > 0; i--) {
drv_usecwait(5);
if ((v & (MDIO_OP_EXECUTE | MDIO_OP_BUSY)) == 0)
break;
}
if (i == 0) {
}
}
void
{
int phyaddr;
drv_usecwait(1000);
drv_usecwait(1000);
/*
* Some fast ethernet chips may not be able to auto-nego with
* switches even though they have 1000T based PHY. Hence we need
* to write 0 to MII_MSCONTROL control register.
*/
/* Enable hibernation mode. */
/* Set Class A/B for all modes. */
/* Enable 10BT power saving. */
/* Adjust 1000T power. */
/* 10BT center tap voltage. */
drv_usecwait(1000);
}
void
{
int linkup, i;
int phyaddr;
drv_usecwait(1000);
drv_usecwait(1000);
for (i = 200; i > 0; i--) {
drv_usecwait(1000);
if ((reg & PHY_CDTC_ENB) == 0)
break;
}
drv_usecwait(1000);
linkup++;
break;
}
}
if (linkup == 0) {
}
}
void
{
int phyaddr;
/* Reset magic from Linux, via Freebsd */
/*
* Some fast ethernet chips may not be able to auto-nego with
* switches even though they have 1000T based PHY. Hence we need
* to write 0 to MII_MSCONTROL control register.
*/
/* DSP fixup, Vendor magic. */
/* FALLTHROUGH */
break;
}
break;
case ATGE_CHIP_L1CG_DEV_ID:
case ATGE_CHIP_L1CF_DEV_ID:
break;
}
/* Load DSP codes, vendor magic. */
((1 << ANA_INTERVAL_SEL_TIMER_SHIFT) &
((33 << ANA_SHORT_CABLE_TH_100_SHIFT) &
drv_usecwait(1000);
}
{
if (phy != 0) {
/* avoid PHY address alias */
return (0xffffU);
}
}
void
{
if (phy != 0) {
/* avoid PHY address alias */
return;
}
if (reg == MII_CONTROL) {
/*
* Don't issue a reset if MII_CONTROL_RESET is set.
* Otherwise it occasionally
* advertises incorrect capability.
*/
if ((val & MII_CONTROL_RESET) == 0) {
/* RESET bit is required to set mode */
}
} else {
}
}