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

bcm953547r.asm (4559B)


      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 ; This example is used for showing the serial EGPHY LEDs on
      9 ; bcm953547r.
     10 ;
     11 ; To start it, use the following commands from BCM:
     12 ;
     13 ;       led load bcm953547r.hex
     14 ;       led auto on
     15 ;       led start
     16 ;
     17 ; Each port needs to output 2 bits stream,
     18 ;   bit 0: LED_0 (Link / Activeity)
     19 ;   bit 1: LED_1 (Speed)
     20 ;
     21 ; Totally 28 ports need be outputed, i.e. 56 (= 28 * 2) bits.
     22 ; The output sequence for EGPHY will follow the user port sequence.
     23 ;
     24 ; The LED sequence is (User Port, Front Panel Order)
     25 ;   13...2 14...29
     26 ; Mapping onto physical port view, the sequence is:
     27 ;   13...2 18...29 34...37   
     28 ; The output order should be the inverted sequence of the physical
     29 ; mapping view
     30 ;   37...34 29...18 2..13
     31 ; Link up/down info cannot be derived from LINKEN, as the LED
     32 ; processor does not always have access to link status.  This program
     33 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     34 ; Generally, a program running on the main CPU must update these
     35 ; locations on link change; see linkscan callback in
     36 ; $SDK/src/appl/diag/ledproc.c.
     37 ;
     38 
     39 ;
     40 ; Constants
     41 ;
     42 
     43 ; the smaller the TXRX_ALT_TICKS the faster it blinks
     44 TXRX_ALT_TICKS  EQU     5
     45 TXRX_ALT_COUNT  equ     30
     46 
     47 NUM_PORTS   equ 28
     48 
     49 START_PORT_0 equ 34
     50 END_PORT_0 equ 37
     51 START_PORT_1 equ 29
     52 END_PORT_1 equ 18
     53 START_PORT_2 equ 2
     54 END_PORT_2 equ 13
     55 ;
     56 ; LED process
     57 ;
     58 
     59 start_sec0:
     60     ld a, START_PORT_0
     61 iter_sec0:
     62     port    a
     63     ld  (PORT_NUM), a
     64     call get_link_hw
     65 
     66     ld  a, (PORT_NUM)
     67     inc a
     68     cmp a, END_PORT_0 + 1
     69     jnz iter_sec0
     70 
     71 start_sec1:
     72     ld a, START_PORT_1
     73 iter_sec1:
     74     port    a
     75     ld  (PORT_NUM), a
     76     call get_link_hw
     77 
     78     ld  a, (PORT_NUM)
     79     dec a
     80     cmp a, END_PORT_1 - 1
     81     jnz iter_sec1
     82 
     83 start_sec2:
     84     ld a, START_PORT_2
     85 iter_sec2:
     86     port    a
     87     ld  (PORT_NUM), a
     88     call get_link_hw
     89 
     90     ld  a, (PORT_NUM)
     91     inc a
     92     cmp a, END_PORT_2 + 1
     93     jnz iter_sec2
     94 
     95 start_sec3:
     96     ld a, START_PORT_0
     97 iter_sec3:
     98     port    a
     99     ld  (PORT_NUM), a
    100     call get_linkact_status
    101 
    102     ld  a, (PORT_NUM)
    103     inc a
    104     cmp a, END_PORT_0 + 1
    105     jnz iter_sec3
    106 
    107 start_sec4:
    108     ld a, START_PORT_1
    109 iter_sec4:
    110     port    a
    111     ld  (PORT_NUM), a
    112     call get_linkact_status
    113 
    114     ld  a, (PORT_NUM)
    115     dec a
    116     cmp a, END_PORT_1 - 1
    117     jnz iter_sec4
    118 
    119 start_sec5:
    120     ld a, START_PORT_2
    121 iter_sec5:
    122     port    a
    123     ld  (PORT_NUM), a
    124     call get_linkact_status
    125 
    126     ld  a, (PORT_NUM)
    127     inc a
    128     cmp a, END_PORT_2 + 1
    129     jnz iter_sec5
    130 
    131 update:
    132     inc (TXRX_ALT_COUNT)
    133 
    134 end:
    135     send    2*NUM_PORTS
    136 
    137 ;
    138 ; get_link_hw
    139 ;
    140 ;  This routine finds the link status LED for a port from HW.
    141 ;  Inputs: (PORT_NUM)
    142 ;  Outputs: Carry flag set if link is up, clear if link is down.
    143 ;  Destroys: a, b
    144 get_link_hw:
    145     pushst LINKEN
    146     pop
    147 
    148     jc led_on
    149     jmp led_off
    150 
    151 ;
    152 ; get_activity_hw
    153 ;
    154 ;  This routine finds the link status LED for a port from HW.
    155 ;  Inputs: (PORT_NUM)
    156 ;  Outputs: Carry flag set if RX or TX is up, clear if link is down.
    157 ;  Destroys: a, b
    158 
    159 get_activity_hw:
    160     pushst RX
    161     pushst TX
    162     tor
    163     pop
    164 
    165     jc led_on
    166     jmp led_off
    167 
    168 ;
    169 ; get_linkact_status
    170 ;
    171 ;  This routine finds the link and activity status for a port from HW.
    172 ;  The LED will blink if there is activity.
    173 ;  Inputs: a
    174 ;  Outputs: LED stream for on or off.
    175 ;  Destroys: b
    176 get_linkact_status:
    177     port   a
    178 
    179     pushst LINKEN
    180     pop
    181     jnc     led_off   ; Always black, No LINK
    182 
    183     pushst  RX
    184     pushst  TX
    185     tor
    186     pop
    187 
    188     jc led_blink        ; Show activity
    189     jmp led_on       ; Show Link
    190 led_blink:
    191     ld      b, (TXRX_ALT_COUNT)
    192     and     b, TXRX_ALT_TICKS
    193     jz     led_on
    194     jmp     led_off
    195 
    196     
    197 ;
    198 ; led_on
    199 ;
    200 ;  Outputs: Bits to the LED stream indicating ON
    201 ;
    202 led_on:
    203     push 0
    204     pack
    205     ret
    206 
    207 ;
    208 ; led_off
    209 ;
    210 ;  Outputs: Bits to the LED stream indicating OFF
    211 ;
    212 led_off:
    213     push 1
    214     pack
    215     ret
    216 
    217 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    218 PORTDATA    equ 0xA0
    219 PORT_NUM    equ 0xE0
    220 
    221 ; Symbolic names for the bits of the port status fields
    222 RX      equ 0x0 ; received packet
    223 TX      equ 0x1 ; transmitted packet
    224 COLL    equ 0x2 ; collision indicator
    225 SPEED_C equ 0x3 ; 100 Mbps
    226 SPEED_M equ 0x4 ; 1000 Mbps
    227 DUPLEX  equ 0x5 ; half/full duplex
    228 FLOW    equ 0x6 ; flow control capable
    229 LINKUP  equ 0x7 ; link down/up status
    230 LINKEN  equ 0x8 ; link disabled/enabled status
    231 ZERO    equ 0xE ; always 0
    232 ONE     equ 0xF ; always 1
    233