Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1599 art_zh 1
$Revision: 1598 $
2
 
3
SMBUS_PCIE_ADDR		equ	0xF00A0000    	; bdf0:20.0  = SB7xx SMBus PCI Config Registers
4
LPC_PCIE_ADDR		equ	0xF00A3000    	; bdf0:20.3  = SB7xx LPC ISA bridge Config Registers
5
 
6
SB_SIO_INDEX	equ	0x2e
7
 
8
;---------------------------------------------------------------------
9
align 4
10
smbus_read_pciconfig:
11
; in:  dl = reg#  |  out: eax = data
12
	mov	ebx, SMBUS_PCIE_ADDR
13
	and	edx, 0x0FC
14
	mov	eax, dword [ebx+edx]
15
	ret
16
;------------------------------------------------
17
align 4
18
smbus_write_pciconfig:
19
; in: dl = reg#; eax = data
20
	mov	ebx, SMBUS_PCIE_ADDR
21
	and	edx, 0x0FC
22
	mov	dword [ebx+edx], eax
23
	ret
24
 
25
;--------------------------------------------------------------------
26
align 4
27
lpc_read_pciconfig:
28
; in:  dl = reg#  |  out: eax = data
29
	mov	ebx, LPC_PCIE_ADDR
30
	and	edx, 0x0FC
31
	mov	eax, dword [ebx+edx]
32
	ret
33
;------------------------------------------------
34
align 4
35
lpc_write_pciconfig:
36
; in: dl = reg#; eax = data
37
	mov	ebx, LPC_PCIE_ADDR
38
	and	edx, 0x0FC
39
	mov	dword [ebx+edx], eax
40
	ret
41
 
42
;--------------------------------------------------------------------
43
align 4
44
read_sio_cfg:
45
; in:  al = reg#  |  out: al =  data
46
	mov	dx,  SB_SIO_INDEX
47
	out	dx, al
48
	inc	dl
49
	in	al, dx
50
	ret
51
 
52
;------------------------------------------------
53
align 4
54
write_sio_cfg:
55
; in:  al = reg#; ah = data
56
;------------------------------------------------
57
	mov	dx,  SB_SIO_INDEX
58
	out	dx, al
59
	inc	dl
60
	xchg	al, ah
61
	out	dx, al
62
	xchg	al, ah
63
	ret
64
;------------------------------------------------
65
align 4
66
enter_sio_cfg_mode:
67
; the magic sequence to unlock the port
68
;------------------------------------------------
69
	mov	dx, SB_SIO_INDEX
70
	mov	eax, 0x55550187 ; low byte first
71
	out	dx, al
72
	shr	eax, 8
73
	out	dx, al
74
	shr	eax, 8
75
	out	dx, al
76
	shr	eax, 8
77
	out	dx, al
78
	ret
79
 
80
;-----------------------------------------------------------------------
81
; ATTENTION: the functions assume that RESET# signals use pins 84 and 34
82
; of IT8712F SuperIO chip. These signals may be (and will be!) different
83
; for every particular motherboard and SIO. Please refer to your m/board
84
; documentation to define the correct pins and GPIO lines!
85
;
86
;   Note this example DOES NOT PRETEND to be 100% correct implementation
87
;   of PCIe hotplug techniques !!
88
;-----------------------------------------------------------------------
89
align 4
90
init_pcie_slot_control:
91
;------------------------------------------------
92
	call	enter_sio_cfg_mode
93
	mov	ax, 0x0707	; LDN = 07
94
	call	write_sio_cfg
95
	mov	al, 0x25
96
	call	read_sio_cfg	; ah = reg25h (Multy-function pin selector)
97
	or	ah, 3		; set bits 0, 1 (GPIO)
98
	call	write_sio_cfg
99
	mov	al, 0x2A
100
	call	read_sio_cfg	; ah = reg2Ah (Extended fn pin selector)
101
	or	ah, 3		; set bits 0, 1 (GPIO)
102
	call	write_sio_cfg
103
	mov	al, 0xB8
104
	call	read_sio_cfg	; ah = regB8h (internal pull-up enable)
105
	or	ah, 3		; set bits 0, 1
106
	call	write_sio_cfg
107
	mov	al, 0xC0
108
	call	read_sio_cfg	; ah = regC0h (simple IO enable)
109
	or	ah, 3		; set bits 0, 1
110
	call	write_sio_cfg
111
	mov	ax, 0x0202	; Lock SIO config ports
112
	call	write_sio_cfg
113
	ret
114
 
115
align 4
116
reset_pcie_slot:
117
;------------------------------------------------
118
	call	enter_sio_cfg_mode
119
	mov	ax, 0x0707	; LDN = 07
120
	call	write_sio_cfg
121
	mov	al, 0xB0
122
	call	read_sio_cfg	; ah = regB0h (Pin polarity)
123
	and	ah, 0xFC	; invert bits 0, 1
124
	call	write_sio_cfg
125
	or	ah, 3		; restore bits 0, 1
126
	call	write_sio_cfg
127
	mov	ax, 0x0202	; Lock SIO config ports
128
	call	write_sio_cfg
129
	ret
130