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

sdk56960.asm (4989B)


      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 BCM56960 SDKs.
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led 0 load sdk56960x.hex
     13 ;       led 0 auto on
     14 ;       led 0 start
     15 ;
     16 ; The are 2 LEDs per port one for Link(Top) and one for activity(Bottom).
     17 ;
     18 ; Each chip drives only its own LEDs and needs to write them in the order:
     19 ;       L01/A01, L02/A02, ..., L64/A64
     20 ;
     21 ; There are two bits per Ethernet LED for activity with the following colors:
     22 ;       ZERO, ZERO      Black
     23 ;       ZERO, ONE       Amber
     24 ;       ONE, ZERO       Green
     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 (0xA0 + 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 ;       Green: Link
     38 ;
     39 ; A01 reflects port 1 activity status:
     40 ;       Black: no link
     41 ;       Green: Link
     42 ;       Amber: Activity
     43 ;
     44 ;
     45 TICKS           EQU     1
     46 SECOND_TICKS    EQU     (30*TICKS)
     47 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     48 
     49 MIN_PORT        EQU     0
     50 MAX_PORT        EQU     63
     51 NUM_PORT        EQU     64
     52 
     53 
     54 ; Assumptions
     55 ; LED status [TX/RX Activity] is organized to map 1:1 for indexing with
     56 ; link status data thru' CMIC_LEDUP*_PORT_ORDER_REMAP_* registers.
     57 ; Link status is injected by SDK from Linkscan task at PORTDATA offset
     58 
     59 ;
     60 ; Main Update Routine
     61 ;
     62 ;  This routine is called once per tick.
     63 ;
     64 
     65 update:
     66         ld      A,MIN_PORT
     67 port_loop:
     68         port    A
     69         ld      (PORT_NUM),A
     70 
     71         call    link_status    ; Top LED for this port
     72         call    chk_activity   ; Bottom LED for this port
     73 
     74         ; Debug
     75         ;call led_green
     76         ;call led_amber
     77         ; Debug
     78 
     79 
     80         ld      a,(PORT_NUM)
     81         inc     a
     82         cmp     a,NUM_PORT
     83         jnz     port_loop
     84 
     85         ; Update various timers
     86         inc     (TXRX_ALT_COUNT)
     87 
     88         send    252 ; 2 * 2 * 63
     89 
     90 ;
     91 ;
     92 ;
     93 ;  This routine calculates the activity LED for the current port.
     94 ;  It extends the activity lights using timers (new activity overrides
     95 ;  and resets the timers).
     96 ;
     97 ;  Inputs: (PORT_NUM)
     98 ;  Outputs: two bit sent to LED stream
     99 ;
    100 
    101 ;       Activity status LED update
    102 chk_activity:
    103         port    A
    104         pushst  RX
    105         pushst  TX
    106         tor
    107         pop
    108 
    109         jnc     led_black       ; Always black, No Activity
    110 
    111         ;jmp     led_green      ;DEBUG ONLY
    112 
    113         ld      b, (TXRX_ALT_COUNT)
    114         and     b, TXRX_ALT_TICKS
    115         jnz     led_amber
    116         jmp     led_black       ; Fast alternation of black/amber
    117 
    118 ; Link status LED update
    119 link_status:
    120         call    get_link
    121         jnc     led_black
    122         jmp     led_green
    123 
    124 ;
    125 ; get_link
    126 ;
    127 ;  This routine finds the link status LED for a port.
    128 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    129 ;
    130 ;  Inputs: Port number in a
    131 ;  Outputs: Carry flag set if link is up, clear if link is down.
    132 ;  Destroys: a, b
    133 ;
    134 
    135 get_link:
    136         ld      b,PORTDATA
    137         add     b,a
    138         ld      b,(b)
    139         tst     b,0
    140         ret
    141 
    142 
    143 get_link_hw:
    144         port    a
    145         pushst  LINKUP
    146         pop
    147         ret
    148 
    149 ;
    150 ; led_black, led_amber, led_green
    151 ;
    152 ;  Inputs: None
    153 ;  Outputs: Two bits to the LED stream indicating color
    154 ;  Destroys: None
    155 ;
    156 
    157 led_black:
    158         pushst  ZERO
    159         pack
    160         pushst  ZERO
    161         pack
    162         ret
    163 
    164 led_amber:
    165         pushst  ONE
    166         pack
    167         pushst  ZERO
    168         pack
    169         ret
    170 
    171 led_green:
    172         pushst  ZERO
    173         pack
    174         pushst  ONE
    175         pack
    176         ret
    177 
    178 ;
    179 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0)
    180 ;
    181 
    182 TXRX_ALT_COUNT  equ     0xe0
    183 PORT_NUM        equ     0xe1
    184 
    185 ;
    186 ; Port data, which must be updated continually by main CPU's
    187 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    188 ; In this program, bit 0 is assumed to contain the link up/down status.
    189 ;
    190 
    191 ;Offset 0x1e00 - 0x80
    192 ;LED scan chain assembly area
    193 
    194 ;Offset 0x1e80 - 0xa0
    195 PORTDATA        equ     0xa0    ; Size 48 + 1 + 4 bytes
    196 
    197 ;
    198 ; Symbolic names for the bits of the port status fields
    199 ;
    200 
    201 RX              equ     0x0     ; received packet
    202 TX              equ     0x1     ; transmitted packet
    203 COLL            equ     0x2     ; collision indicator
    204 SPEED_C         equ     0x3     ; 100 Mbps
    205 SPEED_M         equ     0x4     ; 1000 Mbps
    206 DUPLEX          equ     0x5     ; half/full duplex
    207 FLOW            equ     0x6     ; flow control capable
    208 LINKUP          equ     0x7     ; link down/up status
    209 LINKEN          equ     0x8     ; link disabled/enabled status
    210 ZERO            equ     0xE     ; always 0
    211 ONE             equ     0xF     ; always 1
    212