bcm956174r_0.asm (4662B)
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 ; bcm956174r on option 11b. 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; led load bcm956174r.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 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-9 18-33 26 ; Mapping onto physical port view, the sequence is: 27 ; 26-33 42-57 28 ; The output order should be the inverted sequence of the physical 29 ; mapping view 30 ; 57-42 33-26 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 TXRX_ALT_TICKS EQU 5 45 TXRX_ALT_COUNT equ 30 46 47 NUM_PORTS equ 24 48 49 START_PORT_0 equ 57 50 END_PORT_0 equ 42 51 START_PORT_1 equ 33 52 END_PORT_1 equ 26 53 54 ; 55 ; LED process 56 ; 57 58 start_sec0: 59 ld a, START_PORT_0 60 iter_sec0: 61 port a 62 ld (PORT_NUM), a 63 call get_activity_hw 64 call get_link_hw 65 66 ld a, (PORT_NUM) 67 dec a 68 cmp a, END_PORT_0 - 1 69 jnz iter_sec0 70 71 start_sec1: 72 ld a, START_PORT_1 73 iter_sec1: 74 port a 75 ld (PORT_NUM), a 76 call get_activity_hw 77 call get_link_hw 78 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 142 ; 143 ; get_linkact_status 144 ; 145 ; This routine finds the link and activity status for a port from HW. 146 ; The LED will blink if there is activity. 147 ; Inputs: a 148 ; Outputs: LED stream for on or off. 149 ; Destroys: b 150 get_linkact_status: 151 port a 152 153 pushst LINKEN 154 pop 155 jnc led_off ; Always black, No LINK 156 157 pushst RX 158 pushst TX 159 tor 160 pop 161 162 jc led_blink ; Show activity 163 jmp led_on ; Show Link 164 165 166 led_blink: 167 ld b, (TXRX_ALT_COUNT) 168 and b, TXRX_ALT_TICKS 169 jz led_on 170 jmp led_off 171 172 173 ; 174 ; led_on 175 ; 176 ; Outputs: Bits to the LED stream indicating ON 177 ; 178 led_on: 179 push 0 180 pack 181 ret 182 183 ; 184 ; led_off 185 ; 186 ; Outputs: Bits to the LED stream indicating OFF 187 ; 188 led_off: 189 push 1 190 pack 191 ret 192 193 ; 194 ; led_off_2 195 ; 196 ; Outputs: Bits to the LED stream indicating OFF 197 ; 198 led_off_2: 199 push 1 200 pack 201 push 1 202 pack 203 ret 204 205 ; 206 ; led_green 207 ; For 10G port LED, outputs two bit 208 ; Outputs: Bits to the LED stream indicating GREEN 209 ; 210 led_green: 211 push 0 212 pack 213 push 0 214 pack 215 ret 216 217 ; 218 ; led_orange 219 ; For 1G port LED, outputs two bit 220 ; Outputs: Bits to the LED stream indicating GREEN 221 ; 222 led_orange: 223 push 1 224 pack 225 push 0 226 pack 227 ret 228 229 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 230 PORTDATA equ 0xA0 231 PORT_NUM equ 0xE0 232 233 ; Symbolic names for the bits of the port status fields 234 RX equ 0x0 ; received packet 235 TX equ 0x1 ; transmitted packet 236 COLL equ 0x2 ; collision indicator 237 SPEED_C equ 0x3 ; 100 Mbps 238 SPEED_M equ 0x4 ; 1000 Mbps 239 DUPLEX equ 0x5 ; half/full duplex 240 FLOW equ 0x6 ; flow control capable 241 LINKUP equ 0x7 ; link down/up status 242 LINKEN equ 0x8 ; link disabled/enabled status 243 ZERO equ 0xE ; always 0 244 ONE equ 0xF ; always 1 245