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

sdk56018.asm (8264B)


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