bcm953549k.asm (3179B)
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 ; BCM953549K. 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; led load bcm953549k.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 8 ports need be outputed, i.e. 16 (= 8 * 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, ... 9 26 ; Mapping onto physical port view, the sequence is: 27 ; 18, 19, ...21 26, ...29 28 ; The output order should be the inverted sequence of the physical 29 ; mapping view 30 ; 29, 28, ..26 21, ..18 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 8 44 45 START_PORT_1 equ 29 46 END_PORT_1 equ 26 47 START_PORT_2 equ 21 48 END_PORT_2 equ 18 49 50 ; 51 ; LED process 52 ; 53 54 start_sec1: 55 ld a, START_PORT_1 56 iter_sec1: 57 port a 58 ld (PORT_NUM), a 59 call get_activity_hw 60 61 ld a, (PORT_NUM) 62 port a 63 call get_link_hw 64 65 ld a, (PORT_NUM) 66 dec a 67 cmp a, END_PORT_1 - 1 68 jnz iter_sec1 69 70 start_sec2: 71 ld a, START_PORT_2 72 iter_sec2: 73 port a 74 ld (PORT_NUM), a 75 call get_activity_hw 76 77 ld a, (PORT_NUM) 78 port a 79 call get_link_hw 80 81 ld a, (PORT_NUM) 82 dec a 83 cmp a, END_PORT_2 - 1 84 jnz iter_sec2 85 86 end: 87 send 2*NUM_PORTS 88 89 ; 90 ; get_link_hw 91 ; 92 ; This routine finds the link status LED for a port from HW. 93 ; Inputs: (PORT_NUM) 94 ; Outputs: Carry flag set if link is up, clear if link is down. 95 ; Destroys: a, b 96 get_link_hw: 97 pushst LINKEN 98 pop 99 100 jc led_on 101 jmp led_off 102 103 ; 104 ; get_activity_hw 105 ; 106 ; This routine finds the link status LED for a port from HW. 107 ; Inputs: (PORT_NUM) 108 ; Outputs: Carry flag set if RX or TX is up, clear if link is down. 109 ; Destroys: a, b 110 111 get_activity_hw: 112 pushst RX 113 pushst TX 114 tor 115 pop 116 117 jc led_on 118 jmp led_off 119 ; 120 ; led_on 121 ; 122 ; Outputs: Bits to the LED stream indicating ON 123 ; 124 led_on: 125 push 0 126 pack 127 ret 128 129 ; 130 ; led_off 131 ; 132 ; Outputs: Bits to the LED stream indicating OFF 133 ; 134 led_off: 135 push 1 136 pack 137 ret 138 139 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 140 PORTDATA equ 0xA0 141 PORT_NUM equ 0xE0 142 143 ; Symbolic names for the bits of the port status fields 144 RX equ 0x0 ; received packet 145 TX equ 0x1 ; transmitted packet 146 COLL equ 0x2 ; collision indicator 147 SPEED_C equ 0x3 ; 100 Mbps 148 SPEED_M equ 0x4 ; 1000 Mbps 149 DUPLEX equ 0x5 ; half/full duplex 150 FLOW equ 0x6 ; flow control capable 151 LINKUP equ 0x7 ; link down/up status 152 LINKEN equ 0x8 ; link disabled/enabled status 153 ZERO equ 0xE ; always 0 154 ONE equ 0xF ; always 1 155