bcm956160k.asm (3785B)
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 to parallel EGPHY LEDs on 9 ; BCM956160K. 10 ; To enalbe serial to parallel LED, TOP_PARALLEL_LED_CTRLr.LED_SER2PAR_SELf 11 ; must be set. 12 ; 13 ; To start it, use the following commands from BCM: 14 ; 15 ; led load bcm956160k.hex 16 ; led auto on 17 ; led start 18 ; 19 ; Each port needs to output 4 bits stream, 20 ; bit 0: LED_0 21 ; bit 1: LED_1 22 ; bit 2: Not used. Must be 0. 23 ; bit 3: Not used. Must be 0. 24 ; 25 ; Totally 24 ports need be outputed, i.e. 96 (= 24 * 4) bits. 26 ; However, only the first 16 (EGPHY) ports are displayed by serial to parallel LED. 27 ; The output sequence for EGPHY will follow the user port sequence. 28 ; 29 ; In physical port view, the output order is: 30 ; 17, 16, ..., 10, 26, 27, ..., 33, 2, 3, 4, 5, 18, 19, 20, 21 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 17 45 END_PORT_0 equ 10 46 START_PORT_1 equ 26 47 END_PORT_1 equ 33 48 START_PORT_2 equ 2 49 END_PORT_2 equ 5 50 START_PORT_3 equ 18 51 END_PORT_3 equ 21 52 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 63 call get_link_hw 64 65 ld a, (PORT_NUM) 66 dec a 67 cmp a, END_PORT_0 - 1 68 jnz iter_sec0 69 70 start_sec1: 71 ld a, START_PORT_1 72 iter_sec1: 73 port a 74 ld (PORT_NUM), a 75 76 call get_link_hw 77 78 ld a, (PORT_NUM) 79 inc a 80 cmp a, END_PORT_1 + 1 81 jnz iter_sec1 82 83 start_sec2: 84 ld a, START_PORT_2 85 iter_sec2: 86 port a 87 ld (PORT_NUM), a 88 89 call get_link_hw 90 91 ld a, (PORT_NUM) 92 inc a 93 cmp a, END_PORT_2 + 1 94 jnz iter_sec2 95 96 start_sec3: 97 ld a, START_PORT_3 98 iter_sec3: 99 port a 100 ld (PORT_NUM), a 101 102 call get_link_hw 103 104 ld a, (PORT_NUM) 105 inc a 106 cmp a, END_PORT_3 + 1 107 jnz iter_sec3 108 109 end: 110 send 4*NUM_PORTS 111 112 ; 113 ; get_link_sw 114 ; 115 ; This routine finds the link status LED for a port. 116 ; Link info is in bit 0 of the byte read from PORTDATA[port] 117 ; Inputs: (PORT_NUM) 118 ; Outputs: Carry flag set if link is up, clear if link is down. 119 ; Destroys: a, b 120 get_link_sw: 121 ld b, PORTDATA 122 add b, (PORT_NUM) 123 ld a, (b) 124 tst a, 0 125 126 jc led_on 127 jmp led_off 128 129 ; 130 ; get_link_hw 131 ; 132 ; This routine finds the link status LED for a port from HW. 133 ; Inputs: (PORT_NUM) 134 ; Outputs: Carry flag set if link is up, clear if link is down. 135 ; Destroys: a, b 136 get_link_hw: 137 pushst LINKEN 138 pop 139 140 jc led_on 141 jmp led_off 142 143 ; 144 ; led_on 145 ; 146 ; Outputs: Bits to the LED stream indicating ON 147 ; 148 led_on: 149 push 1 150 pack 151 push 1 152 pack 153 push 0 154 pack 155 push 0 156 pack 157 ret 158 159 ; 160 ; led_off 161 ; 162 ; Outputs: Bits to the LED stream indicating OFF 163 ; 164 led_off: 165 push 0 166 pack 167 push 0 168 pack 169 push 0 170 pack 171 push 0 172 pack 173 ret 174 175 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 176 PORTDATA equ 0xA0 177 PORT_NUM equ 0xE0 178 179 ; Symbolic names for the bits of the port status fields 180 RX equ 0x0 ; received packet 181 TX equ 0x1 ; transmitted packet 182 COLL equ 0x2 ; collision indicator 183 SPEED_C equ 0x3 ; 100 Mbps 184 SPEED_M equ 0x4 ; 1000 Mbps 185 DUPLEX equ 0x5 ; half/full duplex 186 FLOW equ 0x6 ; flow control capable 187 LINKUP equ 0x7 ; link down/up status 188 LINKEN equ 0x8 ; link disabled/enabled status 189 ZERO equ 0xE ; always 0 190 ONE equ 0xF ; always 1