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.asm (8295B)


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