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