📄 hwport.c
字号:
/*
Copyright (c) 2002-2005 Vitesse Semiconductor Corporation "Vitesse".
All Rights Reserved. Unpublished rights reserved under the copyright laws
of the United States of America, other countries and international treaties.
The software is provided without a fee. Permission to use, copy, store and
modify, the software and its source code is granted. Permission to integrate
into other products, disclose, transmit and distribute the software in an
absolute machine readable format (e.g. HEX file) is also granted.
The source code of the software may not be disclosed, transmitted or
distributed without the written permission of Vitesse. The software and its
source code may only be used in products utilizing a Vitesse VSC73xx product.
This copyright notice must appear in any copy, modification, disclosure,
transmission or distribution of the software. Vitesse retains all ownership,
copyright, trade secret and proprietary rights in the software.
THIS SOFTWARE HAS BEEN PROVIDED "AS IS," WITHOUT EXPRESS OR IMPLIED WARRANTY
INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR USE AND NON-INFRINGEMENT.
*/
#include "common.h"
#include "hwconf.h"
#include "hwport.h"
#include "h2io.h"
#include "h2reg.h"
#include "phydrv.h"
#include "absacc.h"
#include "main.h"
#include "timer.h"
#include "version.h"
#include "macaddr.h"
#include "string.h"
#include "phyconf.h"
/* ************************************************************************ **
*
*
* Defines
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Typedefs and enums
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Prototypes for local functions
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Public data
*
*
*
* ************************************************************************ */
#if TRANSIT_VERIPHY || LOOPBACK_TEST
#endif /* TRANSIT_VERIPHY || LOOPBACK_TEST */
/* ************************************************************************ **
*
*
* Local data
*
*
*
* ************************************************************************ */
/* ************************************************************************ */
void get_hw_version (void)
/* ------------------------------------------------------------------------ --
* Purpose : Read hardware version from hardware
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
}
/* ************************************************************************ */
void get_mac_addr (uchar port_no, uchar data *mac_addr)
/* ------------------------------------------------------------------------ --
* Purpose : Read configured MAC address and adjust it according to
* specified port.
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
uchar j;
for (j = 0; j < MAC_ADDR_LEN; j++) {
mac_addr[j] = flash_mac_addr[j];
}
port_no -= MIN_PORT;
if ((mac_addr[5] += port_no) < port_no) {
if (++mac_addr[4] == 0) {
mac_addr[3]++;
}
}
}
/* ************************************************************************ */
uchar get_back_off_seed (uchar port_no)
/* ------------------------------------------------------------------------ --
* Purpose : Get a value to be used for back off seed.
* Remarks : Uses least significant byte of the MAC address for the port.
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
mac_addr_t mac_addr;
get_mac_addr(port_no, mac_addr);
return mac_addr[5];
}
/* ************************************************************************ */
void phy_hw_init (void)
/* ------------------------------------------------------------------------ --
* Purpose : Remove hardware reset of the PHY chips
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
#if VTSS_8538
#ifndef LUTON_G16
#ifndef LUTON_G16R
uchar code ports[] = {0, 16};
#else
uchar code ports[] = {16};
#endif
#else
uchar code ports[] = {0};
#endif
uchar j;
ushort res;
#endif
h2_write(SYSTEM, 0, SYS_GPIO, 0x10); /* reset Spyder PHYs */
delay_1(LED_SYNC_DELAY);
h2_write(SYSTEM, 0, SYS_GPIO, 0x11); /* remove reset for Spyder PHYs */
/* Release reset of built-in PHYs */
h2_write_bit(SYSTEM, 0, SYS_GLORESET, PHY_RESET_RELEASE, 1);
#if VTSS_8538
/* wait for PHY to be available on MII */
do {
res = phy_read(ports[0], 2);
} while (res != 0x0007);
for(j = 0; j < (sizeof(ports) / sizeof(ports[0])); j++) {
phy_immediate_init_seq_8538(ports[j]);
}
#endif
delay_1(20);
}
#if (WATCHDOG_PRESENT && WATCHDOG_ENABLE)
/* ************************************************************************ */
void kick_watchdog (void) small
/* ------------------------------------------------------------------------ --
* Purpose : Kick watchdog.
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
KICK_WATCHDOG;
}
#endif
#if WATCHDOG_PRESENT
/* ************************************************************************ */
void enable_watchdog (void) small
/* ------------------------------------------------------------------------ --
* Purpose : Enable external watchdog.
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
ENABLE_WATCHDOG;
}
#endif
#if FRONT_LED_PRESENT
/* ************************************************************************ */
void front_led (uchar status) small
/* ------------------------------------------------------------------------ --
* Purpose : Set front LED either red, green or off.
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
switch (status) {
case FRONT_LED_RED:
phy_write(PHY_LED_GPIO_PORT, 31, 0x0010);
phy_write_masked(PHY_LED_GPIO_PORT, 0x11, 0xc000, 0xc000); /* Enable GPIO 14 and 15 as outputs */
phy_write_masked(PHY_LED_GPIO_PORT, 0x10, 0x8000, 0xc000);
phy_write(PHY_LED_GPIO_PORT, 31, 0x0000);
break;
case FRONT_LED_GREEN:
phy_write(PHY_LED_GPIO_PORT, 31, 0x0010);
phy_write_masked(PHY_LED_GPIO_PORT, 0x11, 0xc000, 0xc000); /* Enable GPIO 14 and 15 as outputs */
phy_write_masked(PHY_LED_GPIO_PORT, 0x10, 0x4000, 0xc000);
phy_write(PHY_LED_GPIO_PORT, 31, 0x0000);
break;
default:
break;
}
}
#endif
/* ************************************************************************ */
void gpio_init (void)
/* ------------------------------------------------------------------------ --
* Purpose :
* Remarks :
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -