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

sdk56800.asm (8737B)


      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 (20 port) BCM56800 SDKs.
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led load sdk56800.hex
     13 ;       led auto on
     14 ;       led start
     15 ;
     16 ; The is 1 LED per GX port, which is used for both link and activity.
     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 LED and needs to write them in the order:
     24 ;       L01, L02, ..., L20
     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 ; Link activity info for Higig/XE ports are not updated by LED processor in
     34 ; 56800_a0 when the port is in XAUI mode. The counter DMA task reports the
     35 ; activities of Higig/Xe ports in bit 1-3 of RAM byte (0x94 + portnum). Bit 
     36 ; 1 indicates that the link activity is high. Bit 2 indicates that the link 
     37 ; activity is medium. Bit 3 indicates that the link activity is low. If all 
     38 ; three bits are clear, the link activity is either very low or no activity
     39 ; at all.  See counter DMA task in $SDK/src/soc/counter.c
     40 ;
     41 ; Current implementation:
     42 ;
     43 ; L01 reflects port 1 link and activity status:
     44 ;       Black: no link
     45 ;       Green: link
     46 ;
     47 ;   when port speed is higher than 2.5G,
     48 ;       Amber: activity high (blinking interval at ~1/8 sec)
     49 ;       Amber: activity medium (blinking interval at ~1/4 sec)
     50 ;       Amber: activity low (blinking interval at ~1/2 sec)
     51 ;
     52 ;   when port speed is 2.5G and less,
     53 ;       Green: RX (pulse extended to 1/3 sec)
     54 ;       Amber: TX (pulse extended to 1/3 sec, takes precedence over RX)
     55 ;       Green/Amber alternating at 6 Hz: both RX and TX
     56 
     57 MIN_PORT        EQU     0
     58 MAX_PORT        EQU     19
     59 NUM_PORT        EQU     20
     60 
     61 HI_ACT          EQU      2 	; Hi activity bit mask 
     62 ME_ACT          EQU      4	; Medium activity bit mask
     63 LO_ACT          EQU      8	; Low activity bit mask
     64 
     65 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     66 ; so they will be more visible.
     67 SECOND_TICKS    EQU     30
     68 ACT_EXT_TICKS   EQU     (SECOND_TICKS/3)
     69 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     70 
     71 ;
     72 ; Main Update Routine
     73 ;
     74 ;  This routine is called once per tick.
     75 ;
     76 
     77 update:
     78         sub     a,a             ; ld a,MIN_PORT (but only one instr)
     79 
     80 up1:
     81         port    a
     82         ld      (PORT_NUM),a
     83 
     84         call    activity
     85 
     86         ld      a,(PORT_NUM)
     87         inc     a
     88 
     89 up2:
     90         cmp     a,NUM_PORT
     91         jnz     up1
     92 
     93         ; Update various timers
     94         inc     (HIGIG_ALT_COUNT)
     95 
     96 up3:
     97         ld      b,TXRX_ALT_COUNT
     98         inc     (b)
     99         ld      a,(b)
    100         cmp     a,TXRX_ALT_TICKS
    101         jc      up4
    102         ld      (b),0
    103 
    104 up4:
    105         send    40     ; 2 * 20 
    106 
    107 ;
    108 ; activity
    109 ;
    110 ;  This routine calculates the link/activity LED for the current port.
    111 ;
    112 ;  Inputs: (PORT_NUM)
    113 ;  Outputs: Two bits sent to LED stream
    114 ;
    115 
    116 activity:
    117         pushst  RX
    118         pop
    119         jnc     act1
    120 
    121         ld      b,RX_TIMERS     ; Start RX LED extension timer
    122         add     b,(PORT_NUM)
    123         ld      a,ACT_EXT_TICKS
    124         ld      (b),a
    125 
    126 act1:
    127         pushst  TX
    128         pop
    129         jnc     act2
    130 
    131         ld      b,TX_TIMERS     ; Start TX LED extension timer
    132         add     b,(PORT_NUM)
    133         ld      a,ACT_EXT_TICKS
    134         ld      (b),a
    135 
    136 act2:
    137         ld      b,TX_TIMERS     ; Check TX LED extension timer
    138         add     b,(PORT_NUM)
    139 
    140         dec     (b)
    141         jnc     act3            ; TX active?
    142         inc     (b)
    143 
    144         ld      b,RX_TIMERS     ; Check RX LED extension timer
    145         add     b,(PORT_NUM)
    146 
    147         dec     (b)             ; Extend LED green if only RX active
    148         jnc     led_green
    149         inc     (b)
    150 
    151         jmp     xaui_activity   ; If LED processor status indicates no 
    152                                 ; activity, we check the activity status
    153                                 ; reported by counter thread.
    154 
    155 act3:                           ; TX is active, see if RX also active
    156         ld      b,RX_TIMERS
    157         add     b,(PORT_NUM)
    158 
    159         dec     (b)             ; RX also active?
    160         jnc     act4
    161         inc     (b)
    162 
    163         jmp     led_amber       ; Only TX active
    164 
    165 act4:                           ; Both TX and RX active
    166         ld      b,(TXRX_ALT_COUNT)
    167         cmp     b,TXRX_ALT_TICKS/2
    168         jc      led_amber       ; Fast alternation of green/amber
    169         jmp     led_green
    170 
    171 xaui_activity:
    172         ld      a, (PORT_NUM)
    173         ld      b, ACT_DATA
    174         add     b, a
    175         ld      b, (b)
    176 
    177         ld      a, HI_ACT
    178         and     a, b
    179         jnz     xaui_active
    180         
    181         ld      a, ME_ACT
    182         and     a, b
    183         jnz     xaui_active
    184 
    185         ld      a, LO_ACT
    186         and     a, b
    187         jnz     xaui_active
    188    
    189         jmp     link_status
    190 
    191 xaui_active:
    192         and     a, (HIGIG_ALT_COUNT) 
    193         jnz     led_green
    194         jmp     led_amber
    195 
    196 ;
    197 ; link_status
    198 ;
    199 ;  This routine calculates the link status LED for the current port.
    200 ;
    201 ;  Inputs: (PORT_NUM)
    202 ;  Outputs: Two bits sent to LED stream
    203 ;  Destroys: a, b
    204 ;
    205 
    206 link_status:
    207 ls1:
    208         ld      a,(PORT_NUM)    ; Check for link down
    209         call    get_link
    210         jnc     led_black       ; Link down
    211 
    212         jmp     led_green       ; Link up
    213 
    214 ;
    215 ; get_link
    216 ;
    217 ;  This routine finds the link status LED for a port.
    218 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    219 ;
    220 ;  Inputs: Port number in a
    221 ;  Outputs: Carry flag set if link is up, clear if link is down.
    222 ;  Destroys: a, b
    223 ;
    224 
    225 get_link:
    226         ld      b,LNK_DATA
    227         add     b,a
    228         ld      b,(b)
    229         tst     b,0
    230         ret
    231 
    232 ;
    233 ; led_black, led_amber, led_green
    234 ;
    235 ;  Inputs: None
    236 ;  Outputs: Two bits to the LED stream indicating color
    237 ;  Destroys: None
    238 ;
    239 
    240 led_black:
    241         pushst  ZERO
    242         pack
    243         pushst  ZERO
    244         pack
    245         ret
    246 
    247 led_amber:
    248         pushst  ZERO
    249         pack
    250         pushst  ONE
    251         pack
    252         ret
    253 
    254 led_green:
    255         pushst  ONE
    256         pack
    257         pushst  ZERO
    258         pack
    259         ret
    260 
    261 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0)
    262 ;
    263 
    264 TXRX_ALT_COUNT  equ     0xf0
    265 PORT_NUM        equ     0xf2
    266 HIGIG_ALT_COUNT equ     0xf3 ; HIGIG_ALT_COUNT holds the higig activity
    267                              ; LED blinking rate. Bit 1 corresponds to
    268                              ; to high activity, bit 2 corresponds to
    269                              ; medium activity, and bit 3 corresponds to
    270                              ; low activity. The high activity blinks twice
    271                              ; the speed of medium activity and the medium
    272                              ; activity blinks twice the speed of low
    273                              ; activity.  This counter is incremented
    274                              ; every LED refresh cycle.
    275                               
    276 ;
    277 ; LNK_DATA must be updated continually by main CPU's linkscan task.
    278 ; See $SDK/src/appl/diag/ledproc.c for examples.
    279 ; In this program, 
    280 ; Bit
    281 ; 0   - If set, the link is up. Otherwise, the link is down.
    282 LNK_DATA        equ     0x80               ; 20 bytes
    283 
    284 ;
    285 ; ACT_DATA must be updated continually by counter DMA tasks.  
    286 ; See $SDK/src/soc/counter.c for examples.
    287 ; Bit
    288 ; 1   - If set, the link activity is more than 50% of line rate.
    289 ; 2   - If set, the link activity is between 25 to 50% of line rate.
    290 ; 3   - If set, the link activity is between 3 to 25% of line  rate.
    291 ; If bit 1, 2, and 3 are all clear, the link activity is less than 3%.
    292 ACT_DATA	equ     0x80+0x14          ; 20 bytes
    293 
    294 ;
    295 ; LED extension timers
    296 ;
    297 RX_TIMERS       equ     ACT_DATA+0x14  ; NUM_PORT bytes
    298 TX_TIMERS       equ     RX_TIMERS+NUM_PORT ; NUM_PORT bytes
    299 
    300 ;
    301 ; Symbolic names for the bits of the port status fields
    302 ;
    303 
    304 RX              equ     0x0     ; received packet
    305 TX              equ     0x1     ; transmitted packet
    306 COLL            equ     0x2     ; collision indicator
    307 SPEED_C         equ     0x3     ; 100 Mbps
    308 SPEED_M         equ     0x4     ; 1000 Mbps
    309 DUPLEX          equ     0x5     ; half/full duplex
    310 FLOW            equ     0x6     ; flow control capable
    311 LINKUP          equ     0x7     ; link down/up status
    312 LINKEN          equ     0x8     ; link disabled/enabled status
    313 ZERO            equ     0xE     ; always 0
    314 ONE             equ     0xF     ; always 1