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

lm48p56504_50.asm (8431B)


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