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

sdk56560.asm (5642B)


      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 BCM5656x/BCM5676x.
     10 ; There are two LED processors on BCM5656x/BCM5676x.
     11 ; Each LED processor accomodates 36 ports.
     12 ; LED processor 0 : Physical Ports 1-36
     13 ; LED processor 1 : Physical Ports 37-72
     14 ;
     15 ; To start the first one, use the following commands from BCM:
     16 ;
     17 ;       led 0 load sdk56560.hex
     18 ;       led 0 auto on
     19 ;       led 0 start
     20 ; To start the second one:
     21 ;
     22 ;       led 1 load sdk56560.hex
     23 ;       led 1 auto on
     24 ;       led 1 start
     25 ;
     26 ; The are 2 LEDs per port one for Link(Top) and one for activity(Bottom).
     27 ;
     28 ; Each chip drives only its own LEDs and needs to write them in the order:
     29 ;       L01/A01, L02/A02, ..., L36/A36
     30 ;
     31 ; There are two bits per Ethernet LED for activity with the following colors:
     32 ;       ZERO, ZERO      Black
     33 ;       ZERO, ONE       Amber
     34 ;       ONE, ZERO       Green
     35 ;
     36 ; This program assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     37 ; Generally, a program running on the main CPU must update these
     38 ; locations on link change; see linkscan callback in
     39 ; $SDK/src/appl/diag/ledproc.c.
     40 ;
     41 ; Current implementation:
     42 ;
     43 ; L01 reflects port 1 link status:
     44 ;       Black: no link
     45 ;       Green: Link
     46 ;
     47 ; A01 reflects port 1 activity status:
     48 ;       Black: no activity
     49 ;       Blinking Green and Black: TX activity
     50 ;       Blinking Amber and Black: RX activity
     51 ;       Blinking Green and Amber: TX and RX activity
     52 ;
     53 ;
     54 TICKS           EQU     1
     55 SECOND_TICKS    EQU     (30*TICKS)
     56 
     57 TXRX_ALT_TICKS  EQU     (SECOND_TICKS)
     58 
     59 MIN_PORT        EQU     0
     60 NUM_PORT        EQU     35
     61 MAX_PORT        EQU     36
     62 
     63 
     64 ; Assumptions
     65 ; Link status is injected by SDK from Linkscan task at PORTDATA offset
     66 
     67 ;
     68 ; Main Update Routine
     69 ;
     70 ;  This routine is called once per tick.
     71 ;
     72 
     73 update:
     74         ld      a,MIN_PORT
     75 port_loop:
     76 
     77         call    link_status    ; Top LED for this port
     78         call    chk_activity   ; Bottom LED for this port
     79 
     80         inc     a
     81         cmp     a,MAX_PORT
     82         jnz     port_loop
     83 
     84         ; Update various timers
     85         inc     (TXRX_ALT_COUNT)
     86 
     87         send    248 ; offset to shift bits so as to align LEDs on board intuitively
     88 
     89 
     90 ; Activity status LED update
     91 chk_activity:
     92         call    get_txact   ;get TX activity
     93         jnc     act1        ;TX not active, check if RX active
     94         jmp     act2        ;TX active, check if RX active
     95         ret
     96 act1:
     97         call    get_rxact
     98         jnc     led_black   ;no activity
     99         jmp     blink_amber ;only RX active
    100         ret
    101 act2:
    102         call    get_rxact
    103         jnc     blink_green ;only TX active
    104         jmp     blink_amg   ;TX and RX both active
    105         ret
    106 
    107 ; Link status LED update
    108 link_status:
    109         call    get_link
    110         jnc     led_black
    111         jmp     led_green
    112         clc
    113         ret
    114 
    115 ;
    116 ; get_link
    117 ;
    118 ;  This routine finds the link status for a port.
    119 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    120 ;
    121 ;  Inputs: Port number in a
    122 ;  Outputs: Carry flag set if link is up, clear if link is down.
    123 ;  Destroys: b
    124 ;
    125 
    126 get_link:
    127         clc
    128         ld      b,PORTDATA
    129         add     b,a
    130         ld      b,(b)
    131         tst     b,0
    132         ret
    133 
    134 ;
    135 ; get_txact
    136 ;
    137 ;  This routine finds the TX activity status for a port.
    138 ;  TX activity info is in bit 4 of the byte read from PORTDATA[port]
    139 ;
    140 ;  Inputs: Port number in a
    141 ;  Outputs: Carry flag set if TX activity is in progress, clear if not..
    142 ;  Destroys: b
    143 ;
    144 get_txact:
    145         clc
    146         ld      b,PORTDATA
    147         add     b,a
    148         ld      b,(b)
    149         tst     b,4
    150         ret
    151 
    152 ;
    153 ; get_rxact
    154 ;
    155 ;  This routine finds the RX activity status for a port.
    156 ;  TX activity info is in bit 5 of the byte read from PORTDATA[port]
    157 ;
    158 ;  Inputs: Port number in a
    159 ;  Outputs: Carry flag set if RX activity is in progress, clear if not..
    160 ;  Destroys: b
    161 ;
    162 get_rxact:
    163         clc
    164         ld      b,PORTDATA
    165         add     b,a
    166         ld      b,(b)
    167         tst     b,5
    168         ret
    169 
    170 ;
    171 ; blink_amber, blink_green, blink_amg
    172 ; Alteration between respective colors based on timer
    173 ;
    174 
    175 blink_amber:
    176         ld      b, (TXRX_ALT_COUNT)
    177         and     b, TXRX_ALT_TICKS
    178         jnz     led_amber
    179         jmp     led_black
    180         clc
    181         ret
    182 
    183 blink_green:
    184         ld      b, (TXRX_ALT_COUNT)
    185         and     b, TXRX_ALT_TICKS
    186         jnz     led_green
    187         jmp     led_black
    188         clc
    189         ret
    190 
    191 blink_amg:
    192         ld      b, (TXRX_ALT_COUNT)
    193         and     b, TXRX_ALT_TICKS
    194         jnz     led_amber
    195         jmp     led_green
    196         clc
    197         ret
    198 
    199 ;
    200 ; led_black, led_amber, led_green
    201 ;
    202 ;  Inputs: None
    203 ;  Outputs: Two bits to the LED stream indicating color
    204 ;  Destroys: None
    205 ;
    206 
    207 led_black:
    208         pushst  ZERO
    209         pack
    210         pushst  ZERO
    211         pack
    212         ret
    213 
    214 led_amber:
    215         pushst  ONE
    216         pack
    217         pushst  ZERO
    218         pack
    219         ret
    220 
    221 led_green:
    222         pushst  ZERO
    223         pack
    224         pushst  ONE
    225         pack
    226         ret
    227 
    228 ;
    229 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0)
    230 ;
    231 
    232 TXRX_ALT_COUNT  equ     0xe0
    233 
    234 ;
    235 ; Port data, which must be updated continually by main CPU's
    236 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    237 ; In this program, bit 0 is assumed to contain the link up/down status.
    238 ;
    239 
    240 ;LED scan chain assembly area
    241 ;Offset 0x20680 for LED 0
    242 ;Offset 0x21680 for LED 1
    243 PORTDATA        equ     0xa0    ; Size 4 bytes for each port starting A0,A4 ...
    244 
    245 ZERO            equ     0xE     ; always 0
    246 ONE             equ     0xF     ; always 1