/*******************************************************************************
** Document: FW_cardinfo_api.c
** Copyright (c) 2004 R&D Center, Tailyn Communication Company, Ltd.  
** Created by: Chien Chung Lo
** Date: DEC. 13, 2004
** Description: API of firmware for card information.
** Version: 0.1
*******************************************************************************/
#include <FW_cardinfo/FW_cardinfo_api.h>
#include <stdio.h>

#include <umap_type.h>

//----------------------------------------------------------------------
// The function will be read and written SRAM
//----------------------------------------------------------------------
/*
UMAP_S32 FW_ReadSRAM(UMAP_U32 addr, void *data)
{
	
	return FW_ReadMainBus(addr, sizeof(*(UMAP_U8 *)data), data);
}

UMAP_S32 FW_WriteSRAM(UMAP_U32 addr, void *data)
{
	
	return FW_WriteMainBus(addr, sizeof(*(UMAP_U8 *)data), data);
}
*/
//----------------------------------------------------------------------
// The function will be got or set RTC.
// The member describes in the struct rtc.
//----------------------------------------------------------------------
/*
UMAP_S32 FW_CheckRtcSetting()
{
	unsigned char buf;
	int rc;
	
	rc = FW_ReadMainBus(RTC_CTRL_ADDR, 1, &buf);
	if(((buf & 0x0f) != STOP) && (!rc)){
		buf = STOP;	
		rc = FW_WriteMainBus(RTC_CTRL_ADDR, 1, &buf);
	}
	return rc;
}

UMAP_S32 FW_GetRtc(struct rtc* time_value)
{
	unsigned char buf[16],ctrl;
	int rc;

	ctrl = UTI | STOP;  //disable value change
	rc = FW_WriteMainBus(RTC_CTRL_ADDR, 1, &ctrl);
	if(!rc)
		rc = FW_ReadMainBus(HOST_RTC_ADDR, 16, buf);
	
	ctrl = STOP;  //enable value change
	rc = FW_WriteMainBus(RTC_CTRL_ADDR, 1, &ctrl) | rc;
		
	(*time_value).second      = (buf[0] >> 4) * 10 + (buf[0] & 0x0f);
	(*time_value).minute      = (buf[2] >> 4) * 10 + (buf[2] & 0x0f);
	(*time_value).am_pm       = (buf[4] >> 7) & 0x01;
	(*time_value).hour        = ((buf[4] >> 4) & 0x03) * 10 + (buf[4] & 0x0f);
	(*time_value).day         = (buf[6] >> 4) * 10 + (buf[6] & 0x0f);
	(*time_value).day_of_week = buf[8] & 0x07;
	(*time_value).month       = (buf[9] >> 4) * 10 + (buf[9] & 0x0f);
	(*time_value).year        = (buf[10] >> 4) * 10 + (buf[10] & 0x0f);
	(*time_value).century     = (buf[15] >> 4) * 10 + (buf[15] & 0x0f);

	return rc;	
}

UMAP_S32 FW_SetRtc(struct rtc time_value)
{
	unsigned char buf;
	int rc;
	
	buf = UTI | STOP;  //disable value change
	rc = FW_WriteMainBus(RTC_CTRL_ADDR, 1, &buf);
	
	buf = (time_value.second / 10); //second
	buf = (buf << 4) | (time_value.second - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_SECOND_ADDR, 1, &buf);
	
	buf = (time_value.minute / 10); //minute
	buf = (buf << 4) | (time_value.minute - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_MINUTE_ADDR, 1, &buf);
	
	buf = (time_value.hour / 10); //hour
	buf = (buf << 4) | (time_value.hour - buf * 10);
	buf = buf | ((time_value.am_pm << 7) & 0x80);
	if(!rc)
		rc = FW_WriteMainBus(RTC_HOUR_ADDR, 1, &buf);
	
	buf = (time_value.day / 10); //day
	buf = (buf << 4) | (time_value.day - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_DAY_ADDR, 1, &buf);
	
	buf = time_value.day_of_week & 0x07; //day of week
	if(!rc)
		rc = FW_WriteMainBus(RTC_WEEK_ADDR, 1, &buf);
	
	buf = (time_value.month / 10); //month
	buf = (buf << 4) | (time_value.month - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_MONTH_ADDR, 1, &buf);
	
	buf = (time_value.year / 10); //year
	buf = (buf << 4) | (time_value.year - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_YEAR_ADDR, 1, &buf);
	
	buf = (time_value.century / 10); //century
	buf = (buf << 4) | (time_value.century - buf * 10); 
	if(!rc)
		rc = FW_WriteMainBus(RTC_CENTURY_ADDR, 1, &buf);
	
	buf = STOP;  //enable value change
	rc = FW_WriteMainBus(RTC_CTRL_ADDR, 1, &buf) | rc;
	return rc;	
}
*/
//----------------------------------------------------------------------
// The function will be got pcb type of the LT card.
// type=0000: ADSL24 Annex A LT w/ ETSI270 Splitter
// type=0001: ADSL24 Annex A LT w/ ANSI900 Splitter
// type=0010: ADSL24 Annex A LT w/ ETSI600 Splitter
// type=0011: ADSL24 Annex A w/0 Splitter
// type=0100: ADSL24 Annex B w/ ISDN Splitter
// type=0101: ADSL24 Annex B w/o Splitter
// type=1000: SHDSL24 w/o wetting current
// type=1001: SHDSL24 w/ wetting current
//----------------------------------------------------------------------
UMAP_S32 FW_GetLtCardType(UMAP_S32 slot_id, UMAP_U8* type)
{
	return FW_ReadLT(type, CARD_TYPE_ADDR(slot_id), 1);
}

//----------------------------------------------------------------------
// The function will be got pcb version of the LT card.
// version=000: PCB Ver A
// version=001: PCB Ver B
// version=010: PCB Ver C
// ¡K¡K¡K
// version=111: PCB Ver H
//----------------------------------------------------------------------
UMAP_S32 FW_GetLtCardVersion(UMAP_S32 slot_id, UMAP_U8* version)
{
	return FW_ReadLT(version, CARD_VERSION_ADDR(slot_id), 1);
}

//----------------------------------------------------------------------
// The function will be got slot id.
// id=000: SLOT 0
// id=001: SLOT 1
// id=010: SLOT 2
// id=011: SLOT 3
// id=100: SLOT 4
//----------------------------------------------------------------------
//UMAP_S32 FW_GetLtCardSlotId(UMAP_S32 card_num, UMAP_U8* slot_id)
//{
//	return FW_ReadMainBus(CARD_ID_ADDR(card_num), 1, slot_id, UNIT_BYTE);
//}

//----------------------------------------------------------------------
// The function will be set utopia bus enable/disable.
// en=0: Enable LT UTOPIA BUS
// en=1: Disable LT UTOPIA BUS
//----------------------------------------------------------------------
UMAP_S32 FW_SetLtCardUtopia(UMAP_S32 slot_id, UMAP_U8 en)
{
	return FW_WriteLT(&en, UTOPIA_ENABLE_ADDR(slot_id), 1);
}

UMAP_S32 FW_GetLtCardUtopia(UMAP_S32 slot_id, UMAP_U8* en)
{
	return FW_ReadLT(en, UTOPIA_ENABLE_ADDR(slot_id), 1);
}

//----------------------------------------------------------------------
// The function will be set system led of the LT card.
// bit3:system led(green) bit2:system led(red)
// sys=00xxxxxxb: turn off light
// sys=10xxxxxxb: red
// sys=01xxxxxxb: green
//----------------------------------------------------------------------
UMAP_S32 FW_SetLtSystemLed(UMAP_S32 slot_id, UMAP_U8 sys_led)
{
	UMAP_U8 buf;
	FW_ReadLT(&buf, LT_LED_CONTROL_ADDR(slot_id), 1);
	buf = buf & 0x3f;
	buf = buf | sys_led;
	return FW_WriteLT(&buf, LT_LED_CONTROL_ADDR(slot_id), 1);	
}

UMAP_S32 FW_GetLtSystemLed(UMAP_S32 slot_id, UMAP_U8* sys_led)
{
	UMAP_S32 result;
	
	result = FW_ReadLT(sys_led, LT_LED_CONTROL_ADDR(slot_id), 1);
	*sys_led = *sys_led & 0xc0;
	return result;
}

//----------------------------------------------------------------------
// The function will be set dsl led of the LT card.
// bit1:dsl led(green) bit0:dsl led(red)
// dsl=xx00xxxxb: turn off light
// dsl=xx10xxxxb: red
// dsl=xx01xxxxb: green
//----------------------------------------------------------------------
UMAP_S32 FW_SetLtDslLed(UMAP_S32 slot_id, UMAP_U8 dsl_led)
{
	UMAP_U8 buf;
	
	FW_ReadLT(&buf, LT_LED_CONTROL_ADDR(slot_id), 1);
	buf = buf & 0xcf;
	buf = buf | dsl_led;
	return FW_WriteLT(&buf, LT_LED_CONTROL_ADDR(slot_id), 1);
}

UMAP_S32 FW_GetLtDslLed(UMAP_S32 slot_id, UMAP_U8* dsl_led)
{
	UMAP_S32 result;
	
	result = FW_ReadLT(dsl_led, LT_LED_CONTROL_ADDR(slot_id), 1);
	*dsl_led = *dsl_led & 0x30;
	return result;
}

//----------------------------------------------------------------------
// The function will be got or set temperature of the NT or LT.
//----------------------------------------------------------------------
UMAP_S32 FW_GetNtTemperature(UMAP_S32* temperature, UMAP_U32 reg_addr)
{
	int rc;
	unsigned char tmp_value[2];
	
	rc = FW_ReadI2c(tmp_value, NT_THERMAL_SLAVE_ADDR, reg_addr, THERMAL_DATA_SIZE, TYPE_THERMAL);
        if((tmp_value[0] & 0x80) == 0x0)
         	*temperature = (UMAP_S32)(((tmp_value[0] << 1) & 0xfe) | ((tmp_value[1] >> 7) & 0x01)) / 2;
        else
		*temperature = (UMAP_S32)((((tmp_value[0] << 1) & 0xfe) | ((tmp_value[1] >> 7) & 0x01)) - 0x100 ) / 2;
	return rc;	
}

UMAP_S32 FW_SetNtTemperature(UMAP_S32 temperature, UMAP_U32 reg_addr)
{
	unsigned char tmp_value[2];
        
        if((temperature > 125) || (temperature < -125))
        	return -1;  //need error define
        
        if(temperature < 0){
		tmp_value[0] = (((temperature * 2) >> 1) | 0x80);
		tmp_value[1] = (((temperature * 2) << 7) & 0x80);
	}
        else{
		tmp_value[0] = (((temperature * 2) >> 1) & 0x7f);
		tmp_value[1] = (((temperature * 2) << 7) & 0x80);		
	}	
	return FW_WriteI2c(tmp_value, NT_THERMAL_SLAVE_ADDR, reg_addr, THERMAL_DATA_SIZE, TYPE_THERMAL);

}

UMAP_S32 FW_GetLtTemperature(UMAP_S32* temperature, UMAP_U32 reg_addr)
{
	int rc;
	unsigned char tmp_value[2];
	
	rc = FW_ReadI2c(tmp_value, LT_THERMAL_SLAVE_ADDR, reg_addr, THERMAL_DATA_SIZE, TYPE_THERMAL);
        if((tmp_value[0] & 0x80) == 0x0)
        	*temperature = (UMAP_S32)(((tmp_value[0] << 1) & 0xfe) | ((tmp_value[1] >> 7) & 0x01)) / 2;
        else
		*temperature = (UMAP_S32)((((tmp_value[0] << 1) & 0xfe) | ((tmp_value[1] >> 7) & 0x01)) - 0x100 ) / 2;
	return rc;	
}

UMAP_S32 FW_SetLtTemperature(UMAP_S32 temperature, UMAP_U32 reg_addr)
{
	unsigned char tmp_value[2];
        
        if((temperature > 125) || (temperature < -125))
        	return -1;
        
        if(temperature < 0){
		tmp_value[0] = (((temperature * 2) >> 1) | 0x80);
		tmp_value[1] = (((temperature * 2) << 7) & 0x80);
	}
        else{
		tmp_value[0] = (((temperature * 2) >> 1) & 0x7f);
		tmp_value[1] = (((temperature * 2) << 7) & 0x80);		
	}	
	return FW_WriteI2c(tmp_value, LT_THERMAL_SLAVE_ADDR, reg_addr, THERMAL_DATA_SIZE, TYPE_THERMAL);

}


//----------------------------------------------------------------------
// The invInfo of NT is a pointer to the 32 byte in which the information will be got or placed.
//----------------------------------------------------------------------
UMAP_S32 FW_GetNtInventory(void* invInfo)
{
	// You must be set GPIO(I2C_SEL) befor you will get NT info.
	
	return FW_ReadI2c(invInfo, NT_SLAVE_ADDR, BASE_ADDR, NT_INFO_SIZE, TYPE_EEPROM);
}

UMAP_S32 FW_SetNtInventory(void* invInfo)
{
	// You must be set GPIO(I2C_SEL) befor you will set NT info.
	
	return FW_WriteI2c(invInfo, NT_SLAVE_ADDR, BASE_ADDR, NT_INFO_SIZE, TYPE_EEPROM);
}

//----------------------------------------------------------------------
// The invInfo of LT is a pointer to the 32 byte in which the information will be got or placed.
//----------------------------------------------------------------------
UMAP_S32 FW_GetLtInventory(UMAP_S32 slot_id, void* invInfo)
{
	UMAP_U32 LT_addr;
	
	if(slot_id >= 0 && slot_id <= 4)
	{
		LT_addr = (LT_BASE + slot_id + 1) && 0xff;
		return FW_ReadI2c(invInfo, LT_addr, BASE_ADDR, LT_INFO_SIZE, TYPE_EEPROM);
	}
	
	return -1;
}

UMAP_S32 FW_SetLtInventory(UMAP_S32 slot_id, void* invInfo)
{
	UMAP_U32 LT_addr;
	
	if(slot_id >= 0 && slot_id <= 4)
	{
		LT_addr = (LT_BASE + slot_id + 1) && 0xff;
		return FW_WriteI2c(invInfo, LT_addr, BASE_ADDR, LT_INFO_SIZE, TYPE_EEPROM);
	}
	
	return -1;
}

//----------------------------------------------------------------------
// Got version of NT or BP(back-plane).
//----------------------------------------------------------------------
UMAP_S32 FW_GetNtVersion(UMAP_U8* nt_version)
{
	UMAP_U8 value;
	UMAP_S32 result;
	
	result = FW_ReadGpio(&value, TRUNK_VER_3);
	if(result < 0)
	{
		return result;
	}
	*nt_version = value;
	
	result = FW_ReadGpio(&value, TRUNK_VER_2);
	if(result < 0)
	{
		return result;
	}
	*nt_version = (*nt_version << 1) | value;
	
	result = FW_ReadGpio(&value, TRUNK_VER_1);
	if(result < 0)
	{
		return result;
	}
	*nt_version = (*nt_version << 1) | value;
	
	result = FW_ReadGpio(&value, TRUNK_VER_0);
	if(result < 0)
	{
		return result;
	}
	*nt_version = (*nt_version << 1) | value;

	return 0;	
}

UMAP_S32 FW_GetBpVersion(UMAP_U8* bp_version)
{
	UMAP_U8 value;
	UMAP_S32 result;
	
	result = FW_ReadGpio(&value, BP_PCB_VER_3);
	if(result < 0)
	{
		return result;
	}
	*bp_version = value;
	
	result = FW_ReadGpio(&value, BP_PCB_VER_2);
	if(result < 0)
	{
		return result;
	}
	*bp_version = (*bp_version << 1) | value;
	
	result = FW_ReadGpio(&value, BP_PCB_VER_1);
	if(result < 0)
	{
		return result;
	}
	*bp_version = (*bp_version << 1) | value;
	
	result = FW_ReadGpio(&value, BP_PCB_VER_0);
	if(result < 0)
	{
		return result;
	}
	*bp_version = (*bp_version << 1) | value;

	return 0;		
}

//----------------------------------------------------------------------
// Got card equipment signal. card_equip=1-->un-equipment  
// card_equip=0-->equipment
//----------------------------------------------------------------------
UMAP_S32 FW_GetBpAllCardEquip0(UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_0);
	if(result < 0)
	{
		return result;
	}
	
	return 0;	
}

UMAP_S32 FW_GetBpAllCardEquip1(UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_1);
	if(result < 0)
	{
		return result;
	}
	
	return 0;	
}

UMAP_S32 FW_GetBpAllCardEquip2(UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_2);
	if(result < 0)
	{
		return result;
	}
	
	return 0;	
}

UMAP_S32 FW_GetBpAllCardEquip3(UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_3);
	if(result < 0)
	{
		return result;
	}
	
	return 0;	
}

UMAP_S32 FW_GetBpAllCardEquip4(UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_4);
	if(result < 0)
	{
		return result;
	}
	
	return 0;	
}

UMAP_S32 FW_GetBpAllCardEquipAll(UMAP_S32 slot_id, UMAP_U8* card_equip)
{
	UMAP_S32 result;
	
	switch(slot_id)
	{
	case CARD0:
		result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_0);
		break;
		
	case CARD1:
		result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_1);
		break;
	
	case CARD2:
		result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_2);
		break;
		
	case CARD3:
		result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_3);
		break;
	
	case CARD4:
		result = FW_ReadGpio(card_equip, BP_CARD_EQUIP_4);
		break;
		
	default:
		result = -1;
	}
	
	if(result < 0)
	{
		return result;
	}
	return 0;
}

//----------------------------------------------------------------------
// Got house keeping. hk is bit map. bit0 is house keeping 1,
// bit1 is house keeping 2 and bit2 is house keeping 3
// bit x =1-->no event  bit x=0-->has event
//----------------------------------------------------------------------
UMAP_S32 FW_GetBpHk(UMAP_U8* hk)
{
	UMAP_U8 value;
	UMAP_S32 result;
	
	result = FW_ReadGpio(&value, BP_HK_3);
	if(result < 0)
	{
		return result;
	}
	*hk = value;
	
	result = FW_ReadGpio(&value, BP_HK_2);
	if(result < 0)
	{
		return result;
	}
	*hk = (*hk << 1) | value;
	
	result = FW_ReadGpio(&value, BP_HK_1);
	if(result < 0)
	{
		return result;
	}
	*hk = (*hk << 1) | value;
	
	return 0;	
}

//----------------------------------------------------------------------
// Got fibre status. fibre=1-->fibre is not active  fibre=0-->fibre is active
//----------------------------------------------------------------------
UMAP_S32 FW_GetFibreOpticsUnit1(UMAP_U8* fibre)
{	
	return FW_ReadGpio(fibre, FIBRE_OPTICS_1);
}

UMAP_S32 FW_GetFibreOpticsUnit2(UMAP_U8* fibre)
{
	return FW_ReadGpio(fibre, FIBRE_OPTICS_2);
}

//----------------------------------------------------------------------
// Got ACO. aco=1-->normal  aco=0-->got a signal of cutoff
//----------------------------------------------------------------------
UMAP_S32 FW_GetAcoButton(UMAP_U8* aco)
{	
	return FW_ReadGpio(aco, ACO_BUTTON);
}

//----------------------------------------------------------------------
// Set led of alarm.
// bit1:alarm led(green) bit2:alarm led(red)
// alarm=00: turn off light
// alarm=01: red
// alarm=10: green
// alarm=11: yellow
//----------------------------------------------------------------------
UMAP_S32 FW_SetNtAlarmLed(UMAP_U8 alarm)
{
	FW_WriteGpio(alarm, ALARM_LED_1);
	FW_WriteGpio((alarm >> 1), ALARM_LED_2);
	
	return 0;
}

UMAP_S32 FW_GetNtAlarmLed(UMAP_U8* alarm)
{
	UMAP_U8 value;
	
	FW_ReadGpio(&value, ALARM_LED_1);
	*alarm = value;
	FW_ReadGpio(&value, ALARM_LED_2);
	*alarm = *alarm | (value << 1);
	
	return 0;
}

//----------------------------------------------------------------------
// Set led of system.
// bit1:sys led(green) bit2:sys led(red)
// sys=00: turn off light
// sys=01: red
// sys=10: green
// sys=11: yellow
//----------------------------------------------------------------------
UMAP_S32 FW_SetNtSystemLed(UMAP_U8 sys)
{
	FW_WriteGpio(~sys, SYSTEM_LED_1);
	FW_WriteGpio(~(sys >> 1), SYSTEM_LED_2);

	return 0;
}

UMAP_S32 FW_GetNtSystemLed(UMAP_U8* sys)
{
	UMAP_U8 value;
	
	FW_ReadGpio(&value, SYSTEM_LED_1);
	*sys = value;
	FW_ReadGpio(&value, SYSTEM_LED_2);
	*sys = *sys | (value << 1);
	*sys = (~*sys) & 0x03;
	return 0;
}

//----------------------------------------------------------------------
// Got the error of fan. err_sig=1-->fan error  err_sig=0-->fan normal
//----------------------------------------------------------------------
UMAP_S32 FW_GetBpFanErrsig(UMAP_U8* err_sig)
{
	
	return FW_ReadGpio(err_sig, BP_FAN_ERRSIG);
}

//----------------------------------------------------------------------
// LT card enable. en=0-->disable  en=1-->enable
//----------------------------------------------------------------------
UMAP_S32 FW_SetBpHostBusControl0(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_HBUS_CTRL_0);
}

UMAP_S32 FW_SetBpHostBusControl1(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_HBUS_CTRL_1);
}

UMAP_S32 FW_SetBpHostBusControl2(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_HBUS_CTRL_2);
}

UMAP_S32 FW_SetBpHostBusControl3(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_HBUS_CTRL_3);
}

UMAP_S32 FW_SetBpHostBusControl4(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_HBUS_CTRL_4);
}

//----------------------------------------------------------------------
// Reset of LT. rst=1-->normal  rst=0-->reset
//----------------------------------------------------------------------
UMAP_S32 FW_SetBpSwRst0(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, BP_SW_RST_0);
}

UMAP_S32 FW_SetBpSwRst1(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, BP_SW_RST_1);
}

UMAP_S32 FW_SetBpSwRst2(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, BP_SW_RST_2);
}

UMAP_S32 FW_SetBpSwRst3(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, BP_SW_RST_3);
}

UMAP_S32 FW_SetBpSwRst4(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, BP_SW_RST_4);
}

//----------------------------------------------------------------------
// Alarm output. alarm=1-->No alarm  alarm=0-->alarm
//----------------------------------------------------------------------
UMAP_S32 FW_SetAlarm1(UMAP_U8 alarm)
{
	return FW_WriteGpio(alarm, BP_ALARM_1);
}

UMAP_S32 FW_SetAlarm2(UMAP_U8 alarm)
{
	return FW_WriteGpio(alarm, BP_ALARM_2);
}

//----------------------------------------------------------------------
// All bus chip enable. en=1-->disable  en=0-->enable
//----------------------------------------------------------------------
extern UMAP_S32 FW_SetAllBusEn(UMAP_U8 en)
{
	return FW_WriteGpio(en, ALL_BUS_ENABLE);
}

//----------------------------------------------------------------------
// Ethernet controler reset. rst=1-->reset  rst=0-->normal
//----------------------------------------------------------------------
UMAP_S32 FW_SetEthRst(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, ETH_RST);
}

//----------------------------------------------------------------------
// Fan enable control. en=1-->turn off  en=0-->turn on
//----------------------------------------------------------------------
UMAP_S32 FW_SetBpFanEn(UMAP_U8 en)
{
	return FW_WriteGpio(en, BP_FAN_ENABLE);
}

//----------------------------------------------------------------------
// Reset of GiGa phy. rst=1-->normal  rst=0-->reset
//----------------------------------------------------------------------
UMAP_S32 FW_SetGigaPhyRst(UMAP_U8 rst)
{
	return FW_WriteGpio(rst, GIGA_RST);
}


