| 1 | \ ========== Copyright Header Begin ========================================== |
| 2 | \ |
| 3 | \ Hypervisor Software File: bcm8704.fth |
| 4 | \ |
| 5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | \ |
| 7 | \ - Do no alter or remove copyright notices |
| 8 | \ |
| 9 | \ - Redistribution and use of this software in source and binary forms, with |
| 10 | \ or without modification, are permitted provided that the following |
| 11 | \ conditions are met: |
| 12 | \ |
| 13 | \ - Redistribution of source code must retain the above copyright notice, |
| 14 | \ this list of conditions and the following disclaimer. |
| 15 | \ |
| 16 | \ - Redistribution in binary form must reproduce the above copyright notice, |
| 17 | \ this list of conditions and the following disclaimer in the |
| 18 | \ documentation and/or other materials provided with the distribution. |
| 19 | \ |
| 20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors |
| 21 | \ may be used to endorse or promote products derived from this software |
| 22 | \ without specific prior written permission. |
| 23 | \ |
| 24 | \ This software is provided "AS IS," without a warranty of any kind. |
| 25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, |
| 26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
| 27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN |
| 28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR |
| 29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR |
| 30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN |
| 31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR |
| 32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE |
| 33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, |
| 34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF |
| 35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 36 | \ |
| 37 | \ You acknowledge that this software is not designed, licensed or |
| 38 | \ intended for use in the design, construction, operation or maintenance of |
| 39 | \ any nuclear facility. |
| 40 | \ |
| 41 | \ ========== Copyright Header End ============================================ |
| 42 | id: @(#)bcm8704.fth 1.1 07/01/23 |
| 43 | purpose: |
| 44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. |
| 45 | copyright: Use is subject to license terms. |
| 46 | |
| 47 | headerless |
| 48 | |
| 49 | \ BCM8704 is a Broadcom optical transceiver. It interfaces with the |
| 50 | \ Neptune via a XAUI provided by the LSI Logic serdes. |
| 51 | |
| 52 | \ Registers and Bits Definitions |
| 53 | 0 constant phyxs-ctrl-reg |
| 54 | 1 constant phyxs-contorl-rst |
| 55 | h# a constant receive-sig-detect |
| 56 | 1 constant glob-pmd-rx-sig-ok |
| 57 | h# 20 constant 10gbase-r-pcs-status-reg |
| 58 | 1 constant pcs-10gbase-r-pcs-blk-lock |
| 59 | h# 18 constant phyxs-xgxs-lane-status-reg |
| 60 | h# 1000 constant xgxs-lane-align-status |
| 61 | h# c800 constant user-ctrl-reg |
| 62 | h# c803 constant user-pmd-tx-ctrl-reg |
| 63 | h# 80c6 constant user-rx2-ctrl1-reg |
| 64 | h# 80d6 constant user-rx1-ctrl1-reg |
| 65 | h# 80e6 constant user-rx0-ctrl1-reg |
| 66 | 8 constant bcm5464-neptune-port-addr-base |
| 67 | 8 constant neptune-port-addr-base |
| 68 | d# 16 constant n2-port-addr-base |
| 69 | 1 constant pma-pmd-dev-addr |
| 70 | 3 constant pcs-dev-addr |
| 71 | 3 constant user-dev3-addr |
| 72 | 4 constant phyxs-addr |
| 73 | 4 constant user-dev4-addr |
| 74 | |
| 75 | : prtad ( -- x' ) |
| 76 | niu? if |
| 77 | n2-port-addr-base |
| 78 | else |
| 79 | neptune-port-addr-base |
| 80 | then |
| 81 | port + |
| 82 | ; |
| 83 | |
| 84 | \ |
| 85 | \ The bits of register MIF_FRAME_OUTPUT_REG is as follows, |
| 86 | \ RSVD 63:32 |
| 87 | \ frame_msb 31:16 16 MS bits of an MDIO frame |
| 88 | \ frame_lsb_output 15:0 16 LS bits of an MDIO frame |
| 89 | |
| 90 | \ IEEE 802.3 Clause45 MDIO Frame Reg Fields |
| 91 | \ ST: Start of Frame, ST=00 for Clause45, ST=01 for Clause22 |
| 92 | \ OP: Operation Code, |
| 93 | \ PRTAD: Port Addr |
| 94 | \ DEVAD: Device Addr |
| 95 | \ TA: Turnaround(time) |
| 96 | \ |
| 97 | \ Frame ST OP PRTAD DEVAD TA ADDRESS/DATA |
| 98 | \ [31:30] [29:28] [27:23] [22:18] [17:16] [15:0] |
| 99 | \ Address 00 00 PPPPP EEEEE 10 aaaaaaaaaaaaaaaa |
| 100 | \ Write 00 01 PPPPP EEEEE 10 dddddddddddddddd |
| 101 | \ Read 00 11 PPPPP EEEEE Z0 dddddddddddddddd |
| 102 | \ Post-read 00 10 PPPPP EEEEE Z0 dddddddddddddddd |
| 103 | \ |
| 104 | \ PRTAD is a hardware implementation detail |
| 105 | \ Various bcm8704 registers have different DEVAD. Registers |
| 106 | \ with addresses 0xC800 and C803 belong to DEVAD=3, the other |
| 107 | \ registers belong to DEVAD=4. |
| 108 | \ |
| 109 | \ So for the registers with address offset C80x, we have, |
| 110 | \ ST OP PRTAD DEVAD TA |
| 111 | \ P0 Addr C80x: 00 00 01000 00011 10 = 040E.AAAA |
| 112 | \ P0 WR to C80x: 00 01 01000 00011 10 = 140E.DDDD |
| 113 | \ P0 RD C80x: 00 11 01000 00011 10 = 340E.XXXX |
| 114 | \ P1 Addr C80x: 00 00 01001 00011 10 = 048E.AAAA |
| 115 | \ P1 WR to C80x: 00 01 01001 00011 10 = 148E.DDDD |
| 116 | \ P1 Rd C80x: 00 11 01001 00011 10 = 348E.XXXX |
| 117 | \ |
| 118 | \ And for the register with address offset 80x6, we have, |
| 119 | \ ST OP PRTAD DEVAD TA |
| 120 | \ P1 Addr 80x6: 00 00 01001 00100 10 = 0492.AAAA |
| 121 | \ P1 WR to 80x6: 00 01 01001 00100 10 = 1492.DDDD |
| 122 | \ P1 Rd 80x6: 00 11 01001 00100 10 = 3492.XXXX |
| 123 | \ AAAA = 16bits addr, DDDD = 16bits data, XXXX=don't care |
| 124 | \ |
| 125 | |
| 126 | |
| 127 | \ Check the following 3 bits to see if 10G link is up or down |
| 128 | \ Device 1 Register 0xA bit0 |
| 129 | \ Device 3 Register 0x20 bit0 |
| 130 | \ Device 4 Register 0x18 bit12 |
| 131 | \ |
| 132 | : check-3-link-status-bits ( -- link-up? ) |
| 133 | prtad pma-pmd-dev-addr receive-sig-detect clause45-read |
| 134 | glob-pmd-rx-sig-ok and 0<> ( rx-sig ) |
| 135 | |
| 136 | prtad pcs-dev-addr 10gbase-r-pcs-status-reg clause45-read |
| 137 | pcs-10gbase-r-pcs-blk-lock and 0<> ( rx-sig pcs-blk-lock ) |
| 138 | |
| 139 | prtad phyxs-addr phyxs-xgxs-lane-status-reg clause45-read |
| 140 | xgxs-lane-align-status and 0<> ( rx-sig-ok? pcs-blk-lock link-aligned ) |
| 141 | |
| 142 | mac-mode case ( rx-sig-ok? pcs-blk-lock link-aligned ) |
| 143 | |
| 144 | xmac-loopback of |
| 145 | \ Only care about link-aligned? in this case |
| 146 | nip nip ( flag ) |
| 147 | endof |
| 148 | |
| 149 | xpcs-loopback of |
| 150 | \ Ignore rx-sig-ok? and pcs-blk-lock? |
| 151 | nip nip ( flag ) |
| 152 | endof |
| 153 | |
| 154 | serdes-ewrap-loopback of |
| 155 | \ In serdes-ewrap-loopback mode, link-aligned? is false. |
| 156 | \ Ignore it so loopback will not fail for a wrong reason |
| 157 | drop and ( flag ) |
| 158 | endof |
| 159 | |
| 160 | \ link is up only if all 3 flag bits are set |
| 161 | \ link=up? = rx-sig-ok? && pcs-blk-lock? && link-align. |
| 162 | and and ( flag ) |
| 163 | |
| 164 | endcase |
| 165 | 0<> |
| 166 | ; |
| 167 | |
| 168 | : 10g-fiber-link-up? ( -- up? ) |
| 169 | d# 3000 ['] check-3-link-status-bits wait-status |
| 170 | ; |
| 171 | |
| 172 | : wait-phyxs-ctrl-rst ( -- flag ) |
| 173 | prtad phyxs-addr phyxs-ctrl-reg clause45-read |
| 174 | phyxs-contorl-rst and 0= \ reset cleared if done |
| 175 | ; |
| 176 | |
| 177 | : wait-for-transceiver-rst ( -- ok? ) |
| 178 | d# 500 ['] wait-phyxs-ctrl-rst wait-status |
| 179 | ; |
| 180 | |
| 181 | : setup-bcm8704-xcvr ( -- ok? ) |
| 182 | \ Reset the transceiver |
| 183 | prtad phyxs-addr phyxs-ctrl-reg clause45-read |
| 184 | phyxs-contorl-rst or |
| 185 | phyxs-ctrl-reg prtad phyxs-addr clause45-write |
| 186 | wait-for-transceiver-rst 0= if |
| 187 | cmn-note[ " broadcom8704 reset timeout." ]cmn-end |
| 188 | false exit |
| 189 | then |
| 190 | 0 to link-is-up? \ Clear the flag after reset |
| 191 | |
| 192 | \ Write 0x7fbf is required by Broadcom |
| 193 | h# 7fbf user-ctrl-reg prtad user-dev3-addr clause45-write |
| 194 | |
| 195 | \ Set to 0x164 |
| 196 | h# 164 user-pmd-tx-ctrl-reg prtad user-dev3-addr clause45-write |
| 197 | |
| 198 | \ According to Broadcom's instruction, SW needs to read |
| 199 | \ back these registers twice after writing. |
| 200 | prtad user-dev3-addr 2dup ( addr1 addr2 addr1 addr2 ) |
| 201 | user-ctrl-reg ( addr1 addr2 addr1 addr2 addr3 ) |
| 202 | 3dup clause45-read drop ( addr1 addr2 addr1 addr2 addr3 ) |
| 203 | clause45-read drop ( addr1 addr2 ) |
| 204 | user-pmd-tx-ctrl-reg ( addr1 addr2 addr4 ) |
| 205 | 3dup clause45-read drop ( addr1 addr2 addr4 ) |
| 206 | clause45-read drop ( ) |
| 207 | |
| 208 | 10g-fiber-link-up? \ Poll for 3 seconds |
| 209 | |
| 210 | dup 0= if cmn-note[ " link-up check failed" ]cmn-end then |
| 211 | ; |