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

sdk56700.asm (9013B)


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