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

sdk56524.asm (8453B)


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