sdk56840.asm (7403B)
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 the default program for the (36 port) BCM56840 SDKs. 10 ; There are two LED processors on BCM56840. 11 ; To start the first one, use the following commands from BCM: 12 ; 13 ; led load sdk56840.hex 14 ; led auto on 15 ; led start 16 ; To start the second one: 17 ; 18 ; led 1 load sdk56840.hex 19 ; led 1 auto on 20 ; led 1 start 21 ; 22 ; The are 2 LEDs per port one for Link and one for activity. 23 ; 24 ; There are two bits per LED with the following colors: 25 ; ZERO, ZERO Black 26 ; ZERO, ONE Green 27 ; ONE, ZERO Amber 28 ; 29 ; Each chip drives only its own LEDs and needs to write them in the order: 30 ; A01, L01, A02, L02, ..., A24, L24, A25, L25, ..., A35, L35 31 ; 32 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 33 ; processor does not always have access to link status. This program 34 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum). 35 ; Generally, a program running on the main CPU must update these 36 ; locations on link change; see linkscan callback in 37 ; $SDK/src/appl/diag/ledproc.c. 38 ; 39 ; Current implementation: 40 ; 41 ; L01 reflects port 1 link status: 42 ; Black: no link 43 ; Amber: below 10 Gb/s 44 ; Green: 10 Gb/s and above 45 ; 46 ; A01 reflects port 1 activity (even if port is down) 47 ; Black: idle 48 ; Green: RX (pulse extended to 1/3 sec) 49 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 50 ; Green/Amber alternating at 6 Hz: both RX and TX 51 ; 52 ; Scan chain assembly area should start 0x4A and takes 32bytes 53 54 TICKS EQU 1 55 SECOND_TICKS EQU (30*TICKS) 56 57 MIN_PORT EQU 1 58 MAX_PORT EQU 36 59 NUM_PORT EQU 36 60 61 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 62 ; so they will be more visible. 63 64 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 65 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 66 67 ; 68 ; Main Update Routine 69 ; 70 ; This routine is called once per tick. 71 ; 72 73 update: 74 ld a,MIN_PORT 75 up1: 76 port a 77 ld (PORT_NUM),a 78 79 call activity ; Right LED for this port 80 call link_status ; Left LED for this port 81 82 83 ld a,(PORT_NUM) 84 inc a 85 cmp a,NUM_PORT+1 86 jnz up1 87 88 ; Update various timers 89 90 ld b,TXRX_ALT_COUNT 91 inc (b) 92 ld a,(b) 93 cmp a,TXRX_ALT_TICKS 94 jc up4 95 ld (b),0 96 up4: 97 ; The LED test board requires shifting out 256 bits 98 send 252 ; 2 * 2 * 36 + all zeros for remaining bytes 99 100 ; 101 ; activity 102 ; 103 ; This routine calculates the activity LED for the current port. 104 ; It extends the activity lights using timers (new activity overrides 105 ; and resets the timers). 106 ; 107 ; Inputs: (PORT_NUM) 108 ; Outputs: Two bits sent to LED stream 109 ; 110 111 activity: 112 ld a,(PORT_NUM) ; Check for link down 113 call get_rxact 114 jnc act1 115 116 ld b,RX_TIMERS ; Start RX LED extension timer 117 add b,(PORT_NUM) 118 ld a,ACT_EXT_TICKS 119 ld (b),a 120 121 act1: 122 ld a,(PORT_NUM) ; Check for link down 123 call get_txact 124 jnc act2 125 126 ld b,TX_TIMERS ; Start TX LED extension timer 127 add b,(PORT_NUM) 128 ld a,ACT_EXT_TICKS 129 ld (b),a 130 131 act2: 132 ld b,TX_TIMERS ; Check TX LED extension timer 133 add b,(PORT_NUM) 134 135 dec (b) 136 jnc act3 ; TX active? 137 inc (b) 138 139 ld b,RX_TIMERS ; Check RX LED extension timer 140 add b,(PORT_NUM) 141 142 dec (b) ; Extend LED green if only RX active 143 jnc led_green 144 inc (b) 145 146 jmp led_black ; No activity 147 148 act3: ; TX is active, see if RX also active 149 ld b,RX_TIMERS 150 add b,(PORT_NUM) 151 152 dec (b) ; RX also active? 153 jnc act4 154 inc (b) 155 156 jmp led_amber ; Only TX active 157 158 act4: ; Both TX and RX active 159 ld b,(TXRX_ALT_COUNT) 160 cmp b,TXRX_ALT_TICKS/2 161 jc led_amber ; Fast alternation of green/amber 162 jmp led_green 163 164 ; 165 ; link_status 166 ; 167 ; This routine calculates the link status LED for the current port. 168 ; 169 ; Inputs: (PORT_NUM) 170 ; Outputs: Two bits sent to LED stream 171 ; Destroys: a, b 172 ; 173 174 link_status: 175 ld a,(PORT_NUM) ; Check for link down 176 pushst LINKEN 177 pop 178 jnc led_black 179 180 ; ld a,(PORT_NUM) ; Check for link down 181 ; call get_link 182 ; jnc led_black 183 184 ; below 10G amber, 10G and above green 185 pushst SPEED_C ; Check for 100Mb speed 186 pop 187 jnc led_amber 188 189 ; both SPEED_C and SPEED_M set, 10G and above 190 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 191 pop 192 jnc led_amber 193 jmp led_green 194 195 ; 196 ; get_link 197 ; 198 ; This routine finds the link status LED for a port. 199 ; Link info is in bit 0 of the byte read from PORTDATA[port] 200 ; 201 ; Inputs: Port number in a 202 ; Outputs: Carry flag set if link is up, clear if link is down. 203 ; Destroys: a, b 204 ; 205 206 get_link: 207 ld b,PORTDATA 208 add b,a 209 ld b,(b) 210 tst b,0 211 ret 212 213 ; 214 ; get the tx activity status 215 ; 216 get_txact: 217 ld b,PORTDATA 218 add b,a 219 ld b,(b) 220 tst b,4 221 ret 222 223 ; 224 ; get the rx activity status 225 ; 226 get_rxact: 227 ld b,PORTDATA 228 add b,a 229 ld b,(b) 230 tst b,5 231 ret 232 ; 233 ; led_black, led_amber, led_green 234 ; 235 ; Inputs: None 236 ; Outputs: Two bits to the LED stream indicating color 237 ; Destroys: None 238 ; 239 240 led_black: 241 pushst ZERO 242 pack 243 pushst ZERO 244 pack 245 ret 246 247 led_amber: 248 pushst ONE 249 pack 250 pushst ZERO 251 pack 252 ret 253 254 led_green: 255 pushst ZERO 256 pack 257 pushst ONE 258 pack 259 ret 260 261 ; 262 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 263 ; 264 265 TXRX_ALT_COUNT equ 0xf0 266 PORT_NUM equ 0xf3 267 268 ; 269 ; Port data, which must be updated continually by main CPU's 270 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 271 ; In this program, bit 0 is assumed to contain the link up/down status. 272 ; 273 274 PORTDATA equ 0x80 ; Size 36? bytes 275 276 ; 277 ; LED extension timers 278 ; 279 280 RX_TIMERS equ 0xa4+0 ; NUM_PORT bytes 281 TX_TIMERS equ 0xc9 ; NUM_PORT bytes 282 283 ; 284 ; Symbolic names for the bits of the port status fields 285 ; 286 287 RX equ 0x0 ; received packet 288 TX equ 0x1 ; transmitted packet 289 COLL equ 0x2 ; collision indicator 290 SPEED_C equ 0x3 ; 100 Mbps 291 SPEED_M equ 0x4 ; 1000 Mbps 292 DUPLEX equ 0x5 ; half/full duplex 293 FLOW equ 0x6 ; flow control capable 294 LINKUP equ 0x7 ; link down/up status 295 LINKEN equ 0x8 ; link disabled/enabled status 296 ZERO equ 0xE ; always 0 297 ONE equ 0xF ; always 1