bcm956170r_0.asm (4290B)
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 ; bcm956170r on option 3a. 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; led load bcm956170r.hex 14 ; led auto on 15 ; led start 16 ; 17 ; Each GE port needs to output 2 bits stream, 18 ; bit 0: LED_0 (Link) 19 ; bit 1: LED_1 (Activity) 20 ; 21 ; Totally 36 ports need be outputed, i.e. 72 (= 36 * 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-37 26 ; Mapping onto physical port view, the sequence is: 27 ; 2-5 26-57 28 ; The output order should be the inverted sequence of the physical 29 ; mapping view 30 ; 57-26 5-2 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 TICKS EQU 1 45 SECOND_TICKS EQU (30*TICKS) 46 TXRX_ALT_TICKS EQU (SECOND_TICKS/3) 47 TXRX_ALT_COUNT EQU 0xff 48 49 NUM_PORTS equ 36 50 51 START_PORT_0 equ 57 52 END_PORT_0 equ 26 53 START_PORT_1 equ 5 54 END_PORT_1 equ 2 55 56 ; 57 ; LED process 58 ; 59 60 start_sec0: 61 ld a, START_PORT_0 62 iter_sec0: 63 port a 64 ld (PORT_NUM), a 65 call get_activity_hw 66 call get_link_sw 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 call get_activity_hw 78 call get_link_sw 79 ld a, (PORT_NUM) 80 dec a 81 cmp a, END_PORT_1 - 1 82 jnz iter_sec1 83 84 85 update: 86 inc (TXRX_ALT_COUNT) 87 88 end: 89 send 2*NUM_PORTS 90 91 ; 92 ; get_link_hw 93 ; 94 ; This routine finds the link status LED for a port from HW. 95 ; Inputs: (PORT_NUM) 96 ; Outputs: Carry flag set if link is up, clear if link is down. 97 ; Destroys: a, b 98 get_link_hw: 99 pushst LINKEN 100 pop 101 102 jc led_on 103 jmp led_off 104 105 ; 106 ; get_link_sw 107 ; 108 ; This routine finds the link status LED for a port. 109 ; Link info is in bit 0 of the byte read from PORTDATA[port] 110 ; Inputs: (PORT_NUM) 111 ; Outputs: Carry flag set if link is up, clear if link is down. 112 ; Destroys: a, b 113 get_link_sw: 114 ld b, PORTDATA 115 add b, (PORT_NUM) 116 ld a, (b) 117 tst a, 0 118 119 jc led_on 120 jmp led_off 121 122 ; 123 ; get_activity_hw 124 ; 125 ; This routine finds the link status LED for a port from HW. 126 ; Inputs: (PORT_NUM) 127 ; Outputs: Carry flag set if RX or TX is up, clear if link is down. 128 ; Destroys: a, b 129 130 get_activity_hw: 131 port a 132 133 pushst RX 134 pushst TX 135 tor 136 pop 137 138 jc led_blink ; Show activity 139 jmp led_off 140 141 led_blink: 142 ld B, (TXRX_ALT_COUNT) 143 and B, TXRX_ALT_TICKS 144 jnz led_on 145 jmp led_off 146 147 ; 148 ; led_on 149 ; 150 ; Outputs: Bits to the LED stream indicating ON 151 ; 152 led_on: 153 push 0 154 pack 155 ret 156 157 ; 158 ; led_off 159 ; 160 ; Outputs: Bits to the LED stream indicating OFF 161 ; 162 led_off: 163 push 1 164 pack 165 ret 166 167 ; 168 ; led_off_2 169 ; 170 ; Outputs: Bits to the LED stream indicating OFF 171 ; 172 led_off_2: 173 push 1 174 pack 175 push 1 176 pack 177 ret 178 179 ; 180 ; led_green 181 ; For 10G port LED, outputs two bit 182 ; Outputs: Bits to the LED stream indicating GREEN 183 ; 184 led_green: 185 push 0 186 pack 187 push 0 188 pack 189 ret 190 191 ; 192 ; led_orange 193 ; For 1G port LED, outputs two bit 194 ; Outputs: Bits to the LED stream indicating GREEN 195 ; 196 led_orange: 197 push 1 198 pack 199 push 0 200 pack 201 ret 202 203 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 204 PORTDATA equ 0xA0 205 PORT_NUM equ 0xE0 206 207 ; Symbolic names for the bits of the port status fields 208 RX equ 0x0 ; received packet 209 TX equ 0x1 ; transmitted packet 210 COLL equ 0x2 ; collision indicator 211 SPEED_C equ 0x3 ; 100 Mbps 212 SPEED_M equ 0x4 ; 1000 Mbps 213 DUPLEX equ 0x5 ; half/full duplex 214 FLOW equ 0x6 ; flow control capable 215 LINKUP equ 0x7 ; link down/up status 216 LINKEN equ 0x8 ; link disabled/enabled status 217 ZERO equ 0xE ; always 0 218 ONE equ 0xF ; always 1 219