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

lm5690.asm (6600B)


      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 Line Module 5690.
     10 ;
     11 ; To start it on both units, use the following commands from BCM:
     12 ;
     13 ;	1:led load lm5690.hex
     14 ;	1:led auto on
     15 ;	2:led load lm5690.hex
     16 ;	2:led auto on
     17 ;	*:led start
     18 ;
     19 ; The two programs should be started simultaneously so that blinking
     20 ; is in sync across the 5690s.
     21 ;
     22 ; The Line Module has 24 LEDs, one for each port as shown below:
     23 ;
     24 ;               5690 Unit 1                      5690 Unit 2
     25 ;       -----------------------------  -----------------------------
     26 ;       LA01 LA03 LA05 LA07 LA09 LA11  LA01 LA03 LA05 LA07 LA09 LA11
     27 ;       LA02 LA04 LA06 LA08 LA10 LA12  LA02 LA04 LA06 LA08 LA10 LA12
     28 ;
     29 ; This program runs on each 5690.  The one running on unit 1 controls
     30 ; the first 12 LEDs, and the one running on unit 2 controls the second
     31 ; 12 LEDs.
     32 ;
     33 ; There are two bits per gigabit ethernet LED with the following colors:
     34 ;	ZERO, ZERO	Black
     35 ;	ZERO, ONE	Green
     36 ;	ONE, ZERO	Amber
     37 ;
     38 ; Each chip drives only its own LEDs and needs to write them in the order:
     39 ;	LA01, ..., LA11, LA12
     40 ;
     41 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED
     42 ; processor does not always have access to link status.  This program
     43 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum).
     44 ; Generally, a program running on the main CPU must update these
     45 ; locations on link change; see linkscan callback in
     46 ; $SDK/src/appl/diag/ledproc.c.
     47 ;
     48 ; Current implementation:
     49 ;
     50 ; LA01 reflects port 1 link and activity status:
     51 ;	Black: no link
     52 ;	Amber: 10 Mb/s
     53 ;	Green: 100 Mb/s
     54 ;	Alternating green/amber: 1000 Mb/s
     55 ;	Very brief flashes of black at 1 Hz: half duplex
     56 ;	Longer periods of black: collisions in progress
     57 ;	Green: RX (pulse extended to 1/3 sec)
     58 ;	Amber: TX (pulse extended to 1/3 sec, takes precedence over RX)
     59 ;	Green/Amber alternating at 6 Hz: both RX and TX
     60 
     61 TICKS		EQU	1
     62 SECOND_TICKS	EQU	(30*TICKS)
     63 
     64 MIN_GE_PORT	EQU	0
     65 MAX_GE_PORT	EQU	11
     66 NUM_GE_PORT	EQU	12
     67 
     68 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     69 ; so they will be more visible.
     70 
     71 ACT_EXT_TICKS	EQU	(SECOND_TICKS/3)
     72 GIG_ALT_TICKS	EQU	(SECOND_TICKS/2)
     73 HD_OFF_TICKS	EQU	(SECOND_TICKS/20)
     74 HD_ON_TICKS	EQU	(SECOND_TICKS-HD_ON_TICKS)
     75 TXRX_ALT_TICKS	EQU	(SECOND_TICKS/6)
     76 
     77 ;
     78 ; Main Update Routine
     79 ;
     80 ;  This routine is called once per tick.
     81 ;
     82 
     83 update:
     84 	sub	a,a		; ld a,MIN_GE_PORT (but only one instr)
     85 
     86 up1:
     87 	port	a
     88 	ld	(PORT_NUM),a
     89 
     90  	call	activity	; Upper LED for this port
     91 
     92 	ld	a,(PORT_NUM)
     93 	inc	a
     94 	cmp	a,NUM_GE_PORT
     95 	jnz	up1
     96 
     97 	; Update various timers
     98 
     99 	ld	b,GIG_ALT_COUNT
    100 	inc	(b)
    101 	ld	a,(b)
    102 	cmp	a,GIG_ALT_TICKS
    103 	jc	up2
    104 	ld	(b),0
    105 up2:
    106 
    107 	ld	b,HD_COUNT
    108 	inc	(b)
    109 	ld	a,(b)
    110 	cmp	a,HD_ON_TICKS+HD_OFF_TICKS
    111 	jc	up3
    112 	ld	(b),0
    113 up3:
    114 
    115 	ld	b,TXRX_ALT_COUNT
    116 	inc	(b)
    117 	ld	a,(b)
    118 	cmp	a,TXRX_ALT_TICKS
    119 	jc	up4
    120 	ld	(b),0
    121 up4:
    122 
    123 	send	24
    124 
    125 ;
    126 ; activity
    127 ;
    128 ;  This routine calculates the activity LED for the current port.
    129 ;  It extends the activity lights using timers (new activity overrides
    130 ;  and resets the timers).
    131 ;
    132 ;  Inputs: (PORT_NUM)
    133 ;  Outputs: Two bits sent to LED stream
    134 ;
    135 
    136 activity:
    137 	pushst	RX
    138 	pop
    139 	jnc	act1
    140 
    141 	ld	b,RX_TIMERS	; Start RX LED extension timer
    142 	add	b,(PORT_NUM)
    143 	ld	a,ACT_EXT_TICKS
    144 	ld	(b),a
    145 
    146 act1:
    147 	pushst	TX
    148 	pop
    149 	jnc	act2
    150 
    151 	ld	b,TX_TIMERS	; Start TX LED extension timer
    152 	add	b,(PORT_NUM)
    153 	ld	a,ACT_EXT_TICKS
    154 	ld	(b),a
    155 
    156 act2:
    157 	ld	b,TX_TIMERS	; Check TX LED extension timer
    158 	add	b,(PORT_NUM)
    159 
    160 	dec	(b)
    161 	jnc	act3		; TX active?
    162 	inc	(b)
    163 
    164 	ld	b,RX_TIMERS	; Check RX LED extension timer
    165 	add	b,(PORT_NUM)
    166 
    167 	dec	(b)		; Extend LED green if only RX active
    168 	jc	chk_link_status ; No activity - Update Link status
    169 
    170 	ld	b,(TXRX_ALT_COUNT)
    171 	cmp	b,TXRX_ALT_TICKS/2
    172 	jc	led_black	; Fast alternation of black/green
    173 	jmp	led_green	; Only RX active
    174 
    175 chk_link_status:
    176 	inc	(b)
    177 
    178 	jmp	link_status; No activity - Update Link status
    179 
    180 act3:				; TX is active, see if RX also active
    181 	ld	b,RX_TIMERS
    182 	add	b,(PORT_NUM)
    183 
    184 	dec	(b)		; RX also active?
    185 	jnc	act4
    186 	inc	(b)
    187 
    188 	ld	b,(TXRX_ALT_COUNT)
    189 	cmp	b,TXRX_ALT_TICKS/2
    190 	jc	led_black	; Fast alternation of black/amber
    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 	ld	a,(HD_COUNT)	; Provide blink for half duplex
    215 	cmp	a,HD_OFF_TICKS
    216 	jc	led_black
    217 
    218 ls1:
    219 	ld	a,(PORT_NUM)	; Check for link down
    220 	call	get_link
    221 	jnc	led_black
    222 
    223 	pushst	COLL		; Check for collision
    224 	pop
    225 	jc	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