sdk56504ref.asm (9666B)
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 (24+4 port) BCM56504 SDKs. 10 ; To start it, use the following commands from BCM: 11 ; 12 ; led load sdk56504ref.hex 13 ; led auto on 14 ; led start 15 ; 16 ; The are 2 LEDs per Gig port one for Link(Left) and one for activity(Right). 17 ; 18 ; There are two bits per gigabit Ethernet LED with the following colors: 19 ; ZERO, ZERO Black 20 ; ZERO, ONE Amber 21 ; ONE, ZERO Green 22 ; 23 ; There are 8 LEDS two each for HG/10G ports 24 ; There is two bit per higig/10G LED with the following colors: 25 ; ZERO, ZERO Black 26 ; ZERO, ONE Amber 27 ; ONE, ZERO Green 28 ; 29 ; Each chip drives only its own LEDs and needs to write them in the order: 30 ; A01, L01, A02, L02, ..., A24, L24, L25, A26, ..., L28, A28 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: 10 Mb/s 44 ; Green: 100 Mb/s 45 ; Alternating green/amber: 1000 Mb/s 46 ; Very brief flashes of black at 1 Hz: half duplex 47 ; Longer periods of black: collisions in progress 48 ; 49 ; A01 reflects port 1 activity (even if port is down) 50 ; Black: idle 51 ; Green: RX (pulse extended to 1/3 sec) 52 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 53 ; Green/Amber alternating at 6 Hz: both RX and TX 54 ; 55 ; L25-L28 reflects higig/10G link enable/status: 56 ; Black: no link 57 ; amber: Enable 58 ; Green: 10 Gb/s 59 ; A25-A28 reflects port 25-28 activity 60 ; Black: idle 61 ; Green: RX (pulse extended to 1/3 sec) 62 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 63 ; Green/Amber alternating at 6 Hz: both RX and TX 64 ; Note: 65 ; To provide consistent behavior, the gigabit LED patterns match 66 ; those in sdk5605.asm. 67 ; 68 69 TICKS EQU 1 70 SECOND_TICKS EQU (30*TICKS) 71 72 MIN_GE_PORT EQU 0 73 MAX_GE_PORT EQU 23 74 NUM_GE_PORT EQU 24 75 76 MIN_HG_PORT EQU 24 77 MAX_HG_PORT EQU 27 78 NUM_HG_PORT EQU 4 79 NUM_ALL_PORT EQU 28 80 81 MIN_PORT EQU 0 82 MAX_PORT EQU 27 83 NUM_PORT EQU 28 84 85 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 86 ; so they will be more visible. 87 88 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 89 GIG_ALT_TICKS EQU (SECOND_TICKS/2) 90 HD_OFF_TICKS EQU (SECOND_TICKS/20) 91 HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 92 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 93 94 ; 95 ; Main Update Routine 96 ; 97 ; This routine is called once per tick. 98 ; 99 100 update: 101 sub a,a ; ld a,MIN_GE_PORT (but only one instr) 102 103 up1: 104 port a 105 ld (PORT_NUM),a 106 107 call activity ; Right LED for this port 108 call link_status ; Left LED for this port 109 110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 111 ; Uncomment for Rev 0 of the board 112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 113 ; ld a,(PORT_NUM) 114 ; inc a 115 ; port a 116 ; ld (PORT_NUM),a 117 ; 118 ; call link_status ; Left LED for this port 119 ; call activity ; Right LED for this port 120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 121 122 ld a,(PORT_NUM) 123 inc a 124 cmp a,NUM_GE_PORT 125 jnz up1 126 127 ; Put out 8 bits for higig/10G port 128 up1_5: 129 port a 130 ld (PORT_NUM),a 131 132 ; LINKUP LINKEN 133 ; ZERO, ZERO Black 134 ; ZERO, ONE Amber 135 ; ONE, ZERO Green 136 ; 137 call get_link 138 jnc no_link 139 call led_green 140 call activity ; Check activity for this port 141 jmp next_hg 142 143 no_link: 144 pushst ZERO 145 pack 146 pushst LINKEN ; For now, copy values directly to LEDs 147 pack 148 call led_black ; No link. Therefore, no activity. 149 150 next_hg: 151 ld a,(PORT_NUM) 152 inc a 153 cmp a,NUM_ALL_PORT 154 jnz up1_5 155 156 ; Update various timers 157 158 ld b,GIG_ALT_COUNT 159 inc (b) 160 ld a,(b) 161 cmp a,GIG_ALT_TICKS 162 jc up2 163 ld (b),0 164 up2: 165 166 ld b,HD_COUNT 167 inc (b) 168 ld a,(b) 169 cmp a,HD_ON_TICKS+HD_OFF_TICKS 170 jc up3 171 ld (b),0 172 up3: 173 174 ld b,TXRX_ALT_COUNT 175 inc (b) 176 ld a,(b) 177 cmp a,TXRX_ALT_TICKS 178 jc up4 179 ld (b),0 180 up4: 181 182 send 112 ; 2 * 2 * 28 183 184 ; 185 ; activity 186 ; 187 ; This routine calculates the activity LED for the current port. 188 ; It extends the activity lights using timers (new activity overrides 189 ; and resets the timers). 190 ; 191 ; Inputs: (PORT_NUM) 192 ; Outputs: Two bits sent to LED stream 193 ; 194 195 activity: 196 pushst RX 197 pop 198 jnc act1 199 200 ld b,RX_TIMERS ; Start RX LED extension timer 201 add b,(PORT_NUM) 202 ld a,ACT_EXT_TICKS 203 ld (b),a 204 205 act1: 206 pushst TX 207 pop 208 jnc act2 209 210 ld b,TX_TIMERS ; Start TX LED extension timer 211 add b,(PORT_NUM) 212 ld a,ACT_EXT_TICKS 213 ld (b),a 214 215 act2: 216 ld b,TX_TIMERS ; Check TX LED extension timer 217 add b,(PORT_NUM) 218 219 dec (b) 220 jnc act3 ; TX active? 221 inc (b) 222 223 ld b,RX_TIMERS ; Check RX LED extension timer 224 add b,(PORT_NUM) 225 226 dec (b) ; Extend LED green if only RX active 227 jnc led_green 228 inc (b) 229 230 jmp led_black ; No activity 231 232 act3: ; TX is active, see if RX also active 233 ld b,RX_TIMERS 234 add b,(PORT_NUM) 235 236 dec (b) ; RX also active? 237 jnc act4 238 inc (b) 239 240 jmp led_amber ; Only TX active 241 242 act4: ; Both TX and RX active 243 ld b,(TXRX_ALT_COUNT) 244 cmp b,TXRX_ALT_TICKS/2 245 jc led_amber ; Fast alternation of green/amber 246 jmp led_green 247 248 ; 249 ; link_status 250 ; 251 ; This routine calculates the link status LED for the current port. 252 ; 253 ; Inputs: (PORT_NUM) 254 ; Outputs: Two bits sent to LED stream 255 ; Destroys: a, b 256 ; 257 258 link_status: 259 pushst DUPLEX ; Skip blink code if full duplex 260 pop 261 jc ls1 262 263 pushst COLL ; Check for collision in half duplex 264 pop 265 jc led_black 266 267 ld a,(HD_COUNT) ; Provide blink for half duplex 268 cmp a,HD_OFF_TICKS 269 jc led_black 270 271 ls1: 272 ld a,(PORT_NUM) ; Check for link down 273 call get_link 274 jnc led_black 275 276 pushst SPEED_C ; Check for 100Mb speed 277 pop 278 jc led_green 279 280 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 281 pop 282 jnc led_amber 283 284 ld a,(GIG_ALT_COUNT) 285 cmp a,GIG_ALT_TICKS/2 286 jc led_amber 287 288 jmp led_green 289 290 ; 291 ; get_link 292 ; 293 ; This routine finds the link status LED for a port. 294 ; Link info is in bit 0 of the byte read from PORTDATA[port] 295 ; 296 ; Inputs: Port number in a 297 ; Outputs: Carry flag set if link is up, clear if link is down. 298 ; Destroys: a, b 299 ; 300 301 get_link: 302 ld b,PORTDATA 303 add b,a 304 ld b,(b) 305 tst b,0 306 ret 307 308 ; 309 ; led_black, led_amber, led_green 310 ; 311 ; Inputs: None 312 ; Outputs: Two bits to the LED stream indicating color 313 ; Destroys: None 314 ; 315 316 led_black: 317 pushst ZERO 318 pack 319 pushst ZERO 320 pack 321 ret 322 323 led_amber: 324 pushst ZERO 325 pack 326 pushst ONE 327 pack 328 ret 329 330 led_green: 331 pushst ONE 332 pack 333 pushst ZERO 334 pack 335 ret 336 337 ; 338 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 339 ; 340 341 TXRX_ALT_COUNT equ 0xe0 342 HD_COUNT equ 0xe1 343 GIG_ALT_COUNT equ 0xe2 344 PORT_NUM equ 0xe3 345 346 ; 347 ; Port data, which must be updated continually by main CPU's 348 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 349 ; In this program, bit 0 is assumed to contain the link up/down status. 350 ; 351 352 PORTDATA equ 0x80 ; Size 24 + 4? bytes 353 354 ; 355 ; LED extension timers 356 ; 357 358 RX_TIMERS equ 0xa0+0 ; NUM_PORT bytes 359 TX_TIMERS equ 0xa0+NUM_PORT ; NUM_PORT bytes 360 361 ; 362 ; Symbolic names for the bits of the port status fields 363 ; 364 365 RX equ 0x0 ; received packet 366 TX equ 0x1 ; transmitted packet 367 COLL equ 0x2 ; collision indicator 368 SPEED_C equ 0x3 ; 100 Mbps 369 SPEED_M equ 0x4 ; 1000 Mbps 370 DUPLEX equ 0x5 ; half/full duplex 371 FLOW equ 0x6 ; flow control capable 372 LINKUP equ 0x7 ; link down/up status 373 LINKEN equ 0x8 ; link disabled/enabled status 374 ZERO equ 0xE ; always 0 375 ONE equ 0xF ; always 1