Ejemplo n.º 1
0
static inline u16 next_desc(port_t *port, u16 desc, int transmit)
{
	return (desc + 1) % (transmit ? port_to_card(port)->tx_ring_buffers
			     : port_to_card(port)->rx_ring_buffers);
}
Ejemplo n.º 2
0
static inline u32 buffer_offset(port_t *port, u16 desc, int transmit)
{
	return port_to_card(port)->buff_offset +
		desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU;
}
Ejemplo n.º 3
0
static void sca_init_sync_port(port_t *port)
{
	card_t *card = port_to_card(port);
	int transmit, i;

	port->rxin = 0;
	port->txin = 0;
	port->txlast = 0;

#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED)
	openwin(card, 0);
#endif

	for (transmit = 0; transmit < 2; transmit++) {
		u16 dmac = transmit ? get_dmac_tx(port) : get_dmac_rx(port);
		u16 buffs = transmit ? card->tx_ring_buffers
			: card->rx_ring_buffers;

		for (i = 0; i < buffs; i++) {
			pkt_desc* desc = desc_address(port, i, transmit);
			u16 chain_off = desc_offset(port, i + 1, transmit);
			u32 buff_off = buffer_offset(port, i, transmit);

			writea(chain_off, &desc->cp);
			writel(buff_off, &desc->bp);
			writew(0, &desc->len);
			writeb(0, &desc->stat);
		}

		/* DMA disable - to halt state */
		sca_out(0, transmit ? DSR_TX(phy_node(port)) :
			DSR_RX(phy_node(port)), card);
		/* software ABORT - to initial state */
		sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
			DCR_RX(phy_node(port)), card);

#ifdef __HD64570_H
		sca_out(0, dmac + CPB, card); /* pointer base */
#endif
		/* current desc addr */
		sca_outa(desc_offset(port, 0, transmit), dmac + CDAL, card);
		if (!transmit)
			sca_outa(desc_offset(port, buffs - 1, transmit),
				 dmac + EDAL, card);
		else
			sca_outa(desc_offset(port, 0, transmit), dmac + EDAL,
				 card);

		/* clear frame end interrupt counter */
		sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(phy_node(port)) :
			DCR_RX(phy_node(port)), card);

		if (!transmit) { /* Receive */
			/* set buffer length */
			sca_outw(HDLC_MAX_MRU, dmac + BFLL, card);
			/* Chain mode, Multi-frame */
			sca_out(0x14, DMR_RX(phy_node(port)), card);
			sca_out(DIR_EOME | DIR_BOFE, DIR_RX(phy_node(port)),
				card);
			/* DMA enable */
			sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
		} else {	/* Transmit */
			/* Chain mode, Multi-frame */
			sca_out(0x14, DMR_TX(phy_node(port)), card);
			/* enable underflow interrupts */
			sca_out(DIR_BOFE, DIR_TX(phy_node(port)), card);
		}
	}

	hdlc_set_carrier(!(sca_in(get_msci(port) + ST3, card) & ST3_DCD),
			 port_to_dev(port));
}
Ejemplo n.º 4
0
static void sca_init_port(port_t *port)
{
    card_t *card = port_to_card(port);
    int transmit, i;

    port->rxin = 0;
    port->txin = 0;
    port->txlast = 0;

#ifndef PAGE0_ALWAYS_MAPPED
    openwin(card, 0);
#endif

    for (transmit = 0; transmit < 2; transmit++) {
        u16 dmac = transmit ? get_dmac_tx(port) : get_dmac_rx(port);
        u16 buffs = transmit ? card->tx_ring_buffers
                    : card->rx_ring_buffers;

        for (i = 0; i < buffs; i++) {
            pkt_desc __iomem *desc = desc_address(port, i, transmit);
            u16 chain_off = desc_offset(port, i + 1, transmit);
            u32 buff_off = buffer_offset(port, i, transmit);

            writew(chain_off, &desc->cp);
            writel(buff_off, &desc->bp);
            writew(0, &desc->len);
            writeb(0, &desc->stat);
        }


        sca_out(0, transmit ? DSR_TX(phy_node(port)) :
                DSR_RX(phy_node(port)), card);

        sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
                DCR_RX(phy_node(port)), card);


        sca_out(0, dmac + CPB, card);
        sca_outw(desc_offset(port, 0, transmit), dmac + CDAL, card);
        if (!transmit)
            sca_outw(desc_offset(port, buffs - 1, transmit),
                     dmac + EDAL, card);
        else
            sca_outw(desc_offset(port, 0, transmit), dmac + EDAL,
                     card);


        sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(phy_node(port)) :
                DCR_RX(phy_node(port)), card);

        if (!transmit) {

            sca_outw(HDLC_MAX_MRU, dmac + BFLL, card);

            sca_out(0x14, DMR_RX(phy_node(port)), card);
            sca_out(DIR_EOME | DIR_BOFE, DIR_RX(phy_node(port)),
                    card);

            sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
        } else {

            sca_out(0x14, DMR_TX(phy_node(port)), card);

            sca_out(DIR_BOFE, DIR_TX(phy_node(port)), card);
        }
    }
    sca_set_carrier(port);
}