openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

wk5690.asm (6771B)


      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 White Knight 5690.
     10 ;
     11 ; To start it, use the following commands from BCM,
     12 ; where unit 0 is the 5670 and units 1 and 2 are the 5690s:
     13 ;
     14 ;	0:led load wk5670.hex
     15 ;	1:led load wk5690.hex
     16 ;	1:led auto on
     17 ;	2:led load wk5690.hex
     18 ;	2:led auto on
     19 ;	*:led start
     20 ;
     21 ; The 3 programs should be started all at once so that blinking
     22 ; is in sync across the 5690s.
     23 ;
     24 ; The White Knight has 14 columns of 4 LEDs each as shown below:
     25 ;
     26 ;            5690 Unit 1              5690 Unit 2          5670 Unit 0
     27 ;       -----------------------  -----------------------  --------------
     28 ;       L01 L03 L05 L07 L09 L11  L01 L03 L05 L07 L09 L11     E1 E2
     29 ;       A01 A03 A05 A07 A09 A11  A01 A03 A05 A07 A09 A11     L1 L2
     30 ;       L02 L04 L06 L08 L10 L12  L02 L04 L06 L08 L10 L12     T1 T2
     31 ;       A02 A04 A06 A08 A10 A12  A02 A04 A06 A08 A10 A12     R1 R2
     32 ;
     33 ; This program runs on each 5690.  The one running on unit 1 controls
     34 ; the first 6 columns, the one running on unit 2 controls the second
     35 ; 6 columns, and a separate program (wk5670) controls the last
     36 ; two columns (external Higig ports).
     37 ;
     38 ; There are two bits per gigabit ethernet LED with the following colors:
     39 ;	ZERO, ZERO	Black
     40 ;	ZERO, ONE	Green
     41 ;	ONE, ZERO	Amber
     42 ;
     43 ; Each chip drives only its own LEDs and needs to write them in the order:
     44 ;	A01, L01, ..., A11, L11, A12, L12
     45 ;
     46 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED
     47 ; processor does not always have access to link status.  This program
     48 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum).
     49 ; Generally, a program running on the main CPU must update these
     50 ; locations on link change; see linkscan callback in
     51 ; $SDK/src/appl/diag/ledproc.c.
     52 ; On the higig ports, LINKEN and LINKUP are used.
     53 ;
     54 ; Current implementation:
     55 ;
     56 ; L01 reflects port 1 link status:
     57 ;	Black: no link
     58 ;	Amber: 10 Mb/s
     59 ;	Green: 100 Mb/s
     60 ;	Alternating green/amber: 1000 Mb/s
     61 ;	Very brief flashes of black at 1 Hz: half duplex
     62 ;	Longer periods of black: collisions in progress
     63 ;
     64 ; A01 reflects port 1 activity (even if port is down)
     65 ;	Black: idle
     66 ;	Green: RX (pulse extended to 1/3 sec)
     67 ;	Amber: TX (pulse extended to 1/3 sec, takes precedence over RX)
     68 ;	Green/Amber alternating at 6 Hz: both RX and TX
     69 
     70 TICKS		EQU	1
     71 SECOND_TICKS	EQU	(30*TICKS)
     72 
     73 MIN_GE_PORT	EQU	0
     74 MAX_GE_PORT	EQU	11
     75 NUM_GE_PORT	EQU	12
     76 
     77 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     78 ; so they will be more visible.
     79 
     80 ACT_EXT_TICKS	EQU	(SECOND_TICKS/3)
     81 GIG_ALT_TICKS	EQU	(SECOND_TICKS/2)
     82 HD_OFF_TICKS	EQU	(SECOND_TICKS/20)
     83 HD_ON_TICKS	EQU	(SECOND_TICKS-HD_ON_TICKS)
     84 TXRX_ALT_TICKS	EQU	(SECOND_TICKS/6)
     85 
     86 ;
     87 ; Main Update Routine
     88 ;
     89 ;  This routine is called once per tick.
     90 ;
     91 
     92 update:
     93 	sub	a,a		; ld a,MIN_GE_PORT (but only one instr)
     94 
     95 up1:
     96 	port	a
     97 	ld	(PORT_NUM),a
     98 
     99 	call	activity	; Upper LED for this port
    100 	call	link_status	; Lower LED for this port
    101 
    102 	ld	a,(PORT_NUM)
    103 	inc	a
    104 	cmp	a,NUM_GE_PORT
    105 	jnz	up1
    106 
    107 	; Update various timers
    108 
    109 	ld	b,GIG_ALT_COUNT
    110 	inc	(b)
    111 	ld	a,(b)
    112 	cmp	a,GIG_ALT_TICKS
    113 	jc	up2
    114 	ld	(b),0
    115 up2:
    116 
    117 	ld	b,HD_COUNT
    118 	inc	(b)
    119 	ld	a,(b)
    120 	cmp	a,HD_ON_TICKS+HD_OFF_TICKS
    121 	jc	up3
    122 	ld	(b),0
    123 up3:
    124 
    125 	ld	b,TXRX_ALT_COUNT
    126 	inc	(b)
    127 	ld	a,(b)
    128 	cmp	a,TXRX_ALT_TICKS
    129 	jc	up4
    130 	ld	(b),0
    131 up4:
    132 
    133 	send	48
    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 ; link_status
    201 ;
    202 ;  This routine calculates the link status LED for the current port.
    203 ;
    204 ;  Inputs: (PORT_NUM)
    205 ;  Outputs: Two bits sent to LED stream
    206 ;  Destroys: a, b
    207 ;
    208 
    209 link_status:
    210 	pushst	DUPLEX		; Skip blink code if full duplex
    211 	pop
    212 	jc	ls1
    213 
    214 	pushst	COLL		; Check for collision in half duplex
    215 	pop
    216 	jc	led_black
    217 
    218 	ld	a,(HD_COUNT)	; Provide blink for half duplex
    219 	cmp	a,HD_OFF_TICKS
    220 	jc	led_black
    221 
    222 ls1:
    223 	ld	a,(PORT_NUM)	; Check for link down
    224 	call	get_link
    225 	jnc	led_black
    226 
    227 	pushst	SPEED_C		; Check for 100Mb speed
    228 	pop
    229 	jc	led_green
    230 
    231 	pushst	SPEED_M		; Check for 10Mb (i.e. not 100 or 1000)
    232 	pop
    233 	jnc	led_amber
    234 
    235 	ld	a,(GIG_ALT_COUNT)
    236 	cmp	a,GIG_ALT_TICKS/2
    237 	jc	led_amber
    238 
    239 	jmp	led_green
    240 
    241 ;
    242 ; get_link
    243 ;
    244 ;  This routine finds the link status LED for a port.
    245 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    246 ;
    247 ;  Inputs: Port number in a
    248 ;  Outputs: Carry flag set if link is up, clear if link is down.
    249 ;  Destroys: a, b
    250 ;
    251 
    252 get_link:
    253 	ld	b,PORTDATA
    254 	add	b,a
    255 	ld	b,(b)
    256 	tst	b,0
    257 	ret
    258 
    259 ;
    260 ; led_black, led_amber, led_green
    261 ;
    262 ;  Inputs: None
    263 ;  Outputs: Two bits to the LED stream indicating color
    264 ;  Destroys: None
    265 ;
    266 
    267 led_black:
    268 	pushst	ZERO
    269 	pack
    270 	pushst	ZERO
    271 	pack
    272 	ret
    273 
    274 led_amber:
    275 	pushst	ZERO
    276 	pack
    277 	pushst	ONE
    278 	pack
    279 	ret
    280 
    281 led_green:
    282 	pushst	ONE
    283 	pack
    284 	pushst	ZERO
    285 	pack
    286 	ret
    287 
    288 ;
    289 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0)
    290 ;
    291 
    292 TXRX_ALT_COUNT	equ	0xc0
    293 HD_COUNT	equ	0xc1
    294 GIG_ALT_COUNT	equ	0xc2
    295 PORT_NUM	equ	0xc3
    296 
    297 ;
    298 ; Port data, which must be updated continually by main CPU's
    299 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    300 ; In this program, bit 0 is assumed to contain the link up/down status.
    301 ;
    302 
    303 PORTDATA	equ	0x80	; Size 12 bytes
    304 
    305 ;
    306 ; LED extension timers
    307 ;
    308 
    309 RX_TIMERS	equ	0xa0+0			; NUM_GE_PORT bytes
    310 TX_TIMERS	equ	0xa0+NUM_GE_PORT	; NUM_GE_PORT bytes
    311 
    312 ;
    313 ; Symbolic names for the bits of the port status fields
    314 ;
    315 
    316 RX		equ	0x0	; received packet
    317 TX		equ	0x1	; transmitted packet
    318 COLL		equ	0x2	; collision indicator
    319 SPEED_C		equ	0x3	; 100 Mbps
    320 SPEED_M		equ	0x4	; 1000 Mbps
    321 DUPLEX		equ	0x5	; half/full duplex
    322 FLOW		equ	0x6	; flow control capable
    323 LINKUP		equ	0x7	; link down/up status
    324 LINKEN		equ	0x8	; link disabled/enabled status
    325 ZERO		equ	0xE	; always 0
    326 ONE		equ	0xF	; always 1