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); 47*37d3bfd9SDavid Daney 48*37d3bfd9SDavid Daney int __cvmx_helper_xaui_enumerate(int interface) 49*37d3bfd9SDavid Daney { 50*37d3bfd9SDavid Daney union cvmx_gmxx_hg2_control gmx_hg2_control; 51*37d3bfd9SDavid Daney 52*37d3bfd9SDavid Daney /* If HiGig2 is enabled return 16 ports, otherwise return 1 port */ 53*37d3bfd9SDavid Daney gmx_hg2_control.u64 = cvmx_read_csr(CVMX_GMXX_HG2_CONTROL(interface)); 54*37d3bfd9SDavid Daney if (gmx_hg2_control.s.hg2tx_en) 55*37d3bfd9SDavid Daney return 16; 56*37d3bfd9SDavid Daney else 57*37d3bfd9SDavid Daney return 1; 58*37d3bfd9SDavid Daney } 59*37d3bfd9SDavid 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 } 105*37d3bfd9SDavid 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; 154af866496SDavid Daney xauiCtl.s.reset = 1; 155af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_CONTROL1_REG(interface), xauiCtl.u64); 156af866496SDavid Daney 157af866496SDavid Daney /* Wait for PCS to come out of reset */ 158af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 159af866496SDavid Daney (CVMX_PCSXX_CONTROL1_REG(interface), union cvmx_pcsxx_control1_reg, 160af866496SDavid Daney reset, ==, 0, 10000)) 161af866496SDavid Daney return -1; 162af866496SDavid Daney /* Wait for PCS to be aligned */ 163af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 164af866496SDavid Daney (CVMX_PCSXX_10GBX_STATUS_REG(interface), 165af866496SDavid Daney union cvmx_pcsxx_10gbx_status_reg, alignd, ==, 1, 10000)) 166af866496SDavid Daney return -1; 167af866496SDavid Daney /* Wait for RX to be ready */ 168af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 169af866496SDavid Daney (CVMX_GMXX_RX_XAUI_CTL(interface), union cvmx_gmxx_rx_xaui_ctl, 170af866496SDavid Daney status, ==, 0, 10000)) 171af866496SDavid Daney return -1; 172af866496SDavid Daney 173af866496SDavid Daney /* (6) Configure GMX */ 174af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 175af866496SDavid Daney gmx_cfg.s.en = 0; 176af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 177af866496SDavid Daney 178af866496SDavid Daney /* Wait for GMX RX to be idle */ 179af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 180af866496SDavid Daney (CVMX_GMXX_PRTX_CFG(0, interface), union cvmx_gmxx_prtx_cfg, 181af866496SDavid Daney rx_idle, ==, 1, 10000)) 182af866496SDavid Daney return -1; 183af866496SDavid Daney /* Wait for GMX TX 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 tx_idle, ==, 1, 10000)) 187af866496SDavid Daney return -1; 188af866496SDavid Daney 189af866496SDavid Daney /* GMX configure */ 190af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 191af866496SDavid Daney gmx_cfg.s.speed = 1; 192af866496SDavid Daney gmx_cfg.s.speed_msb = 0; 193af866496SDavid Daney gmx_cfg.s.slottime = 1; 194af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_PRTS(interface), 1); 195af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TXX_SLOT(0, interface), 512); 196af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TXX_BURST(0, interface), 8192); 197af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 198af866496SDavid Daney 199af866496SDavid Daney /* (7) Clear out any error state */ 200af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(0, interface), 201af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(0, interface))); 202af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_REG(interface), 203af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_TX_INT_REG(interface))); 204af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_REG(interface), 205af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_INT_REG(interface))); 206af866496SDavid Daney 207af866496SDavid Daney /* Wait for receive link */ 208af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 209af866496SDavid Daney (CVMX_PCSXX_STATUS1_REG(interface), union cvmx_pcsxx_status1_reg, 210af866496SDavid Daney rcv_lnk, ==, 1, 10000)) 211af866496SDavid Daney return -1; 212af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 213af866496SDavid Daney (CVMX_PCSXX_STATUS2_REG(interface), union cvmx_pcsxx_status2_reg, 214af866496SDavid Daney xmtflt, ==, 0, 10000)) 215af866496SDavid Daney return -1; 216af866496SDavid Daney if (CVMX_WAIT_FOR_FIELD64 217af866496SDavid Daney (CVMX_PCSXX_STATUS2_REG(interface), union cvmx_pcsxx_status2_reg, 218af866496SDavid Daney rcvflt, ==, 0, 10000)) 219af866496SDavid Daney return -1; 220af866496SDavid Daney 221af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(0, interface), gmx_rx_int_en.u64); 222af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64); 223af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_EN_REG(interface), pcsx_int_en_reg.u64); 224af866496SDavid Daney 225af866496SDavid Daney cvmx_helper_link_autoconf(cvmx_helper_get_ipd_port(interface, 0)); 226af866496SDavid Daney 227af866496SDavid Daney /* (8) Enable packet reception */ 228af866496SDavid Daney xauiMiscCtl.s.gmxeno = 0; 229af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_MISC_CTL_REG(interface), xauiMiscCtl.u64); 230af866496SDavid Daney 231af866496SDavid Daney gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(0, interface)); 232af866496SDavid Daney gmx_cfg.s.en = 1; 233af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_PRTX_CFG(0, interface), gmx_cfg.u64); 234af866496SDavid Daney 235af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(0, interface); 236af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(1, interface); 237af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(2, interface); 238af866496SDavid Daney __cvmx_interrupt_pcsx_intx_en_reg_enable(3, interface); 239af866496SDavid Daney __cvmx_interrupt_pcsxx_int_en_reg_enable(interface); 240af866496SDavid Daney __cvmx_interrupt_gmxx_enable(interface); 241af866496SDavid Daney 242af866496SDavid Daney return 0; 243af866496SDavid Daney } 244af866496SDavid Daney 245af866496SDavid Daney /** 246af866496SDavid Daney * Return the link state of an IPD/PKO port as returned by 247af866496SDavid Daney * auto negotiation. The result of this function may not match 248af866496SDavid Daney * Octeon's link config if auto negotiation has changed since 249af866496SDavid Daney * the last call to cvmx_helper_link_set(). 250af866496SDavid Daney * 251af866496SDavid Daney * @ipd_port: IPD/PKO port to query 252af866496SDavid Daney * 253af866496SDavid Daney * Returns Link state 254af866496SDavid Daney */ 255af866496SDavid Daney cvmx_helper_link_info_t __cvmx_helper_xaui_link_get(int ipd_port) 256af866496SDavid Daney { 257af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 258af866496SDavid Daney union cvmx_gmxx_tx_xaui_ctl gmxx_tx_xaui_ctl; 259af866496SDavid Daney union cvmx_gmxx_rx_xaui_ctl gmxx_rx_xaui_ctl; 260af866496SDavid Daney union cvmx_pcsxx_status1_reg pcsxx_status1_reg; 261af866496SDavid Daney cvmx_helper_link_info_t result; 262af866496SDavid Daney 263af866496SDavid Daney gmxx_tx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_TX_XAUI_CTL(interface)); 264af866496SDavid Daney gmxx_rx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RX_XAUI_CTL(interface)); 265af866496SDavid Daney pcsxx_status1_reg.u64 = 266af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_STATUS1_REG(interface)); 267af866496SDavid Daney result.u64 = 0; 268af866496SDavid Daney 269af866496SDavid Daney /* Only return a link if both RX and TX are happy */ 270af866496SDavid Daney if ((gmxx_tx_xaui_ctl.s.ls == 0) && (gmxx_rx_xaui_ctl.s.status == 0) && 271af866496SDavid Daney (pcsxx_status1_reg.s.rcv_lnk == 1)) { 272af866496SDavid Daney result.s.link_up = 1; 273af866496SDavid Daney result.s.full_duplex = 1; 274af866496SDavid Daney result.s.speed = 10000; 275af866496SDavid Daney } else { 276af866496SDavid Daney /* Disable GMX and PCSX interrupts. */ 277af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(0, interface), 0x0); 278af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), 0x0); 279af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_INT_EN_REG(interface), 0x0); 280af866496SDavid Daney } 281af866496SDavid Daney return result; 282af866496SDavid Daney } 283af866496SDavid Daney 284af866496SDavid Daney /** 285af866496SDavid Daney * Configure an IPD/PKO port for the specified link state. This 286af866496SDavid Daney * function does not influence auto negotiation at the PHY level. 287af866496SDavid Daney * The passed link state must always match the link state returned 288af866496SDavid Daney * by cvmx_helper_link_get(). It is normally best to use 289af866496SDavid Daney * cvmx_helper_link_autoconf() instead. 290af866496SDavid Daney * 291af866496SDavid Daney * @ipd_port: IPD/PKO port to configure 292af866496SDavid Daney * @link_info: The new link state 293af866496SDavid Daney * 294af866496SDavid Daney * Returns Zero on success, negative on failure 295af866496SDavid Daney */ 296af866496SDavid Daney int __cvmx_helper_xaui_link_set(int ipd_port, cvmx_helper_link_info_t link_info) 297af866496SDavid Daney { 298af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 299af866496SDavid Daney union cvmx_gmxx_tx_xaui_ctl gmxx_tx_xaui_ctl; 300af866496SDavid Daney union cvmx_gmxx_rx_xaui_ctl gmxx_rx_xaui_ctl; 301af866496SDavid Daney 302af866496SDavid Daney gmxx_tx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_TX_XAUI_CTL(interface)); 303af866496SDavid Daney gmxx_rx_xaui_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RX_XAUI_CTL(interface)); 304af866496SDavid Daney 305af866496SDavid Daney /* If the link shouldn't be up, then just return */ 306af866496SDavid Daney if (!link_info.s.link_up) 307af866496SDavid Daney return 0; 308af866496SDavid Daney 309af866496SDavid Daney /* Do nothing if both RX and TX are happy */ 310af866496SDavid Daney if ((gmxx_tx_xaui_ctl.s.ls == 0) && (gmxx_rx_xaui_ctl.s.status == 0)) 311af866496SDavid Daney return 0; 312af866496SDavid Daney 313af866496SDavid Daney /* Bring the link up */ 314af866496SDavid Daney return __cvmx_helper_xaui_enable(interface); 315af866496SDavid Daney } 316af866496SDavid Daney 317af866496SDavid Daney /** 318af866496SDavid Daney * Configure a port for internal and/or external loopback. Internal loopback 319af866496SDavid Daney * causes packets sent by the port to be received by Octeon. External loopback 320af866496SDavid Daney * causes packets received from the wire to sent out again. 321af866496SDavid Daney * 322af866496SDavid Daney * @ipd_port: IPD/PKO port to loopback. 323af866496SDavid Daney * @enable_internal: 324af866496SDavid Daney * Non zero if you want internal loopback 325af866496SDavid Daney * @enable_external: 326af866496SDavid Daney * Non zero if you want external loopback 327af866496SDavid Daney * 328af866496SDavid Daney * Returns Zero on success, negative on failure. 329af866496SDavid Daney */ 330af866496SDavid Daney extern int __cvmx_helper_xaui_configure_loopback(int ipd_port, 331af866496SDavid Daney int enable_internal, 332af866496SDavid Daney int enable_external) 333af866496SDavid Daney { 334af866496SDavid Daney int interface = cvmx_helper_get_interface_num(ipd_port); 335af866496SDavid Daney union cvmx_pcsxx_control1_reg pcsxx_control1_reg; 336af866496SDavid Daney union cvmx_gmxx_xaui_ext_loopback gmxx_xaui_ext_loopback; 337af866496SDavid Daney 338af866496SDavid Daney /* Set the internal loop */ 339af866496SDavid Daney pcsxx_control1_reg.u64 = 340af866496SDavid Daney cvmx_read_csr(CVMX_PCSXX_CONTROL1_REG(interface)); 341af866496SDavid Daney pcsxx_control1_reg.s.loopbck1 = enable_internal; 342af866496SDavid Daney cvmx_write_csr(CVMX_PCSXX_CONTROL1_REG(interface), 343af866496SDavid Daney pcsxx_control1_reg.u64); 344af866496SDavid Daney 345af866496SDavid Daney /* Set the external loop */ 346af866496SDavid Daney gmxx_xaui_ext_loopback.u64 = 347af866496SDavid Daney cvmx_read_csr(CVMX_GMXX_XAUI_EXT_LOOPBACK(interface)); 348af866496SDavid Daney gmxx_xaui_ext_loopback.s.en = enable_external; 349af866496SDavid Daney cvmx_write_csr(CVMX_GMXX_XAUI_EXT_LOOPBACK(interface), 350af866496SDavid Daney gmxx_xaui_ext_loopback.u64); 351af866496SDavid Daney 352af866496SDavid Daney /* Take the link through a reset */ 353af866496SDavid Daney return __cvmx_helper_xaui_enable(interface); 354af866496SDavid Daney } 355