Ejemplo n.º 1
0
static void cvm_oct_spi_poll(struct ifnet *ifp)
{
	static int spi4000_port;
	cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
	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;
		}
	}
}
Ejemplo n.º 2
0
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);
			}
		}

		
		if (priv->port == spi4000_port) {
			
			cvmx_spi4000_check_speed(interface, priv->port);
			
			spi4000_port--;
			if (spi4000_port < 0)
				spi4000_port = 10;
		}
	}
}
Ejemplo n.º 3
0
int cvm_oct_spi_init(struct net_device *dev)
{
	int r;
	struct octeon_ethernet *priv = netdev_priv(dev);

	if (number_spi_ports == 0) {
		r = request_irq(OCTEON_IRQ_RML, cvm_oct_spi_rml_interrupt,
				IRQF_SHARED, "SPI", &number_spi_ports);
	}
	number_spi_ports++;

	if ((priv->port == 0) || (priv->port == 16)) {
		cvm_oct_spi_enable_error_reporting(INTERFACE(priv->port));
		priv->poll = cvm_oct_spi_poll;
	}
	cvm_oct_common_init(dev);
	return 0;
}
Ejemplo n.º 4
0
int cvm_oct_spi_init(struct ifnet *ifp)
{
	struct octebus_softc *sc;
	cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
	int error;
	int rid;

	if (number_spi_ports == 0) {
		sc = device_get_softc(device_get_parent(priv->dev));

		rid = 0;
		sc->sc_spi_irq = bus_alloc_resource(sc->sc_dev, SYS_RES_IRQ,
						    &rid, OCTEON_IRQ_RML,
						    OCTEON_IRQ_RML, 1,
						    RF_ACTIVE);
		if (sc->sc_spi_irq == NULL) {
			device_printf(sc->sc_dev, "could not allocate SPI irq");
			return ENXIO;
		}

		error = bus_setup_intr(sc->sc_dev, sc->sc_spi_irq,
				       INTR_TYPE_NET | INTR_MPSAFE,
				       cvm_oct_spi_rml_interrupt, NULL,
				       &number_spi_ports, NULL);
		if (error != 0) {
			device_printf(sc->sc_dev, "could not setup SPI irq");
			return error;
		}
	}
	number_spi_ports++;

	if ((priv->port == 0) || (priv->port == 16)) {
		cvm_oct_spi_enable_error_reporting(INTERFACE(priv->port));
		priv->poll = cvm_oct_spi_poll;
	}
	if (cvm_oct_common_init(ifp) != 0)
	    return ENXIO;
	return 0;
}