Subversion Repositories Kolibri OS

Rev

Rev 241 | Rev 313 | 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
251 Ghost 57
	jc	.no_lpc
223 Ghost 58
	in	al, UGURU_CMD_PORT
59
	test	al, al
60
	jz	@f
61
	cmp	al, 0xac
62
	jne	.bad_sig
63
@@:	in	al, UGURU_DATA_PORT
64
	test	al, al
65
	jz	@f
66
	cmp	al, 8
67
	jne	.bad_sig
68
@@:	mov	[hwm_chip_name], msg_uguru
69
	popa
70
	clc
71
	ret
72
.bad_sig:
73
	; popa				;
74
	; clc				; <- uncomment this three line, if you certain that you
75
	; ret				;         have ABIT uGuru but he is not defined
76
.no_lpc:
77
	mov	ecx, UGURU_CMD_PORT
78
	mov	edx, UGURU_DATA_PORT
79
	call	FreePorts
80
	popa
81
.uGuru_no:
82
	stc
83
	ret
84
;-----------------------------------
85
uGuru_getparam:
86
	; Temperature
87
	mov	ax, UGURU_CPUTEMP
88
	call	uGuru_ReadSensor
89
	mov	[hwm_temps + 0], al
90
	mov	ax, UGURU_SYSTEMP
91
	call	uGuru_ReadSensor
92
	mov	[hwm_temps + 1], al
93
	mov	ax, UGURU_PWMTEMP
94
	call	uGuru_ReadSensor
95
	mov	[hwm_temps + 2], al
96
	; Fan speed
97
	mov	ax, SENS_CPUFAN
98
	call	uGuru_ReadSensor
99
	mov	dl, 60
100
	mul	dl
101
	mov	word[hwm_rpms + 0 ], ax
102
	mov	ax, SENS_NBFAN
103
	call	uGuru_ReadSensor
104
	mov	dl, 60
105
	mul	dl
106
	mov	word[hwm_rpms + 4 ], ax
107
	mov	ax, SENS_SYSFAN
108
	call	uGuru_ReadSensor
109
	mov	dl, 60
110
	mul	dl
111
	mov	word[hwm_rpms + 8 ], ax
112
	mov	ax, SENS_AUXFAN1
113
	call	uGuru_ReadSensor
114
	mov	dl, 60
115
	mul	dl
116
	mov	word[hwm_rpms + 12], ax
117
	mov	ax, SENS_AUXFAN2
118
	call	uGuru_ReadSensor
119
	mov	dl, 60
120
	mul	dl
121
	mov	word[hwm_rpms + 16], ax
122
	; voltages
123
	cld				; Paranoia
124
	xor	ecx, ecx
125
	mov	esi, v_addr
126
@@:	push	ecx
127
	lodsw
128
	call	uGuru_ReadSensor
129
	movzx	eax, al
130
	fld	dword[v_mult + ecx * 4]
131
	push	eax
132
	fild	dword [esp]
133
	fmulp	st1, st0
134
	fstp	dword [hwm_voltages + ecx * 4]
135
	pop	eax
136
	pop	ecx
137
	inc	ecx
138
	cmp	ecx, 11			; <-- количество датчиков (ADC Vin)
139
	jne	@b
140
 
141
	ret
142
;-----------------------------------
143
uGuru_ReadSensor:
144
; Read a sensor
145
; In  : ax - sensorID
146
; Out : al - result
147
	mov	ebx, eax		; Ask to read from uGuru
148
	shr	eax, 8
149
	out	UGURU_DATA_PORT, al
150
	mov	ecx, 1000		; I guess this is to se if uGuru is ready to take a command
151
.is_ready:
152
	in	al, UGURU_DATA_PORT
153
	dec	ecx
154
	jnz	@f
155
	xor	al, al
156
	ret
157
@@:	cmp	al, 8
158
	jne	.is_ready
159
	mov	al, bl			; Whitch sensor to read?
160
	out	UGURU_CMD_PORT, al
161
	mov	ecx, 1000		; Wait until uGuru is ready to be read
162
.is_ready2:
163
	in	al, UGURU_DATA_PORT
164
	dec	ecx
165
	jnz	@f
166
	xor	al, al
167
	ret
168
@@:	cmp	al, 1
169
	jne	.is_ready2
170
	in	al, UGURU_CMD_PORT	; Read the sensor
171
	push	eax
172
	call	uGuru_Ready		; Put the chip in ready state
173
	pop	eax			; Return the result of the sensor
174
	ret
175
;-----------------------------------
176
uGuru_Ready:
177
; Put uGuru in ready state. uGuru will hold 0x08 at Data port and 0xAC at Command port after this.
178
; Out : CF = 1 - error
179
	; Wait until uGuru is in ready-state
180
	; The loop shouldn't be needed to execut more then one time
181
	mov	edx, 1000
182
.nxt:	in	al, UGURU_DATA_PORT
183
	cmp	al, 8
184
	je	.ok
185
	xor	al, al			; after 0x00 is written to Data port
186
	out	UGURU_DATA_PORT, al
187
	mov	ecx, 1000		; Wait until 0x09 is read at Data port
188
.is_ready:
189
	in	al, UGURU_DATA_PORT
190
	dec	ecx
191
	jnz	@f
192
	stc
193
	ret
194
@@:	cmp	al, 9
195
	jne	.is_ready
196
	mov	ecx, 1000		; Wait until 0xAC is read at Cmd port
197
.is_ready2:
198
	in	al, UGURU_CMD_PORT
199
	dec	ecx
200
	jnz	@f
201
	stc
202
	ret
203
@@:	cmp	al, 0xAC
204
	jne	.is_ready2
205
	dec	edx			; Prevent a lockup
206
	jnz	.nxt
207
	stc
208
	ret
209
.ok:	clc
210
	ret
211