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

sdk56601.asm (9655B)


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