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

merlin5690.asm (6837B)


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