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

bcm956174r_1.asm (6389B)


      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 LEDs on
      9 ; bcm956174r on option 11b.
     10 ;
     11 ; To start it, use the following commands from BCM:
     12 ;
     13 ;       led 1 load bcm956174r_1.hex
     14 ;       led 1 auto on
     15 ;       led 1 start
     16 ;
     17 ; For CL port needs to output 2 bits stream,
     18 ;   bit 0: LED_0 (Link)
     19 ;   bit 1: LED_1 (Activity)
     20 ; For TSCE 10G port need to output 4 bits stream,
     21 ;   bit 0: LED_0 (Link/Activity)
     22 ;   bit 1: LED_1 (Link/Activity)
     23 ;   bit 2: LED_2 (Speed)
     24 ;   bit 3: LED_3 (Speed)
     25 ;
     26 ; Totally 6 ports need be outputed, i.e. 12 (= 6 * 2 ) bits.
     27 ; The output sequence for EGPHY will follow the user port sequence.
     28 ;
     29 ; The LED sequence is (User Port, Front Panel Order)
     30 ;   25-30 (Lport 38-43, Routing 41-38 42 43)
     31 ; Mapping onto physical port view, the sequence is:
     32 ;   77 76 75 74 82 86
     33 ;   21 20 19 18 26 30  (LED1 remap, -56)
     34 ;
     35 ; The CMIC_LEDUP1_PORT_ORDER_REMAP_XXX can only store 6 bits value for 64 ports, also for
     36 ; CMIC_LEDUP1_DATA_RAM it can only store data of 64 ports (128 bytes, each port requires
     37 ; 2 bytes). So for LED1 which is for physical ports 58-89, the physical port id has to be
     38 ; shifted in order to fit in the capability of the HW tables. GH2 LED driver shifts physical
     39 ; ports 58-89 to indices 2-33 (by minus 56) for LED1 tables, so that the shifted value can
     40 ; be stored in PORT_ORDER_REMAP and reflects on the DATA_RAM.
     41 ;
     42 ; The output order should be the inverted sequence of the physical
     43 ; mapping view
     44 ;   30 26 18 19 20 21
     45 ; Link up/down info cannot be derived from LINKEN, as the LED
     46 ; processor does not always have access to link status.  This program
     47 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     48 ; Generally, a program running on the main CPU must update these
     49 ; locations on link change; see linkscan callback in
     50 ; $SDK/src/appl/diag/ledproc.c.
     51 ;
     52 
     53 ;
     54 ; Constants
     55 ;
     56 
     57 ; the smaller the TXRX_ALT_TICKS the faster it blinks
     58 TXRX_ALT_TICKS  EQU     5
     59 TXRX_ALT_COUNT  equ     30
     60 
     61 NUM_PORTS   equ 6
     62 
     63 START_PORT_0 equ 30
     64 END_PORT_0 equ 30
     65 START_PORT_1 equ 26
     66 END_PORT_1 equ 26
     67 START_PORT_2 equ 21
     68 END_PORT_2 equ 18
     69 ;
     70 ; LED process
     71 ;
     72 
     73 start_sec0:
     74     ld a, START_PORT_0
     75 iter_sec0:
     76     port    a
     77     ld  (PORT_NUM), a
     78     call get_link_hw
     79     call get_activity_hw
     80 
     81     ld  a, (PORT_NUM)
     82     inc a
     83     cmp a, END_PORT_0 + 1
     84     jnz iter_sec0
     85 
     86 start_sec1:
     87     ld a, START_PORT_1
     88 iter_sec1:
     89     port    a
     90     ld  (PORT_NUM), a
     91     call get_link_hw
     92     call get_activity_hw
     93 
     94     ld  a, (PORT_NUM)
     95     dec a
     96     cmp a, END_PORT_1 - 1
     97     jnz iter_sec1
     98 
     99 start_sec2:
    100     ld a, START_PORT_2
    101 iter_sec2:
    102     port    a
    103     ld  (PORT_NUM), a
    104     call get_link1Gspeed_status
    105     call get_link10Gspeed_status
    106 
    107     ld  a, (PORT_NUM)
    108     dec a
    109     cmp a, END_PORT_2 - 1
    110     jnz iter_sec2
    111 
    112 update:
    113     inc (TXRX_ALT_COUNT)
    114 
    115 end:
    116     send    2*NUM_PORTS
    117 
    118 ;
    119 ; get_link_hw
    120 ;
    121 ;  This routine finds the link status LED for a port from HW.
    122 ;  Inputs: (PORT_NUM)
    123 ;  Outputs: Carry flag set if link is up, clear if link is down.
    124 ;  Destroys: a, b
    125 get_link_hw:
    126     pushst LINKEN
    127     pop
    128 
    129     jc led_on
    130     jmp led_off
    131 
    132 ;
    133 ; get_link_sw
    134 ;
    135 ;  This routine finds the link status LED for a port.
    136 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    137 ;  Inputs: (PORT_NUM)
    138 ;  Outputs: Carry flag set if link is up, clear if link is down.
    139 ;  Destroys: a, b
    140 get_link_sw:
    141     ld  b, PORTDATA
    142     add b, (PORT_NUM)
    143     ld  a, (b)
    144     tst a, 0
    145 
    146     jc led_on
    147     jmp led_off
    148 
    149 ;
    150 ; get_activity_hw
    151 ;
    152 ;  This routine finds the link status LED for a port from HW.
    153 ;  Inputs: (PORT_NUM)
    154 ;  Outputs: Carry flag set if RX or TX is up, clear if link is down.
    155 ;  Destroys: a, b
    156 
    157 get_activity_hw:
    158     pushst RX
    159     pushst TX
    160     tor
    161     pop
    162 
    163     jc led_blink
    164     jmp led_off
    165 
    166 ;
    167 ; get_linkact_status
    168 ;
    169 ;  This routine finds the link and activity status for a port from HW.
    170 ;  The LED will blink if there is activity.
    171 ;  Inputs: a
    172 ;  Outputs: LED stream for on or off.
    173 ;  Destroys: b
    174 get_linkact_status:
    175     port   a
    176 
    177     pushst LINKEN
    178     pop
    179     jnc     led_off   ; Always black, No LINK
    180 
    181     pushst  RX
    182     pushst  TX
    183     tor
    184     pop
    185 
    186     jc led_blink        ; Show activity
    187     jmp led_on       ; Show Link
    188 
    189 
    190 ;
    191 ; get_link10Gspeed_status
    192 ;
    193 ;  This routine finds the link and 10G speed status for a port from HW.
    194 ;  The LED will blink if there is activity.
    195 ;  Inputs: a
    196 ;  Outputs: LED stream for on or off.
    197 ;  Destroys: b
    198 get_link10Gspeed_status:
    199     port   a
    200 
    201     pushst LINKEN
    202     pop
    203     jnc     led_off   ; Always black, No LINK
    204 
    205     pushst SPEED_C
    206     pushst SPEED_M
    207     tand
    208     pop
    209     jnc     led_off   ; Always black, No 10G
    210 
    211     pushst  RX
    212     pushst  TX
    213     tor
    214     pop
    215 
    216     jc led_blink        ; Show activity
    217     jmp led_on       ; Show Link
    218 
    219 ;
    220 ; get_link1Gspeed_status
    221 ;
    222 ;  This routine finds the link and 1G speed status for a port from HW.
    223 ;  The LED will blink if there is activity.
    224 ;  Inputs: a
    225 ;  Outputs: LED stream for on or off.
    226 ;  Destroys: b
    227 get_link1Gspeed_status:
    228     port   a
    229 
    230     pushst LINKEN
    231     pop
    232     jnc     led_off   ; Always black, No LINK
    233 
    234     pushst SPEED_M
    235     pop
    236     jnc     led_off   ; Always black, No 1G
    237 
    238     pushst SPEED_C
    239     pop
    240     jc     led_off   ; If 100M also up, indicate its 10G not 1G
    241 
    242     pushst  RX
    243     pushst  TX
    244     tor
    245     pop
    246 
    247     jc led_blink        ; Show activity
    248     jmp led_on       ; Show Link
    249 
    250 ;
    251 ; led_blink
    252 ;
    253 ;  Making the LED blinking
    254 ;
    255 led_blink:
    256     ld      b, (TXRX_ALT_COUNT)
    257     and     b, TXRX_ALT_TICKS
    258     jz     led_on
    259     jmp     led_off
    260 
    261 ;
    262 ; led_on
    263 ;
    264 ;  Outputs: Bits to the LED stream indicating ON
    265 ;
    266 led_on:
    267     push 0
    268     pack
    269     ret
    270 
    271 ;
    272 ; led_off
    273 ;
    274 ;  Outputs: Bits to the LED stream indicating OFF
    275 ;
    276 led_off:
    277     push 1
    278     pack
    279     ret
    280 
    281 
    282 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    283 PORTDATA    equ 0xA0
    284 PORT_NUM    equ 0xE0
    285 
    286 ; Symbolic names for the bits of the port status fields
    287 RX      equ 0x0 ; received packet
    288 TX      equ 0x1 ; transmitted packet
    289 COLL    equ 0x2 ; collision indicator
    290 SPEED_C equ 0x3 ; 100 Mbps
    291 SPEED_M equ 0x4 ; 1000 Mbps
    292 DUPLEX  equ 0x5 ; half/full duplex
    293 FLOW    equ 0x6 ; flow control capable
    294 LINKUP  equ 0x7 ; link down/up status
    295 LINKEN  equ 0x8 ; link disabled/enabled status
    296 ZERO    equ 0xE ; always 0
    297 ONE     equ 0xF ; always 1
    298