Subversion Repositories Kolibri OS

Rev

Rev 223 | Rev 251 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
223 Ghost 1
; ABIT uGuru
2
;
3
;	Chip		Temp	Volt	Fan   ISA   SMBus    LPC
4
;    W83L950D(?)	 3	 11	 5     -      -       +
5
 
6
 
7
; uGuru ports
8
UGURU_CMD_PORT		equ	0x0e0
9
UGURU_DATA_PORT 	equ	0x0e4
10
; temp sensors
11
UGURU_CPUTEMP		equ	0x2100
12
UGURU_SYSTEMP		equ	0x2101
13
UGURU_PWMTEMP		equ	0x210f
14
; fans. These are placed at bank 2
15
SENS_CPUFAN	    	equ	0x2600
16
SENS_NBFAN	   	equ	0x2601
17
SENS_SYSFAN	   	equ	0x2602
18
SENS_AUXFAN1    	equ	0x2603
19
SENS_AUXFAN2    	equ	0x2604
20
; Voltage sensors
21
SENS_VCORE		equ	0x2103	; 3.49V max
22
SENS_DDRVDD		equ	0x2104	; 3.49V max
23
SENS_DDRVTT		equ	0x210A	; 3.49V max
24
SENS_NBVDD		equ	0x2108	; 3.49V max
25
SENS_SBVDD		equ	0x210E	; 3.49V max
26
SENS_HTV		equ	0x2102	; 3.49V max
27
SENS_AGP		equ	0x2109	; 3.49V max
28
SENS_5V			equ	0x2106	; 6.25V max
29
SENS_3V3		equ	0x2105	; 4.36V max
30
SENS_5VSB		equ	0x210B	; 6.25V max
31
SENS_3VDUAL		equ	0x210D	; 4.36V max
32
; Voltage ADC multipliers
33
MLTP_3V49		equ	0.0136862745098039
34
MLTP_4V36		equ	0.0170980392156863
35
MLTP_6V25		equ	0.0245098039215686
36
 
37
 
38
v_addr:	dw	SENS_VCORE, SENS_DDRVDD, SENS_DDRVTT, SENS_NBVDD, SENS_SBVDD
39
	dw	SENS_HTV, SENS_AGP, SENS_5V, SENS_3V3, SENS_5VSB, SENS_3VDUAL
40
 
41
v_mult:	dd	MLTP_3V49, MLTP_3V49, MLTP_3V49, MLTP_3V49, MLTP_3V49, MLTP_3V49
42
	dd	MLTP_3V49, MLTP_6V25, MLTP_4V36, MLTP_6V25, MLTP_4V36
43
 
44
 
45
msg_uguru:	db	10, 'ABIT uGuru'
46
 
47
;-----------------------------------
48
uGuru_init:
49
; Проверка наличия и инициализация
50
; OUT - CF = 1 - error
241 Ghost 51
	cmp	byte[acc_type], 2	; Special IO interface
223 Ghost 52
	jne	.uGuru_no
53
	pusha
54
	mov	ecx, UGURU_CMD_PORT
55
	mov	edx, UGURU_DATA_PORT
56
	call	ReservePorts
57
	test	eax, eax
58
	jnz	.no_lpc
59
	in	al, UGURU_CMD_PORT
60
	test	al, al
61
	jz	@f
62
	cmp	al, 0xac
63
	jne	.bad_sig
64
@@:	in	al, UGURU_DATA_PORT
65
	test	al, al
66
	jz	@f
67
	cmp	al, 8
68
	jne	.bad_sig
69
@@:	mov	[hwm_chip_name], msg_uguru
70
	popa
71
	clc
72
	ret
73
.bad_sig:
74
	; popa				;
75
	; clc				; <- uncomment this three line, if you certain that you
76
	; ret				;         have ABIT uGuru but he is not defined
77
.no_lpc:
78
	mov	ecx, UGURU_CMD_PORT
79
	mov	edx, UGURU_DATA_PORT
80
	call	FreePorts
81
	popa
82
.uGuru_no:
83
	stc
84
	ret
85
;-----------------------------------
86
uGuru_getparam:
87
	; Temperature
88
	mov	ax, UGURU_CPUTEMP
89
	call	uGuru_ReadSensor
90
	mov	[hwm_temps + 0], al
91
	mov	ax, UGURU_SYSTEMP
92
	call	uGuru_ReadSensor
93
	mov	[hwm_temps + 1], al
94
	mov	ax, UGURU_PWMTEMP
95
	call	uGuru_ReadSensor
96
	mov	[hwm_temps + 2], al
97
	; Fan speed
98
	mov	ax, SENS_CPUFAN
99
	call	uGuru_ReadSensor
100
	mov	dl, 60
101
	mul	dl
102
	mov	word[hwm_rpms + 0 ], ax
103
	mov	ax, SENS_NBFAN
104
	call	uGuru_ReadSensor
105
	mov	dl, 60
106
	mul	dl
107
	mov	word[hwm_rpms + 4 ], ax
108
	mov	ax, SENS_SYSFAN
109
	call	uGuru_ReadSensor
110
	mov	dl, 60
111
	mul	dl
112
	mov	word[hwm_rpms + 8 ], ax
113
	mov	ax, SENS_AUXFAN1
114
	call	uGuru_ReadSensor
115
	mov	dl, 60
116
	mul	dl
117
	mov	word[hwm_rpms + 12], ax
118
	mov	ax, SENS_AUXFAN2
119
	call	uGuru_ReadSensor
120
	mov	dl, 60
121
	mul	dl
122
	mov	word[hwm_rpms + 16], ax
123
	; voltages
124
	cld				; Paranoia
125
	xor	ecx, ecx
126
	mov	esi, v_addr
127
@@:	push	ecx
128
	lodsw
129
	call	uGuru_ReadSensor
130
	movzx	eax, al
131
	fld	dword[v_mult + ecx * 4]
132
	push	eax
133
	fild	dword [esp]
134
	fmulp	st1, st0
135
	fstp	dword [hwm_voltages + ecx * 4]
136
	pop	eax
137
	pop	ecx
138
	inc	ecx
139
	cmp	ecx, 11			; <-- количество датчиков (ADC Vin)
140
	jne	@b
141
 
142
	ret
143
;-----------------------------------
144
uGuru_ReadSensor:
145
; Read a sensor
146
; In  : ax - sensorID
147
; Out : al - result
148
	mov	ebx, eax		; Ask to read from uGuru
149
	shr	eax, 8
150
	out	UGURU_DATA_PORT, al
151
	mov	ecx, 1000		; I guess this is to se if uGuru is ready to take a command
152
.is_ready:
153
	in	al, UGURU_DATA_PORT
154
	dec	ecx
155
	jnz	@f
156
	xor	al, al
157
	ret
158
@@:	cmp	al, 8
159
	jne	.is_ready
160
	mov	al, bl			; Whitch sensor to read?
161
	out	UGURU_CMD_PORT, al
162
	mov	ecx, 1000		; Wait until uGuru is ready to be read
163
.is_ready2:
164
	in	al, UGURU_DATA_PORT
165
	dec	ecx
166
	jnz	@f
167
	xor	al, al
168
	ret
169
@@:	cmp	al, 1
170
	jne	.is_ready2
171
	in	al, UGURU_CMD_PORT	; Read the sensor
172
	push	eax
173
	call	uGuru_Ready		; Put the chip in ready state
174
	pop	eax			; Return the result of the sensor
175
	ret
176
;-----------------------------------
177
uGuru_Ready:
178
; Put uGuru in ready state. uGuru will hold 0x08 at Data port and 0xAC at Command port after this.
179
; Out : CF = 1 - error
180
	; Wait until uGuru is in ready-state
181
	; The loop shouldn't be needed to execut more then one time
182
	mov	edx, 1000
183
.nxt:	in	al, UGURU_DATA_PORT
184
	cmp	al, 8
185
	je	.ok
186
	xor	al, al			; after 0x00 is written to Data port
187
	out	UGURU_DATA_PORT, al
188
	mov	ecx, 1000		; Wait until 0x09 is read at Data port
189
.is_ready:
190
	in	al, UGURU_DATA_PORT
191
	dec	ecx
192
	jnz	@f
193
	stc
194
	ret
195
@@:	cmp	al, 9
196
	jne	.is_ready
197
	mov	ecx, 1000		; Wait until 0xAC is read at Cmd port
198
.is_ready2:
199
	in	al, UGURU_CMD_PORT
200
	dec	ecx
201
	jnz	@f
202
	stc
203
	ret
204
@@:	cmp	al, 0xAC
205
	jne	.is_ready2
206
	dec	edx			; Prevent a lockup
207
	jnz	.nxt
208
	stc
209
	ret
210
.ok:	clc
211
	ret
212