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