2010-09-02 22:24:07 +02:00
|
|
|
$Revision: 1598 $
|
|
|
|
|
2011-07-23 17:27:18 +02:00
|
|
|
SMBUS_PCIE_ADDR equ 0xF00A0000 ; bdf0:20.0 = SB7xx SMBus PCI Config Registers
|
|
|
|
LPC_PCIE_ADDR equ 0xF00A3000 ; bdf0:20.3 = SB7xx LPC ISA bridge Config Registers
|
2010-09-02 22:24:07 +02:00
|
|
|
|
2011-07-23 17:27:18 +02:00
|
|
|
SB_SIO_INDEX equ 0x2E
|
|
|
|
SB_PM_INDEX equ 0xCD6
|
|
|
|
|
|
|
|
if PLATFORM>PLATFORM_RS780
|
|
|
|
include "bus/sb/hudson.inc"
|
|
|
|
else
|
|
|
|
include "bus/sb/sb710.inc"
|
|
|
|
end if
|
2010-09-02 22:24:07 +02:00
|
|
|
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
smbus_read_pciconfig:
|
|
|
|
; in: dl = reg# | out: eax = data
|
|
|
|
mov ebx, SMBUS_PCIE_ADDR
|
|
|
|
and edx, 0x0FC
|
|
|
|
mov eax, dword [ebx+edx]
|
|
|
|
ret
|
|
|
|
;------------------------------------------------
|
|
|
|
align 4
|
|
|
|
smbus_write_pciconfig:
|
|
|
|
; in: dl = reg#; eax = data
|
|
|
|
mov ebx, SMBUS_PCIE_ADDR
|
|
|
|
and edx, 0x0FC
|
|
|
|
mov dword [ebx+edx], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
lpc_read_pciconfig:
|
|
|
|
; in: dl = reg# | out: eax = data
|
|
|
|
mov ebx, LPC_PCIE_ADDR
|
|
|
|
and edx, 0x0FC
|
|
|
|
mov eax, dword [ebx+edx]
|
|
|
|
ret
|
|
|
|
;------------------------------------------------
|
|
|
|
align 4
|
|
|
|
lpc_write_pciconfig:
|
|
|
|
; in: dl = reg#; eax = data
|
|
|
|
mov ebx, LPC_PCIE_ADDR
|
|
|
|
and edx, 0x0FC
|
|
|
|
mov dword [ebx+edx], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
read_sio_cfg:
|
|
|
|
; in: al = reg# | out: al = data
|
2011-07-23 17:27:18 +02:00
|
|
|
push edx
|
2010-09-02 22:24:07 +02:00
|
|
|
mov dx, SB_SIO_INDEX
|
|
|
|
out dx, al
|
|
|
|
inc dl
|
|
|
|
in al, dx
|
2011-07-23 17:27:18 +02:00
|
|
|
pop edx
|
|
|
|
ret
|
|
|
|
|
|
|
|
;------------------------------------------------
|
|
|
|
align 4
|
|
|
|
write_pm_cfg:
|
|
|
|
; in: al = reg#; ah = data
|
|
|
|
;------------------------------------------------
|
|
|
|
push edx
|
|
|
|
mov dx, SB_PM_INDEX
|
|
|
|
out dx, al
|
|
|
|
inc dl
|
|
|
|
xchg al, ah
|
|
|
|
out dx, al
|
|
|
|
xchg al, ah
|
|
|
|
pop edx
|
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
read_pm_cfg:
|
|
|
|
; in: al = reg# | out: al = data
|
|
|
|
push edx
|
|
|
|
mov dx, SB_PM_INDEX
|
|
|
|
out dx, al
|
|
|
|
inc dl
|
|
|
|
in al, dx
|
|
|
|
pop edx
|
2010-09-02 22:24:07 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
;------------------------------------------------
|
|
|
|
align 4
|
|
|
|
write_sio_cfg:
|
|
|
|
; in: al = reg#; ah = data
|
|
|
|
;------------------------------------------------
|
2011-07-23 17:27:18 +02:00
|
|
|
push edx
|
2010-09-02 22:24:07 +02:00
|
|
|
mov dx, SB_SIO_INDEX
|
|
|
|
out dx, al
|
|
|
|
inc dl
|
|
|
|
xchg al, ah
|
|
|
|
out dx, al
|
|
|
|
xchg al, ah
|
2011-07-23 17:27:18 +02:00
|
|
|
pop edx
|
2010-09-02 22:24:07 +02:00
|
|
|
ret
|
|
|
|
;------------------------------------------------
|
|
|
|
align 4
|
|
|
|
enter_sio_cfg_mode:
|
|
|
|
; the magic sequence to unlock the port
|
|
|
|
;------------------------------------------------
|
|
|
|
mov dx, SB_SIO_INDEX
|
|
|
|
mov eax, 0x55550187 ; low byte first
|
|
|
|
out dx, al
|
|
|
|
shr eax, 8
|
|
|
|
out dx, al
|
|
|
|
shr eax, 8
|
|
|
|
out dx, al
|
|
|
|
shr eax, 8
|
|
|
|
out dx, al
|
|
|
|
ret
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------------
|
2011-07-23 17:27:18 +02:00
|
|
|
; ATTENTION: the functions assume that RESET# signals use pins 84 and 34
|
|
|
|
; of IT8712F SuperIO chip. These signals may be (and will be!) different
|
2010-09-02 22:24:07 +02:00
|
|
|
; for every particular motherboard and SIO. Please refer to your m/board
|
2011-07-23 17:27:18 +02:00
|
|
|
; documentation to define the correct pins and GPIO lines!
|
2010-09-02 22:24:07 +02:00
|
|
|
;
|
2011-07-23 17:27:18 +02:00
|
|
|
; Note this example DOES NOT PRETEND to be 100% correct implementation
|
2010-09-02 22:24:07 +02:00
|
|
|
; of PCIe hotplug techniques !!
|
|
|
|
;-----------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
init_pcie_slot_control:
|
|
|
|
;------------------------------------------------
|
|
|
|
call enter_sio_cfg_mode
|
|
|
|
mov ax, 0x0707 ; LDN = 07
|
|
|
|
call write_sio_cfg
|
|
|
|
mov al, 0x25
|
|
|
|
call read_sio_cfg ; ah = reg25h (Multy-function pin selector)
|
|
|
|
or ah, 3 ; set bits 0, 1 (GPIO)
|
|
|
|
call write_sio_cfg
|
|
|
|
mov al, 0x2A
|
|
|
|
call read_sio_cfg ; ah = reg2Ah (Extended fn pin selector)
|
|
|
|
or ah, 3 ; set bits 0, 1 (GPIO)
|
|
|
|
call write_sio_cfg
|
|
|
|
mov al, 0xB8
|
|
|
|
call read_sio_cfg ; ah = regB8h (internal pull-up enable)
|
|
|
|
or ah, 3 ; set bits 0, 1
|
|
|
|
call write_sio_cfg
|
|
|
|
mov al, 0xC0
|
|
|
|
call read_sio_cfg ; ah = regC0h (simple IO enable)
|
|
|
|
or ah, 3 ; set bits 0, 1
|
|
|
|
call write_sio_cfg
|
|
|
|
mov ax, 0x0202 ; Lock SIO config ports
|
|
|
|
call write_sio_cfg
|
|
|
|
ret
|
2011-07-23 17:27:18 +02:00
|
|
|
|
2010-09-02 22:24:07 +02:00
|
|
|
align 4
|
|
|
|
reset_pcie_slot:
|
|
|
|
;------------------------------------------------
|
|
|
|
call enter_sio_cfg_mode
|
|
|
|
mov ax, 0x0707 ; LDN = 07
|
|
|
|
call write_sio_cfg
|
|
|
|
mov al, 0xB0
|
|
|
|
call read_sio_cfg ; ah = regB0h (Pin polarity)
|
|
|
|
and ah, 0xFC ; invert bits 0, 1
|
|
|
|
call write_sio_cfg
|
2011-07-23 17:27:18 +02:00
|
|
|
or ah, 3 ; restore bits 0, 1
|
2010-09-02 22:24:07 +02:00
|
|
|
call write_sio_cfg
|
|
|
|
mov ax, 0x0202 ; Lock SIO config ports
|
|
|
|
call write_sio_cfg
|
|
|
|
ret
|
|
|
|
|
|
|
|
|