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

bcm956314p24ref.asm (7832B)


      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 (28 port) BCM9956314P24REF
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       *:led load bcm56314p24ref.hex
     13 ;       *:led auto on
     14 ;       *:led start
     15 ;
     16 ; The are 2 LEDs per Gig port one for Link(Top) and one for activity(bottom).
     17 ; The is  1 LED  per HiGig port for Link.
     18 ;
     19 ; There is one bit per gigabit Ethernet / higig LED with the following colors:
     20 ;       ONE       Black
     21 ;       ZERO      Green
     22 ;
     23 ; Each chip drives only its own LEDs and needs to write them in the order:
     24 ;   L01, A01, L02, A02, ..., L24, A24, .. L25, blank, L26, blank, L27, blank, L28
     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 (0x80 + 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 Full Duplex
     38 ;       Green Blink : Link Half duplex
     39 ;
     40 ; A01 reflects port 1 activity (even if port is down)
     41 ;       Black: idle
     42 ;       Green: RX/TX
     43 ;
     44 ;
     45 
     46 TICKS           EQU     1
     47 SECOND_TICKS    EQU     (30*TICKS)
     48 
     49 MIN_GE_PORT     EQU     0
     50 MAX_GE_PORT     EQU     23
     51 NUM_GE_PORT     EQU     24
     52 
     53 MIN_HG_PORT     EQU     24
     54 MAX_HG_PORT     EQU     27
     55 NUM_HG_PORT     EQU     4
     56 NUM_ALL_PORT    EQU     28
     57 
     58 MIN_PORT        EQU     0
     59 MAX_PORT        EQU     27
     60 NUM_PORT        EQU     28
     61 
     62 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     63 ; so they will be more visible.
     64 
     65 ACT_EXT_TICKS   EQU     (SECOND_TICKS/3)
     66 GIG_ALT_TICKS   EQU     (SECOND_TICKS/2)
     67 HD_OFF_TICKS    EQU     (SECOND_TICKS/20)
     68 HD_ON_TICKS     EQU     (SECOND_TICKS-HD_ON_TICKS)
     69 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     70 
     71 ;
     72 ; Main Update Routine
     73 ;
     74 ;  This routine is called once per tick.
     75 ;
     76 
     77 update:
     78         sub     a,a             ; ld a,MIN_GE_PORT (but only one instr)
     79 
     80 up1:
     81         port    a
     82         ld      (PORT_NUM),a
     83 
     84         call    link_status     ; Top LED for this port
     85         call    activity        ; Bottom LED for this port
     86 
     87         ld      a,(PORT_NUM)
     88         inc     a
     89         cmp     a,NUM_GE_PORT
     90         jnz     up1
     91 
     92 up15:
     93         port    a
     94         ld      (PORT_NUM),a
     95 
     96         call    link_status     ; Top LED for this port
     97         call    led_black
     98 
     99         ld      a,(PORT_NUM)
    100         inc     a
    101         cmp     a,NUM_ALL_PORT
    102         jnz     up15
    103 
    104         ; Update various timers
    105 
    106         ld      b,GIG_ALT_COUNT
    107         inc     (b)
    108         ld      a,(b)
    109         cmp     a,GIG_ALT_TICKS
    110         jc      up2
    111         ld      (b),0
    112 up2:
    113 
    114         ld      b,HD_COUNT
    115         inc     (b)
    116         ld      a,(b)
    117         cmp     a,HD_ON_TICKS+HD_OFF_TICKS
    118         jc      up3
    119         ld      (b),0
    120 up3:
    121 
    122         ld      b,TXRX_ALT_COUNT
    123         inc     (b)
    124         ld      a,(b)
    125         cmp     a,TXRX_ALT_TICKS
    126         jc      up4
    127         ld      (b),0
    128 up4:
    129 
    130         send    56     ; 2 * 24 + 4 + 4 (Don't care)
    131 
    132 ;
    133 ; activity
    134 ;
    135 ;  This routine calculates the activity LED for the current port.
    136 ;  It extends the activity lights using timers (new activity overrides
    137 ;  and resets the timers).
    138 ;
    139 ;  Inputs: (PORT_NUM)
    140 ;  Outputs: One bit sent to LED stream
    141 ;
    142 
    143 activity:
    144         pushst  RX
    145         pop
    146         jnc     act1
    147 
    148         ld      b,RX_TIMERS     ; Start RX LED extension timer
    149         add     b,(PORT_NUM)
    150         ld      a,ACT_EXT_TICKS
    151         ld      (b),a
    152 
    153 act1:
    154         pushst  TX
    155         pop
    156         jnc     act2
    157 
    158         ld      b,TX_TIMERS     ; Start TX LED extension timer
    159         add     b,(PORT_NUM)
    160         ld      a,ACT_EXT_TICKS
    161         ld      (b),a
    162 
    163 act2:
    164         ld      b,TX_TIMERS     ; Check TX LED extension timer
    165         add     b,(PORT_NUM)
    166 
    167         dec     (b)
    168         jnc     act3            ; TX active?
    169         inc     (b)
    170 
    171         ld      b,RX_TIMERS     ; Check RX LED extension timer
    172         add     b,(PORT_NUM)
    173 
    174         dec     (b)             ; Extend LED green if only RX active
    175         jnc     led_green
    176         inc     (b)
    177 
    178         jmp     led_black       ; No activity
    179 
    180 act3:                           ; TX is active, see if RX also active
    181         ld      b,RX_TIMERS
    182         add     b,(PORT_NUM)
    183 
    184         dec     (b)             ; RX also active?
    185         jnc     act4
    186         inc     (b)
    187 
    188         jmp     led_amber       ; Only TX active
    189 
    190 act4:                           ; Both TX and RX active
    191         ld      b,(TXRX_ALT_COUNT)
    192         cmp     b,TXRX_ALT_TICKS/2
    193         jc      led_amber       ; Fast alternation of green/amber
    194         jmp     led_green
    195 
    196 ;
    197 ; link_status
    198 ;
    199 ;  This routine calculates the link status LED for the current port.
    200 ;
    201 ;  Inputs: (PORT_NUM)
    202 ;  Outputs: One bit sent to LED stream
    203 ;  Destroys: a, b
    204 ;
    205 
    206 link_status:
    207         pushst  DUPLEX          ; Skip blink code if full duplex
    208         pop
    209         jc      ls1
    210 
    211         pushst  COLL            ; Check for collision in half duplex
    212         pop
    213         jc      led_black
    214 
    215         ld      a,(HD_COUNT)    ; Provide blink for half duplex
    216         cmp     a,HD_OFF_TICKS
    217         jc      led_black
    218 
    219 ls1:
    220         ld      a,(PORT_NUM)    ; Check for link down
    221         call    get_link
    222         jnc     led_black
    223 
    224         pushst  SPEED_C         ; Check for 100Mb speed
    225         pop
    226         jc      led_green
    227 
    228         pushst  SPEED_M         ; Check for 10Mb (i.e. not 100 or 1000)
    229         pop
    230         jnc     led_amber
    231 
    232         ld      a,(GIG_ALT_COUNT)
    233         cmp     a,GIG_ALT_TICKS/2
    234         jc      led_amber
    235 
    236         jmp     led_green
    237 
    238 ;
    239 ; get_link
    240 ;
    241 ;  This routine finds the link status LED for a port.
    242 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    243 ;
    244 ;  Inputs: Port number in a
    245 ;  Outputs: Carry flag set if link is up, clear if link is down.
    246 ;  Destroys: a, b
    247 ;
    248 
    249 get_link:
    250         ld      b,PORTDATA
    251         add     b,a
    252         ld      b,(b)
    253         tst     b,0
    254         ret
    255 
    256 ;
    257 ; led_black, led_amber, led_green
    258 ;
    259 ;  Inputs: None
    260 ;  Outputs: Two bits to the LED stream indicating color
    261 ;  Destroys: None
    262 ;
    263 
    264 led_black:
    265         pushst  ONE
    266         pack
    267 ;        pushst  ZERO
    268 ;        pack
    269         ret
    270 
    271 led_amber:
    272         pushst  ZERO
    273         pack
    274 ;       pushst  ONE
    275 ;       pack
    276         ret
    277 
    278 led_green:
    279 ;       pushst  ONE
    280 ;       pack
    281         pushst  ZERO
    282         pack
    283         ret
    284 
    285 ;
    286 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0)
    287 ;
    288 
    289 TXRX_ALT_COUNT  equ     0xe0
    290 HD_COUNT        equ     0xe1
    291 GIG_ALT_COUNT   equ     0xe2
    292 PORT_NUM        equ     0xe3
    293 
    294 ;
    295 ; Port data, which must be updated continually by main CPU's
    296 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    297 ; In this program, bit 0 is assumed to contain the link up/down status.
    298 ;
    299 
    300 PORTDATA        equ     0x80    ; Size 24 + 4? bytes
    301 
    302 ;
    303 ; LED extension timers
    304 ;
    305 
    306 RX_TIMERS       equ     0xa0+0                  ; NUM_PORT bytes
    307 TX_TIMERS       equ     0xa0+NUM_PORT           ; NUM_PORT bytes
    308 
    309 ;
    310 ; Symbolic names for the bits of the port status fields
    311 ;
    312 
    313 RX              equ     0x0     ; received packet
    314 TX              equ     0x1     ; transmitted packet
    315 COLL            equ     0x2     ; collision indicator
    316 SPEED_C         equ     0x3     ; 100 Mbps
    317 SPEED_M         equ     0x4     ; 1000 Mbps
    318 DUPLEX          equ     0x5     ; half/full duplex
    319 FLOW            equ     0x6     ; flow control capable
    320 LINKUP          equ     0x7     ; link down/up status
    321 LINKEN          equ     0x8     ; link disabled/enabled status
    322 ZERO            equ     0xE     ; always 0
    323 ONE             equ     0xF     ; always 1