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

lm48p5695_10.asm (6434B)


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