sdk56960_mt2.asm (5296B)
1 ; 2 ; 3 ; 4 ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 ; 6 ; Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 ; 8 ; 9 ; This is to be used on the BCM56960 SDKs with MOntreal2. 10 ; To start it, use the following commands from BCM: 11 ; 12 ; led 0 load sdk56960_mt2.hex 13 ; led 0 auto on 14 ; led 0 start 15 ; 16 ; The are 2 LEDs per port one for Link(Top) and one for activity(Bottom). 17 ; 18 ; Each chip drives only its own LEDs and needs to write them in the order: 19 ; L01/A01, L02/A02, ..., L64/A64 20 ; 21 ; There are two bits per Ethernet LED for activity with the following colors: 22 ; ZERO, ZERO Black 23 ; ZERO, ONE Amber 24 ; ONE, ZERO Green 25 ; 26 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 27 ; processor does not always have access to link status. This program 28 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum). 29 ; Generally, a program running on the main CPU must update these 30 ; locations on link change; see linkscan callback in 31 ; $SDK/src/appl/diag/ledproc.c. 32 ; 33 ; When Montreal2 inband stats collection is running, the activity is not 34 ; derived from TX and RX. The Software-calculated activity is kept in the 35 ; RAM byte (0xA0 + portnum) in bits 1 & 2 36 ; 37 ; Current implementation: 38 ; 39 ; L01 reflects port 1 link status: 40 ; Black: no link 41 ; Green: Link 42 ; 43 ; A01 reflects port 1 activity status: 44 ; Black: no link 45 ; Green: Link 46 ; Amber: Activity 47 ; 48 ; 49 TICKS EQU 1 50 SECOND_TICKS EQU (30*TICKS) 51 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 52 53 MIN_PORT EQU 0 54 MAX_PORT EQU 63 55 NUM_PORT EQU 64 56 57 58 ; Assumptions 59 ; LED status [TX/RX Activity] is organized to map 1:1 for indexing with 60 ; link status data thru' CMIC_LEDUP*_PORT_ORDER_REMAP_* registers. 61 ; Link status is injected by SDK from Linkscan task at PORTDATA offset 62 63 ; 64 ; Main Update Routine 65 ; 66 ; This routine is called once per tick. 67 ; 68 69 update: 70 ld A,MIN_PORT 71 port_loop: 72 port A 73 ld (PORT_NUM),A 74 75 call link_status ; Top LED for this port 76 call chk_activity ; Bottom LED for this port 77 78 ; Debug 79 ;call led_green 80 ;call led_amber 81 ; Debug 82 83 84 ld a,(PORT_NUM) 85 inc a 86 cmp a,NUM_PORT 87 jnz port_loop 88 89 ; Update various timers 90 inc (TXRX_ALT_COUNT) 91 92 send 252 ; 2 * 2 * 63 93 94 ; 95 ; 96 ; 97 ; This routine calculates the activity LED for the current port. 98 ; It extends the activity lights using timers (new activity overrides 99 ; and resets the timers). 100 ; 101 ; Inputs: (PORT_NUM) 102 ; Outputs: two bit sent to LED stream 103 ; 104 105 ; Activity status LED update 106 chk_activity: 107 ld b,PORTDATA 108 add b,a 109 ld b,(b) 110 tst b,1 111 push CY ; TX 112 tst b,2 113 push CY ; RX 114 115 tor 116 pop 117 118 jnc led_black ; Always black, No Activity 119 120 ;jmp led_green ;DEBUG ONLY 121 122 ld b, (TXRX_ALT_COUNT) 123 and b, TXRX_ALT_TICKS 124 jnz led_amber 125 jmp led_black ; Fast alternation of black/amber 126 127 ; Link status LED update 128 link_status: 129 call get_link 130 jnc led_black 131 jmp led_green 132 133 ; 134 ; get_link 135 ; 136 ; This routine finds the link status LED for a port. 137 ; Link info is in bit 0 of the byte read from PORTDATA[port] 138 ; 139 ; Inputs: Port number in a 140 ; Outputs: Carry flag set if link is up, clear if link is down. 141 ; Destroys: a, b 142 ; 143 144 get_link: 145 ld b,PORTDATA 146 add b,a 147 ld b,(b) 148 tst b,0 149 ret 150 151 152 get_link_hw: 153 port a 154 pushst LINKUP 155 pop 156 ret 157 158 ; 159 ; led_black, led_amber, led_green 160 ; 161 ; Inputs: None 162 ; Outputs: Two bits to the LED stream indicating color 163 ; Destroys: None 164 ; 165 166 led_black: 167 pushst ZERO 168 pack 169 pushst ZERO 170 pack 171 ret 172 173 led_amber: 174 pushst ONE 175 pack 176 pushst ZERO 177 pack 178 ret 179 180 led_green: 181 pushst ZERO 182 pack 183 pushst ONE 184 pack 185 ret 186 187 ; 188 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0) 189 ; 190 191 TXRX_ALT_COUNT equ 0xe0 192 PORT_NUM equ 0xe1 193 194 ; 195 ; Port data, which must be updated continually by main CPU's 196 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 197 ; In this program, bit 0 is assumed to contain the link up/down status. 198 ; 199 200 ;Offset 0x1e00 - 0x80 201 ;LED scan chain assembly area 202 203 ;Offset 0x1e80 - 0xa0 204 PORTDATA equ 0xa0 ; Size 48 + 1 + 4 bytes 205 206 ; 207 ; Symbolic names for the bits of the port status fields 208 ; 209 210 RX equ 0x0 ; received packet 211 TX equ 0x1 ; transmitted packet 212 COLL equ 0x2 ; collision indicator 213 SPEED_C equ 0x3 ; 100 Mbps 214 SPEED_M equ 0x4 ; 1000 Mbps 215 DUPLEX equ 0x5 ; half/full duplex 216 FLOW equ 0x6 ; flow control capable 217 LINKUP equ 0x7 ; link down/up status 218 LINKEN equ 0x8 ; link disabled/enabled status 219 ZERO equ 0xE ; always 0 220 ONE equ 0xF ; always 1 221