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

bcm956024r50t.asm (7620B)


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