static void cvm_oct_spi_poll(struct net_device *dev) { static int spi4000_port; struct octeon_ethernet *priv = netdev_priv(dev); int interface; for (interface = 0; interface < 2; interface++) { if ((priv->port == interface * 16) && need_retrain[interface]) { if (cvmx_spi_restart_interface (interface, CVMX_SPI_MODE_DUPLEX, 10) == 0) { need_retrain[interface] = 0; cvm_oct_spi_enable_error_reporting(interface); } } /* * The SPI4000 TWSI interface is very slow. In order * not to bring the system to a crawl, we only poll a * single port every second. This means negotiation * speed changes take up to 10 seconds, but at least * we don't waste absurd amounts of time waiting for * TWSI. */ if (priv->port == spi4000_port) { /* * This function does nothing if it is called on an * interface without a SPI4000. */ cvmx_spi4000_check_speed(interface, priv->port); /* * Normal ordering increments. By decrementing * we only match once per iteration. */ spi4000_port--; if (spi4000_port < 0) spi4000_port = 10; } } }
/** * Return the link state of an IPD/PKO port as returned by * auto negotiation. The result of this function may not match * Octeon's link config if auto negotiation has changed since * the last call to cvmx_helper_link_set(). * * @ipd_port: IPD/PKO port to query * * Returns Link state */ cvmx_helper_link_info_t __cvmx_helper_spi_link_get(int ipd_port) { cvmx_helper_link_info_t result; int interface = cvmx_helper_get_interface_num(ipd_port); int index = cvmx_helper_get_interface_index_num(ipd_port); result.u64 = 0; if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM) { /* The simulator gives you a simulated full duplex link */ result.s.link_up = 1; result.s.full_duplex = 1; result.s.speed = 10000; } else if (cvmx_spi4000_is_present(interface)) { union cvmx_gmxx_rxx_rx_inbnd inband = cvmx_spi4000_check_speed(interface, index); result.s.link_up = inband.s.status; result.s.full_duplex = inband.s.duplex; switch (inband.s.speed) { case 0: /* 10 Mbps */ result.s.speed = 10; break; case 1: /* 100 Mbps */ result.s.speed = 100; break; case 2: /* 1 Gbps */ result.s.speed = 1000; break; case 3: /* Illegal */ result.s.speed = 0; result.s.link_up = 0; break; } } else { /* For generic SPI we can't determine the link, just return some sane results */ result.s.link_up = 1; result.s.full_duplex = 1; result.s.speed = 10000; } return result; }
cvmx_helper_link_info_t __cvmx_helper_spi_link_get(int ipd_port) { cvmx_helper_link_info_t result; int interface = cvmx_helper_get_interface_num(ipd_port); int index = cvmx_helper_get_interface_index_num(ipd_port); result.u64 = 0; if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM) { /* */ result.s.link_up = 1; result.s.full_duplex = 1; result.s.speed = 10000; } else if (cvmx_spi4000_is_present(interface)) { union cvmx_gmxx_rxx_rx_inbnd inband = cvmx_spi4000_check_speed(interface, index); result.s.link_up = inband.s.status; result.s.full_duplex = inband.s.duplex; switch (inband.s.speed) { case 0: /* */ result.s.speed = 10; break; case 1: /* */ result.s.speed = 100; break; case 2: /* */ result.s.speed = 1000; break; case 3: /* */ result.s.speed = 0; result.s.link_up = 0; break; } } else { /* */ result.s.link_up = 1; result.s.full_duplex = 1; result.s.speed = 10000; } return result; }
/** * @INTERNAL * Configure the SPI4000 PHYs */ static void __cvmx_spi4000_configure_phy(int interface) { int port; /* We use separate loops below since it allows us to save a write to the SPI4000 for each repeated value. This adds up to a couple of seconds */ /* Update the link state before resets. It takes a while for the links to come back after the resets. Most likely they'll come back the same as they are now */ for (port=0; port < 10; port++) cvmx_spi4000_check_speed(interface, port); /* Enable RGMII DELAYS for TX_CLK and RX_CLK (see spec) */ for (port=0; port < 10; port++) __cvmx_spi4000_mdio_write(interface, port, 0x14, 0x00e2); /* Advertise pause and 100 Full Duplex. Don't advertise half duplex or 10Mbpa */ for (port=0; port < 10; port++) __cvmx_spi4000_mdio_write(interface, port, 0x4, 0x0d01); /* Enable PHY reset */ for (port=0; port < 10; port++) __cvmx_spi4000_mdio_write(interface, port, 0x0, 0x9140); }