;	[]===========================================================[]
;
;	NOTICE: THIS PROGRAM BELONGS TO AWARD SOFTWARE INTERNATIONAL(R)
;	        INC. IT IS CONSIDERED A TRADE SECRET AND IS NOT TO BE
;	        DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED
;	        WRITTEN AUTHORIZATION FROM THE OWNER.
;
; 	[]===========================================================[]
;

;----------------------------------------------------------------------------
;Rev	Date	 Name	Description
;----------------------------------------------------------------------------
;R02A	12/22/98 KGN	Fix code for can't record cardbus chip type
;R04	10/08/98 KGN	Add RICOH cardbus support
;R03	07/02/98 KGN	Add code for fill Subvender ID and SERIRQ function
;R02	10/28/97 RAX	Fixed mistake
;R01	09/10/97 ADS	Fixed complier error .
;R00	09/19/97 RAX	Init Version



ifdef	MASM611
.MODEL  SMALL,BASIC
OPTION	PROC: PRIVATE
endif	;MASM611

.386P

		PAGE	56,132
.XLIST
		INCLUDE BIOS.CFG
		include	COMMON.EQU
		INCLUDE COMMON.MAC
		include	bsetup.inc
		include	fshadow.equ

ifdef	PNP_BIOS
		include	PNP.EQU
endif	;PNP_BIOS


G_RAM		SEGMENT USE16 AT 0

		ORG	04H*4
		INCLUDE SEG_0.INC

		ORG	400H
		INCLUDE G_RAM.INC
ifdef	PNP_BIOS
		ORG	2000h
		INCLUDE PNPDATA.INC
endif	;PNP_BIOS

G_RAM		ENDS

.LIST

ifdef	Cardbus_support		;R01
		extrn	F000_Set_CfgSpace_Byte:near
		extrn	F000_Set_CfgSpace_Word:near
		extrn	F000_get_CfgSpace_Word:near		;r02
endif;	Cardbus_support		;R01

EGROUP		GROUP	ECODE
ECODE		SEGMENT USE16 PARA PUBLIC 'ECODE'
		ASSUME	CS:EGROUP,DS:G_RAM,ES:EGROUP

;================================================================
; Cardbus_Init:
; Init Cardbus for legacy support
; Input : CH = Slot No+Dev No.
; Output: None
; Remark: Don't destroy any register
;================================================================
		public	Cardbus_Init
Cardbus_Init	proc	near
ifdef	Cardbus_support
		pushad

		xor	cl,cl
		mov	Cardbus_SlotID[bp],cx
		Call	F000_Get_CfgSpace_Word	;R02
;R02		Call	F000_Set_CfgSpace_Word

		mov	bl, Ti_Cardbus
		cmp	ax,104Ch		;Ti cardbus chip?
		je	short unknow_vendor
		mov	bl, O2_Cardbus
		cmp	ax,1217h		;O2 cardbus chip?
;R02		je	short unknow_vendor
;R02A		je	short Not_Ti_type	;R02
		je	short unknow_vendor	;R02
;R03		mov	bl, O2_Cardbus
		mov	bl, Cirrus_Cardbus	;R03
		cmp	ax,1013h		;Cirrus cardbus chip?
		je	short unknow_vendor
;R04 - Start
		mov	bl, RICOH_Cardbus
		cmp	ax, 1180h		;RICOH cardbus chip?
;R02A		je	short Not_Ti_type
		je	short unknow_vendor	;R02A
;R04 - End
		xor	bl,bl			;Non support
unknow_vendor:
		mov	byte ptr Cardbus_Vendor[bp], bl

		mov	cx,Cardbus_SlotID[bp]
		mov	cl,4				;Reg 4h
		mov	al,07
		Call	F000_Set_CfgSpace_Byte

		mov	cx,Cardbus_SlotID[bp]
		mov	cl,44h				;Reg 44h
		mov	al,0E1h
		Call	F000_Set_CfgSpace_Byte

		mov	cx,Cardbus_SlotID[bp]
		mov	cl,45h				;Reg 45h
		mov	al,003h
		Call	F000_Set_CfgSpace_Byte

		mov	cx,Cardbus_SlotID[bp]
		mov	cl,82h				;Reg 82h
		mov	al,024h
		Call	F000_Set_CfgSpace_Byte

		mov	cx,Cardbus_SlotID[bp]
		mov	cl,92h				;Reg 92h
		mov	al,072h
		Call	F000_Set_CfgSpace_Byte

	;;;; Ti cardbus Set reg.91 default value for speaker-out and PCI INTA(B)
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,91h				;func0 Reg 91h
		mov	al,22h
		push	cx
		Call	F000_Set_CfgSpace_Byte
		pop	cx
		or	cx,100h				;func1 Reg 91h
		Call	F000_Set_CfgSpace_Byte

Not_Ti_type:						;R02
;R03 - Start
ifdef	Cardbus_Use_SERIRQ
		cmp	byte ptr Cardbus_Vendor[bp], Ti_Cardbus
		jne	short NotTiCardbus
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,92h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		and	al,11111001b		;set serialized interrupt
		or	al,00000100b		;and parallel PCI interrupt INTA
		Call	F000_Set_CfgSpace_Byte
		jmp	short SetCardbusOver
NotTiCardbus:
		cmp	byte ptr Cardbus_Vendor[bp], O2_Cardbus
		jne	short NotO2Cardbus

		mov	dx, 3e0h
		mov	al, 3bh
		out	dx, al
		inc	dx
		mov	al, 2			;set PCI/Way interrupt
		out	dx, al
NotO2Cardbus:
;R04 - Start
		cmp	byte ptr Cardbus_Vendor[bp], RICOH_Cardbus
		jne	short NotRICOHCardbus
		mov	cx,Cardbus_SlotID[bp]
		mov	cl, 82h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		or	al, 10000000b		;enable SERIRQ INTA, INTB
		Call	F000_Set_CfgSpace_Byte
NotRICOHCardbus:
;R04 - End
SetCardbusOver:
endif	;Cardbus_Use_SERIRQ
;R03 - End
		extrn	Ct_Cardbus_init:near
		call	Ct_Cardbus_init
;R03 - Start
	; fill SubVenderID
;R04 - Start
		cmp	byte ptr Cardbus_Vendor[bp], RICOH_Cardbus
		jne	short NotRICOHCardbus1
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,82h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		or	al,01000000b		;Enable Subsystem ID Writeable
		Call	F000_Set_CfgSpace_Byte
NotRICOHCardbus1:
		cmp	byte ptr Cardbus_Vendor[bp], Ti_Cardbus
		jne	short NotTiCardbus1
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,80h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		and	al,11011111b		;Enable Subsystem ID Writeable
		Call	F000_Set_CfgSpace_Byte
NotTiCardbus1:
;R04 - End
		mov	cx,Cardbus_SlotID[bp]
		mov	cl, 40h
		mov	al, 12h
		Call	F000_Set_CfgSpace_Byte
		mov	cl, 41h
		mov	al, 34h
		Call	F000_Set_CfgSpace_Byte
		mov	cl, 42h
		mov	al, 56h
		Call	F000_Set_CfgSpace_Byte
		mov	cl, 43h
		mov	al, 78h
		Call	F000_Set_CfgSpace_Byte
;R03 - End
;R04 - Start
		cmp	byte ptr Cardbus_Vendor[bp], RICOH_Cardbus
		jne	short NotRICOHCardbus2
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,82h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		and	al, not 01000000b	;Disable Subsystem ID Writeable
		Call	F000_Set_CfgSpace_Byte
NotRICOHCardbus2:
		cmp	byte ptr Cardbus_Vendor[bp], Ti_Cardbus
		jne	short NotTiCardbus2
		mov	cx,Cardbus_SlotID[bp]
		mov	cl,80h
		push	cx
		Call	F000_Get_CfgSpace_Word
		pop	cx
		or	al,00100000b		;Disable Subsystem ID Writeable
		Call	F000_Set_CfgSpace_Byte
NotTiCardbus2:
;R04 - End
		popad
endif	;Cardbus_support
		ret
Cardbus_Init	ENDP

ECODE		ENDS


DGROUP		GROUP	FCODE
FCODE		SEGMENT USE16 PARA PUBLIC 'CODE'
		ASSUME	CS:DGROUP,DS:DGROUP

ifdef	Cardbus_support
ifdef	Cardbus_ZV_Firmware_SUPPORT
		public	Chk_ZV_SUPPORT
Chk_ZV_SUPPORT	PROC	near
		extrn	Ct_Chk_ZV_SUPPORT:near
		call	Ct_Chk_ZV_SUPPORT
		ret
Chk_ZV_SUPPORT	ENDP

		public	ZV_buffer_Ctrl
ZV_buffer_Ctrl	PROC	near
		extrn	Ct_ZV_buffer_Ctrl:near
		call	Ct_ZV_buffer_Ctrl
		ret
ZV_buffer_Ctrl	ENDP
endif	;Cardbus_ZV_Firmware_SUPPORT
endif	;Cardbus_support

FCODE		ENDS
		END
