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

bcm953570k_1.asm (3823B)


      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 BCM953570K using LED bus.
      9 ;
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led 1 load bcm953570k_1.hex
     13 ;       led 1 auto on
     14 ;       led 1 start
     15 ;
     16 ; Each port needs to output 4 bits stream,
     17 ;   bit 0: LED_0 (activity)
     18 ;   bit 1: LED_0 (activity)
     19 ;   bit 2: LED_1 (link up/down)
     20 ;   bit 3: LED_1 (link up/down)
     21 ;
     22 ; Totally 32 ports need be outputed
     23 ;
     24 ; In physical port view, the output order is:
     25 ;   58, 59 ..89
     26 ; Remap to LED1, the physical port num -56 is the new rempa port to LED1 data ram address
     27 ;   2, 3, 4 ... 33
     28 ;
     29 ; The CMIC_LEDUP1_PORT_ORDER_REMAP_XXX can only store 6 bits value for 64 ports, also for
     30 ; CMIC_LEDUP1_DATA_RAM it can only store data of 64 ports (128 bytes, each port requires
     31 ; 2 bytes). So for LED1 which is for physical ports 58-89, the physical port id has to be
     32 ; shifted in order to fit in the capability of the HW tables. GH2 LED driver shifts physical
     33 ; ports 58-89 to indices 2-33 (by minus 56) for LED1 tables, so that the shifted value can
     34 ; be stored in PORT_ORDER_REMAP and reflects on the DATA_RAM.
     35 ;
     36 ; Link up/down info cannot be derived from LINKEN, as the LED
     37 ; processor does not always have access to link status.  This program
     38 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     39 ; Generally, a program running on the main CPU must update these
     40 ; locations on link change; see linkscan callback in
     41 ; $SDK/src/appl/diag/ledproc.c.
     42 ;
     43 
     44 ;
     45 ; Constants
     46 ;
     47 START_PORT_0 equ 2
     48 END_PORT_0 equ 33
     49 
     50 ;
     51 ; LED process
     52 ;
     53 
     54 start_sec0:
     55     ld a, START_PORT_0
     56 iter_sec0:
     57     port    a
     58     ld  (PORT_NUM), a
     59     call get_activity_hw
     60 
     61     ld  a, (PORT_NUM)
     62     port    a
     63     call get_link_hw
     64     
     65     ld  a, (PORT_NUM)
     66     inc a
     67     cmp a, END_PORT_0 + 1
     68     jnz iter_sec0
     69 
     70 end:
     71 ;    output the maximun bits for the LED bus
     72 ;    to avoid undesired repetitive behavior
     73     send    255
     74 
     75 ;
     76 ; get_activity_hw
     77 ;
     78 ;  This routine finds the link status LED for a port from HW.
     79 ;  Inputs: (PORT_NUM)
     80 ;  Outputs: Carry flag set if RX or TX is up, clear if link is down.
     81 ;  Destroys: a, b
     82 
     83 get_activity_hw:
     84     pushst RX
     85     pushst TX
     86     tor
     87     pop
     88 
     89     jc led_on_green
     90     jmp led_off
     91 
     92 ;
     93 ; get_link_hw
     94 ;
     95 ;  This routine finds the link status LED for a port from HW.
     96 ;  Inputs: (PORT_NUM)
     97 ;  Outputs: Carry flag set if link is up, clear if link is down.
     98 ;  Destroys: a, b
     99 get_link_hw:
    100     pushst LINKEN
    101     pop
    102 
    103     jc led_on_green
    104     jmp led_off
    105 
    106 ;
    107 ; get_link_sw
    108 ;
    109 ;  This routine finds the link status LED for a port.
    110 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    111 ;  Inputs: (PORT_NUM)
    112 ;  Outputs: Carry flag set if link is up, clear if link is down.
    113 ;  Destroys: a, b
    114 get_link_sw:
    115     ld  b, PORTDATA
    116     add b, (PORT_NUM)
    117     ld  a, (b)
    118     tst a, 0
    119 
    120     jc led_on_green
    121     jmp led_off
    122 
    123 ;
    124 ; led_on_green
    125 ;
    126 ;  Outputs: Bits to the LED stream indicating ON
    127 ;
    128 led_on_green:
    129     push 1
    130     pack
    131     push 0
    132     pack
    133     ret
    134 
    135 ;
    136 ; led_off
    137 ;
    138 ;  Outputs: Bits to the LED stream indicating OFF
    139 ;
    140 led_off:
    141     push 0
    142     pack
    143     push 0
    144     pack
    145     ret
    146 
    147 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    148 PORTDATA    equ 0xA0
    149 PORT_NUM    equ 0xE0
    150 
    151 ; Symbolic names for the bits of the port status fields
    152 RX      equ 0x0 ; received packet
    153 TX      equ 0x1 ; transmitted packet
    154 COLL    equ 0x2 ; collision indicator
    155 SPEED_C equ 0x3 ; 100 Mbps
    156 SPEED_M equ 0x4 ; 1000 Mbps
    157 DUPLEX  equ 0x5 ; half/full duplex
    158 FLOW    equ 0x6 ; flow control capable
    159 LINKUP  equ 0x7 ; link down/up status
    160 LINKEN  equ 0x8 ; link disabled/enabled status
    161 ZERO    equ 0xE ; always 0
    162 ONE     equ 0xF ; always 1
    163