1af866496SDavid Daney /***********************license start*************** 2af866496SDavid Daney * Author: Cavium Networks 3af866496SDavid Daney * 4af866496SDavid Daney * Contact: support@caviumnetworks.com 5af866496SDavid Daney * This file is part of the OCTEON SDK 6af866496SDavid Daney * 7af866496SDavid Daney * Copyright (c) 2003-2008 Cavium Networks 8af866496SDavid Daney * 9af866496SDavid Daney * This file is free software; you can redistribute it and/or modify 10af866496SDavid Daney * it under the terms of the GNU General Public License, Version 2, as 11af866496SDavid Daney * published by the Free Software Foundation. 12af866496SDavid Daney * 13af866496SDavid Daney * This file is distributed in the hope that it will be useful, but 14af866496SDavid Daney * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 15af866496SDavid Daney * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 16af866496SDavid Daney * NONINFRINGEMENT. See the GNU General Public License for more 17af866496SDavid Daney * details. 18af866496SDavid Daney * 19af866496SDavid Daney * You should have received a copy of the GNU General Public License 20af866496SDavid Daney * along with this file; if not, write to the Free Software 21af866496SDavid Daney * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22af866496SDavid Daney * or visit http://www.gnu.org/licenses/. 23af866496SDavid Daney * 24af866496SDavid Daney * This file may also be available under a different license from Cavium. 25af866496SDavid Daney * Contact Cavium Networks for more information 26af866496SDavid Daney ***********************license end**************************************/ 27af866496SDavid Daney 28af866496SDavid Daney /* 29af866496SDavid Daney * Functions for XAUI initialization, configuration, 30af866496SDavid Daney * and monitoring. 31af866496SDavid Daney * 32af866496SDavid Daney */ 33af866496SDavid Daney 34af866496SDavid Daney #include <asm/octeon/octeon.h> 35af866496SDavid Daney 36af866496SDavid Daney #include <asm/octeon/cvmx-config.h> 37af866496SDavid Daney 38af866496SDavid Daney #include <asm/octeon/cvmx-helper.h> 39af866496SDavid Daney 40af866496SDavid Daney #include <asm/octeon/cvmx-pko-defs.h> 41af866496SDavid Daney #include <asm/octeon/cvmx-gmxx-defs.h> 42af866496SDavid Daney #include <asm/octeon/cvmx-pcsxx-defs.h> 43af866496SDavid Daney 44af866496SDavid Daney void __cvmx_interrupt_gmxx_enable(int interface); 45af866496SDavid Daney void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block); 46af866496SDavid Daney void __cvmx_interrupt_pcsxx_int_en_reg_enable(int index); 4737d3bfd9SDavid Daney 4837d3bfd9SDavid Daney int __cvmx_helper_xaui_enumerate(int interface) 4937d3bfd9SDavid Daney { 5037d3bfd9SDavid Daney union cvmx_gmxx_hg2_control gmx_hg2_control; 5137d3bfd9SDavid Daney 5237d3bfd9SDavid Daney /* If HiGig2 is enabled return 16 ports, otherwise return 1 port */ 5337d3bfd9SDavid Daney gmx_hg2_control.u64 = cvmx_read_csr(CVMX_GMXX_HG2_CONTROL(interface)); 5437d3bfd9SDavid Daney if (gmx_hg2_control.s.hg2tx_en) 5537d3bfd9SDavid Daney return 16; 5637d3bfd9SDavid Daney else 5737d3bfd9SDavid Daney return 1; 5837d3bfd9SDavid Daney } 5937d3bfd9SDavid Daney 60af866496SDavid Daney /** 61af866496SDavid Daney * Probe a XAUI interface and determine the number of ports 62af866496SDavid Daney * connected to it. The XAUI interface should still be down 63af866496SDavid Daney * after this call. 64af866496SDavid Daney * 65af866496SDavid Daney * @interface: Interface to probe 66af866496SDavid Daney * 67af866496SDavid Daney * Returns Number of ports on the interface. Zero to disable. 68af866496SDavid Daney */ 69af866496SDavid Daney int __cvmx_helper_xaui_probe(int interface) 70af866496SDavid Daney { 71af866496SDavid Daney int i; 72af866496SDavid Daney union cvmx_gmxx_inf_mode mode; 73af866496SDavid Daney 74af866496SDavid Daney /* 75af866496SDavid Daney * Due to errata GMX-700 on CN56XXp1.x and CN52XXp1.x, the 76af866496SDavid Daney * interface needs to be enabled before IPD otherwise per port 77af866496SDavid Daney * backpressure may not work properly. 78af866496SDavid Daney */ 79af866496SDavid Daney mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface)); 80af866496SDavid Daney mode.s.en = 1; 81af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_INF_MODE(interface), mode.u64); 82af866496SDavid Daney 83af866496SDavid Daney __cvmx_helper_setup_gmx(interface, 1); 84af866496SDavid Daney 85af866496SDavid Daney /* 86af866496SDavid Daney * Setup PKO to support 16 ports for HiGig2 virtual 87af866496SDavid Daney * ports. We're pointing all of the PKO packet ports for this 88af866496SDavid Daney * interface to the XAUI. This allows us to use HiGig2 89af866496SDavid Daney * backpressure per port. 90af866496SDavid Daney */ 91af866496SDavid Daney for (i = 0; i < 16; i++) { 92af866496SDavid Daney union cvmx_pko_mem_port_ptrs pko_mem_port_ptrs; 93af866496SDavid Daney pko_mem_port_ptrs.u64 = 0; 94af866496SDavid Daney /* 95af866496SDavid Daney * We set each PKO port to have equal priority in a 96af866496SDavid Daney * round robin fashion. 97af866496SDavid Daney */ 98af866496SDavid Daney pko_mem_port_ptrs.s.static_p = 0; 99af866496SDavid Daney pko_mem_port_ptrs.s.qos_mask = 0xff; 100af866496SDavid Daney /* All PKO ports map to the same XAUI hardware port */ 101af866496SDavid Daney pko_mem_port_ptrs.s.eid = interface * 4; 102af866496SDavid Daney pko_mem_port_ptrs.s.pid = interface * 16 + i; 103af866496SDavid Daney cvmx_write_csr(CVMX_PKO_MEM_PORT_PTRS, pko_mem_port_ptrs.u64); 104af866496SDavid Daney } 10537d3bfd9SDavid Daney return __cvmx_helper_xaui_enumerate(interface); 106af866496SDavid Daney } 107af866496SDavid Daney 108af866496SDavid Daney /** 109af866496SDavid Daney * Bringup and enable a XAUI interface. After this call packet 110af866496SDavid Daney * I/O should be fully functional. This is called with IPD 111af866496SDavid Daney * enabled but PKO disabled. 112af866496SDavid Daney * 113af866496SDavid Daney * @interface: Interface to bring up 114af866496SDavid Daney * 115af866496SDavid Daney * Returns Zero on success, negative on failure 116af866496SDavid Daney */ 117af866496SDavid Daney int __cvmx_helper_xaui_enable(int interface) 118af866496SDavid Daney { 119af866496SDavid Daney union cvmx_gmxx_prtx_cfg gmx_cfg; 120af866496SDavid Daney union cvmx_pcsxx_control1_reg xauiCtl; 121af866496SDavid Daney union cvmx_pcsxx_misc_ctl_reg xauiMiscCtl; 122af866496SDavid Daney union cvmx_gmxx_tx_xaui_ctl gmxXauiTxCtl; 123af866496SDavid Daney union cvmx_gmxx_rxx_int_en gmx_rx_int_en; 124af866496SDavid Daney union cvmx_gmxx_tx_int_en gmx_tx_int_en; 125af866496SDavid Daney union cvmx_pcsxx_int_en_reg pcsx_int_en_reg; 126af866496SDavid Daney 127af866496SDavid Daney /* (1) Interface has already been enabled. */ 128af866496SDavid Daney 129af866496SDavid Daney /* (2) Disable GMX. */ 130af866496SDavid Daney xauiMiscCtl.u64 = cvmx_read_csr(CVMX_PCSXX_MISC_CTL_REG(interface)); 131af866496SDavid Daney xauiMiscCtl.s.gmxeno = 1; 132af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_MISC_CTL_REG(interface), xauiMiscCtl.u64); 133af866496SDavid Daney 134af866496SDavid Daney /* (3) Disable GMX and PCSX interrupts. */ 135af866496SDavid Daney gmx_rx_int_en.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_EN(0, interface)); 136af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(0, interface), 0x0); 137af866496SDavid Daney gmx_tx_int_en.u64 = cvmx_read_csr(CVMX_GMXX_TX_INT_EN(interface)); 138af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), 0x0); 139af866496SDavid Daney pcsx_int_en_reg.u64 = cvmx_read_csr(CVMX_PCSXX_INT_EN_REG(interface)); 140af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_EN_REG(interface), 0x0); 141af866496SDavid Daney 142af866496SDavid Daney /* (4) Bring up the PCSX and GMX reconciliation layer. */ 143af866496SDavid Daney /* (4)a Set polarity and lane swapping. */ 144af866496SDavid Daney /* (4)b */ 145af866496SDavid Daney gmxXauiTxCtl.u64 = cvmx_read_csr(CVMX_GMXX_TX_XAUI_CTL(interface)); 146af866496SDavid Daney /* Enable better IFG packing and improves performance */ 147af866496SDavid Daney gmxXauiTxCtl.s.dic_en = 1; 148af866496SDavid Daney gmxXauiTxCtl.s.uni_en = 0; 149af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_XAUI_CTL(interface), gmxXauiTxCtl.u64); 150af866496SDavid Daney 151af866496SDavid Daney /* (4)c Aply reset sequence */ 152af866496SDavid Daney xauiCtl.u64 = cvmx_read_csr(CVMX_PCSXX_CONTROL1_REG(interface)); 153af866496SDavid Daney xauiCtl.s.lo_pwr = 0; 154*c0034c30SJanne Huttunen 155*c0034c30SJanne Huttunen /* Issuing a reset here seems to hang some CN68XX chips. */ 156*c0034c30SJanne Huttunen if (!OCTEON_IS_MODEL(OCTEON_CN68XX_PASS1_X) && 157*c0034c30SJanne Huttunen !OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X)) 158af866496SDavid Daney xauiCtl.s.reset = 1; 159*c0034c30SJanne Huttunen 160af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_CONTROL1_REG(interface), xauiCtl.u64); 161af866496SDavid Daney 162af866496SDavid Daney /* Wait for PCS to come out of reset */ 163af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 164af866496SDavid Daney (CVMX_PCSXX_CONTROL1_REG(interface), union cvmx_pcsxx_control1_reg, 165af866496SDavid Daney reset, ==, 0, 10000)) 166af866496SDavid Daney return -1; 167af866496SDavid Daney /* Wait for PCS to be aligned */ 168af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 169af866496SDavid Daney (CVMX_PCSXX_10GBX_STATUS_REG(interface), 170af866496SDavid Daney union cvmx_pcsxx_10gbx_status_reg, alignd, ==, 1, 10000)) 171af866496SDavid Daney return -1; 172af866496SDavid Daney /* Wait for RX to be ready */ 173af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 174af866496SDavid Daney (CVMX_GMXX_RX_XAUI_CTL(interface), union cvmx_gmxx_rx_xaui_ctl, 175af866496SDavid Daney status, ==, 0, 10000)) 176af866496SDavid Daney return -1; 177af866496SDavid Daney 178af866496SDavid Daney /* (6) Configure GMX */ 179af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 180af866496SDavid Daney gmx_cfg.s.en = 0; 181af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 182af866496SDavid Daney 183af866496SDavid Daney /* Wait for GMX RX to be idle */ 184af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 185af866496SDavid Daney (CVMX_GMXX_PRTX_CFG(0, interface), union cvmx_gmxx_prtx_cfg, 186af866496SDavid Daney rx_idle, ==, 1, 10000)) 187af866496SDavid Daney return -1; 188af866496SDavid Daney /* Wait for GMX TX to be idle */ 189af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 190af866496SDavid Daney (CVMX_GMXX_PRTX_CFG(0, interface), union cvmx_gmxx_prtx_cfg, 191af866496SDavid Daney tx_idle, ==, 1, 10000)) 192af866496SDavid Daney return -1; 193af866496SDavid Daney 194af866496SDavid Daney /* GMX configure */ 195af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 196af866496SDavid Daney gmx_cfg.s.speed = 1; 197af866496SDavid Daney gmx_cfg.s.speed_msb = 0; 198af866496SDavid Daney gmx_cfg.s.slottime = 1; 199af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_PRTS(interface), 1); 200af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TXX_SLOT(0, interface), 512); 201af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TXX_BURST(0, interface), 8192); 202af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 203af866496SDavid Daney 204af866496SDavid Daney /* (7) Clear out any error state */ 205af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(0, interface), 206af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(0, interface))); 207af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_REG(interface), 208af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_TX_INT_REG(interface))); 209af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_REG(interface), 210af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_INT_REG(interface))); 211af866496SDavid Daney 212af866496SDavid Daney /* Wait for receive link */ 213af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 214af866496SDavid Daney (CVMX_PCSXX_STATUS1_REG(interface), union cvmx_pcsxx_status1_reg, 215af866496SDavid Daney rcv_lnk, ==, 1, 10000)) 216af866496SDavid Daney return -1; 217af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 218af866496SDavid Daney (CVMX_PCSXX_STATUS2_REG(interface), union cvmx_pcsxx_status2_reg, 219af866496SDavid Daney xmtflt, ==, 0, 10000)) 220af866496SDavid Daney return -1; 221af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 222af866496SDavid Daney (CVMX_PCSXX_STATUS2_REG(interface), union cvmx_pcsxx_status2_reg, 223af866496SDavid Daney rcvflt, ==, 0, 10000)) 224af866496SDavid Daney return -1; 225af866496SDavid Daney 226af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(0, interface), gmx_rx_int_en.u64); 227af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64); 228af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_EN_REG(interface), pcsx_int_en_reg.u64); 229af866496SDavid Daney 230af866496SDavid Daney cvmx_helper_link_autoconf(cvmx_helper_get_ipd_port(interface, 0)); 231af866496SDavid Daney 232af866496SDavid Daney /* (8) Enable packet reception */ 233af866496SDavid Daney xauiMiscCtl.s.gmxeno = 0; 234af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_MISC_CTL_REG(interface), xauiMiscCtl.u64); 235af866496SDavid Daney 236af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 237af866496SDavid Daney gmx_cfg.s.en = 1; 238af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 239af866496SDavid Daney 240af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(0, interface); 241af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(1, interface); 242af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(2, interface); 243af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(3, interface); 244af866496SDavid Daney __cvmx_interrupt_pcsxx_int_en_reg_enable(interface); 245af866496SDavid Daney __cvmx_interrupt_gmxx_enable(interface); 246af866496SDavid Daney 247af866496SDavid Daney return 0; 248af866496SDavid Daney } 249af866496SDavid Daney 250af866496SDavid Daney /** 251af866496SDavid Daney * Return the link state of an IPD/PKO port as returned by 252af866496SDavid Daney * auto negotiation. The result of this function may not match 253af866496SDavid Daney * Octeon's link config if auto negotiation has changed since 254af866496SDavid Daney * the last call to cvmx_helper_link_set(). 255af866496SDavid Daney * 256af866496SDavid Daney * @ipd_port: IPD/PKO port to query 257af866496SDavid Daney * 258af866496SDavid Daney * Returns Link state 259af866496SDavid Daney */ 260af866496SDavid Daney cvmx_helper_link_info_t __cvmx_helper_xaui_link_get(int ipd_port) 261af866496SDavid Daney { 262af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 263af866496SDavid Daney union cvmx_gmxx_tx_xaui_ctl gmxx_tx_xaui_ctl; 264af866496SDavid Daney union cvmx_gmxx_rx_xaui_ctl gmxx_rx_xaui_ctl; 265af866496SDavid Daney union cvmx_pcsxx_status1_reg pcsxx_status1_reg; 266af866496SDavid Daney cvmx_helper_link_info_t result; 267af866496SDavid Daney 268af866496SDavid Daney gmxx_tx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_TX_XAUI_CTL(interface)); 269af866496SDavid Daney gmxx_rx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RX_XAUI_CTL(interface)); 270af866496SDavid Daney pcsxx_status1_reg.u64 = 271af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_STATUS1_REG(interface)); 272af866496SDavid Daney result.u64 = 0; 273af866496SDavid Daney 274af866496SDavid Daney /* Only return a link if both RX and TX are happy */ 275af866496SDavid Daney if ((gmxx_tx_xaui_ctl.s.ls == 0) && (gmxx_rx_xaui_ctl.s.status == 0) && 276af866496SDavid Daney (pcsxx_status1_reg.s.rcv_lnk == 1)) { 277af866496SDavid Daney result.s.link_up = 1; 278af866496SDavid Daney result.s.full_duplex = 1; 279af866496SDavid Daney result.s.speed = 10000; 280af866496SDavid Daney } else { 281af866496SDavid Daney /* Disable GMX and PCSX interrupts. */ 282af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(0, interface), 0x0); 283af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), 0x0); 284af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_EN_REG(interface), 0x0); 285af866496SDavid Daney } 286af866496SDavid Daney return result; 287af866496SDavid Daney } 288af866496SDavid Daney 289af866496SDavid Daney /** 290af866496SDavid Daney * Configure an IPD/PKO port for the specified link state. This 291af866496SDavid Daney * function does not influence auto negotiation at the PHY level. 292af866496SDavid Daney * The passed link state must always match the link state returned 293af866496SDavid Daney * by cvmx_helper_link_get(). It is normally best to use 294af866496SDavid Daney * cvmx_helper_link_autoconf() instead. 295af866496SDavid Daney * 296af866496SDavid Daney * @ipd_port: IPD/PKO port to configure 297af866496SDavid Daney * @link_info: The new link state 298af866496SDavid Daney * 299af866496SDavid Daney * Returns Zero on success, negative on failure 300af866496SDavid Daney */ 301af866496SDavid Daney int __cvmx_helper_xaui_link_set(int ipd_port, cvmx_helper_link_info_t link_info) 302af866496SDavid Daney { 303af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 304af866496SDavid Daney union cvmx_gmxx_tx_xaui_ctl gmxx_tx_xaui_ctl; 305af866496SDavid Daney union cvmx_gmxx_rx_xaui_ctl gmxx_rx_xaui_ctl; 306af866496SDavid Daney 307af866496SDavid Daney gmxx_tx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_TX_XAUI_CTL(interface)); 308af866496SDavid Daney gmxx_rx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RX_XAUI_CTL(interface)); 309af866496SDavid Daney 310af866496SDavid Daney /* If the link shouldn't be up, then just return */ 311af866496SDavid Daney if (!link_info.s.link_up) 312af866496SDavid Daney return 0; 313af866496SDavid Daney 314af866496SDavid Daney /* Do nothing if both RX and TX are happy */ 315af866496SDavid Daney if ((gmxx_tx_xaui_ctl.s.ls == 0) && (gmxx_rx_xaui_ctl.s.status == 0)) 316af866496SDavid Daney return 0; 317af866496SDavid Daney 318af866496SDavid Daney /* Bring the link up */ 319af866496SDavid Daney return __cvmx_helper_xaui_enable(interface); 320af866496SDavid Daney } 321af866496SDavid Daney 322af866496SDavid Daney /** 323af866496SDavid Daney * Configure a port for internal and/or external loopback. Internal loopback 324af866496SDavid Daney * causes packets sent by the port to be received by Octeon. External loopback 325af866496SDavid Daney * causes packets received from the wire to sent out again. 326af866496SDavid Daney * 327af866496SDavid Daney * @ipd_port: IPD/PKO port to loopback. 328af866496SDavid Daney * @enable_internal: 329af866496SDavid Daney * Non zero if you want internal loopback 330af866496SDavid Daney * @enable_external: 331af866496SDavid Daney * Non zero if you want external loopback 332af866496SDavid Daney * 333af866496SDavid Daney * Returns Zero on success, negative on failure. 334af866496SDavid Daney */ 335af866496SDavid Daney extern int __cvmx_helper_xaui_configure_loopback(int ipd_port, 336af866496SDavid Daney int enable_internal, 337af866496SDavid Daney int enable_external) 338af866496SDavid Daney { 339af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 340af866496SDavid Daney union cvmx_pcsxx_control1_reg pcsxx_control1_reg; 341af866496SDavid Daney union cvmx_gmxx_xaui_ext_loopback gmxx_xaui_ext_loopback; 342af866496SDavid Daney 343af866496SDavid Daney /* Set the internal loop */ 344af866496SDavid Daney pcsxx_control1_reg.u64 = 345af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_CONTROL1_REG(interface)); 346af866496SDavid Daney pcsxx_control1_reg.s.loopbck1 = enable_internal; 347af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_CONTROL1_REG(interface), 348af866496SDavid Daney pcsxx_control1_reg.u64); 349af866496SDavid Daney 350af866496SDavid Daney /* Set the external loop */ 351af866496SDavid Daney gmxx_xaui_ext_loopback.u64 = 352af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_XAUI_EXT_LOOPBACK(interface)); 353af866496SDavid Daney gmxx_xaui_ext_loopback.s.en = enable_external; 354af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_XAUI_EXT_LOOPBACK(interface), 355af866496SDavid Daney gmxx_xaui_ext_loopback.u64); 356af866496SDavid Daney 357af866496SDavid Daney /* Take the link through a reset */ 358af866496SDavid Daney return __cvmx_helper_xaui_enable(interface); 359af866496SDavid Daney } 360