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

sdk56800c.asm (7688B)


      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 GE port) BCM56800 SDKs.
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led load sdk56800c.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 ; Each chip drives only its own LEDs and needs to write them in the order:
     24 ;       L01, A01, L02, A02, ..., L20, A20
     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.
     52 ;
     53 
     54 SECOND_TICKS    EQU     30
     55 
     56 MIN_PORT        EQU     0
     57 MAX_PORT        EQU     19
     58 NUM_PORT        EQU     20
     59 
     60 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     61 ; so they will be more visible.
     62 
     63 ACT_EXT_TICKS   EQU     (SECOND_TICKS/3)
     64 GIG_ALT_TICKS   EQU     (SECOND_TICKS/2)
     65 HD_OFF_TICKS    EQU     (SECOND_TICKS/20)
     66 HD_ON_TICKS     EQU     (SECOND_TICKS-HD_ON_TICKS)
     67 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     68 
     69 ;
     70 ; Main Update Routine
     71 ;
     72 ;  This routine is called once per tick.
     73 ;
     74 
     75 update:
     76         sub     a,a             ; ld a,MIN_PORT (but only one instr)
     77 
     78 up1:
     79         port    a
     80         ld      (PORT_NUM),a
     81 
     82         call    activity        ; Left LED for this port
     83         call    link_status     ; Right LED for this port
     84 
     85         ld      a,(PORT_NUM)
     86         inc     a
     87         cmp     a,NUM_PORT
     88         jnz     up1
     89 
     90         ; Update various timers
     91 
     92         ld      b,GIG_ALT_COUNT
     93         inc     (b)
     94         ld      a,(b)
     95         cmp     a,GIG_ALT_TICKS
     96         jc      up2
     97         ld      (b),0
     98 up2:
     99 
    100         ld      b,HD_COUNT
    101         inc     (b)
    102         ld      a,(b)
    103         cmp     a,HD_ON_TICKS+HD_OFF_TICKS
    104         jc      up3
    105         ld      (b),0
    106 up3:
    107 
    108         ld      b,TXRX_ALT_COUNT
    109         inc     (b)
    110         ld      a,(b)
    111         cmp     a,TXRX_ALT_TICKS
    112         jc      up4
    113         ld      (b),0
    114 up4:
    115 
    116         send    80     ; 2 * 2 * 20
    117 
    118 ;
    119 ; activity
    120 ;
    121 ;  This routine calculates the activity LED for the current port.
    122 ;  It extends the activity lights using timers (new activity overrides
    123 ;  and resets the timers).
    124 ;
    125 ;  Inputs: (PORT_NUM)
    126 ;  Outputs: Two bits sent to LED stream
    127 ;
    128 
    129 activity:
    130         pushst  RX
    131         pop
    132         jnc     act1
    133 
    134         ld      b,RX_TIMERS     ; Start RX LED extension timer
    135         add     b,(PORT_NUM)
    136         ld      a,ACT_EXT_TICKS
    137         ld      (b),a
    138 
    139 act1:
    140         pushst  TX
    141         pop
    142         jnc     act2
    143 
    144         ld      b,TX_TIMERS     ; Start TX LED extension timer
    145         add     b,(PORT_NUM)
    146         ld      a,ACT_EXT_TICKS
    147         ld      (b),a
    148 
    149 act2:
    150         ld      b,TX_TIMERS     ; Check TX LED extension timer
    151         add     b,(PORT_NUM)
    152 
    153         dec     (b)
    154         jnc     act3            ; TX active?
    155         inc     (b)
    156 
    157         ld      b,RX_TIMERS     ; Check RX LED extension timer
    158         add     b,(PORT_NUM)
    159 
    160         dec     (b)             ; Extend LED green if only RX active
    161         jnc     led_green
    162         inc     (b)
    163 
    164         jmp     led_black       ; No activity
    165 
    166 act3:                           ; TX is active, see if RX also active
    167         ld      b,RX_TIMERS
    168         add     b,(PORT_NUM)
    169 
    170         dec     (b)             ; RX also active?
    171         jnc     act4
    172         inc     (b)
    173 
    174         jmp     led_amber       ; Only TX active
    175 
    176 act4:                           ; Both TX and RX active
    177         ld      b,(TXRX_ALT_COUNT)
    178         cmp     b,TXRX_ALT_TICKS/2
    179         jc      led_amber       ; Fast alternation of green/amber
    180         jmp     led_green
    181 
    182 ;
    183 ; link_status
    184 ;
    185 ;  This routine calculates the link status LED for the current port.
    186 ;
    187 ;  Inputs: (PORT_NUM)
    188 ;  Outputs: Two bits sent to LED stream
    189 ;  Destroys: a, b
    190 ;
    191 
    192 link_status:
    193         pushst  DUPLEX          ; Skip blink code if full duplex
    194         pop
    195         jc      ls1
    196 
    197         pushst  COLL            ; Check for collision in half duplex
    198         pop
    199         jc      led_black
    200 
    201         ld      a,(HD_COUNT)    ; Provide blink for half duplex
    202         cmp     a,HD_OFF_TICKS
    203         jc      led_black
    204 
    205 ls1:
    206         ld      a,(PORT_NUM)    ; Check for link down
    207         call    get_link
    208         jnc     led_black
    209 
    210         pushst  SPEED_C         ; Check for 100Mb speed
    211         pop
    212         jc      led_green
    213 
    214         pushst  SPEED_M         ; Check for 10Mb (i.e. not 100 or 1000)
    215         pop
    216         jnc     led_amber
    217 
    218         ld      a,(GIG_ALT_COUNT)
    219         cmp     a,GIG_ALT_TICKS/2
    220         jc      led_amber
    221 
    222         jmp     led_green
    223 
    224 ;
    225 ; get_link
    226 ;
    227 ;  This routine finds the link status LED for a port.
    228 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    229 ;
    230 ;  Inputs: Port number in a
    231 ;  Outputs: Carry flag set if link is up, clear if link is down.
    232 ;  Destroys: a, b
    233 ;
    234 
    235 get_link:
    236         ld      b,PORTDATA
    237         add     b,a
    238         ld      b,(b)
    239         tst     b,0
    240         ret
    241 
    242 ;
    243 ; led_black, led_amber, led_green
    244 ;
    245 ;  Inputs: None
    246 ;  Outputs: Two bits to the LED stream indicating color
    247 ;  Destroys: None
    248 ;
    249 
    250 led_black:
    251         pushst  ZERO
    252         pack
    253         pushst  ZERO
    254         pack
    255         ret
    256 
    257 led_amber:
    258         pushst  ZERO
    259         pack
    260         pushst  ONE
    261         pack
    262         ret
    263 
    264 led_green:
    265         pushst  ONE
    266         pack
    267         pushst  ZERO
    268         pack
    269         ret
    270 
    271 ;
    272 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0)
    273 ;
    274 
    275 TXRX_ALT_COUNT  equ     0xe0
    276 HD_COUNT        equ     0xe1
    277 GIG_ALT_COUNT   equ     0xe2
    278 PORT_NUM        equ     0xe3
    279 
    280 ;
    281 ; Port data, which must be updated continually by main CPU's
    282 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    283 ; In this program, bit 0 is assumed to contain the link up/down status.
    284 ;
    285 
    286 PORTDATA        equ     0x80    ; Size 24 + 4? bytes
    287 
    288 ;
    289 ; LED extension timers
    290 ;
    291 
    292 RX_TIMERS       equ     0xa0+0                  ; NUM_PORT bytes
    293 TX_TIMERS       equ     0xa0+NUM_PORT           ; NUM_PORT bytes
    294 
    295 ;
    296 ; Symbolic names for the bits of the port status fields
    297 ;
    298 
    299 RX              equ     0x0     ; received packet
    300 TX              equ     0x1     ; transmitted packet
    301 COLL            equ     0x2     ; collision indicator
    302 SPEED_C         equ     0x3     ; 100 Mbps
    303 SPEED_M         equ     0x4     ; 1000 Mbps
    304 DUPLEX          equ     0x5     ; half/full duplex
    305 FLOW            equ     0x6     ; flow control capable
    306 LINKUP          equ     0x7     ; link down/up status
    307 LINKEN          equ     0x8     ; link disabled/enabled status
    308 ZERO            equ     0xE     ; always 0
    309 ONE             equ     0xF     ; always 1