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