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