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

bcm956160r_opt6.asm (5401B)


      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 ; This example is used for BCM956160R.
      9 ;
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led load bcm956160r_opt6.hex
     13 ;       led auto on
     14 ;       led start
     15 ;
     16 ; For TSCE (10G+) ports, each port needs to output 2 bits for 2 LEDs
     17 ;   LED_0: bit 0
     18 ;   LED_1: bit 1
     19 ;
     20 ; For QTC (2.5G) ports, each port needs to output 2 bits for 1 LED
     21 ;   LED_0: bit 0-1 
     22 ;
     23 ; For EGPHY (1G) ports, each port needs to output 2 bits for 2 LEDs
     24 ;   LED_0: bit 0
     25 ;   LED_1: bit 1
     26 ;
     27 ; Totally 26 ports will be outputed, i.e. 52 (= 26 * 2) bits.
     28 ; The output sequence is TSCE->QTC->EGPHY, and high port is first.
     29 ;
     30 ; In physical port view, the output order is:
     31 ;   36->34(TSCE), 21->18(QTC), 5->2(QTC), 33->26(EGPHY), 10->17(EGPHY)
     32 ;
     33 ; Link up/down info cannot be derived from LINKEN, 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 (0xA0 + 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 
     41 ;
     42 ; Constants
     43 ;
     44 TICKS           EQU     1
     45 SECOND_TICKS    EQU     (30*TICKS)
     46 ACT_EXT_TICKS   EQU     (SECOND_TICKS/3)
     47 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     48 
     49 NUM_PORTS   equ 27
     50 START_PORT_0 equ 36
     51 END_PORT_0 equ 34
     52 START_PORT_1 equ 21
     53 END_PORT_1 equ 18
     54 START_PORT_2 equ 5
     55 END_PORT_2 equ 2
     56 START_PORT_3 equ 33
     57 END_PORT_3 equ 26
     58 START_PORT_4 equ 10
     59 END_PORT_4 equ 17
     60 
     61 ;
     62 ; LED process
     63 ;
     64 
     65 start_sec0:
     66     ld a, START_PORT_0
     67 iter_sec0:
     68     port    a
     69     ld  (PORT_NUM), a
     70 
     71     call get_activity
     72     call get_link_sw
     73 
     74     ld  a, (PORT_NUM)
     75     dec a
     76     cmp a, END_PORT_0 - 1
     77     jnz iter_sec0
     78 
     79 start_sec1:
     80     ld a, START_PORT_1
     81 iter_sec1:
     82     port    a
     83     ld  (PORT_NUM), a
     84 
     85     call get_port_status
     86 
     87     ld  a, (PORT_NUM)
     88     dec a
     89     cmp a, END_PORT_1 - 1
     90     jnz iter_sec1
     91 
     92 start_sec2:
     93     ld a, START_PORT_2
     94 iter_sec2:
     95     port    a
     96     ld  (PORT_NUM), a
     97 
     98     call get_port_status
     99 
    100     ld  a, (PORT_NUM)
    101     dec a
    102     cmp a, END_PORT_2 - 1
    103     jnz iter_sec2
    104 
    105 start_sec3:
    106     ld a, START_PORT_3
    107 iter_sec3:
    108     port    a
    109     ld  (PORT_NUM), a
    110 
    111     call get_activity
    112     call get_link_sw
    113 
    114     ld  a, (PORT_NUM)
    115     dec a
    116     cmp a, END_PORT_3 - 1
    117     jnz iter_sec3
    118 
    119 start_sec4:
    120     ld a, START_PORT_4
    121 iter_sec4:
    122     port    a
    123     ld  (PORT_NUM), a
    124 
    125     call get_activity
    126     call get_link_sw
    127 
    128     ld  a, (PORT_NUM)
    129     inc a
    130     cmp a, END_PORT_4 + 1
    131     jnz iter_sec4
    132 
    133 end:
    134     inc     (TXRX_ALT_COUNT)
    135 	send    2*NUM_PORTS
    136 
    137 ;
    138 ; get_link_sw
    139 ;
    140 ;  This routine finds the link status LED for a port.
    141 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    142 ;  Inputs: (PORT_NUM)
    143 ;  Outputs: LED stream for on or off.
    144 ;  Destroys: a, b
    145 get_link_sw:
    146     ld  b, PORTDATA
    147     add b, (PORT_NUM)
    148     ld  a, (b)
    149     tst a, 0
    150 
    151     jc led_on
    152     jmp led_off
    153 
    154 ;
    155 ; get_link_hw
    156 ;
    157 ;  This routine finds the link status LED for a port from HW.
    158 ;  Inputs: a
    159 ;  Outputs: LED stream for on or off.
    160 ;  Destroys: b
    161 get_link_hw:
    162     port   a
    163     pushst LINKEN
    164     pop
    165 
    166     jc led_on
    167     jmp led_off
    168 
    169 ;
    170 ; get_activity
    171 ;
    172 ;  This routine finds the activity for a port from HW.
    173 ;  Inputs: a
    174 ;  Outputs: LED stream for on or off.
    175 ;  Destroys: b
    176 get_activity:
    177         port    a
    178         pushst  RX
    179         pushst  TX
    180         tor
    181         pop
    182 
    183         jnc     led_off       ; Always black, No Activity
    184 
    185         ld      b, (TXRX_ALT_COUNT)
    186         and     b, TXRX_ALT_TICKS
    187         jnz     led_on
    188         jmp     led_off
    189 
    190 ;
    191 ; get_port_status
    192 ;
    193 ;  This routine finds the link and activity status for a port from HW.
    194 ;  Inputs: a
    195 ;  Outputs: LED stream for on or off.
    196 ;  Destroys: b
    197 get_port_status:
    198     port   a
    199 
    200     pushst LINKEN
    201     pop
    202     jnc     led_black   ; Always black, No LINK
    203 
    204     pushst  RX
    205     pushst  TX
    206     tor
    207     pop
    208 
    209     jc led_blink        ; Show activity
    210     jmp led_green       ; Show Link
    211 led_blink:
    212     ld      b, (TXRX_ALT_COUNT)
    213     and     b, TXRX_ALT_TICKS
    214     jnz     led_green
    215     jmp     led_black
    216 
    217 ;
    218 ; led_on: 
    219 ;
    220 ;  For 10G+ and 1G port LED, outputs one bit
    221 ;  Outputs: Bits to the LED stream indicating ON
    222 ;
    223 led_on:
    224     push 0
    225     pack
    226     ret
    227 
    228 ;
    229 ; led_off
    230 ;  For 10G+ and 1G port LED, outputs one bit
    231 ;  Outputs: Bits to the LED stream indicating OFF
    232 ;
    233 led_off:
    234     push 1
    235     pack
    236     ret
    237 
    238 ;
    239 ; led_black
    240 ;  For 2.5G port LED, outputs two bit
    241 ;  Outputs: Bits to the LED stream indicating BLACK(OFF)
    242 ;
    243 led_black:
    244     push 1
    245     pack
    246     push 1
    247     pack
    248     ret
    249 
    250 ;
    251 ; led_green
    252 ;  For 2.5G port LED, outputs two bit
    253 ;  Outputs: Bits to the LED stream indicating GREEN
    254 ;
    255 led_green:
    256     push 0
    257     pack
    258     push 0
    259     pack
    260     ret
    261 
    262 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    263 PORTDATA    equ 0xA0
    264 TXRX_ALT_COUNT  equ     0xE0
    265 PORT_NUM        equ     0xE1
    266 
    267 ; Symbolic names for the bits of the port status fields
    268 RX      equ 0x0 ; received packet
    269 TX      equ 0x1 ; transmitted packet
    270 COLL    equ 0x2 ; collision indicator
    271 SPEED_C equ 0x3 ; 100 Mbps
    272 SPEED_M equ 0x4 ; 1000 Mbps
    273 DUPLEX  equ 0x5 ; half/full duplex
    274 FLOW    equ 0x6 ; flow control capable
    275 LINKUP  equ 0x7 ; link down/up status
    276 LINKEN  equ 0x8 ; link disabled/enabled status
    277 ZERO    equ 0xE ; always 0
    278 ONE     equ 0xF ; always 1