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

bcm953547k.asm (3273B)


      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 ; BCM953547K.
     10 ;
     11 ; To start it, use the following commands from BCM:
     12 ;
     13 ;       led load bcm953547k.hex
     14 ;       led auto on
     15 ;       led start
     16 ;
     17 ; Each port needs to output 2 bits stream,
     18 ;   bit 0: LED_0
     19 ;   bit 1: LED_1
     20 ;
     21 ; Totally 24 ports need be outputed, i.e. 48 (= 24 * 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 ;   2, 3, ... 25
     26 ; Mapping onto physical port view, the sequence is:
     27 ;   13, 12, ..., 2, 18, 19, ..., 29
     28 ; The output order should be the inverted sequence of the physical
     29 ; mapping view
     30 ;   29, 28, ..., 18, 2, 3, ..., 13
     31 ;
     32 ; Link up/down info cannot be derived from LINKEN, as the LED
     33 ; processor does not always have access to link status.  This program
     34 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     35 ; Generally, a program running on the main CPU must update these
     36 ; locations on link change; see linkscan callback in
     37 ; $SDK/src/appl/diag/ledproc.c.
     38 ;
     39 
     40 ;
     41 ; Constants
     42 ;
     43 NUM_PORTS   equ 24
     44 ;START_PORT_0 equ 13
     45 ;END_PORT_0 equ 2
     46 ;START_PORT_1 equ 18
     47 ;END_PORT_1 equ 29
     48 
     49 START_PORT_0 equ 29
     50 END_PORT_0 equ 18
     51 START_PORT_1 equ 2
     52 END_PORT_1 equ 13
     53 ;
     54 ; LED process
     55 ;
     56 
     57 start_sec0:
     58     ld a, START_PORT_0
     59 iter_sec0:
     60     port    a
     61     ld  (PORT_NUM), a
     62     call get_activity_hw
     63 
     64     ld  a, (PORT_NUM)
     65     port    a
     66     call get_link_hw
     67 
     68     ld  a, (PORT_NUM)
     69     dec a
     70     cmp a, END_PORT_0 - 1
     71     jnz iter_sec0
     72 
     73 start_sec1:
     74     ld a, START_PORT_1
     75 iter_sec1:
     76     port    a
     77     ld  (PORT_NUM), a
     78     call get_activity_hw
     79 
     80     ld  a, (PORT_NUM)
     81     port    a
     82     call get_link_hw
     83 
     84     ld  a, (PORT_NUM)
     85     inc a
     86     cmp a, END_PORT_1 + 1
     87     jnz iter_sec1
     88 
     89 end:
     90     send    2*NUM_PORTS
     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
    104     jmp led_off
    105 
    106 ;
    107 ; get_activity_hw
    108 ;
    109 ;  This routine finds the link status LED for a port from HW.
    110 ;  Inputs: (PORT_NUM)
    111 ;  Outputs: Carry flag set if RX or TX is up, clear if link is down.
    112 ;  Destroys: a, b
    113 
    114 get_activity_hw:
    115     pushst RX
    116     pushst TX
    117     tor
    118     pop
    119 
    120     jc led_on
    121     jmp led_off
    122 ;
    123 ; led_on
    124 ;
    125 ;  Outputs: Bits to the LED stream indicating ON
    126 ;
    127 led_on:
    128     push 0
    129     pack
    130     ret
    131 
    132 ;
    133 ; led_off
    134 ;
    135 ;  Outputs: Bits to the LED stream indicating OFF
    136 ;
    137 led_off:
    138     push 1
    139     pack
    140     ret
    141 
    142 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    143 PORTDATA    equ 0xA0
    144 PORT_NUM    equ 0xE0
    145 
    146 ; Symbolic names for the bits of the port status fields
    147 RX      equ 0x0 ; received packet
    148 TX      equ 0x1 ; transmitted packet
    149 COLL    equ 0x2 ; collision indicator
    150 SPEED_C equ 0x3 ; 100 Mbps
    151 SPEED_M equ 0x4 ; 1000 Mbps
    152 DUPLEX  equ 0x5 ; half/full duplex
    153 FLOW    equ 0x6 ; flow control capable
    154 LINKUP  equ 0x7 ; link down/up status
    155 LINKEN  equ 0x8 ; link disabled/enabled status
    156 ZERO    equ 0xE ; always 0
    157 ONE     equ 0xF ; always 1
    158