poe48p56504.asm (9149B)
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 (48+4 port) BCM956504P48POEREF. 10 ; To start it, use the following commands from BCM: 11 ; 12 ; *:led load poe48p56504.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 ; L01, A01, L02, A02, ..., L24, A24, L25, A25, L26, A26 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-L26 reflects higig/10G link enable/status: 56 ; Black: no link 57 ; amber: Enable 58 ; Green: 10 Gb/s 59 ; A25-A26 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 25 78 NUM_HG_PORT EQU 2 79 NUM_ALL_PORT EQU 26 80 81 MIN_PORT EQU 0 82 MAX_PORT EQU 25 83 NUM_PORT EQU 26 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 link_status ; Left LED for this port 108 call activity ; Right LED for this port 109 110 ld a,(PORT_NUM) 111 inc a 112 cmp a,NUM_GE_PORT 113 jnz up1 114 115 ; Put out 4 bits for higig/10G port 116 up1_5: 117 port a 118 ld (PORT_NUM),a 119 120 ; LINKUP LINKEN 121 ; ZERO, ZERO Black 122 ; ZERO, ONE Amber 123 ; ONE, ZERO Green 124 ; 125 call get_link 126 jnc no_link 127 call led_green 128 jmp chk_act 129 no_link: 130 pushst ZERO 131 pack 132 pushst LINKEN ; For now, copy values directly to LEDs 133 pack 134 chk_act: 135 call activity ; Down LED for this port 136 137 ld a,(PORT_NUM) 138 inc a 139 cmp a,NUM_ALL_PORT 140 jnz up1_5 141 142 ; Update various timers 143 144 ld b,GIG_ALT_COUNT 145 inc (b) 146 ld a,(b) 147 cmp a,GIG_ALT_TICKS 148 jc up2 149 ld (b),0 150 up2: 151 152 ld b,HD_COUNT 153 inc (b) 154 ld a,(b) 155 cmp a,HD_ON_TICKS+HD_OFF_TICKS 156 jc up3 157 ld (b),0 158 up3: 159 160 ld b,TXRX_ALT_COUNT 161 inc (b) 162 ld a,(b) 163 cmp a,TXRX_ALT_TICKS 164 jc up4 165 ld (b),0 166 up4: 167 168 send 104 ; 2 * 2 * 26 169 170 ; 171 ; activity 172 ; 173 ; This routine calculates the activity LED for the current port. 174 ; It extends the activity lights using timers (new activity overrides 175 ; and resets the timers). 176 ; 177 ; Inputs: (PORT_NUM) 178 ; Outputs: Two bits sent to LED stream 179 ; 180 181 activity: 182 pushst RX 183 pop 184 jnc act1 185 186 ld b,RX_TIMERS ; Start RX LED extension timer 187 add b,(PORT_NUM) 188 ld a,ACT_EXT_TICKS 189 ld (b),a 190 191 act1: 192 pushst TX 193 pop 194 jnc act2 195 196 ld b,TX_TIMERS ; Start TX LED extension timer 197 add b,(PORT_NUM) 198 ld a,ACT_EXT_TICKS 199 ld (b),a 200 201 act2: 202 ld b,TX_TIMERS ; Check TX LED extension timer 203 add b,(PORT_NUM) 204 205 dec (b) 206 jnc act3 ; TX active? 207 inc (b) 208 209 ld b,RX_TIMERS ; Check RX LED extension timer 210 add b,(PORT_NUM) 211 212 dec (b) ; Extend LED green if only RX active 213 jnc led_green 214 inc (b) 215 216 jmp led_black ; No activity 217 218 act3: ; TX is active, see if RX also active 219 ld b,RX_TIMERS 220 add b,(PORT_NUM) 221 222 dec (b) ; RX also active? 223 jnc act4 224 inc (b) 225 226 jmp led_amber ; Only TX active 227 228 act4: ; Both TX and RX active 229 ld b,(TXRX_ALT_COUNT) 230 cmp b,TXRX_ALT_TICKS/2 231 jc led_amber ; Fast alternation of green/amber 232 jmp led_green 233 234 ; 235 ; link_status 236 ; 237 ; This routine calculates the link status LED for the current port. 238 ; 239 ; Inputs: (PORT_NUM) 240 ; Outputs: Two bits sent to LED stream 241 ; Destroys: a, b 242 ; 243 244 link_status: 245 pushst DUPLEX ; Skip blink code if full duplex 246 pop 247 jc ls1 248 249 pushst COLL ; Check for collision in half duplex 250 pop 251 jc led_black 252 253 ld a,(HD_COUNT) ; Provide blink for half duplex 254 cmp a,HD_OFF_TICKS 255 jc led_black 256 257 ls1: 258 ld a,(PORT_NUM) ; Check for link down 259 call get_link 260 jnc led_black 261 262 pushst SPEED_C ; Check for 100Mb speed 263 pop 264 jc led_green 265 266 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 267 pop 268 jnc led_amber 269 270 ld a,(GIG_ALT_COUNT) 271 cmp a,GIG_ALT_TICKS/2 272 jc led_amber 273 274 jmp led_green 275 276 ; 277 ; get_link 278 ; 279 ; This routine finds the link status LED for a port. 280 ; Link info is in bit 0 of the byte read from PORTDATA[port] 281 ; 282 ; Inputs: Port number in a 283 ; Outputs: Carry flag set if link is up, clear if link is down. 284 ; Destroys: a, b 285 ; 286 287 get_link: 288 ld b,PORTDATA 289 add b,a 290 ld b,(b) 291 tst b,0 292 ret 293 294 ; 295 ; led_black, led_amber, led_green 296 ; 297 ; Inputs: None 298 ; Outputs: Two bits to the LED stream indicating color 299 ; Destroys: None 300 ; 301 302 led_black: 303 pushst ZERO 304 pack 305 pushst ZERO 306 pack 307 ret 308 309 led_amber: 310 pushst ZERO 311 pack 312 pushst ONE 313 pack 314 ret 315 316 led_green: 317 pushst ONE 318 pack 319 pushst ZERO 320 pack 321 ret 322 323 ; 324 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 325 ; 326 327 TXRX_ALT_COUNT equ 0xe0 328 HD_COUNT equ 0xe1 329 GIG_ALT_COUNT equ 0xe2 330 PORT_NUM equ 0xe3 331 332 ; 333 ; Port data, which must be updated continually by main CPU's 334 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 335 ; In this program, bit 0 is assumed to contain the link up/down status. 336 ; 337 338 PORTDATA equ 0x80 ; Size 24 + 4? bytes 339 340 ; 341 ; LED extension timers 342 ; 343 344 RX_TIMERS equ 0xa0+0 ; NUM_PORT bytes 345 TX_TIMERS equ 0xa0+NUM_PORT ; NUM_PORT bytes 346 347 ; 348 ; Symbolic names for the bits of the port status fields 349 ; 350 351 RX equ 0x0 ; received packet 352 TX equ 0x1 ; transmitted packet 353 COLL equ 0x2 ; collision indicator 354 SPEED_C equ 0x3 ; 100 Mbps 355 SPEED_M equ 0x4 ; 1000 Mbps 356 DUPLEX equ 0x5 ; half/full duplex 357 FLOW equ 0x6 ; flow control capable 358 LINKUP equ 0x7 ; link down/up status 359 LINKEN equ 0x8 ; link disabled/enabled status 360 ZERO equ 0xE ; always 0 361 ONE equ 0xF ; always 1