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

bcm953446r.asm (4174B)


      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 to parallel EGPHY LEDs on 
      9 ; BCM953446R.
     10 ; To enalbe serial to parallel LED, TOP_PARALLEL_LED_CTRLr.LED_SER2PAR_SELf 
     11 ; must be set.
     12 ;
     13 ; To start it, use the following commands from BCM:
     14 ;
     15 ;       led load bcm953446r.hex
     16 ;       led auto on
     17 ;       led start
     18 ;
     19 ; Each EGPHY port needs to output 4 bits stream,
     20 ;   bit 0: LED_0
     21 ;   bit 1: LED_1
     22 ;   bit 2: Not used. Must be 0. 
     23 ;   bit 3: Not used. Must be 0.
     24 ;
     25 ; Each TSCE port needs to output 2 bits stream,
     26 ;   bit 0: LED_0
     27 ;   bit 1: LED_1
     28 ;
     29 ; Totally 96 bits need be outputed. (96 = 24 * 4).
     30 ; The first 48 bits (for 16 EGPHY ports) are displayed by serial to parallel LED.
     31 ; The last 8 bits are used for TSCE serial LED.
     32 ; The other 24 bits are not used for LED.
     33 ;
     34 ; In physical port view, the output order is:
     35 ;   17, 16, ..., 10, 26, 27, ..., 33, 24-dummy-bits, 34, 35, 36, 37
     36 ;
     37 ; Link up/down info cannot be derived from LINKEN, as the LED
     38 ; processor does not always have access to link status.  This program
     39 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     40 ; Generally, a program running on the main CPU must update these
     41 ; locations on link change; see linkscan callback in
     42 ; $SDK/src/appl/diag/ledproc.c.
     43 ;
     44 
     45 ;
     46 ; Constants
     47 ;
     48 START_PORT_0 equ 17
     49 END_PORT_0 equ 10
     50 START_PORT_1 equ 26
     51 END_PORT_1 equ 33
     52 START_PORT_2 equ 37
     53 END_PORT_2 equ 34
     54 
     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 
     65     call get_link_hw
     66 
     67     ld  a, (PORT_NUM)
     68     dec a
     69     cmp a, END_PORT_0 - 1
     70     jnz iter_sec0
     71 
     72 start_sec1:
     73     ld a, START_PORT_1
     74 iter_sec1:
     75     port    a
     76     ld  (PORT_NUM), a
     77 
     78     call get_link_hw
     79 
     80     ld  a, (PORT_NUM)
     81     inc a
     82     cmp a, END_PORT_1 + 1
     83     jnz iter_sec1
     84 
     85 start_dummy_bits:
     86     ld a, 0
     87 iter_dummy_bits:
     88     call led_off_4bits
     89     inc a
     90     cmp a, 6
     91     jnz iter_dummy_bits
     92 
     93 start_sec2:
     94     ld a, START_PORT_2
     95 iter_sec2:
     96     port    a
     97     ld  (PORT_NUM), a
     98 
     99     call get_link_hw
    100 
    101     ld  a, (PORT_NUM)
    102     dec a
    103     cmp a, END_PORT_2 - 1
    104     jnz iter_sec2
    105 
    106 end:
    107 	send 96
    108 
    109 ;
    110 ; get_link_sw
    111 ;
    112 ;  This routine finds the link status LED for a port.
    113 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    114 ;  Inputs: (PORT_NUM)
    115 ;  Outputs: Carry flag set if link is up, clear if link is down.
    116 ;  Destroys: a, b
    117 get_link_sw:
    118     ld  b, PORTDATA
    119     add b, (PORT_NUM)
    120     ld  a, (b)
    121     tst a, 0
    122 
    123     jc led_on
    124     jmp led_off
    125 
    126 ;
    127 ; get_link_hw
    128 ;
    129 ;  This routine finds the link status LED for a port from HW.
    130 ;  Inputs: (PORT_NUM)
    131 ;  Outputs: Carry flag set if link is up, clear if link is down.
    132 ;  Destroys: a, b
    133 get_link_hw:
    134     pushst LINKEN
    135     pop
    136 
    137     jc led_on
    138     jmp led_off
    139 
    140 ;
    141 ; led_on
    142 ;
    143 ;  Outputs: Bits to the LED stream indicating ON
    144 ;
    145 led_on:
    146     ld  b, (PORT_NUM)
    147     cmp b, 34
    148     jc led_on_4bits
    149     jmp led_on_2bits
    150 
    151 ; Trun on LED for GE port
    152 led_on_4bits:
    153     push 1
    154     pack
    155     push 1
    156     pack
    157     push 0
    158     pack
    159     push 0
    160     pack
    161     ret
    162 ; Trun on LED for XE port
    163 led_on_2bits:
    164     push 0
    165     pack
    166     push 0
    167     pack
    168     ret
    169 ;
    170 ; led_off
    171 ;
    172 ;  Outputs: Bits to the LED stream indicating OFF
    173 ;
    174 led_off:
    175     ld  b, (PORT_NUM)
    176     cmp b, 34
    177     jc led_off_4bits
    178     jmp led_off_2bits
    179 
    180 ; Trun off LED for GE port
    181 led_off_4bits:
    182     push 0
    183     pack
    184     push 0
    185     pack
    186     push 0
    187     pack
    188     push 0
    189     pack
    190     ret
    191 
    192 ; Trun off LED for XE port
    193 led_off_2bits:
    194     push 1
    195     pack
    196     push 1
    197     pack
    198     ret
    199 
    200 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    201 PORTDATA    equ 0xA0
    202 PORT_NUM    equ 0xE0
    203 
    204 ; Symbolic names for the bits of the port status fields
    205 RX      equ 0x0 ; received packet
    206 TX      equ 0x1 ; transmitted packet
    207 COLL    equ 0x2 ; collision indicator
    208 SPEED_C equ 0x3 ; 100 Mbps
    209 SPEED_M equ 0x4 ; 1000 Mbps
    210 DUPLEX  equ 0x5 ; half/full duplex
    211 FLOW    equ 0x6 ; flow control capable
    212 LINKUP  equ 0x7 ; link down/up status
    213 LINKEN  equ 0x8 ; link disabled/enabled status
    214 ZERO    equ 0xE ; always 0
    215 ONE     equ 0xF ; always 1