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

sdk56504.asm (9500B)


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