/*******************************************************************************
** Document: FW_cardinfo_api.h
** Copyright (c) 2004 R&D Center, Tailyn Communication Company, Ltd.  
** Created by: Chien Chung Lo
** Date: Dec. 13, 2004
** Description: Firmware interface API.
** Version: 0.1
*******************************************************************************/
#ifndef FW_CARDINFO_H_
#define FW_CARDINFO_H_
//----------------------------------------------------------------------
#include <FW_i2c/FW_i2c_api.h>
#include <FW_gpio/FW_gpio_api.h>
#include <FW_lt/FW_lt_api.h>
#include <FW_mainbus/FW_mainbus_api.h>
#include <FW_flash/FW_flash_api.h>

#include <umap_type.h>

#define CARD0		0
#define CARD1		1
#define CARD2		2
#define CARD3		3
#define CARD4		4

//----------------------------------------------------------------------
//  The function will be read and written SRAM
//#define SRAM_BASE_ADDR        HOST_SRAM_ADDR

//UMAP_S32 FW_ReadSRAM(UMAP_U32 addr, void *data);
//UMAP_S32 FW_WriteSRAM(UMAP_U32 addr, void *data);
//----------------------------------------------------------------------
/*              "RTC No supported"
struct rtc{
        UMAP_U32 century; // 0~99
	UMAP_U32 year; // 0~99
	UMAP_U32 month; // 01~12
	UMAP_U32 day_of_week; // 01~07 sunday=1 ... saturday=7
	UMAP_U32 day; // 01~31
	UMAP_U32 am_pm; //am:0   pm:1
	UMAP_U32 hour; // 1~12
	UMAP_U32 minute; // 0~59
	UMAP_U32 second; // 0~59
};

//----------------------------------------------------------------------
// The function will be got or set RTC.
// The member describes the value in the struct rtc
#define RTC_SECOND_ADDR       (HOST_RTC_ADDR + 0)
#define RTC_MINUTE_ADDR       (HOST_RTC_ADDR + 2)
#define RTC_HOUR_ADDR         (HOST_RTC_ADDR + 4)
#define RTC_DAY_ADDR          (HOST_RTC_ADDR + 6)
#define RTC_WEEK_ADDR         (HOST_RTC_ADDR + 8)
#define RTC_MONTH_ADDR        (HOST_RTC_ADDR + 9)
#define RTC_YEAR_ADDR         (HOST_RTC_ADDR + 10)
#define RTC_CTRL_ADDR         (HOST_RTC_ADDR + 14)
#define RTC_CENTURY_ADDR      (HOST_RTC_ADDR + 15)

#define STOP      0x04
#define UTI       0x08


extern UMAP_S32 FW_CheckRtcSetting();
extern UMAP_S32 FW_GetRtc(struct rtc* time_value);
extern UMAP_S32 FW_SetRtc(struct rtc time_value);
*/
//----------------------------------------------------------------------
// 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
#define CARD_TYPE_ADDR(x)      (CARD0_CARD_TYPE_ADDR + x * 0x40000)

extern UMAP_S32 FW_GetLtCardType(UMAP_S32 slot_id, UMAP_U8* type);

//----------------------------------------------------------------------
// 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
#define CARD_VERSION_ADDR(x)   (CARD0_PCB_VERSION_ADDR + x * 0x40000)

extern UMAP_S32 FW_GetLtCardVersion(UMAP_S32 slot_id, UMAP_U8* version);

//----------------------------------------------------------------------
// 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
//#define CARD_ID_ADDR(x)  (CARD0_SLOT_ID_ADDR + x *0x40000)

//extern UMAP_S32 FW_GetLtCardSlotId(UMAP_S32 card_num, UMAP_U8* slot_id);

//----------------------------------------------------------------------
// The function will be set utopia.
// en=0: Enable LT UTOPIA BUS
// en=1: Disable LT UTOPIA BUS
#define UTOPIA_ENABLE_ADDR(x)		(CARD0_UTOPIA_ENABLE_ADDR + x * 0x40000)
#define LT_UTOPIA_BUS_ENABLE		0
#define LT_UTOPIA_BUS_DISABLE		1
extern UMAP_S32 FW_SetLtCardUtopia(UMAP_S32 slot_id, UMAP_U8 en);
extern UMAP_S32 FW_GetLtCardUtopia(UMAP_S32 slot_id, UMAP_U8* en);

//----------------------------------------------------------------------
// The function will be set led of the LT card.
// bit1:system led(green) bit2:system led(red)
// sys=00xxxxxxb: turn off light
// sys=10xxxxxxb: red
// sys=01xxxxxxb: green
#define LT_LED_CONTROL_ADDR(x)			(CADR0_LED_CONTROL_ADDR + x * 0x40000)
#define UNIT_LED_RED				0x80
#define UNIT_LED_GREEN				0x40
#define UNIT_LED_YELLOW				0xc0
#define UNIT_LED_TURN_OFF			0x00

extern UMAP_S32 FW_SetLtSystemLed(UMAP_S32 slot_id, UMAP_U8 sys_led);
extern UMAP_S32 FW_GetLtSystemLed(UMAP_S32 slot_id, UMAP_U8* sys_led);

//----------------------------------------------------------------------
// The function will be set dsl led of the LT card.
// bit1:dsl led(green) bit2:dsl led(red)
// dsl=xx00xxxxb: turn off light
// dsl=xx10xxxxb: red
// dsl=xx01xxxxb: green
#define LINK_LED_RED				0x20
#define LINK_LED_GREEN				0x10
#define LINK_LED_YELLOW				0x30
#define LINK_LED_TURN_OFF			0x00

extern UMAP_S32 FW_SetLtDslLed(UMAP_S32 slot_id, UMAP_U8 dsl_led);
extern UMAP_S32 FW_GetLtDslLed(UMAP_S32 slot_id, UMAP_U8* dsl_led);

//----------------------------------------------------------------------
// The function will be got or set temperature of NT or LT.
extern UMAP_S32 FW_GetNtTemperature(UMAP_S32* temperature, UMAP_U32 reg_addr);
extern UMAP_S32 FW_SetNtTemperature(UMAP_S32 temperature, UMAP_U32 reg_addr);

extern UMAP_S32 FW_GetLtTemperature(UMAP_S32* temperature, UMAP_U32 reg_addr);
extern UMAP_S32 FW_SetLtTemperature(UMAP_S32 temperature, UMAP_U32 reg_addr);

//----------------------------------------------------------------------
// The invInfo of NT is a pointer to the 32 byte in which the information will be got or placed.
extern UMAP_S32 FW_GetNtInventory(void* invInfo);
extern UMAP_S32 FW_SetNtInventory(void* invInfo);

//----------------------------------------------------------------------
// The invInfo of LT is a pointer to the 32 byte in which the information will be got or placed.
extern UMAP_S32 FW_GetLtInventory(UMAP_S32 slot_id, void* invInfo);
extern UMAP_S32 FW_SetLtInventory(UMAP_S32 slot_id, void* invInfo);

//----------------------------------------------------------------------
// Got version of NT or BP(back-plane).
extern UMAP_S32 FW_GetNtVersion(UMAP_U8* nt_version);
extern UMAP_S32 FW_GetBpVersion(UMAP_U8* bp_version);

//----------------------------------------------------------------------
// Got card equipment signal. card_equip=0-->un-equipment card_equip=1-->equipment
#define LT_EQUIP			1
#define LT_UN_EQUIP			0
extern UMAP_S32 FW_GetBpAllCardEquip0(UMAP_U8* card_equip);
extern UMAP_S32 FW_GetBpAllCardEquip1(UMAP_U8* card_equip);
extern UMAP_S32 FW_GetBpAllCardEquip2(UMAP_U8* card_equip);
extern UMAP_S32 FW_GetBpAllCardEquip3(UMAP_U8* card_equip);
extern UMAP_S32 FW_GetBpAllCardEquip4(UMAP_U8* card_equip);
extern UMAP_S32 FW_GetBpAllCardEquipAll(UMAP_S32 slot_id, UMAP_U8* card_equip);

//----------------------------------------------------------------------
// 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
#define NO_EVENT			1
#define EVENT				0
extern UMAP_S32 FW_GetBpHk(UMAP_U8* hk);

//----------------------------------------------------------------------
// Got fibre status. fibre=1-->fibre is not active  fibre=0-->fibre is active
#define FIBRE_NOACTION		1
#define FIBRE_ACTION		0
extern UMAP_S32 FW_GetFibreOpticsUnit1(UMAP_U8* fibre);
extern UMAP_S32 FW_GetFibreOpticsUnit2(UMAP_U8* fibre);

//----------------------------------------------------------------------
// Got ACO. aco=1-->normal  aco=0-->got a signal of cutoff
#define ACO_NORMAL			1
#define ACO_CUTOFF			0
extern UMAP_S32 FW_GetAcoButton(UMAP_U8* aco);

//----------------------------------------------------------------------
// Set led of alarm.
// bit1:alarm led(green) bit2:alarm led(red)
// alarm=00b: turn off light
// alarm=01b: red
// alarm=10b: green
// alarm=11b: yellow
#define ALARM_LED_TURN_OFF		0
#define ALARM_LED_RED			1
#define ALARM_LED_GREEN			2
#define ALARM_LED_YELLOW		3
extern UMAP_S32 FW_SetNtAlarmLed(UMAP_U8 alarm);
extern UMAP_S32 FW_GetNtAlarmLed(UMAP_U8* alarm);

//----------------------------------------------------------------------
// Set led of system.
// bit1:sys led(green) bit2:sys led(red)
// sys=00b: turn off light
// sys=01b: red
// sys=10b: green
// sys=11b: yellow
#define SYS_LED_TURN_OFF		0
#define SYS_LED_RED				1
#define SYS_LED_GREEN			2
#define SYS_LED_YELLOW			3
extern UMAP_S32 FW_SetNtSystemLed(UMAP_U8 sys);
extern UMAP_S32 FW_GetNtSystemLed(UMAP_U8* sys);

//----------------------------------------------------------------------
// Got the error of fan. err_sig=1-->fan error  err_sig=0-->fan normal
#define FAN_ERROR		1
#define FAN_NORMAL		0
extern UMAP_S32 FW_GetBpFanErrsig(UMAP_U8* err_sig);

//----------------------------------------------------------------------
// LT card enable. en=0-->disable  en=1-->enable
#define LT_ENABLE		1
#define LT_DISABLE		0
extern UMAP_S32 FW_SetBpHostBusControl0(UMAP_U8 en);
extern UMAP_S32 FW_SetBpHostBusControl1(UMAP_U8 en);
extern UMAP_S32 FW_SetBpHostBusControl2(UMAP_U8 en);
extern UMAP_S32 FW_SetBpHostBusControl3(UMAP_U8 en);
extern UMAP_S32 FW_SetBpHostBusControl4(UMAP_U8 en);

//----------------------------------------------------------------------
// Reset of LT. rst=1-->normal  rst=0-->reset
#define LT_RESET		0
#define LT_NORMAL		1
extern UMAP_S32 FW_SetBpSwRst0(UMAP_U8 rst);
extern UMAP_S32 FW_SetBpSwRst1(UMAP_U8 rst);
extern UMAP_S32 FW_SetBpSwRst2(UMAP_U8 rst);
extern UMAP_S32 FW_SetBpSwRst3(UMAP_U8 rst);
extern UMAP_S32 FW_SetBpSwRst4(UMAP_U8 rst);

//----------------------------------------------------------------------
// Alarm output. alarm=1-->No alarm  alarm=0-->alarm
#define ALARM_ENABLE	0	
#define ALARM_DISABLE	1
extern UMAP_S32 FW_SetAlarm1(UMAP_U8 alarm);
extern UMAP_S32 FW_SetAlarm2(UMAP_U8 alarm);

//----------------------------------------------------------------------
// All bus chip enable. en=1-->disable  en=0-->enable
#define ALL_ENABLE		0
#define ALL_DISABLE		1
extern UMAP_S32 FW_SetAllBusEn(UMAP_U8 en);

//----------------------------------------------------------------------
// Ethernet controler reset. rst=1-->reset  rst=0-->normal
#define ETH_RESET			1
#define ETH_NORMAL		0
extern UMAP_S32 FW_SetEthRst(UMAP_U8 rst);

//----------------------------------------------------------------------
// Fan enable control. en=1-->turn off  en=0-->turn on
#define FAN_ENABLE		0
#define FAN_DISABLE		1
extern UMAP_S32 FW_SetBpFanEn(UMAP_U8 en);

//----------------------------------------------------------------------
// Reset of GiGa phy. rst=1-->normal  rst=0-->reset
#define GIGA_RESET		0
#define GIGA_NORMAL		1
extern UMAP_S32 FW_SetGigaPhyRst(UMAP_U8 rst);

//----------------------------------------------------------------------
#endif /* FW_CARDINFO_H_ */
