;	[]===========================================================[]
;
;	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
;----------------------------------------------------------------------------
;R35	01/29/99 PHI	Move sensor code to XGROUP.  
;			Please use define SENSOR_IN_XGROUP.
;R34	12/23/98 JMS	Add Cyrix SMBus support. for Cyrix chipset
;R33	10/12/98 PAL	Remove definition for Cyrix compiler error
;R32	10/09/98 PAL	Move all the SMbus of the chipset and use the chipset
;			standard I2C code in CHIPPOST.ASM
;R31	09/28/98 PAL	Fix coding error
;R30	09/18/98 PAL	Move VIA SMbus to sensor.asm
;R10A	09/10/98 AVN	Fixed symbol redefinition.
;R29	09/03/98 LAW	Fixed LM75 work with M1543/M1543C not well
;R28	09/03/98 TNY	Support structure for setup string moving to X-Group.
;R27	07/06/98 RIC	Fixed that CPU Temperature always was showed Zero in
;			VIA VT596 chipset.
;R26	07/01/98 RIC	Add VIA SMBus Support.
;R25	06/19/98 ADS	Add "LM75_SCALE_40_TO_90" define to expand temprature
;			rang form 8 teams to 12 teams. 
;R24	06/18/98 PAL	Add Patch_Temp_offset_for_customer definition
;R23	05/26/98 PAL	Add Cyrix SMBus support.
;R22	05/20/98 PAL	Disable Critical temp and Warning temp item when sensor
;			not exist
;R21	05/15/98 PAL	Change Critical temp range for fitting ACPI HCT testing
;R20	05/11/98 TNY	Add "Update_Sensor_in_CPUFEAT" option.
;R19	05/08/98 DNL	Added sensor chip auto detection function for ACPI
;R18	04/24/98 RAY	Add macro definition for supporting BIOS 6.0
;			"DEFINE_MENUITEM" is a dummy macro in BIOS 4.51 & 4.6
;R16A	04/23/98 RAY	Don't use CMOS directly for CPU FAN
;R17 	04/22/98 JSN	Add No_Special_LM75_Item_Patch defination.
;R16 	04/22/98 PAL	Added CPU_Fan_Turn_on_in_Win98 Support
;R15A	04/16/98 PAL	Fix R15 Compiler error for comflict with some sensor
;R15 	04/16/98 PAL	Added CPU_Temp_Selectable Support 
;R07G	04/01/98 RIC	Fixed that "LM75_ID" define can't set other in VIA
;			chip. (Fixed that it always be set 98h)
;R14	12/31/97 TNY	Add "Temp_Always_Add_20C" definition.
;R13	12/24/97 AVN	Change sensor show in IOFEAT.ASM
;			define 'Update_Sensor_in_IOFEAT'
;R07F	12/08/97 RIC	Fixed that CPU FAN(GPIO4) control fail in Setup.
;R07E	12/04/97 RIC	Fixed that keyboard(GPIO0) have garbage in Setup.
;R12A	12/04/97 RCH	Don't use CMOS directly for ACPI critical temperature
;			setting
;R12	12/03/97 DNL	Added ACPI Thermal Zone support
;R11	11/10/97 TNY	Add "LM75_LoLimit_Difference" option.
;R07D	10/24/97 RIC	Fixed that R07C code mistake in set temp low byte.
;R10	10/27/97 TNY	Support SiS software I2C programming.
;R07C	10/24/97 RIC	Fixed that LM75 warning temp setting is in vain.
;R02B	10/16/97 RCH	Auto-detect LM75 and disabling display item become
;			standard feature.
;R07B	10/06/97 RIC	Fixed that R07 Code. Because E000_GET_SET_PMIO have
;			too much delay.
;R07A	10/03/97 RIC	Reduce R07 Code.
;R09	09/10/97 TNY	Add "Dual_LM75_Support" definition.
;R08	09/09/97 TNY	Add "LM75_SCALE_40_TO_70" definition.
;R07	08/21/97 RIC	Add VIA 586B chipset SMBus support(soft programing).
;R06	08/08/97 TNY	Add ALi M1543 SMBus support.
;R05	08/07/97 RCH	Make routine "Chk_SMBus_READY" and "WaitSmbus" as
;			public procedure for both LM78 & LM75 to prevent
;			duplicate codes
;R02A	07/17/97 TNY	Rewrite "Special_LM75_Item_Patch" .
;R04	07/09/97 TNY	Change disable item to be 120C.
;R03	07/04/97 RAY	Fixed : run from modbin --> hang
;R02	06/23/97 TNY	Add "Special_LM75_Item_Patch" definition, for auto-detection LM75 
;R01	06/18/97 TNY	Always show sensor values in runtime.

ifdef	COMPILE_FOR_SENSOR_ASM
IF	COMPILE_FOR_SENSOR_ASM EQ 2
ifndef	SENSOR_IN_XGROUP			;R35
;R32 - start
ifndef		LM75_ID				
LM75_ID         EQU     98H
endif;		LM75_ID				
		public	Get_LM75_Byte
		public	Set_LM75_Byte
		public	Get_LM75_Word
		public	Set_LM75_Word
		extrn	Ct_I2CReadByte:near
		extrn	Ct_I2CWriteByte:near
		extrn	Ct_I2CReadWord:near
		extrn	Ct_I2CWriteWord:near
Get_LM75_Byte	Proc	Near
	mov	ch, Lm75_ID
	call	Ct_I2CReadByte
			ret
Get_LM75_Byte	ENDP
Set_LM75_Byte	Proc	Near

	mov	ch, Lm75_ID
	call	Ct_I2CWriteByte
			ret
Set_LM75_Byte	ENDP

Get_LM75_Word	Proc	Near
	mov	ch, Lm75_ID
	call	Ct_I2CReadWord
		ret
Get_LM75_Word	ENDP

Set_LM75_Word	Proc	Near
	mov	ch, Lm75_ID
	call	Ct_I2CWriteWord
			ret
Set_LM75_Word	ENDP
;R32 - end
comment	%		    		;R32
ifdef	PIIX_ID					;R06

;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	Get_LM75_Byte
		public	Set_LM75_Byte
		public	Get_LM75_Word
		public	Set_LM75_Word
Get_LM75_Byte	Proc	Near

		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID + 1)	;LM78 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;read data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Byte	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte	Proc	Near

		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID		;LM78 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Byte	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word	Proc	Near

		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID + 1)		;LM75 write ID 
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		mov	dl,03h
		pop	ax
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,06
		in	al,dx			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	ah,al

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Word	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word	Proc	Near

		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,06
		mov	al,ah
		out	dx,al			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Word	Endp
%						;R32
;R09 - start
ifdef	Dual_LM75_Support
;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	Get_LM75_Byte2
		public	Set_LM75_Byte2
		public	Get_LM75_Word2
		public	Set_LM75_Word2
Get_LM75_Byte2	Proc	Near
		mov	ch, LM75_ID2		;R32
		call	Ct_I2CReadByte		;R32
comment	%			;R32
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID2 + 1)	;LM78 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;read data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY
%				;R32
		ret
Get_LM75_Byte2	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte2	Proc	Near
		mov	ch, LM75_ID2		;R32
		call	Ct_I2CWriteByte		;R32
comment	%			;R32
		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID2		;LM78 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 
%				;R32
		ret
Set_LM75_Byte2	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word2	Proc	Near
		mov	ch, LM75_ID2		;R32
		call	Ct_I2CReadWord		;R32
comment	%			;R32
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID2 + 1)		;LM75 write ID 
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		mov	dl,03h
		pop	ax
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,06
		in	al,dx			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	ah,al

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY
%				;R32
		ret
Get_LM75_Word2	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word2	Proc	Near
		mov	ch, LM75_ID2		;R32
		call	Ct_I2CWriteWord		;R32
comment	%			;R32
		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID2		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,06
		mov	al,ah
		out	dx,al			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 
%				;R32
		ret
Set_LM75_Word2	Endp
endif;	Dual_LM75_Support
;R09 - end
;R32endif;	PIIX_ID					;R06
comment %					;R32
;R06 - start
ifdef	M1543
;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	Get_LM75_Byte
		public	Set_LM75_Byte
		public	Get_LM75_Word
		public	Set_LM75_Word
Get_LM75_Byte	Proc	Near

		push	cx

		call	Wait_SMBUS_Idle_Status	;R29

		mov	dx,SMBus_Port +03h
		mov	al,(LM75_ID + 1)	;LM75 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		mov	dl,01h
		mov	al,20h
		out	dx,al			;read data
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,07h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,0ffh
		out	dx,al			;starting access
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:
		newiodelay
		loop	short @B

		call	Chk_SMBus_READY 

		mov	dl,04
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Byte	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte	Proc	Near

		push	ax
		push	cx

		call	Wait_SMBUS_Idle_Status	;R29

		mov	dx,SMBus_Port +03h
		mov	al,LM75_ID		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		mov	dl,01h
		mov	al,20h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,07h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,04h
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,0ffh
		out	dx,al			;starting access
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Byte	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word	Proc	Near

		push	cx

		call	Wait_SMBUS_Idle_Status	;R29

		mov	dx,SMBus_Port +03h
		mov	al,(LM75_ID + 1)	;LM75 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		mov	dl,01h
		mov	al,30h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,07h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,0ffh
		out	dx,al			;starting access
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:
		newiodelay
		loop	short @B

		call	Chk_SMBus_READY 

		mov	dl,05h
		in	al,dx			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	ah,al

		mov	dl,04h
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Word	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word	Proc	Near

		push	ax
		push	cx

		call	Wait_SMBUS_Idle_Status	;R29

		mov	dx,SMBus_Port +03h
		mov	al,LM75_ID		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		mov	dl,01h
		mov	al,30h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,07h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,04
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,05
		mov	al,ah
		out	dx,al			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,0ffh
		out	dx,al			;starting access
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Word	Endp

;R29 - start
		Public	Wait_SMBUS_Idle_Status
Wait_SMBUS_Idle_Status	Proc Near
		push	cx
		mov	cx, 01000h
	Wait_SMBus_Idle_Status_loop:
		mov	dx, SMBus_Port + 0
		mov	al, 0ffh
		out	dx, al

		in	al, dx			;get status
		test	al, 04h
		jnz	short Clear_final
		loop	short Wait_SMBus_Idle_Status_Loop
	Clear_final:
		pop	cx
		ret
Wait_SMBUS_Idle_Status	EndP
;R29 - end
endif;	M1543
;R06 - end

;R07 - starts
ifdef   VT586_ACPI		; VIA Chipset
  IF		VIA_SMBus	EQ	0		;R26

;R30ifdef	SDA_In_GPIO1
;R30SDA             EQU     02	;GPIO1 Data
;R30SCL             EQU     04	;GPIO2 Clock
;R30else;	SDA_In_GPIO1
;R30SDA             EQU     04	;GPIO2 Data (Normal)
;R30SCL             EQU     02	;GPIO1 Clock
;R30endif;	SDA_In_GPIO1

ifndef		LM75_ID				;R07G
LM75_ID         EQU     98H
endif;		LM75_ID				;R07G

;R07A GPIO_Dir        EQU     ACPI_Port+40h
;R07A GPIO_WPort      EQU     ACPI_Port+42h
;R07A GPIO_RdPort     EQU     ACPI_Port+44h
;R30GPIO_Dir        EQU     ACPI_Port+40h		;R07B
;R30GPIO_WPort      EQU     ACPI_Port+42h		;R07B
;R30GPIO_RdPort     EQU     ACPI_Port+44h		;R07B

;R07A - starts
;R30		extrn	Dir_Out:Near
;R30		extrn	Set_Start:Near
;R30		extrn	Wr_Byte:Near
;R30		extrn	Wait_ACK:Near
;R30		extrn	Set_Stop:Near
;R30		extrn	E000_Get_PMIO:near		
;R30		extrn	E000_Set_PMIO:near		
;R30		extrn	E000_Get_Set_PMIO:near		
;R30		extrn	E000_Get_Set_PMIO_OR:near	
;R30		extrn	E000_Get_Set_PMIO_AND:near	
;R07A - ends
;R07A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R07A ;บ  Dir_Out                                                                 บ
;R07A ;บ                                                                          บ
;R07A ;บ  Input:  None                                                            บ
;R07A ;บ  Output: None                                                            บ
;R07A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R07A Dir_Out proc
;R07A         push    ax
;R07A         push    dx
;R07A         mov     dx,GPIO_Dir
;R07A         in      al,dx
;R07A         or      al,06h
;R07A         out     dx,al
;R07A         pop     dx
;R07A         pop     ax
;R07A         ret
;R07A Dir_Out endp
;R07A 
;R30;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R30;บ  Set_Pointer                                                             บ
;R30;บ  Input:  BX = pointer                                                    บ
;R30;บ  Output: CLC = PK                                                        บ
;R30;บ          STC = Fail                                                      บ
;R30;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R30Set_Pointer     proc
;R30        push    bx              ;Save Register Pointer
;R30        call    Dir_Out
;R30        call    Set_Start
;R30        mov     bl,LM75_ID
;R30        call    Wr_Byte
;R30        call    Wait_ACK
;R30        pop     bx
;R30        jc      ErrSet_Pointer
;R30        call    Wr_Byte         ;bx = pointer
;R30        call    Wait_ACK
;R30;Frank  call    Wait_ACK0
;R30        jc      ErrSet_Pointer
;R30        clc
;R30        ret
;R30ErrSet_Pointer:
;R30        stc
;R30        ret
;R30Set_Pointer     endp

;R07A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R07A ;บ  Set_Start                                                               บ
;R07A ;บ  Input:  None                                                            บ
;R07A ;บ  Output: None                                                            บ
;R07A ;บ                                                                          บ
;R07A ;บ  SDA  ----\___                                                           บ
;R07A ;บ  SCL  -------\                                                           บ
;R07A ;บ       1   2                                                              บ
;R07A ;บ        4us 4us                                                           บ
;R07A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R07A Set_Start       proc
;R07A         mov     dx,GPIO_WPort
;R07A         in      al, dx
;R07A         or      al, SDA
;R07A         or      al, SCL
;R07A         out     dx, al                    ;(1) SCL high, SDA hight
;R07A ;;        NEWIODELAY
;R07A         mov     cx, 3                     ;T(su) = 4.7 us
;R07A @@:
;R07A         out     0ebh,al
;R07A         loop    short @B
;R07A 
;R07A         and     al, NOT SDA                     
;R07A         out     dx, al                    ;(2) SCL high,SDA low
;R07A 
;R07A ;;        NEWIODELAY
;R07A         mov     cx, 3                     ;T(su) = 4.7 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A 
;R07A ;For 1'st clock low time
;R07A         and     al, NOT SCL
;R07A         out     dx, al                    ;(3) SCL low, SDA low
;R07A         ret
;R07A Set_Start       endp
;R07A 
;R07A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R07A ;บ  Wr_Byte                                                                 บ
;R07A ;บ                                                                          บ
;R07A ;บ  Input:   BL:Data to I2C Bus                                             บ
;R07A ;บ  Output: None                                                            บ
;R07A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R07A Wr_Byte proc
;R07A         mov     cx ,8
;R07A         mov     dx,GPIO_WPort
;R07A write_B:
;R07A         push    cx
;R07A         mov     cx, 10                          ;T(low) = 4.7 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A 
;R07A         xor     bh, bh
;R07A         shl     bx, 1
;R07A ifdef	SDA_In_GPIO1
;R07A         shl     bh, 1		;;if SDA=02h, SCL=04h
;R07A else;	SDA_In_GPIO1
;R07A         shl     bh,2            ;;if SDA=04h, SCL=02h
;R07A endif;	SDA_In_GPIO1
;R07A         in      al, dx
;R07A         and     al, NOT SDA
;R07A         or      al, bh
;R07A         out     dx, al                          ;out data bit MSB first
;R07A 
;R07A         out     0ebh, al                        ;T(setup) = 250 ns
;R07A 
;R07A         or      al, SCL
;R07A         out     dx, al                          ;SCL high, receiver will read data
;R07A         
;R07A         mov     cx, 8                           ;T(high) = 4 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A 
;R07A         and     al, NOT SCL                     ;SCL low
;R07A         out     dx, al
;R07A 
;R07A         pop     cx
;R07A         loop    write_B
;R07A         ret
;R07A Wr_Byte endp
;R07A 
;R07A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R07A ;บ  Wait_ACK                                                                บ
;R07A ;บ                                                                          บ
;R07A ;บ  Input:  None                                                            บ
;R07A ;บ  Output: CLR :  Acknowledge                                              บ
;R07A ;บ          STC : !Acknowledge                                              บ
;R07A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R07A Wait_ACK        proc
;R07A         mov     cx, 8                           ;T(hold) = 4.7 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A 
;R07A         mov     dx,GPIO_WPort
;R07A         out     0ebh, al                        ;T(setup) = 250 ns
;R07A         or      al, SCL                         ;SCL = high
;R07A         out     dx, al
;R07A ;;;; Wait SDA low
;R07A         mov     dx,GPIO_Dir
;R07A         in      al, dx
;R07A         and     al, NOT SDA      
;R07A         out     dx, al                          ;set SDA input mode     
;R07A 
;R07A         mov     cx, 8                           ;T(high) >= 8 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A 
;R07A         mov     dx,GPIO_RdPort
;R07A         in      al, dx                          ;read ack
;R07A         mov     bl, al                          ;Saved data
;R07A         mov     dx,GPIO_WPort
;R07A         in      al, dx
;R07A         and     al, NOT SCL                     ;SCL low
;R07A         out     dx, al
;R07A         mov     dx,GPIO_Dir
;R07A         in      al, dx
;R07A         or      al, SDA  
;R07A         or      al, SCL  
;R07A         out     dx, al                          ;set SDA,SCL Output mode        
;R07A         test    bl, SDA
;R07A         jnz     ACK_Err_ret
;R07A         clc
;R07A         ret
;R07A ACK_Err_ret:
;R07A         stc
;R07A         ret
;R07A Wait_ACK        endp
;R07A 
;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Rd_Data                                                                 บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: BL: return data                                                 บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R30Rd_Data proc
;R07A        mov     dx,GPIO_Dir
;R07A        in      al, dx
;R07A        and     al, NOT SDA             
;R07A        or      al, SCL
;R07A        out     dx, al                  ; Set SCL O/P , SDA I/P
;R30        mov     cx,40h                  ;R07A
;R30        mov     bl, NOT SDA		;R07A
;R30	mov	bh, SCL			;R07A
;R30        call    E000_Get_Set_PMIO       ;R07A
;R30
;R30        xor     bx, bx          ;Frank
;R30        xor     ax, ax
;R30        mov     cx, 8
;R30Rd_byte:
;R30        push    cx
;R30        mov     cx, 8                           ;T(low) = 4.7 us
;R30@@:
;R30        out     0ebh, al
;R30        loop    short @B
;R07A        mov     dx,GPIO_WPort
;R07A        or      al, SCL
;R07A        out     dx, al                          ;SCL high, receiver will read data
;R07B        mov     cx,42h                  ;R07A
;R07B        mov     bl,SCL                  ;R07A
;R07B        call    E000_Get_Set_PMIO_OR    ;R07A
;R30        mov     dx,GPIO_WPort		;R07B
;R30	in	al, dx			;R07F
;R30        or      al, SCL			;R07B
;R30        out     dx, al                  ;R07B SCL high, receiver will read data
;R30        mov     cx, 8                           ;T(high) = 4 us
;R30@@:
;R30        out     0ebh, al
;R30        loop    short @B
;R30
;R07A        mov     dx,GPIO_RdPort
;R07A        in      al, dx
;R30        mov     cx,44h			;R07A
;R30        call    E000_Get_PMIO		;R07A
;R30
;R30        and     al, SDA 
;R30ifdef	SDA_In_GPIO1
;R30        shr     al, 1		;;if SDA=02h, SCL=04h
;R30else;	SDA_In_GPIO1
;R30        shr     al, 2		;;if SDA=04h, SCL=02h
;R30endif;	SDA_In_GPIO1
;R30        shl     bl, 1           
;R30        or      bl, al

;R07F         and     al, NOT SCL                     ;SCL low
;R07F ;R07A        mov     dx,GPIO_WPort
;R07F ;R07A        out     dx, al
;R07F         mov     cx,42h                  ;R07A
;R07F         call    E000_Set_PMIO		;R07A
;R30		mov     dx, GPIO_WPort		;R07F
;R30		in	al, dx			;R07F
;R30		and     al, NOT SCL             ;R07F SCL low
;R30		out	dx, al			;R07F
;R30
;R30        pop     cx
;R30        loop    Rd_byte
;R30
;R30        mov     cx, 8                           ;T(hd)
;R30@@:
;R30        out     0ebh, al
;R30        loop    short @B
;R30
;R07A        mov     dx,GPIO_Dir
;R07A        in      al, dx
;R07A        or      al, SDA
;R07A        or      al, SCL
;R07A        out     dx, al                  ; Set SCL O/P , SDA I/P
;R07B        mov     cx,40h                  ;R07A
;R07B        mov     bl, SDA			;R07A
;R07B	or	bl, SCL			;R07A
;R07B        call    E000_Get_Set_PMIO_OR	;R07A
;R30        mov     dx,GPIO_Dir		;R07B
;R30        in      al, dx			;R07B
;R30        or      al, SDA			;R07B
;R30        or      al, SCL			;R07B
;R30        out     dx, al                  ;R07B Set SCL O/P , SDA I/P
;R30
;R30        ret
;R30Rd_Data endp
;R30
;R30
;R30;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R30;บ  Set_NoACK                                                               บ
;R30;บ                                                                          บ
;R30;บ  Input:  None                                                            บ
;R30;บ  Output: None                                                            บ
;R30;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R30Set_NoACK       proc
;R07A        mov     dx,GPIO_WPort
;R07A        in      al, dx
;R07A        and     al, NOT SCL
;R07A        or      al, SDA
;R07A        out     dx, al                  ;out No ACK
;R07B    mov     cx,42h                  ;R07A
;R07B        mov     bl, NOT SCL             ;R07A
;R07B        mov     bh, SDA			;R07A
;R07B        call    E000_Get_Set_PMIO	;R07A
;R30        mov     dx,GPIO_WPort		;R07B
;R30        in      al, dx			;R07B
;R30        and     al, NOT SCL		;R07B
;R30        or      al, SDA			;R07B
;R30        out     dx, al                  ;R07B out No ACK
;R30
;R30        out     0ebh, al                ;T(setup) = 250 ns
;R30
;R30        or      al, SCL
;R30        out     dx, al                  ;SCL ,SDA = high
;R30        mov     cx, 8                   ;T(high) = 4 us
;R30@@:
;R30        out     0ebh, al
;R30        loop    short @B
;R30
;R30        and     al, NOT SCL
;R30        out     dx, al                  ;SCL = low
;R30        out     0ebh, al
;R30
;R30        and     al, NOT SDA
;R30        out     dx, al                  ;SDA = low
;R30        out     0ebh, al
;R30
;R30        ret
;R30Set_NoACK       endp

;R07A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R07A ;บ  Set_Stop                                                                บ
;R07A ;บ                                                                          บ
;R07A ;บ  Input:  None                                                            บ
;R07A ;บ  Output: None                                                            บ
;R07A ;บ  SDA  ___/-----                                                          บ
;R07A ;บ  SCL  ---------                                                          บ
;R07A ;บ       1  2   3                                                           บ
;R07A ;บ        4us 4us                                                           บ
;R07A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R07A Set_Stop        proc
;R07A ;Frank  call    Dir_Out
;R07A         mov     dx,GPIO_WPort
;R07A         out     0ebh, al
;R07A         out     0ebh, al
;R07A 
;R07A         in      al, dx
;R07A         or      al, SCL                         
;R07A         and     al, NOT SDA                             
;R07A         out     dx, al                    ;(1) SCL high, SDA low
;R07A         mov     cx, 10h                    ;4 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A         or      al, SDA                         
;R07A         out     dx, al                    ;(2) SCL high, SDA high
;R07A         mov     cx, 10h                    ;4 us
;R07A @@:
;R07A         out     0ebh, al
;R07A         loop    short @B
;R07A         ret
;R07A Set_Stop        endp
;R07A 
;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_ACK                                                                 บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: None                                                            บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R30Set_ACK proc
;R07A        mov     dx,GPIO_WPort
;R07A        in      al, dx
;R07A        and     al, NOT SCL
;R07A        and     al, NOT SDA
;R07A        out     dx, al                  ;out ACK
;R30        mov     cx,42h                  ;R07A
;R30	in	al, dx			;R07F
;R30        mov     bl, NOT SCL             ;R07A
;R30        and	bl, NOT SDA		;R07A
;R30        call    E000_Get_Set_PMIO_AND	;R07A
;R30
;R30        out     0ebh, al                ;T(setup) = 250 ns
;R30
;R30	mov	dx,GPIO_WPort		;R07E
;R30        or      al, SCL
;R30        out     dx, al                  ;SCL ,SDA = high
;R30        mov     cx, 8                   ;T(high) = 4 us
;R30@@:
;R30        out     0ebh, al
;R30        loop    short @B
;R30        and     al, NOT SCL
;R30        out     dx, al                  ;SCL = low
;R30        out     0ebh, al
;R30
;R30        and     al, NOT SDA
;R30        out     dx, al                  ;SDA = low
;R30        out     0ebh, al
;R30        ret
;R30Set_ACK endp


;[]==============================================================[]
;Input  : CL - register index
;Output : AL - Value read
;[]==============================================================[]
                public  Get_LM75_Byte
                public  Set_LM75_Byte
                public  Get_LM75_Word
                public  Set_LM75_Word
Get_LM75_Byte   Proc    Near

        mov     ch,LM75_ID		;R30
        mov     bl,cl
        call    Set_Pointer
        NEWIODELAY
        NEWIODELAY
        call    Set_Start
        mov     bl,LM75_ID
        inc     bl              ;for read operation
        call    Wr_Byte
        call    Wait_ACK
        jc      Rd_1ByteReg_Fail
        call    Rd_Data         ;bl = data
        shl     ebx,16
        call    Set_NoACK
        call    Set_Stop
        shr     ebx,16
        xor     bh,bh   ;BL = value
        mov     al,bl
        clc
        ret
Rd_1ByteReg_Fail:
        stc
        ret

Get_LM75_Byte   Endp

;[]==============================================================[]
;Input : CL - register index
;        AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte   Proc    Near
        push    ax      ;R07C
        mov     bl,cl
;R07C   shl     eax,16
        cli
	mov	ch, LM75_ID		;R30
        call    Set_Pointer
        newiodelay
        newiodelay
;R07C   shr     eax,16
        pop     ax      ;R07C
        mov     bl,al
        call    Wr_Byte
        call    Wait_ACK
        jc      Wr_1ByteReg_Fail
        call    Set_Stop
        clc
        sti
        ret
Wr_1ByteReg_Fail:
        stc
        sti
        ret
Set_LM75_Byte   Endp

;[]==============================================================[]
;Input  : CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word   Proc    Near
        mov     ch,LM75_ID		;R30
        mov     bl,cl           
        call    Set_Pointer
        NEWIODELAY
        NEWIODELAY
        call    Set_Start
        mov     bl,LM75_ID
        inc     bl              ;for read operation
        call    Wr_Byte
        call    Wait_ACK
        jc      Rd_2ByteReg_Fail
        call    Rd_Data 
        shl     ebx,16
        call    Set_ACK
        call    Rd_Data 
        mov     bh,bl
        shl     ebx,8
        call    Set_NoACK
        call    Set_Stop
        shr     ebx,16
        mov     ax,bx
        clc
        ret
Rd_2ByteReg_Fail:
        stc
        ret
Get_LM75_Word   endp

;[]==============================================================[]
;Input : CL - register index
;        AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word   Proc    Near
        push    ax      ;R07C
        mov     bx,cx
;R07C   shl     ebx,16
        push    bx      ;R07C
;R07C   shl     eax,16
        call    Set_Start
        mov     bl,LM75_ID
        call    Wr_Byte
        call    Wait_ACK
        jc      Wr_2ByteReg_Fail
;R07C   shr     ebx,16
        pop     bx      ;R07C
        call    Wr_Byte                 ;bx = TempPoint
        call    Wait_ACK
        jc      Wr_2ByteReg_Fail
;R07C   shr     eax,16
        pop     ax      ;R07C
        push     ax      ;R07D
        mov     bl,al
        call    Wr_Byte
        call    Wait_ACK
        jc      Wr_2ByteReg_Fail
;R07C   shr     eax,8
        pop     ax      ;R07D
        shr     ax,8    ;R07C
        mov     bl,al
        call    Wr_Byte
        call    Wait_ACK
        jc      Wr_2ByteReg_Fail
        call    Set_Stop
        clc
        ret
Wr_2ByteReg_Fail:
        stc
        ret
Set_LM75_Word   Endp

  ENDIF;	VIA_SMBus	EQ	0		;R26
endif;	VT586_ACPI
;R07 - ends

;R26 - starts
if	VIA_SMBus

;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	Get_LM75_Byte
		public	Set_LM75_Byte
		public	Get_LM75_Word
		public	Set_LM75_Word
Get_LM75_Byte	Proc	Near

		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID + 1)	;LM78 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;read data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Byte	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte	Proc	Near

		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID		;LM78 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Byte	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word	Proc	Near

		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID + 1)		;LM75 write ID 
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		mov	dl,03h
		pop	ax
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,06
		in	al,dx			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	ah,al

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY

		ret
Get_LM75_Word	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word	Proc	Near

		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,06
		mov	al,ah
		out	dx,al			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		ret
Set_LM75_Word	Endp
ifdef	Dual_LM75_Support
;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	Get_LM75_Byte2
		public	Set_LM75_Byte2
		public	Get_LM75_Word2
		public	Set_LM75_Word2
Get_LM75_Byte2	Proc	Near
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID2 + 1)	;LM78 read cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;read data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY
		ret
Get_LM75_Byte2	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte2	Proc	Near

		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID2		;LM78 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,48h
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 
		ret
Set_LM75_Byte2	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word2	Proc	Near
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,(LM75_ID2 + 1)		;LM75 write ID 
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		mov	dl,03h
		pop	ax
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 

		mov	dl,06
		in	al,dx			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	ah,al

		mov	dl,05
		in	al,dx			;Data0
		NEWIODELAY
		NEWIODELAY
		ret
Get_LM75_Word2	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word2	Proc	Near
		push	ax
		push	cx

		mov	dx,SMBus_Port +04h
		mov	al,LM75_ID2		;LM75 write cmd
		out	dx,al
		NEWIODELAY
		NEWIODELAY

		call	Chk_SMBus_READY 

		pop	ax
		mov	dl,03h
		out	dx,al			;Index
		NEWIODELAY
		NEWIODELAY

		pop	ax
		mov	dl,05
		out	dx,al			;Data0
		NEWIODELAY
		NEWIODELAY

		mov	dl,06
		mov	al,ah
		out	dx,al			;Data1
		NEWIODELAY
		NEWIODELAY

		mov	dl,02h
		mov	al,4ch
		out	dx,al			;write data
		NEWIODELAY
		NEWIODELAY

		xor	cx,cx
	@@:				
		newiodelay			
		loop	short @B			

		call	Chk_SMBus_READY 
		ret
Set_LM75_Word2	Endp
endif;	Dual_LM75_Support
endif;	VIA_SMBus
;R26 - ends
SIS_SMBus	=	0
ifdef   SIS_5598_PCI_RESET		
SIS_SMBus	=	1
endif;  SIS_5598_PCI_RESET		
ifdef   SIS5595_ID
SIS_SMBus	=	1
endif;  SIS5595_ID

;R10 - starts
if	SIS_SMBus		; SiS Chipset

;R10A SDA             EQU     10h	;I2C Data 
;R10A SCL             EQU     08h	;I2C Clock
;R10A 
;R10A 		extrn	F000_Get_CT:near
;R10A 		extrn	F000_Set_CT:near
;R10A 
;R10A DelayIO:
;R10A 		push	cx
;R10A 		mov	cx,300h
;R10A 	@@:
;R10A 		newiodelay
;R10A 		loop	@B
;R10A 		pop	cx
;R10A 		ret
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Set_Start                                                               บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: None                                                            บ
;R10A ;บ                                                                          บ
;R10A ;บ  SDA  ----\___                                                           บ
;R10A ;บ  SCL  -------\                                                           บ
;R10A ;บ       1   2                                                              บ
;R10A ;บ        4us 4us                                                           บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Set_Start       proc	Near
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A         	or	al, SCL
;R10A         	call	F000_Set_Ct
;R10A         
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A         	or	al, SDA
;R10A         	call	F000_Set_Ct
;R10A 
;R10A 		call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,NOT SDA
;R10A         	call	F000_Set_Ct
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A 
;R10A                 call	DelayIO			
;R10A         
;R10A ;For 1'st clock low time
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,NOT SCL
;R10A         	call	F000_Set_Ct
;R10A 
;R10A                 call	DelayIO			
;R10A         
;R10A                 ret
;R10A Set_Start       endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Wr_Byte                                                                 บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:   BL:Data to I2C Bus                                             บ
;R10A ;บ  Output: None                                                            บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Wr_Byte		proc	Near
;R10A 
;R10A                 pusha					
;R10A         	mov	cx,086dh
;R10A                 call	F000_Get_Ct			
;R10A                 and     al,NOT SCL			
;R10A                 call	F000_Set_Ct			
;R10A                 popa					
;R10A 
;R10A                 mov     dx,bx
;R10A                 mov     cx ,8
;R10A write_B:
;R10A                 push    cx
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A 
;R10A                 xor     dh,dh   
;R10A                 shl     dx,1    
;R10A                 shl     dh,4            ;;if SDA=10h, SCL=08h
;R10A         	mov	bl,dh
;R10A 
;R10A         	push	dx
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,NOT SDA              
;R10A                 or      al,bl			;data                   
;R10A         	call	F000_Set_Ct
;R10A                 NEWIODELAY      
;R10A         
;R10A                 call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al,SCL			
;R10A         	call	F000_Set_Ct
;R10A                 call	DelayIO			
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A                 NEWIODELAY      
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,NOT SCL		
;R10A         	call	F000_Set_Ct
;R10A                 call	DelayIO			
;R10A         
;R10A         	pop	dx
;R10A                 pop     cx
;R10A                 loop    write_B
;R10A                 ret
;R10A Wr_Byte endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Wait_ACK                                                                บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: CLR :  Acknowledge                                              บ
;R10A ;บ          STC : !Acknowledge                                              บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Wait_ACK        proc	Near
;R10A         	mov	cx,086dh
;R10A                 call	F000_Get_Ct		
;R10A                 and     al, not SCL		
;R10A                 call	F000_Set_Ct		
;R10A                 call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al, SCL			
;R10A         	call	F000_Set_Ct
;R10A 
;R10A                 call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A                 call	F000_Get_Ct		
;R10A                 and	al,NOT SCL		
;R10A                 call	F000_Set_Ct		
;R10A                 call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 call	DelayIO			
;R10A                 mov     bl, al			
;R10A         	and	al,NOT SCL
;R10A         	call	F000_Set_Ct
;R10A                 call	DelayIO			
;R10A         
;R10A                 test    bl, SDA
;R10A                 jnz     short ACK_Err_ret
;R10A                 clc
;R10A                 ret
;R10A ACK_Err_ret:
;R10A 	        stc
;R10A         	ret
;R10A Wait_ACK        endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Set_Stop                                                                บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: None                                                            บ
;R10A ;บ  SDA  ___/-----                                                          บ
;R10A ;บ  SCL  ---------                                                          บ
;R10A ;บ       1  2   3                                                           บ
;R10A ;บ        4us 4us                                                           บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Set_Stop        proc	Near
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,not SCL
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al,NOT SDA              
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al,SCL
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al,SDA
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A 
;R10A                 ret
;R10A Set_Stop        endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Set_Pointer                                                             บ
;R10A ;บ  Input:  BX = pointer                                                    บ
;R10A ;บ  Output: CLC = PK                                                        บ
;R10A ;บ          STC = Fail                                                      บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Set_Pointer     proc
;R10A                 push    bx              ;Save Register Pointer
;R10A                 call    Set_Start
;R10A                 mov     bl,LM75_ID
;R10A                 call    Wr_Byte
;R10A                 call    Wait_ACK
;R10A                 pop     bx
;R10A                 jc      ErrSet_Pointer
;R10A                 call    Wr_Byte         ;bx = pointer
;R10A                 call    Wait_ACK
;R10A                 jc      ErrSet_Pointer
;R10A                 clc
;R10A                 ret
;R10A ErrSet_Pointer:
;R10A                 stc
;R10A                 ret
;R10A Set_Pointer     endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Rd_Data                                                                 บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: BL: return data                                                 บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Rd_Data 	proc
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A         	and	al, not SCL
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A         
;R10A                 xor     bx, bx
;R10A                 xor     ax, ax
;R10A                 mov     cx, 8
;R10A Rd_byte:
;R10A                 push    cx
;R10A                 mov     cx, 8                           ;T(low) = 4.7 us
;R10A @@:
;R10A         	NEWIODELAY
;R10A                 loop    short @B
;R10A 
;R10A         	mov	cx,086dh		
;R10A         	call	F000_Get_Ct		
;R10A         	or	al, SDA			
;R10A         	call	F000_Set_Ct		
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A         	or	al, SCL
;R10A         	call	F000_Set_Ct		;SCL high, receiver will read data
;R10A         	call	DelayIO			
;R10A 
;R10A                 mov     cx, 8                   ;T(high) = 4 us
;R10A 	@@:
;R10A         	NEWIODELAY
;R10A                 loop    short @B
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A 
;R10A         	push	ax
;R10A                 and     al, SDA 
;R10A                 shr     al, 4
;R10A                 shl     bl, 1           
;R10A                 or      bl, al
;R10A         	pop	ax
;R10A                 and     al, NOT SCL                     ;SCL low
;R10A         	mov	cx,086dh
;R10A         	call	F000_Set_Ct
;R10A         	call	DelayIO			
;R10A 
;R10A                 pop     cx
;R10A                 loop    short Rd_byte
;R10A 
;R10A                 mov     cx, 8                           ;T(hd)
;R10A         @@:
;R10A         	NEWIODELAY
;R10A                 loop    short @B
;R10A 
;R10A                 ret
;R10A Rd_Data endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Set_NoACK                                                               บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: None                                                            บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Set_NoACK       proc
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al, NOT SCL
;R10A         	call	F000_Set_Ct		;out No ACK
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al, SDA
;R10A         	call	F000_Set_Ct		;out No ACK
;R10A         	call	DelayIO			
;R10A 
;R10A                 NEWIODELAY                	;T(setup) = 250 ns
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al, SCL
;R10A         	call	F000_Set_Ct		;SCL ,SDA = high
;R10A                 call	DelayIO			
;R10A 
;R10A                 mov     cx, 8                   ;T(high) = 4 us
;R10A         @@:
;R10A                 NEWIODELAY
;R10A                 loop    short @B
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al, not SCL
;R10A         	call	F000_Set_Ct		;SCL = low
;R10A 
;R10A         	call	DelayIO			
;R10A 
;R10A                 ret
;R10A Set_NoACK       endp
;R10A 
;R10A ;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;R10A ;บ  Set_ACK                                                                 บ
;R10A ;บ                                                                          บ
;R10A ;บ  Input:  None                                                            บ
;R10A ;บ  Output: None                                                            บ
;R10A ;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
;R10A Set_ACK 	proc
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al, NOT SCL
;R10A                 and     al, NOT SDA
;R10A         	call	F000_Set_Ct		
;R10A                 NEWIODELAY                	;T(setup) = 250 ns
;R10A         	call	DelayIO			
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 or      al, SCL
;R10A         	call	F000_Set_Ct		;SCL = high
;R10A         	call	DelayIO			
;R10A 
;R10A                 mov     cx, 8                   ;T(high) = 4 us
;R10A         @@:
;R10A                 NEWIODELAY
;R10A                 loop    short @B
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al, NOT SCL
;R10A         	call	F000_Set_Ct		;SCL = low
;R10A         	call	DelayIO			
;R10A                 NEWIODELAY
;R10A 
;R10A         	mov	cx,086dh
;R10A         	call	F000_Get_Ct
;R10A                 and     al, NOT SDA
;R10A         	call	F000_Set_Ct		;SDA = low
;R10A         	call	DelayIO			
;R10A                 NEWIODELAY
;R10A 
;R10A                 ret
;R10A Set_ACK endp

;[]==============================================================[]
;Input  : CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word   Proc    Near
                mov     ch,LM75_ID		;R31
                mov     bl,cl					
                call    Set_Pointer				
                NEWIODELAY					
                NEWIODELAY					
                call    Set_Start
                mov     bl,LM75_ID
                inc     bl              ;for read operation
                call    Wr_Byte
                call    Wait_ACK
                jc      Rd_2ByteReg_Fail
                call    Rd_Data 
                shl     ebx,16
                call    Set_ACK
                call    Rd_Data 
                mov     bh,bl
                shl     ebx,8
                call    Set_NoACK
                call    Set_Stop
                shr     ebx,16
                mov     ax,bx
                clc
                ret
Rd_2ByteReg_Fail:
                stc
                ret
Get_LM75_Word   endp

;[]==============================================================[]
;Input  : CL - register index
;Output : AL - Value read
;[]==============================================================[]
                public  Get_LM75_Byte
                public  Set_LM75_Byte
                public  Get_LM75_Word
                public  Set_LM75_Word
Get_LM75_Byte   Proc    Near
                mov     ch,LM75_ID		;R31
                mov     bl,cl
                call    Set_Pointer
                NEWIODELAY
                NEWIODELAY
                call    Set_Start
                mov     bl,LM75_ID
                inc     bl              ;for read operation
                call    Wr_Byte
                call    Wait_ACK
        	jc      Rd_1ByteReg_Fail
                call    Rd_Data         ;bl = data
                shl     ebx,16
                call    Set_NoACK
                call    Set_Stop
                shr     ebx,16
                xor     bh,bh   ;BL = value
                mov     al,bl
                clc
                ret
Rd_1ByteReg_Fail:

                stc
                ret

Get_LM75_Byte   Endp

;[]==============================================================[]
;Input : CL - register index
;        AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte   Proc    Near

                push    ax      
                mov     ch,LM75_ID		;R31
                mov     bl,cl
                cli
                call    Set_Pointer
                newiodelay
                newiodelay
                pop     ax      
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_1ByteReg_Fail
                call    Set_Stop
                clc
                sti
                ret
Wr_1ByteReg_Fail:
                stc
                sti
                ret
Set_LM75_Byte   Endp

;[]==============================================================[]
;Input : CL - register index
;        AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word   Proc    Near

                push    ax
                mov     bx,cx
                push    bx
                call    Set_Start
                mov     bl,LM75_ID
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     bx
                call    Wr_Byte                 ;bx = TempPoint
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     ax      
                push    ax     			
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     ax      		
                shr     ax,8    
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                call    Set_Stop
                clc
                ret
Wr_2ByteReg_Fail:
                stc
                ret
Set_LM75_Word   Endp

endif;	SIS_SMBus		
;R10 - ends



;==========================================================================
;	SMbus for Cyrix 5520
;==========================================================================
;R23 - start
ifdef	Cx5520_USB_REG

Cx5520_SMBus	=	0
ifdef	Cx5520_USB_REG
Cx5520_SMBus	=	1
endif;  Cx5520_USB_REG
if	Cx5520_SMBus		; Cx5520 Chipset
SDA             EQU     10h	;I2C Data 
SCL             EQU     08h	;I2C Clock
DelayIO:
		push	cx
		mov	cx,300h
	@@:
		newiodelay
		loop	@B
		pop	cx
		ret

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_Start                                                               บ
;บ  Input:  None                                                            บ
;บ  Output: None                                                            บ
;บ                                                                          บ
;บ  SDA  ----\___                                                           บ
;บ  SCL  -------\                                                           บ
;บ       1   2                                                              บ
;บ        4us 4us                                                           บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Set_Start       proc	Near
        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct
        
        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

		call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,NOT SDA
        	call	F000_Set_Ct
                NEWIODELAY      
                NEWIODELAY      
                NEWIODELAY      

                call	DelayIO			
        
;For 1'st clock low time

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,NOT SCL
        	call	F000_Set_Ct

                call	DelayIO			
        
                ret
Set_Start       endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Wr_Byte                                                                 บ
;บ                                                                          บ
;บ  Input:   BL:Data to I2C Bus                                             บ
;บ  Output: None                                                            บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Wr_Byte		proc	Near

                pusha					
        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
                call	F000_Get_Ct			
                and     al,NOT SCL			
                call	F000_Set_Ct			
                popa					

                mov     dx,bx
                mov     cx ,8
write_B:
                push    cx
                NEWIODELAY      
                NEWIODELAY      
                NEWIODELAY      

                xor     dh,dh   
                shl     dx,1    
                shl     dh,4            ;;if SDA=10h, SCL=08h
        	mov	bl,dh

        	push	dx

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,NOT SDA              
                or      al,bl			;data                   
        	call	F000_Set_Ct
                NEWIODELAY      
        
                call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al,SCL			
        	call	F000_Set_Ct
                call	DelayIO			
                NEWIODELAY      
                NEWIODELAY      
                NEWIODELAY      

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,NOT SCL		
        	call	F000_Set_Ct
                call	DelayIO			
        
        	pop	dx
                pop     cx
                loop    write_B
                ret
Wr_Byte endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Wait_ACK                                                                บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: CLR :  Acknowledge                                              บ
;บ          STC : !Acknowledge                                              บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Wait_ACK        proc	Near
        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	and	al, Not SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
                call	F000_Get_Ct		
                and     al, not SCL		
                call	F000_Set_Ct		
                call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al, SCL			
        	call	F000_Set_Ct

                call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
                call	F000_Get_Ct		
                and	al,NOT SCL		
                call	F000_Set_Ct		
                call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                call	DelayIO			
                mov     bl, al			
        	and	al,NOT SCL
        	call	F000_Set_Ct
                call	DelayIO			
        
                test    bl, SDA
                jnz     short ACK_Err_ret
                clc
                ret
ACK_Err_ret:
	        stc
        	ret
Wait_ACK        endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_Stop                                                                บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: None                                                            บ
;บ  SDA  ___/-----                                                          บ
;บ  SCL  ---------                                                          บ
;บ       1  2   3                                                           บ
;บ        4us 4us                                                           บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Set_Stop        proc	Near

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,not SCL
        	call	F000_Set_Ct
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al,NOT SDA              
        	call	F000_Set_Ct
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al,SCL
        	call	F000_Set_Ct
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al,SDA
        	call	F000_Set_Ct
        	call	DelayIO			

                ret
Set_Stop        endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_Pointer                                                             บ
;บ  Input:  BX = pointer                                                    บ
;บ  Output: CLC = PK                                                        บ
;บ          STC = Fail                                                      บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Set_Pointer     proc
                push    bx              ;Save Register Pointer
                call    Set_Start
                mov     bl,LM75_ID
                call    Wr_Byte
                call    Wait_ACK
                pop     bx
                jc      ErrSet_Pointer
                call    Wr_Byte         ;bx = pointer
                call    Wait_ACK
                jc      ErrSet_Pointer
                clc
                ret
ErrSet_Pointer:
                stc
                ret
Set_Pointer     endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Rd_Data                                                                 บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: BL: return data                                                 บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Rd_Data 	proc
        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	and	al, Not SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
        	and	al, not SCL
        	call	F000_Set_Ct
        	call	DelayIO			
        
                xor     bx, bx
                xor     ax, ax
                mov     cx, 8
Rd_byte:
                push    cx
                mov     cx, 8                           ;T(low) = 4.7 us
@@:
        	NEWIODELAY
                loop    short @B

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h		
        	call	F000_Get_Ct		
        	or	al, SDA			
        	call	F000_Set_Ct		
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct		;SCL high, receiver will read data
        	call	DelayIO			

                mov     cx, 8                   ;T(high) = 4 us
	@@:
        	NEWIODELAY
                loop    short @B

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct

        	push	ax
                and     al, SDA 
                shr     al, 4
                shl     bl, 1           
                or      bl, al
        	pop	ax
                and     al, NOT SCL                     ;SCL low
        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Set_Ct
        	call	DelayIO			

                pop     cx
                loop    short Rd_byte

                mov     cx, 8                           ;T(hd)
        @@:
        	NEWIODELAY
                loop    short @B

                ret
Rd_Data endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_NoACK                                                               บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: None                                                            บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Set_NoACK       proc

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al, NOT SCL
        	call	F000_Set_Ct		;out No ACK
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al, SDA
        	call	F000_Set_Ct		;out No ACK
        	call	DelayIO			

                NEWIODELAY                	;T(setup) = 250 ns

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al, SCL
        	call	F000_Set_Ct		;SCL ,SDA = high
                call	DelayIO			

                mov     cx, 8                   ;T(high) = 4 us
        @@:
                NEWIODELAY
                loop    short @B

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al, not SCL
        	call	F000_Set_Ct		;SCL = low

        	call	DelayIO			

                ret
Set_NoACK       endp

;ษออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
;บ  Set_ACK                                                                 บ
;บ                                                                          บ
;บ  Input:  None                                                            บ
;บ  Output: None                                                            บ
;ศออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
Set_ACK 	proc
        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SCL
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+90h
        	call	F000_Get_Ct
        	or	al, SDA
        	call	F000_Set_Ct

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al, NOT SCL
                and     al, NOT SDA
        	call	F000_Set_Ct		
                NEWIODELAY                	;T(setup) = 250 ns
        	call	DelayIO			

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                or      al, SCL
        	call	F000_Set_Ct		;SCL = high
        	call	DelayIO			

                mov     cx, 8                   ;T(high) = 4 us
        @@:
                NEWIODELAY
                loop    short @B

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al, NOT SCL
        	call	F000_Set_Ct		;SCL = low
        	call	DelayIO			
                NEWIODELAY

        	mov	cx,(Cx5510_PCI_REG shl 8)+91h
        	call	F000_Get_Ct
                and     al, NOT SDA
        	call	F000_Set_Ct		;SDA = low
        	call	DelayIO			
                NEWIODELAY

                ret
Set_ACK endp

                public  Get_LM75_Byte
                public  Set_LM75_Byte
                public  Get_LM75_Word
                public  Set_LM75_Word
;[]==============================================================[]
;Input  : CL - register index
;Output : AX - Value read
;[]==============================================================[]
Get_LM75_Word   Proc    Near

                mov     bl,cl					
                call    Set_Pointer				
                NEWIODELAY					
                NEWIODELAY					
                call    Set_Start
                mov     bl,LM75_ID
                inc     bl              ;for read operation
                call    Wr_Byte
                call    Wait_ACK
                jc      Rd_2ByteReg_Fail
                call    Rd_Data 
                shl     ebx,16
                call    Set_ACK
                call    Rd_Data 
                mov     bh,bl
                shl     ebx,8
                call    Set_NoACK
                call    Set_Stop
                shr     ebx,16
                mov     ax,bx
                clc
                ret
Rd_2ByteReg_Fail:
                stc
                ret
Get_LM75_Word   endp

;[]==============================================================[]
;Input  : CL - register index
;Output : AL - Value read
;[]==============================================================[]
Get_LM75_Byte   Proc    Near

                mov     bl,cl
                call    Set_Pointer
                NEWIODELAY
                NEWIODELAY
                call    Set_Start
                mov     bl,LM75_ID
                inc     bl              ;for read operation
                call    Wr_Byte
                call    Wait_ACK
        	jc      Rd_1ByteReg_Fail
                call    Rd_Data         ;bl = data
                shl     ebx,16
                call    Set_NoACK
                call    Set_Stop
                shr     ebx,16
                xor     bh,bh   ;BL = value
                mov     al,bl
                clc
                ret
Rd_1ByteReg_Fail:

                stc
                ret

Get_LM75_Byte   Endp

;[]==============================================================[]
;Input : CL - register index
;        AL - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Byte   Proc    Near

                push    ax      
                mov     bl,cl
                cli
                call    Set_Pointer
                newiodelay
                newiodelay
                pop     ax      
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_1ByteReg_Fail
                call    Set_Stop
                clc
                sti
                ret
Wr_1ByteReg_Fail:
                stc
                sti
                ret
Set_LM75_Byte   Endp

;[]==============================================================[]
;Input : CL - register index
;        AX - Value to write
;Output: none
;[]==============================================================[]
Set_LM75_Word   Proc    Near

                push    ax
                mov     bx,cx
                push    bx
                call    Set_Start
                mov     bl,LM75_ID
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     bx
                call    Wr_Byte                 ;bx = TempPoint
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     ax      
                push    ax     			
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                pop     ax      		
                shr     ax,8    
                mov     bl,al
                call    Wr_Byte
                call    Wait_ACK
                jc      Wr_2ByteReg_Fail
                call    Set_Stop
                clc
                ret
Wr_2ByteReg_Fail:
                stc
                ret
Set_LM75_Word   Endp

endif;	Cx5520_SMBus		

F000_Get_CT	Proc	Near
		extrn	Get_CT:near
		F000_Call	DGROUP:Get_Ct
		ret
F000_Get_CT	Endp
F000_Set_CT	Proc	Near
		extrn	Set_CT:near
		F000_Call	DGROUP:Set_Ct
		ret
F000_Set_CT	Endp

endif;	Cx5520_USB_REG
;R23 - end

;R05 Chk_SMBus_READY	Proc	Near
;R05 		mov	dx,SMBus_Port + 0
;R05 		clc
;R05 		mov	cx,0100h
;R05 Chk_I2C_OK:
;R05 		in	al,dx		;get status
;R05 		or	al,al
;R05 		jz	short Clear_final
;R05 
;R05 		test	al,04h			;R02A
;R05 		jnz	short SMBus_Err		;R02A
;R05 
;R05 		test	al,01h		;busy ?
;R05 		jz	short Not_Smbusy
;R05 		call	WaitSmbus
;R05 Not_Smbusy:
;R05 		out 	dx,al
;R05 		loop	short Chk_I2C_OK
;R05 SMBus_Err:					;R02A
;R05 		stc
;R05 Clear_final:
;R05 		ret
;R05 Chk_SMBus_READY	Endp
;R05 
;R05 WaitSmbus	proc	near			
;R05 		push	cx			
;R05 		mov	cx,1000h
;R05 	@@:						
;R05 		loop	short @B		
;R05 		pop	cx			
;R05 		ret				
;R05 WaitSmbus	endp
%						;R32
;R12 - start
ifdef	ACPI_Support
		extrn	ACPI_Critical_Item:near
		extrn	TEMP1_HIGH:near		
		extrn	SENSOR_FLAG:near		;R19
;[]========================================================================[]
;Procedure:	Ct_FillTempPointer
;
;Function :	Return Thermal Zone Temperature pointer 
;
;Input	  :	F segment shadow RAM is writeable 
;
;Output   :	none
;	
;[]========================================================================[]
		Public	Ct_FillTempPointer
Ct_FillTempPointer	Proc	Near

		push	es
		
		mov	ax,0f000h
		mov	es,ax
;R19 - start
		mov	di,offset DGROUP:SENSOR_FLAG
		test	word ptr es:[di],01h
		jz	short No_Sensor
;R19 - end
		mov	di,offset DGROUP:TEMP1_HIGH

		extrn	LM75_TEMP_ITEM:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	E_GetItem_Value
;R15 - start
ifndef	CPU_Temp_Selectable
		xor	ah,ah
		mov	si,offset CPU_TEMP_VAL
		add	si,ax
		mov	al,byte ptr cs:[si]
endif;	CPU_Temp_Selectable
;R15 - end
		mov	cl,10
		mul	cl
		add	ax,2732

		mov	word ptr es:[di],ax	; Trip point 1 high
		mov	word ptr es:[di+4],ax	; Trip point 2 high
		sub	ax,30
		mov	word ptr es:[di+2],ax	; Trip point 1 low
		mov	word ptr es:[di+6],ax	; Trip point 2 low

;R16 - start
ifdef	CPU_Fan_Turn_on_in_WIN98
		extrn	CPU_Fan_in_WIN98_ITEM:near
		mov	si,offset DGROUP:CPU_Fan_in_WIN98_ITEM
		call	E_GetItem_Value
		or	al,al
		jz	Short	CPUFan_Disable					       	
		mov	word ptr es:[di], 2732	; Trip point 1 high
		mov	word ptr es:[di+2], 2732; Trip point 1 low
CPUFan_Disable:
endif;	CPU_Fan_Turn_on_in_WIN98
;R16 - end

		mov	si,offset DGROUP:ACPI_Critical_Item
		call	E_GetItem_Value
		xor	ah,ah
		shl	ax,1
		mov	si,offset Critical_Table
		add	si,ax

		mov	ax,word ptr cs:[si]
		mov	word ptr es:[di+8],ax	;Critical trip point

No_Sensor:					;R19
		pop	es
		ret
Ct_FillTempPointer	Endp

Critical_Table:
;R21		dw	3932			;120c
;R21		dw	3532			;80c
;R21		dw	3582			;85c
;R21		dw	3632			;90c

		dw	3332			;60c		;R21
		dw	3382			;65c		;R21
		dw	3432			;70c		;R21
		dw	3482			;75c		;R21

endif	;ACPI_Support
;R12 - end

;***************************************************************************
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;***************************************************************************

;[]==============================================================[]
;[]==============================================================[]
		Public	Prg_LM75_Chip	;R28
Prg_LM75_Chip	Proc	Near

;R02 - start
;R02B ifdef	Special_LM75_Item_Patch
ifndef	No_Special_LM75_Item_Patch		;R17
	;Mask LM75's display items if it is not mounted on M/B
		mov	cl,0
		call	Get_LM75_Word
;R02A		cmp	al,0h
;R02A		jne	short @F
		jnc	short @F		;LM75 not found	;R02A

	;Disable items by change item's status
		push	ds
		mov	ax,0f000h
		mov	ds,ax
		extrn	Current_Temp_Item:near
		extrn	LM75_TEMP_ITEM:near
		extrn	F000_Shadow_W:near
		extrn	F000_Shadow_R:near
		extrn	F000_call_proc:near
		assume	ds:DGROUP
		f000_call	DGROUP:F000_Shadow_W
		or	word ptr ds:[LM75_TEMP_ITEM].ITEMSTAT,ITEMDISABLE
		or	word ptr ds:[Current_Temp_Item].ITEMSTAT,ITEMDISABLE
;R09 - start
ifdef	Dual_LM75_Support
		extrn	Current_Temp_Item2:near			;R02B
		or	word ptr ds:[Current_Temp_Item2].ITEMSTAT,ITEMDISABLE
endif;	Dual_LM75_Support
;R09 - end

;R22 - start
ifdef	ACPI_Support
		extrn	ACPI_Critical_Item:near
		or	word ptr ds:[ACPI_Critical_Item].ITEMSTAT,ITEMDISABLE
ifdef	CPU_Fan_Turn_on_in_Win98
		extrn	CPU_Fan_in_WIN98_ITEM:near
		or	word ptr ds:[CPU_Fan_in_WIN98_ITEM].ITEMSTAT,ITEMDISABLE
endif;	CPU_Fan_Turn_on_in_Win98
endif;	ACPI_Support
;R22 - end

;R19 - start
ifdef	ACPI_SUPPORT
		and	word ptr ds:[SENSOR_FLAG],not 01h
endif	;ACPI_SUPPORT
;R19 - end
		f000_call	DGROUP:F000_Shadow_R
		pop	ds
		jmp	short Prg_LM75_Chip_End
	@@:
;R02B endif;	Special_LM75_Item_Patch
endif	;No_Special_LM75_Item_Patch		;R17
;R02 - end
		mov	cl,01
		mov	al,01				;reset LM75
		call	Set_LM75_Byte

		xor	cx,cx
      @@:
	      	newiodelay
		loop	short @B

		mov	cl,01
		mov	al,0				;LM75 start
		call	Set_LM75_Byte

		extrn	LM75_TEMP_ITEM:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	E_GetItem_Value
;R15 - start
ifndef	CPU_Temp_Selectable
		mov	si,offset CPU_TEMP_VAL
		xor	ah,ah
		add	si,ax
		mov	al,cs:[si]
endif;	CPU_Temp_Selectable
;R15 - end

ifdef	Patch_Temp_offset_for_customer		;R24
		sub	ax, 15			;R24
endif;	Patch_Temp_offset_for_customer		;R24

		push	ax
		xor	ah,ah
		mov	cl,03
		call	Set_LM75_Word		;set Tos (High limit)

		pop	ax

ifdef	LM75_LoLimit_Difference				;R11
		sub	al,LM75_LoLimit_Difference	;R11
else;	LM75_LoLimit_Difference				;R11
		sub	al,5
endif;	LM75_LoLimit_Difference				;R11

		xor	ah,ah
		mov	cl,02
		call	Set_LM75_Word		;set Thyst (Low limit)

ifdef	Thermal_Enable_Use_SMI
		mov	al,02h			;interrupt mode
else;	Thermal_Enable_Use_SMI
		mov	al,0			;comparator mode
endif;	Thermal_Enable_Use_SMI
		mov	cl,1
		call	Set_LM75_Byte

;R09 - start
ifdef	Dual_LM75_Support

		mov	cl,01
		mov	al,01				;reset LM75
		call	Set_LM75_Byte2

		xor	cx,cx
      @@:
	      	newiodelay
		loop	short @B

		mov	cl,01
		mov	al,0				;LM75 start
		call	Set_LM75_Byte2

		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	E_GetItem_Value

		mov	si,offset CPU_TEMP_VAL
		xor	ah,ah
		add	si,ax
		mov	al,cs:[si]

		push	ax
		xor	ah,ah
		mov	cl,03
		call	Set_LM75_Word2		;set Tos (High limit)

		pop	ax
		sub	al,5
		xor	ah,ah
		mov	cl,02
		call	Set_LM75_Word2		;set Thyst (Low limit)

ifdef	Thermal_Enable_Use_SMI
		mov	al,02h			;interrupt mode
else;	Thermal_Enable_Use_SMI
		mov	al,0			;comparator mode
endif;	Thermal_Enable_Use_SMI
		mov	cl,1
		call	Set_LM75_Byte2

endif;	Dual_LM75_Support
;R09 - end

	Prg_LM75_Chip_End:				;R02

		ret

Prg_LM75_Chip	Endp

		assume	ds:EGROUP			;R02
ifndef	CPU_Temp_Selectable				;R15
ifndef	LM75_SCALE_40_TO_90		 		;R25
ifndef  LM75_SCALE_60_TO_90		 
	ifndef	LM75_SCALE_40_TO_70			;R08
		ALIGN	4
CPU_TEMP_VAL:
;R04		db	099	;disabled
		db	0120	;disabled		;R04
		db	032h	;50C
		db	035h	;53C
		db	038h	;56C
		db	03ch	;60C
		db	03fh	;63C
		db	042h	;66C
		db	046h	;70C
	else;	LM75_SCALE_40_TO_70			;R08
		ALIGN	4				;R08
CPU_TEMP_VAL:						;R08
		db	0120	;disabled		;R08
		db	028h	;40C			;R08
		db	02dh	;45C			;R08
		db	032h	;50C			;R08
		db	037h	;55C			;R08
		db	03ch	;60C			;R08
		db	041h	;65C			;R08
		db	046h	;70C			;R08
	endif;	LM75_SCALE_40_TO_70			;R08
else;	LM75_SCALE_60_TO_90		 
		ALIGN	4		 
CPU_TEMP_VAL:				 
;R04		db	099	;disabled
		db	0120	;disabled		;R04
		db	03ch	;60C	 
		db	041h	;65C	 
		db	046h	;70C	 
		db	04bh	;75C	 
		db	050h	;80C	 
		db	055h	;85C	 
		db	05ah	;90C	 
endif;	LM75_SCALE_60_TO_90		 
;R25 -starts
else;	LM75_SCALE_40_TO_90		 		
CPU_TEMP_VAL:				 
		db	0120	;disabled		
		db	028h	;40C			
		db	02dh	;45C			
		db	032h	;50C			
		db	037h	;55C			
		db	03ch	;60C			
		db	041h	;65C			
		db	046h	;70C			
		db	04bh	;75C	 
		db	050h	;80C	 
		db	055h	;85C	 
		db	05ah	;90C	 
endif;	LM75_SCALE_40_TO_90		 		
;R25 - end
endif;	CPU_Temp_Selectable				;R15

endif	;SENSOR_IN_XGROUP			;R35
ENDIF	;COMPILE_FOR_SENSOR_ASM EQ 2	;Rnn
endif	;COMPILE_FOR_SENSOR_ASM

ifdef	COMPILE_FOR_SENSOR_MNU 
;***************************************************************************
;***** Special_Show Special_Show Special_Show Special_Show Special_Show ****
;***** Special_Show Special_Show Special_Show Special_Show Special_Show ****
;***** Special_Show Special_Show Special_Show Special_Show Special_Show ****
;***************************************************************************
IF	COMPILE_FOR_SENSOR_MNU EQ 2
ifdef	CPU_Temp_Selectable						;R15
		dw	offset LM75_Temp_Item, offset Show_Scale	;R15
endif;	CPU_Temp_Selectable			     			;R15
		dw	offset Current_Temp_Item, offset Show_Current_Temp
;R09 - start
ifdef	Dual_LM75_Support
		dw	offset Current_Temp_Item2, offset Show_Current_Temp2
endif;	Dual_LM75_Support
;R09 - end
ENDIF	;COMPILE_FOR_SENSOR_MNU 

;***************************************************************************
;**** SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU ****
;**** SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU ****
;**** SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU ****
;**** SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU SENSOR.MNU ****
;***************************************************************************
IF	COMPILE_FOR_SENSOR_MNU EQ 1

		Public	First_LM75_Item	;R28
First_LM75_Item	Label	Near		;R28

ifndef	LM75_CMOS_Bits
ifndef	LM75_SCALE_40_TO_90		 		;R25
LM75_CMOS_Bits = 00000111b
else;	LM75_SCALE_40_TO_90		 		;R25
LM75_CMOS_Bits = 00001111b				;R25
endif;	LM75_SCALE_40_TO_90		 		;R25
endif;	LM75_CMOS_Bits
ifdef	CPU_Temp_Selectable		;R15
;R15 - start
DEFINE_ITEM	LM75_Temp_Item
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
	menuitem <NOMODBIN+SHOWNUM+DIGIT3,\
		  offset LM75_Temp_Str,NOCT,00000000b,LM75_CMOS,01111111b,\
		  offset Nullstr,30,120,Xaxis,Yaxis,120,30,offset Nullstr>
;R15 - end
else;	CPU_Temp_Selectable		;R15

ifndef	LM75_SCALE_40_TO_90		 		;R25
DEFINE_ITEM     LM75_TEMP_ITEM
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
        menuitem <PMITEM,\
                  offset LM75_TEMP_Str,NOCT,LM75_CMOS_Bits,LM75_CMOS,LM75_CMOS_Bits,\
                  offset LM75_TEMP_Val,0,7,Xaxis,Yaxis ,   00000000b, 00000000b,offset Std_Help_Str>
else;	LM75_SCALE_40_TO_90		 		;R25 - starts	
DEFINE_ITEM     LM75_TEMP_ITEM
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				
        menuitem <PMITEM,\
                  offset LM75_TEMP_Str,NOCT,LM75_CMOS_Bits,LM75_CMOS,LM75_CMOS_Bits,\
                  offset LM75_TEMP_Val,0,11,Xaxis,Yaxis ,   00000000b, 00000000b,offset Std_Help_Str>
endif;	LM75_SCALE_40_TO_90		 		;R25  - end
endif;	CPU_Temp_Selectable		;R15

DEFINE_ITEM	Current_Temp_Item
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
        menuitem <SHOWONLY,\
                  offset Current_Temp_Str,NOCT,0,KERNAL_CONTROL,00000001b,\
                  offset NullStr,0,0,Xaxis,Yaxis,0,0,offset Std_Help_Str>
;R09 - start
ifdef	Dual_LM75_Support
DEFINE_ITEM	Current_Temp_Item2
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
        menuitem <SHOWONLY,\
                  offset Current_Temp_Str2,NOCT,0,KERNAL_CONTROL,00000001b,\
                  offset NullStr,0,0,Xaxis,Yaxis,0,0,offset Std_Help_Str>
endif;	Dual_LM75_Support
;R09 - end

;R12 - start
ifdef	ACPI_SUPPORT
DEFINE_ITEM     ACPI_Critical_Item
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
        menuitem <PMITEM,\
                  offset ACPI_Critical_Str           ,NOCT,00011000b,LM75_ACPI_CMOS,LM75_ACPI_CMOS_BITS,\
                  offset Critical_str,0,3,Xaxis,Yaxis,00000000b,    00000000b,offset Std_Help_Str>
;R12A             offset ACPI_Critical_Str           ,NOCT,00011000b,LM75_CMOS+1,00000011b,\
;R12A             offset Critical_str,0,3,Xaxis,Yaxis,00000000b,    00000000b,offset Std_Help_Str>

;R16 - start
ifdef	CPU_Fan_Turn_on_in_WIN98
DEFINE_ITEM	CPU_Fan_in_WIN98_ITEM
DEFINE_MENUITEM	, GROUP_HEALTH, 0, 10				;R18
        menuitem <PMITEM,\
                  offset CPU_Fan_in_WIN98_Str,NOCT,CPU_FAN_ON_CMOS_BIT,CPU_FAN_ON_CMOS,CPU_FAN_ON_CMOS_BIT,\
                  offset Dis_Str,0,1,Xaxis,Yaxis,0,0,offset Std_Help_Str> 
;R16A		  offset CPU_Fan_in_WIN98_Str,NOCT,10000000b,LM75_ACPI_CMOS,10000000b,\
;R16A		  offset Dis_Str,0,1,Xaxis,Yaxis,0,0,offset Std_Help_Str> 
endif;	CPU_Fan_Turn_on_in_WIN98
;R16 - end

endif	;ACPI_SUPPORT
;R12 - end
		Public	Last_LM75_Item	;R28
Last_LM75_Item	Label	Near		;R28

ENDIF	;COMPILE_FOR_SENSOR_MNU 

;***************************************************************************
;**** SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR ****
;**** SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR ****
;**** SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR ****
;**** SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR SENSOR.STR ****
;***************************************************************************
IF	COMPILE_FOR_SENSOR_MNU EQ 0
;R12 - start
ifdef	ACPI_SUPPORT
ACPI_Critical_Str	db      'Shutdown Temperature'
			db	(COLLON_LOC - ($-(offset ACPI_Critical_Str))) dup (" ")
			db	': ',0
;R21Critical_str		db	'Disabled  ',0
;R21			db      '80๘C/176๘F',0
;R21			db      '85๘C/185๘F',0
;R21			db      '90๘C/194๘F',0

Critical_str		db      '60๘C/140๘F',0			;R21
			db      '65๘C/149๘F',0			;R21
			db      '70๘C/158๘F',0			;R21
			db	'75๘C/167๘F',0			;R21

;R16 - start
ifdef	CPU_Fan_Turn_on_in_WIN98
CPU_Fan_in_WIN98_Str	db	'CPUFAN Turn On In Win98  : ',0
endif;	CPU_Fan_Turn_on_in_WIN98
;R16 - end

endif	;ACPI_SUPPORT
;R12 - end
;R09 - start
ifdef	Dual_LM75_Support
Current_Temp_Str2	db	'Current CPU2 Temperature'
			db	(COLLON_LOC - ($-(offset Current_Temp_Str2))) dup (" ")
			db	': ',0
endif;	Dual_LM75_Support
;R09 - end
Current_Temp_Str	db	'Current CPU Temperature'
			db	(COLLON_LOC - ($-(offset Current_Temp_Str))) dup (" ")
			db	': ',0
LM75_TEMP_Str           db      'CPU Warning Temperature'
			db	(COLLON_LOC - ($-(offset LM75_TEMP_Str))) dup (" ")
ifdef	CPU_Temp_Selectable				;R15
		db	':',0				;R15
else;	CPU_Temp_Selectable				;R15
		db	': ',0				
endif;	CPU_Temp_Selectable				;R15

ifndef	CPU_Temp_Selectable				;R15
ifndef	LM75_SCALE_40_TO_90		 		;R25

ifndef	LM75_SCALE_60_TO_90
	ifndef	LM75_SCALE_40_TO_70			;R08
LM75_TEMP_Val           db      'Disabled  ',0
			db      '50๘C/122๘F',0
			db      '53๘C/127๘F',0
			db      '56๘C/133๘F',0
			db      '60๘C/140๘F',0
			db      '63๘C/145๘F',0
			db      '66๘C/151๘F',0
			db      '70๘C/158๘F',0
	else;	LM75_SCALE_40_TO_70			;R08
LM75_TEMP_Val           db      'Disabled  ',0		;R08
			db      '40๘C/104๘F',0		;R08
			db      '45๘C/113๘F',0		;R08
			db      '50๘C/122๘F',0		;R08
			db      '55๘C/131๘F',0		;R08
			db      '60๘C/140๘F',0		;R08
			db      '65๘C/149๘F',0		;R08
			db      '70๘C/158๘F',0		;R08
	endif;	LM75_SCALE_40_TO_70			;R08
else;	LM75_SCALE_60_TO_90					
LM75_TEMP_Val           db      'Disabled  ',0
			db      '60๘C/140๘F',0
			db      '65๘C/149๘F',0
			db      '70๘C/158๘F',0
			db      '75๘C/167๘F',0
			db      '80๘C/176๘F',0
			db      '85๘C/185๘F',0
			db      '90๘C/194๘F',0
endif;	LM75_SCALE_60_TO_90
;R25 - starts
else;	LM75_SCALE_40_TO_90		 	      
LM75_TEMP_Val           db      'Disabled  ',0		
			db      '40๘C/104๘F',0		
			db      '45๘C/113๘F',0		
			db      '50๘C/122๘F',0		
			db      '55๘C/131๘F',0		
			db      '60๘C/140๘F',0		
			db      '65๘C/149๘F',0		
			db      '70๘C/158๘F',0		
			db      '75๘C/167๘F',0
			db      '80๘C/176๘F',0
			db      '85๘C/185๘F',0
			db      '90๘C/194๘F',0
endif;	LM75_SCALE_40_TO_90		 	      
;R25 - end
endif;	CPU_Temp_Selectable				;R15

;=====================
;R15 - start
ifdef	CPU_Temp_Selectable
Show_Scale	Proc	Near

		cmp	byte ptr CALLTYPE[bp],POST_CALL
		jne	short @F
ifndef	SENSOR_IN_XGROUP				;R35
		Post_Func_Call E000_Show_Scale
else	;SENSOR_IN_XGROUP				;R35
		Xcall X_Show_Scale			;R35
endif	;SENSOR_IN_XGROUP				;R35
	@@:
		ret
Show_Scale	Endp
endif;	CPU_Temp_Selectable
;R15 - end

Show_Current_Temp	Proc	Near
		cmp	byte ptr CALLTYPE[bp],POST_CALL	;R03
		jne	short @F			;R03
ifndef	SENSOR_IN_XGROUP				;R35
		Post_Func_Call E000_Show_Current_Temp
else	;SENSOR_IN_XGROUP				;R35
		Xcall X_Show_Current_Temp		;R35
endif	;SENSOR_IN_XGROUP				;R35
	@@:						;R03
		ret
Show_Current_Temp	endp
;R09 - start
ifdef	Dual_LM75_Support
Show_Current_Temp2	Proc	Near
		cmp	byte ptr CALLTYPE[bp],POST_CALL	
		jne	short @F			
ifndef	SENSOR_IN_XGROUP				;R35
		Post_Func_Call E000_Show_Current_Temp2
else	;SENSOR_IN_XGROUP				;R35
		Xcall X_Show_Current_Temp2		;R35
endif	;SENSOR_IN_XGROUP				;R35
	@@:						
		ret
Show_Current_Temp2	endp
endif;	Dual_LM75_Support
;R09 - end
ENDIF	;COMPILE_FOR_SENSOR_MNU

;***************************************************************************
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;***************************************************************************
IF	COMPILE_FOR_SENSOR_MNU EQ 3
ifndef	SENSOR_IN_XGROUP				;R35

SIS_SMBus	=	0
ifdef   SIS_5598_PCI_RESET		
SIS_SMBus	=	1
endif;  SIS_5598_PCI_RESET		
ifdef   SIS5595_ID
SIS_SMBus	=	1
endif;  SIS5595_ID

;R33;R23 - start
;R33Cx5520_SMBus	=	0
;R33ifdef	Cx5520_USB_REG
;R33Cx5520_SMBus	=	1
;R33endif;  Cx5520_USB_REG
;R33;R23 - end

;R15 - start
ifdef	CPU_Temp_Selectable
E000_Show_Scale	Proc	Near
	     	extrn	E_GetItem_Value:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		Post_func_Call	E_GetItem_Value

		mov	bl, al
;R15A		call	E000_DISP_WORD_INT3
		F000_call	DISP_WORD_INT3		;R15A
		mov	al, '๘'
;R15A		call	E000_Display_Char
		F000_call	Display_Char		;R15A
		mov	al, 'C'
;R15A		call	E000_Display_Char
		F000_call	Display_Char		;R15A
		mov	al, '/'
;R15A		call	E000_Display_Char
		F000_call	Display_Char		;R15A

;๘C transed to ๘F --> C = 5/9*(F-32)
		mov	al, bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
;R15A		call	E000_DISP_WORD_INT3
		F000_call	DISP_WORD_INT3		;R15A
		mov	al, '๘'
;R15A		call	E000_Display_Char
		F000_call	Display_Char		;R15A
		mov	al, 'F'
;R15A		call	E000_Display_Char
		F000_call	Display_Char		;R15A
  		sub 	al, -1			;set overflow flag for display error
		ret
E000_Show_Scale	Endp
endif;	CPU_Temp_Selectable
;R15 - end

E000_Show_Current_Temp	Proc	Near

		cmp	al, Special_Before
		je	short @F

		mov	cl,0
		call	Get_LM75_Word
ifdef	Software_I2C				;R27
ifdef	VT586_ACPI				;R07 - starts
                shr     ax,8                    ; get bit7 - bit15
ifdef	ADD_5C
                add     al,5            ; add : increase 5๘C
endif;	ADD_5C
endif;	VT586_ACPI				;R07 - starts
endif;	Software_I2C				;R27

if	SIS_SMBus		; SiS Chipset
                shr     ax,8                    ; get bit7 - bit15
endif;	SIS_SMBus		; SiS Chipset

;R34 ;R23 - start
;R34 ifdef	Cx5520_SMBus		; Cx5520 Chipset;R33
;R34 ;R33if	Cx5520_SMBus		; Cx5520 Chipset
;R34 		shr     ax,8                    ; get bit7 - bit15
;R34 endif;	Cx5520_SMBus		; Cx5520 Chipset
;R34 ;R23 - end

;R34 -starts
ifdef	VSA_VGA			; 
		shr     ax,8                    ; get bit7 - bit15
endif;	VSA_VGA			; 
;R34 -ends

ifdef	Patch_Temp_offset_for_customer		;R24
		add	ax, 15			;R24
endif;	Patch_Temp_offset_for_customer		;R24

		cmp	al,100
		jbe	short OK_75Temp
		mov	al,0
	OK_75Temp:
ifdef	Temp_Always_Add_20C			;R14
		add	al,20			;R14
endif;	Temp_Always_Add_20C			;R14

		mov	bl,al
		F000_call	DISP_Byte_INT2
		mov	al, '๘'
		F000_call	Display_Char
		mov	al, 'C'
		F000_call	Display_Char
		mov	al, '/'
		F000_call	Display_Char

;๘C transed to ๘F --> C = 5/9*(F-32)

		mov	al,bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
		F000_call	DISP_WORD_INT3
		mov	al, '๘'
		F000_call	Display_Char
		mov	al, 'F'
		F000_call	Display_Char
	@@:
		ret

E000_Show_Current_Temp	endp

;R09 - start
ifdef	Dual_LM75_Support
E000_Show_Current_Temp2	Proc	Near

		cmp	al, Special_Before
		je	short @F

		mov	cl,0
		call	Get_LM75_Word2

ifdef	Patch_Temp_offset_for_customer		;R24
		add	ax, 15			;R24
endif;	Patch_Temp_offset_for_customer		;R24

      		cmp	al,100
      		jbe	short OK_75Temp2
      		mov	al,0
	OK_75Temp2:

ifdef	Temp_Always_Add_20C			;R14
		add	al,20			;R14
endif;	Temp_Always_Add_20C			;R14
	 	mov	bl,al
		F000_call	DISP_Byte_INT2
		mov	al, '๘'
		F000_call	Display_Char
		mov	al, 'C'
		F000_call	Display_Char
		mov	al, '/'
		F000_call	Display_Char

;๘C transed to ๘F --> C = 5/9*(F-32)

		mov	al,bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
		F000_call	DISP_WORD_INT3
		mov	al, '๘'
		F000_call	Display_Char
		mov	al, 'F'
		F000_call	Display_Char
	@@:
		ret
E000_Show_Current_Temp2	endp
endif;	Dual_LM75_Support
;R09 - end
;R15 - start
;R15Aifdef	CPU_Temp_Selectable
;R15Aifndef	LM78_Support
;R15AE000_DISP_WORD_INT3	proc	near
;R15A		F000_call	DISP_WORD_INT3
;R15A		ret
;R15AE000_DISP_WORD_INT3	endp
;R15A
;R15AE000_Display_Char	proc	near
;R15A		F000_call	Display_Char
;R15A		ret
;R15AE000_Display_Char	endp
;R15Aendif;	LM78_Support
;R15Aendif;	CPU_Temp_Selectable
;R15 - end
;R01 - starts
ifndef	BIOS60							;R18
		Public	Update_LM75_Screen
Update_LM75_Screen	Proc	near

		pusha

;R20 - start
ifdef	Update_Sensor_in_CPUFEAT				
		cmp	byte ptr CUR_PAGE[bp], PAGE_CPU
else;	Update_Sensor_in_CPUFEAT
;R20 - end
ifdef	Update_Sensor_in_IOFEAT					;R13
		cmp	byte ptr CUR_PAGE[bp], PAGE_IO		;R13
else;	Update_Sensor_in_IOFEAT					;R13
		cmp	byte ptr CUR_PAGE[bp], PAGE_CFEATURE
endif;	Update_Sensor_in_IOFEAT					;R13
endif;	Update_Sensor_in_CPUFEAT				;R20
		jne	short Update_Lm75_End

	;----------------------------------------
		mov	si, offset LM75_Item_List

	Update_Lm75_Start:

		mov	bx, cs:[si]
		cmp	bx, -1
		je	short Update_Lm75_End
		push	si
		F000_call	Display_Whole_Item
		pop	si
		inc	si
		inc	si
		jmp	short Update_Lm75_Start
	;----------------------------------------

	Update_Lm75_End:

		popa
		ret

Update_LM75_Screen	Endp
endif	;BIOS60							;R18

ifdef	BIOS60							;R18
	db	'$SpeRT'					;R18
endif	;BIOS60							;R18

LM75_Item_List	Label	Word

ifdef	BIOS60							;R18
	dw	LM75_Runtime_No					;R18
endif	;BIOS60							;R18

	dw	offset Current_Temp_Item
;R09 - start
ifdef	Dual_LM75_Support
	dw	offset Current_Temp_Item2
endif;	Dual_LM75_Support
;R09 - end

LM75_Runtime_No	EQU	(($ - offset LM75_Item_List)-2)/2	;R18

	dw	-1
;R01 - ends

endif	;SENSOR_IN_XGROUP					;R35
ENDIF	;COMPILE_FOR_SENSOR_MNU

;R28 - start
IF	COMPILE_FOR_SENSOR_MNU EQ 4
	dw	offset First_LM75_Item, offset Last_LM75_Item
ifndef	SENSOR_IN_XGROUP					;R35
	dw	SEG Prg_LM75_Chip, offset Prg_LM75_Chip
else	;SENSOR_IN_XGROUP					;R35
	dw	SEG X_Prg_LM75_Chip, offset X_Prg_LM75_Chip	;R35
endif	;SENSOR_IN_XGROUP					;R35
ENDIF	;COMPILE_FOR_SENSOR_MNU

IF	COMPILE_FOR_SENSOR_MNU EQ 5
	extrn	First_LM75_Item:near
	extrn	Last_LM75_Item:near
ifndef	SENSOR_IN_XGROUP					;R35
	extrn	Prg_LM75_Chip:near
else	;SENSOR_IN_XGROUP					;R35
	extrn	X_Prg_LM75_Chip:far				;R35
endif	;SENSOR_IN_XGROUP					;R35
ENDIF	;COMPILE_FOR_SENSOR_MNU
;R28 - end

endif	;COMPILE_FOR_SENSOR_MNU 


;R35 - start
;==================================================================
;======================== SENSOR IN XGROUP ========================
;======================== SENSOR IN XGROUP ========================
;======================== SENSOR IN XGROUP ========================
;======================== SENSOR IN XGROUP ========================
;==================================================================

ifdef	COMPILE_FOR_SENSOR_ASM
IF	COMPILE_FOR_SENSOR_ASM EQ 2
ifdef	SENSOR_IN_XGROUP			
ifndef		LM75_ID				
LM75_ID         EQU     98H
endif;		LM75_ID				
		public	X_Get_LM75_Byte
		public	X_Set_LM75_Byte
		public	X_Get_LM75_Word
		public	X_Set_LM75_Word

		extrn	X_GetItem_Value:near
		extrn	X_F000_SHADOW_R:near
		extrn	X_F000_SHADOW_W:near

X_Get_LM75_Byte	Proc	Near
	mov	ch, Lm75_ID
	call far ptr	EGROUP:fproc_Ct_I2CReadByte
			ret
X_Get_LM75_Byte	ENDP

X_Set_LM75_Byte	Proc	Near
  	mov	ch, Lm75_ID
	call far ptr	EGROUP:fproc_Ct_I2CWriteByte
			ret
X_Set_LM75_Byte	ENDP

X_Get_LM75_Word	Proc	Near
	mov	ch, Lm75_ID
	call far ptr	EGROUP:fproc_Ct_I2CReadWord
		ret
X_Get_LM75_Word	ENDP

X_Set_LM75_Word	Proc	Near
	mov	ch, Lm75_ID
	call far ptr	EGROUP:fproc_Ct_I2CWriteWord
			ret
X_Set_LM75_Word	ENDP
ifdef	Dual_LM75_Support
;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
		public	X_Get_LM75_Byte2
		public	X_Set_LM75_Byte2
		public	X_Get_LM75_Word2
		public	X_Set_LM75_Word2
X_Get_LM75_Byte2	Proc	Near
			mov	ch, LM75_ID2		
			call far ptr	EGROUP:fproc_Ct_I2CReadByte
			ret
X_Get_LM75_Byte2	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
X_Set_LM75_Byte2	Proc	Near
			mov	ch, LM75_ID2		
			call far ptr	EGROUP:fproc_Ct_I2CWriteByte
			ret
X_Set_LM75_Byte2	Endp

;[]==============================================================[]
;Input	: CL - register index
;Output : AX - Value read
;[]==============================================================[]
X_Get_LM75_Word2	Proc	Near
			mov	ch, LM75_ID2		
			call far ptr	EGROUP:fproc_Ct_I2CReadWord
			ret
X_Get_LM75_Word2	endp

;[]==============================================================[]
;Input : CL - register index
;	 AX - Value to write
;Output: none
;[]==============================================================[]
X_Set_LM75_Word2	Proc	Near
			mov	ch, LM75_ID2		
			call far ptr	EGROUP:fproc_Ct_I2CWriteWord
			ret
X_Set_LM75_Word2	Endp
endif;	Dual_LM75_Support
ifdef	ACPI_Support
		extrn	ACPI_Critical_Item:near
		extrn	TEMP1_HIGH:near		
		extrn	SENSOR_FLAG:near		
;[]========================================================================[]
;Procedure:	Ct_FillTempPointer
;
;Function :	Return Thermal Zone Temperature pointer 
;
;Input	  :	F segment shadow RAM is writeable 
;
;Output   :	none
;	
;[]========================================================================[]
		Public	X_Ct_FillTempPointer
X_Ct_FillTempPointer	Proc	far

		push	es
		
		mov	ax,0f000h
		mov	es,ax
		mov	di,offset DGROUP:SENSOR_FLAG
		test	word ptr es:[di],01h
		jz	short No_Sensor
		mov	di,offset DGROUP:TEMP1_HIGH

		extrn	LM75_TEMP_ITEM:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	X_GetItem_Value
ifndef	CPU_Temp_Selectable
		xor	ah,ah
		mov	si,offset CPU_TEMP_VAL
		add	si,ax
		mov	al,byte ptr cs:[si]
endif;	CPU_Temp_Selectable
		mov	cl,10
		mul	cl
		add	ax,2732

		mov	word ptr es:[di],ax	; Trip point 1 high
		mov	word ptr es:[di+4],ax	; Trip point 2 high
		sub	ax,30
		mov	word ptr es:[di+2],ax	; Trip point 1 low
		mov	word ptr es:[di+6],ax	; Trip point 2 low

ifdef	CPU_Fan_Turn_on_in_WIN98
		extrn	CPU_Fan_in_WIN98_ITEM:near
		mov	si,offset DGROUP:CPU_Fan_in_WIN98_ITEM
		call	X_GetItem_Value
		or	al,al
		jz	Short	CPUFan_Disable					       	
		mov	word ptr es:[di], 2732	; Trip point 1 high
		mov	word ptr es:[di+2], 2732; Trip point 1 low
CPUFan_Disable:
endif;	CPU_Fan_Turn_on_in_WIN98

		mov	si,offset DGROUP:ACPI_Critical_Item
		call	X_GetItem_Value
		xor	ah,ah
		shl	ax,1
		mov	si,offset Critical_Table
		add	si,ax

		mov	ax,word ptr cs:[si]
		mov	word ptr es:[di+8],ax	;Critical trip point

No_Sensor:					
		pop	es
		retf
X_Ct_FillTempPointer	Endp

Critical_Table:

		dw	3332			;60c		
		dw	3382			;65c		
		dw	3432			;70c		
		dw	3482			;75c		

endif	;ACPI_Support

;***************************************************************************
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;**** SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM SENSOR.ASM ****
;***************************************************************************

;[]==============================================================[]
;[]==============================================================[]
		Public	X_Prg_LM75_Chip	
X_Prg_LM75_Chip	Proc	far

ifndef	No_Special_LM75_Item_Patch		
	;Mask LM75's display items if it is not mounted on M/B
		mov	cl,0
		call	X_Get_LM75_Word
		jnc	short @F		;LM75 not found	

	;Disable items by change item's status
		push	ds
		mov	ax,0f000h
		mov	ds,ax
		extrn	Current_Temp_Item:near
		extrn	LM75_TEMP_ITEM:near
		extrn	X_F000_Shadow_W:near
		extrn	X_F000_Shadow_R:near
		assume	ds:DGROUP
		call	X_F000_Shadow_W
		or	word ptr ds:[LM75_TEMP_ITEM].ITEMSTAT,ITEMDISABLE
		or	word ptr ds:[Current_Temp_Item].ITEMSTAT,ITEMDISABLE
ifdef	Dual_LM75_Support
		extrn	Current_Temp_Item2:near			
		or	word ptr ds:[Current_Temp_Item2].ITEMSTAT,ITEMDISABLE
endif;	Dual_LM75_Support

ifdef	ACPI_Support
		extrn	ACPI_Critical_Item:near
		or	word ptr ds:[ACPI_Critical_Item].ITEMSTAT,ITEMDISABLE
ifdef	CPU_Fan_Turn_on_in_Win98
		extrn	CPU_Fan_in_WIN98_ITEM:near
		or	word ptr ds:[CPU_Fan_in_WIN98_ITEM].ITEMSTAT,ITEMDISABLE
endif;	CPU_Fan_Turn_on_in_Win98
endif;	ACPI_Support

ifdef	ACPI_SUPPORT
		and	word ptr ds:[SENSOR_FLAG],not 01h
endif	;ACPI_SUPPORT
		call	X_F000_Shadow_R
		pop	ds
		jmp	short Prg_LM75_Chip_End
	@@:
endif	;No_Special_LM75_Item_Patch		
		mov	cl,01
		mov	al,01				;reset LM75
		call	X_Set_LM75_Byte

		xor	cx,cx
      @@:
	      	newiodelay
		loop	short @B

		mov	cl,01
		mov	al,0				;LM75 start
		call	X_Set_LM75_Byte

		extrn	LM75_TEMP_ITEM:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	X_GetItem_Value
ifndef	CPU_Temp_Selectable
		mov	si,offset CPU_TEMP_VAL
		xor	ah,ah
		add	si,ax
		mov	al,cs:[si]
endif;	CPU_Temp_Selectable

ifdef	Patch_Temp_offset_for_customer		
		sub	ax, 15			
endif;	Patch_Temp_offset_for_customer		

		push	ax
		xor	ah,ah
		mov	cl,03
		call	X_Set_LM75_Word		;set Tos (High limit)

		pop	ax

ifdef	LM75_LoLimit_Difference				
		sub	al,LM75_LoLimit_Difference	
else;	LM75_LoLimit_Difference				
		sub	al,5
endif;	LM75_LoLimit_Difference				

		xor	ah,ah
		mov	cl,02
		call	X_Set_LM75_Word		;set Thyst (Low limit)

ifdef	Thermal_Enable_Use_SMI
		mov	al,02h			;interrupt mode
else;	Thermal_Enable_Use_SMI
		mov	al,0			;comparator mode
endif;	Thermal_Enable_Use_SMI
		mov	cl,1
		call	X_Set_LM75_Byte

ifdef	Dual_LM75_Support

		mov	cl,01
		mov	al,01				;reset LM75
		call	X_Set_LM75_Byte2

		xor	cx,cx
      @@:
	      	newiodelay
		loop	short @B

		mov	cl,01
		mov	al,0				;LM75 start
		call	X_Set_LM75_Byte2

		mov	si,offset DGROUP:LM75_TEMP_ITEM
		call	X_GetItem_Value

		mov	si,offset CPU_TEMP_VAL
		xor	ah,ah
		add	si,ax
		mov	al,cs:[si]

		push	ax
		xor	ah,ah
		mov	cl,03
		call	X_Set_LM75_Word2		;set Tos (High limit)

		pop	ax
		sub	al,5
		xor	ah,ah
		mov	cl,02
		call	X_Set_LM75_Word2		;set Thyst (Low limit)

ifdef	Thermal_Enable_Use_SMI
		mov	al,02h			;interrupt mode
else;	Thermal_Enable_Use_SMI
		mov	al,0			;comparator mode
endif;	Thermal_Enable_Use_SMI
		mov	cl,1
		call	X_Set_LM75_Byte2

endif;	Dual_LM75_Support

	Prg_LM75_Chip_End:				

		retf

X_Prg_LM75_Chip	Endp

		assume	ds:XGROUP			
ifndef	CPU_Temp_Selectable				
ifndef	LM75_SCALE_40_TO_90		 		
ifndef  LM75_SCALE_60_TO_90		 
	ifndef	LM75_SCALE_40_TO_70			
		ALIGN	4
CPU_TEMP_VAL:
		db	0120	;disabled		
		db	032h	;50C
		db	035h	;53C
		db	038h	;56C
		db	03ch	;60C
		db	03fh	;63C
		db	042h	;66C
		db	046h	;70C
	else;	LM75_SCALE_40_TO_70			
		ALIGN	4				
CPU_TEMP_VAL:						
		db	0120	;disabled		
		db	028h	;40C			
		db	02dh	;45C			
		db	032h	;50C			
		db	037h	;55C			
		db	03ch	;60C			
		db	041h	;65C			
		db	046h	;70C			
	endif;	LM75_SCALE_40_TO_70			
else;	LM75_SCALE_60_TO_90		 
		ALIGN	4		 
CPU_TEMP_VAL:				 
		db	0120	;disabled		
		db	03ch	;60C	 
		db	041h	;65C	 
		db	046h	;70C	 
		db	04bh	;75C	 
		db	050h	;80C	 
		db	055h	;85C	 
		db	05ah	;90C	 
endif;	LM75_SCALE_60_TO_90		 
else;	LM75_SCALE_40_TO_90		 		
CPU_TEMP_VAL:				 
		db	0120	;disabled		
		db	028h	;40C			
		db	02dh	;45C			
		db	032h	;50C			
		db	037h	;55C			
		db	03ch	;60C			
		db	041h	;65C			
		db	046h	;70C			
		db	04bh	;75C	 
		db	050h	;80C	 
		db	055h	;85C	 
		db	05ah	;90C	 
endif;	LM75_SCALE_40_TO_90		 		
endif;	CPU_Temp_Selectable				

endif	;SENSOR_IN_XGROUP			
ENDIF	;COMPILE_FOR_SENSOR_ASM EQ 2	
endif	;COMPILE_FOR_SENSOR_ASM


;***************************************************************************
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;**** SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  SENSOR.E8  ****
;***************************************************************************
IFDEF	COMPILE_FOR_SENSOR_MNU 
IF	COMPILE_FOR_SENSOR_MNU EQ 3
ifdef	SENSOR_IN_XGROUP			


SIS_SMBus	=	0
ifdef   SIS_5598_PCI_RESET		
SIS_SMBus	=	1
endif;  SIS_5598_PCI_RESET		
ifdef   SIS5595_ID
SIS_SMBus	=	1
endif;  SIS5595_ID


ifdef	CPU_Temp_Selectable
X_Show_Scale	Proc	Near
	     	extrn	X_GetItem_Value:near
		mov	si,offset DGROUP:LM75_TEMP_ITEM
		Call	X_GetItem_Value

		mov	bl, al
		call far ptr	DGROUP:fproc_DISP_WORD_INT3
		mov	al, '๘'
		call	X_Display_Char		
		mov	al, 'C'
		call	X_Display_Char		
		mov	al, '/'
		call	X_Display_Char		

;๘C transed to ๘F --> C = 5/9*(F-32)
		mov	al, bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
		call far ptr	DGROUP:fproc_DISP_WORD_INT3
		mov	al, '๘'
		call	X_Display_Char	
		mov	al, 'F'
		call	X_Display_Char		
  		sub 	al, -1			;set overflow flag for display error
		ret
X_Show_Scale	Endp
endif;	CPU_Temp_Selectable

X_Show_Current_Temp	Proc	Near

		cmp	al, Special_Before
		je	short @F

		mov	cl,0
		call	x_Get_LM75_Word
ifdef	Software_I2C				
ifdef	VT586_ACPI				
                shr     ax,8                    ; get bit7 - bit15
ifdef	ADD_5C
                add     al,5            ; add : increase 5๘C
endif;	ADD_5C
endif;	VT586_ACPI				
endif;	Software_I2C				

if	SIS_SMBus		; SiS Chipset
                shr     ax,8                    ; get bit7 - bit15
endif;	SIS_SMBus		; SiS Chipset


ifdef	VSA_VGA			; 
		shr     ax,8                    ; get bit7 - bit15
endif;	VSA_VGA			; 

ifdef	Patch_Temp_offset_for_customer		
		add	ax, 15			
endif;	Patch_Temp_offset_for_customer		

		cmp	al,100
		jbe	short OK_75Temp
		mov	al,0
	OK_75Temp:
ifdef	Temp_Always_Add_20C			
		add	al,20			
endif;	Temp_Always_Add_20C			

		mov	bl,al
		call far ptr	DGROUP:fproc_DISP_Byte_INT2
		mov	al, '๘'
		call	X_Display_Char
		mov	al, 'C'
		call	X_Display_Char
		mov	al, '/'
		call	X_Display_Char

;๘C transed to ๘F --> C = 5/9*(F-32)

		mov	al,bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
		call far ptr	DGROUP:fproc_DISP_WORD_INT3
		mov	al, '๘'
		call	X_Display_Char
		mov	al, 'F'
		call    X_Display_Char
	@@:
		ret

X_Show_Current_Temp	endp

ifdef	Dual_LM75_Support
X_Show_Current_Temp2	Proc	Near

		cmp	al, Special_Before
		je	short @F

		mov	cl,0
		call	X_Get_LM75_Word2

ifdef	Patch_Temp_offset_for_customer		
		add	ax, 15			
endif;	Patch_Temp_offset_for_customer		

      		cmp	al,100
      		jbe	short OK_75Temp2
      		mov	al,0
	OK_75Temp2:

ifdef	Temp_Always_Add_20C			
		add	al,20			
endif;	Temp_Always_Add_20C			
	 	mov	bl,al
		call far ptr	DGROUP:fproc_DISP_Byte_INT2
		mov	al, '๘'
		call	X_Display_Char
		mov	al, 'C'
		call	X_Display_Char
		mov	al, '/'
		call	X_Display_Char

;๘C transed to ๘F --> C = 5/9*(F-32)

		mov	al,bl
		mov	bl,9
		mul	bl
		mov	bl,5
		div	bl
		add	al,32
		xor	ah,ah
		call far ptr	DGROUP:fproc_DISP_WORD_INT3
		mov	al, '๘'
		call	X_Display_Char
		mov	al, 'F'
		call	X_Display_Char
	@@:
		ret
X_Show_Current_Temp2	endp
endif;	Dual_LM75_Support
ifndef	BIOS60							
		Public	X_Update_LM75_Screen
X_Update_LM75_Screen	Proc	far

		pusha

ifdef	Update_Sensor_in_CPUFEAT				
		cmp	byte ptr CUR_PAGE[bp], PAGE_CPU
else;	Update_Sensor_in_CPUFEAT
ifdef	Update_Sensor_in_IOFEAT					
		cmp	byte ptr CUR_PAGE[bp], PAGE_IO		
else;	Update_Sensor_in_IOFEAT					
		cmp	byte ptr CUR_PAGE[bp], PAGE_CFEATURE
endif;	Update_Sensor_in_IOFEAT					
endif;	Update_Sensor_in_CPUFEAT				
		jne	short Update_Lm75_End

	;----------------------------------------
		mov	si, offset LM75_Item_List

	Update_Lm75_Start:

		mov	bx, cs:[si]
		cmp	bx, -1
		je	short Update_Lm75_End
		push	si
		call	X_Display_Whole_Item
		pop	si
		inc	si
		inc	si
		jmp	short Update_Lm75_Start
	;----------------------------------------

	Update_Lm75_End:

		popa
		retf

X_Update_LM75_Screen	Endp
endif	;BIOS60							

ifdef	BIOS60							
	db	'$SpeRT'					
endif	;BIOS60							

LM75_Item_List	Label	Word

ifdef	BIOS60							
	dw	LM75_Runtime_No					
endif	;BIOS60							

	dw	offset Current_Temp_Item
ifdef	Dual_LM75_Support
	dw	offset Current_Temp_Item2
endif;	Dual_LM75_Support

LM75_Runtime_No	EQU	(($ - offset LM75_Item_List)-2)/2	

	dw	-1

ENDIF	;SENSOR_IN_XGROUP			
ENDIF	;COMPILE_FOR_SENSOR_MNU
ENDIF	;COMPILE_FOR_SENSOR_MNU

;R35 - end
