Added further documentation from datasheet, fixed typos
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1837e8767a
commit
30dce4171c
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
84
src/pcie.asm
84
src/pcie.asm
|
@ -116,6 +116,35 @@ lock_PCIE_SBUS_release:
|
|||
RET
|
||||
|
||||
; FASTCALL bool, uint result(uint & 0xff Register, uint & 0xff DeviceAddress, bool doRead, uint commandData). bool is in RRET, result in RRET_X
|
||||
;
|
||||
; This is defined on datasheet, page 372, 9.3 SerDes Management and Temperature as pseudocode:
|
||||
;
|
||||
; sbus_xxx_command (device, register, command, data)
|
||||
; {
|
||||
; // Write data
|
||||
; SBUS_XXX_REQUEST = data;
|
||||
; // Start command
|
||||
; SBUS_XXX_COMMAND = (1 << 24) /*Execute*/
|
||||
; + (((command==Write) ? 0x21 : (command==Read) ? 0x22 : 0x0) << 16)
|
||||
; + (device << 8)
|
||||
; + (register);
|
||||
;
|
||||
; // Wait for command to complete
|
||||
; while (SBUS_XXX_COMMAND.Busy) yield();
|
||||
;
|
||||
; // Check result status (optional; failure indicates invalid device number)
|
||||
; result = SBUS_XXX_COMMAND.ResultCode;
|
||||
; if ( command == Write && result != 0x1 ) error;
|
||||
; if ( command == Read && result != 0x4 ) error;
|
||||
;
|
||||
; // Clear register for next command
|
||||
; SBUS_XXX_COMMAND = 0;
|
||||
;
|
||||
; // Read data
|
||||
; data = SBUS_XXX_RESPONSE;
|
||||
; return data;
|
||||
; }
|
||||
;
|
||||
execute_SBus_PCIE_Command:
|
||||
MOV~03 SBUS_PCIE_REQUEST, P3 ; Set commandData into the request
|
||||
SHL R0, P1, 8 ; P1 << 8
|
||||
|
@ -154,32 +183,38 @@ init_PCIE_MASTER_SPICO:
|
|||
MOV api_PCIE_MASTER_STATUS, 0
|
||||
MOV api_BSM_STATUS, 0x0101000e
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x0a, 0xfe, 0, 0x01
|
||||
; Set SBus frequency to refclk/2 for ethernet
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x0a, platform_PCIE_SBUS_CONTROLLER_DEVICE_ADDRESS, 0, 0x01
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Place Master SPICO into Reset and Enable off
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0xc0
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Remove Reset, Enable off, IMEM_CNTL_EN on
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x0240
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Set starting IMEM address for burst download
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x03, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x80000000
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
MOV api_BSM_STATUS, 0x0102000e
|
||||
; Write firmware image to Master SPICO
|
||||
CALL @download_master_spico_fw
|
||||
MOV api_BSM_STATUS, 0x0103000e
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x40
|
||||
; Start the Master SPICO controller
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x40 ; Set IMEM_CNTL_EN off
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x16, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x000c0000
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x16, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x000c0000 ; Turn ECC on
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x0140
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x01, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x0140 ; Set SPICO_ENABLE on
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
MOV api_MASTER_FW_VERSION, plaftorm_MASTER_FW_VERSION
|
||||
MOV api_MASTER_FW_VERSION, platform_MASTER_FW_VERSION
|
||||
|
||||
MOV RRET, 1 ; Success
|
||||
MOV api_BSM_STATUS, 0x0108000e
|
||||
|
@ -198,15 +233,17 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
|
||||
MOV R0, 0 ; Why, this must be a constant!
|
||||
BEQ R0, 1, 0x1, @.skipUnlock
|
||||
MOV api_BSM_STATUS, 0x0001000e
|
||||
|
||||
MOV api_BSM_STATUS, 0x0001000e
|
||||
|
||||
; Place SerDes in Reset & disable SPICO
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x07, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x11
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Remove SerDes Reset
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x07, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x10
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Assert IMEM override
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x00, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x40000000
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
|
@ -231,32 +268,36 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
.skipLock: ; (??)
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x00, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x00
|
||||
|
||||
; Start SerDes controller
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x00, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x00 ; IMEM override off
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x0b, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x0c0000
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x0b, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x0c0000 ; Turn ECC on
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x07, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x02
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x07, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x02 ; Turn SPICO Enable on
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x08, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x00
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x08, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x00 ; Enable core and hardware interrupts
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
.skipFullLock: ; (??)
|
||||
MOV api_SERDES_FW_VERSION, plaftorm_SERDES_FW_VERSION
|
||||
MOV api_SERDES_FW_VERSION, platform_SERDES_FW_VERSION
|
||||
|
||||
; TODO: move this to its own call
|
||||
MOV R3, 1 ; Why, this must be a constant!. Also registered loc_089110_load_config_unknown_1 on original code
|
||||
BEQ R3, 0, 0x1, @.successCommand ; Skip CRC and version checks
|
||||
MOV api_BSM_STATUS, 0x0004000e
|
||||
|
||||
; Execute Master SPICO CRC check interrupt
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x02, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x02 ; Do MASTER FW CRC check
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x07, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x01 ; Do MASTER FW CRC check read result
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
; Execute SerDes CRC check interrupts (broadcast)
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x03, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x3c0000 ; Do All SerDes FW CRC check
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
|
@ -265,9 +306,10 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
.doMasterCRCCheck:
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x09, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 1, 0x00 ; Check MASTER FW CRC check
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
BEQ RRET_X, 0x00008000, 0x00008000, @.doMasterCRCCheck ; If not finish check yet?
|
||||
BEQ RRET_X, 0x00008000, 0x00008000, @.doMasterCRCCheck ; Poll Master SPICO for completion (only check bit[15])
|
||||
|
||||
BNE RRET_X, 0x00010000, 0xffff0000, @.doAllSerdesCRCCheck ; If check failed, skip setting the proper value
|
||||
; Check Master SPICO result
|
||||
BNE RRET_X, 0x00010000, 0xffff0000, @.doAllSerdesCRCCheck ; If check failed, skip setting the proper value, (0x0001 is pass, 0xFFFF is fail)
|
||||
; Command Executed
|
||||
SET api_BSM_STATUS, 0x00100000, 0x00100000 ; Set Master CRC = OK
|
||||
MOV api_PCIE_FW_CHECK_STATUS, api_BSM_STATUS
|
||||
|
@ -283,9 +325,10 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
.doSingleSerdesCRCCheck:
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x04, BSM_COUNTER_1, 1, 0x00 ; Do SerDes SPICO read
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
BEQ RRET_X, 0x00010000, 0x00010000, @.doSingleSerdesCRCCheck ; If not finish check yet?
|
||||
BEQ RRET_X, 0x00010000, 0x00010000, @.doSingleSerdesCRCCheck ; Poll SerDes for completion (only check bit[16])
|
||||
|
||||
BNE RRET_X, 0x00000000, 0x0000ffff, @.finishAllSerdesCRCCheck ; If check failed, skip setting the proper value
|
||||
; Check SerDes result
|
||||
BNE RRET_X, 0x00000000, 0x0000ffff, @.finishAllSerdesCRCCheck ; If check failed, skip setting the proper value, (0x00 is pass, 0xFF is fail)
|
||||
; Prepare and set register for success
|
||||
MOV R4, 0x00000001
|
||||
BEQ BSM_COUNTER_1, platform_SERDES_SPICO_COUNT, 0xffffffff, @.setAllSerdesCRCCheckValue ; Number of SerDes SPICO
|
||||
|
@ -307,6 +350,7 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
MOV api_PCIE_FW_CHECK_STATUS, api_BSM_STATUS
|
||||
|
||||
.doMasterVersionCheck:
|
||||
; Execute Master SPICO Revision check interrupt
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x02, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 0, 0x00 ; Do MASTER FW Version check
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
|
||||
|
@ -316,7 +360,7 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
.doMasterVersionCheckRead:
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x08, platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS, 1, 0x00 ; Check MASTER FW Version
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
BEQ RRET_X, 0x00008000, 0x00008000, @.doMasterVersionCheckRead ; If not finish check yet?
|
||||
BEQ RRET_X, 0x00008000, 0x00008000, @.doMasterVersionCheckRead ; Poll Master SPICO for completion (only check bit[15])
|
||||
|
||||
; Compare api_MASTER_FW_VERSION and Returned version
|
||||
AND R6, api_MASTER_FW_VERSION, 0xffff0000
|
||||
|
@ -329,7 +373,7 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
MOV api_PCIE_FW_CHECK_STATUS, api_BSM_STATUS
|
||||
|
||||
.doAllSerdesVersionCheck:
|
||||
|
||||
; Execute SerDes Revision check interrupts (broadcast)
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x03, platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS, 0, 0x00 ; Do All SerDes FW Version check
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
WRITE api_SERDES_STATUS_3, 0x00000000, 0x00000000 ; 64-bit write
|
||||
|
@ -347,7 +391,7 @@ init_ALL_PCIE_SERDES_SPICO:
|
|||
.doSingleSerdesVersionCheck:
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x04, BSM_COUNTER_1, 1, 0x00 ; Do SerDes SPICO read
|
||||
BNE RRET, 1, 0x1, @.failCommand ; Command failed
|
||||
BEQ RRET_X, 0x00010000, 0x00010000, @.doSingleSerdesVersionCheck ; If not finish check yet?
|
||||
BEQ RRET_X, 0x00010000, 0x00010000, @.doSingleSerdesVersionCheck ; Poll SerDes for completion (only check bit[16])
|
||||
|
||||
AND R7, RRET_X, 0x0000ffff
|
||||
SUB R7, R6, R7 ; Compare against api_SERDES_FW_VERSION
|
||||
|
@ -421,7 +465,7 @@ init_PCIE_EACH_SERDES_SPICO:
|
|||
.continue:
|
||||
BNE R0, platform_SERDES_SPICO_COUNT, 0xFFFFFFFF, @.do
|
||||
|
||||
MOV R0, 3 ; Current SERDES device index, odd
|
||||
MOV R0, 3 ; Current SERDES device index, odd, for PCS access
|
||||
MOV R1, 0x000000d0 ; Current data to write
|
||||
.do2:
|
||||
FASTCALL @execute_SBus_PCIE_Command, 0x24, R0, 0, R1 ; Execute command
|
||||
|
|
|
@ -30,10 +30,16 @@
|
|||
.constant platform_PCIE_SBUS_LOCK_NVM 1
|
||||
.constant platform_PCIE_SBUS_LOCK_API 2
|
||||
|
||||
.constant platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS 0xfd
|
||||
.constant platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS 0xff
|
||||
|
||||
.constant platform_SERDES_SPICO_COUNT 0x42
|
||||
.constant platform_PCIE_RMON0_DEVICE_ADDRESS 1
|
||||
; Here go PCIe Lane 0-66 even 0xFF bcast, and PCIe lane PCS 3-67 odd 0xF7 bcast
|
||||
.constant platform_PCIE_RMON1_DEVICE_ADDRESS 68
|
||||
.constant platform_PCIE_THERMAL_SENSE_DEVICE_ADDRESS 69
|
||||
.constant platform_PCIE_PMRO_DEVICE_ADDRESS 70
|
||||
.constant platform_PCIE_MASTER_SPICO_DEVICE_ADDRESS 0xfd
|
||||
.constant platform_PCIE_SBUS_CONTROLLER_DEVICE_ADDRESS 0xfe
|
||||
.constant platform_PCIE_ALL_SERDES_SPICO_DEVICE_ADDRESS 0xff
|
||||
|
||||
|
||||
; Change this?
|
||||
.constant platform_PCIE_SBUS_LOCK_HOLD BSM_SCRATCH_START +0x166
|
||||
|
|
Loading…
Reference in a new issue