bcm953314k24.asm (5402B)
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 port) BCM953314K reference board. 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; led load bcm953314k24.hex 14 ; led auto on 15 ; led start 16 ; 17 ; The are 2 LEDs per FE port one for Link(Left) and one for activity(Right). 18 ; 19 ; Each chip drives only its own LEDs and needs to write them in the order: 20 ; A01, L01, A02, L02, ..., A24, L24 21 ; 22 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 23 ; processor does not always have access to link status. This program 24 ; assumes link status is kept current in bit 0 of RAM byte (0xa0 + portnum). 25 ; Generally, a program running on the main CPU must update these 26 ; locations on link change; see linkscan callback in 27 ; $SDK/src/appl/diag/ledproc.c. 28 ; 29 ; Current implementation: 30 ; 31 ; L01 reflects port 1 link status: 32 ; Black: no link 33 ; Amber: 10 Mb/s 34 ; Green: 100 Mb/s 35 ; Alternating green/amber: 1000 Mb/s 36 ; Very brief flashes of black at 1 Hz: half duplex 37 ; Longer periods of black: collisions in progress 38 ; 39 ; A01 reflects port 1 activity (even if port is down) 40 ; Black: idle 41 ; Green: RX (pulse extended to 1/3 sec) 42 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 43 ; Green/Amber alternating at 6 Hz: both RX and TX 44 ; 45 46 TICKS EQU 1 47 SECOND_TICKS EQU (30*TICKS) 48 49 MIN_FE_PORT EQU 1 50 MAX_FE_PORT EQU 24 51 NUM_FE_PORT EQU 24 52 53 NUM_PORT EQU 24 54 55 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 56 ; so they will be more visible. 57 58 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 59 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 60 61 ; 62 ; Main Update Routine 63 ; 64 ; This routine is called once per tick. 65 ; 66 67 update: 68 ld a, MIN_FE_PORT 69 70 up1: 71 port a 72 ld (PORT_NUM),a 73 74 call link_status ; Left LED for this port 75 call activity ; Right LED for this port 76 77 ld a,(PORT_NUM) 78 inc a 79 cmp a, MAX_FE_PORT+1 80 jnz up1 81 82 ; Update various timers 83 84 ld b,TXRX_ALT_COUNT 85 inc (b) 86 ld a,(b) 87 cmp a,TXRX_ALT_TICKS 88 jc up2 89 ld (b),0 90 up2: 91 92 send 48 ; 2 * 24 93 94 ; 95 ; activity 96 ; 97 ; This routine calculates the activity LED for the current port. 98 ; It extends the activity lights using timers (new activity overrides 99 ; and resets the timers). 100 ; 101 ; Inputs: (PORT_NUM) 102 ; Outputs: Two bits sent to LED stream 103 ; 104 105 activity: 106 pushst RX 107 pushst TX 108 tor 109 pop 110 jnc act1 111 112 ld b,TXRX_TIMERS ; Start TXRX LED extension timer 113 add b,(PORT_NUM) 114 ld a,ACT_EXT_TICKS 115 ld (b),a 116 117 act1: 118 ld b,TXRX_TIMERS ; Check TXRX LED extension timer 119 add b,(PORT_NUM) 120 121 dec (b) 122 jnc act2 ; TXRX active? 123 inc (b) 124 125 jmp led_black ; No activity 126 127 act2: ; Both TX and RX active 128 ld b,(TXRX_ALT_COUNT) 129 cmp b,TXRX_ALT_TICKS/2 130 jc led_green ; Fast alternation of green/amber 131 jmp led_black 132 133 ; 134 ; link_status 135 ; 136 ; This routine calculates the link status LED for the current port. 137 ; 138 ; Inputs: (PORT_NUM) 139 ; Outputs: Two bits sent to LED stream 140 ; Destroys: a, b 141 ; 142 143 link_status: 144 ld a,(PORT_NUM) 145 call get_link 146 jnc led_black 147 jmp led_green 148 149 ; 150 ; get_link 151 ; 152 ; This routine finds the link status LED for a port. 153 ; Link info is in bit 0 of the byte read from PORTDATA[port] 154 ; 155 ; Inputs: Port number in a 156 ; Outputs: Carry flag set if link is up, clear if link is down. 157 ; Destroys: a, b 158 ; 159 160 get_link: 161 ld b,PORTDATA 162 add b,a 163 ld b,(b) 164 tst b,0 165 ret 166 167 ; 168 ; led_black, led_amber, led_green 169 ; 170 ; Inputs: None 171 ; Outputs: Two bits to the LED stream indicating color 172 ; Destroys: None 173 ; 174 175 led_green: 176 pushst ZERO 177 pack 178 ret 179 180 led_black: 181 pushst ONE 182 pack 183 ret 184 185 ; 186 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0) 187 ; 188 189 ; 190 ; Port data, which must be updated continually by main CPU's 191 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 192 ; In this program, bit 0 is assumed to contain the link up/down status. 193 ; 194 195 PORTDATA equ 0xa0 ; Size 24 + 6? bytes 196 197 ; 198 ; LED extension timers 199 ; 200 201 TXRX_ALT_COUNT equ 0xe0 202 PORT_NUM equ 0xe1 203 TXRX_TIMERS equ 0xe2 ; NUM_PORT bytes C0 - DF 204 205 ; 206 ; Symbolic names for the bits of the port status fields 207 ; 208 209 RX equ 0x0 ; received packet 210 TX equ 0x1 ; transmitted packet 211 COLL equ 0x2 ; collision indicator 212 SPEED_C equ 0x3 ; 100 Mbps 213 SPEED_M equ 0x4 ; 1000 Mbps 214 DUPLEX equ 0x5 ; half/full duplex 215 FLOW equ 0x6 ; flow control capable 216 LINKUP equ 0x7 ; link down/up status 217 LINKEN equ 0x8 ; link disabled/enabled status 218 ZERO equ 0xE ; always 0 219 ONE equ 0xF ; always 1