Lines Matching refs:port

47 #define get_msci(port)	  (port->chan ?   MSCI1_OFFSET :   MSCI0_OFFSET)  argument
48 #define get_dmac_rx(port) (port->chan ? DMAC1RX_OFFSET : DMAC0RX_OFFSET) argument
49 #define get_dmac_tx(port) (port->chan ? DMAC1TX_OFFSET : DMAC0TX_OFFSET) argument
65 static inline void enable_intr(port_t *port) in enable_intr() argument
68 sca_outl(sca_inl(IER0, port->card) | in enable_intr()
69 (port->chan ? 0x08002200 : 0x00080022), IER0, port->card); in enable_intr()
72 static inline void disable_intr(port_t *port) in disable_intr() argument
74 sca_outl(sca_inl(IER0, port->card) & in disable_intr()
75 (port->chan ? 0x00FF00FF : 0xFF00FF00), IER0, port->card); in disable_intr()
78 static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) in desc_abs_number() argument
80 u16 rx_buffs = port->card->rx_ring_buffers; in desc_abs_number()
81 u16 tx_buffs = port->card->tx_ring_buffers; in desc_abs_number()
84 return port->chan * (rx_buffs + tx_buffs) + transmit * rx_buffs + desc; in desc_abs_number()
88 static inline u16 desc_offset(port_t *port, u16 desc, int transmit) in desc_offset() argument
91 return desc_abs_number(port, desc, transmit) * sizeof(pkt_desc); in desc_offset()
95 static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, in desc_address() argument
98 return (pkt_desc __iomem *)(port->card->rambase + in desc_address()
99 desc_offset(port, desc, transmit)); in desc_address()
103 static inline u32 buffer_offset(port_t *port, u16 desc, int transmit) in buffer_offset() argument
105 return port->card->buff_offset + in buffer_offset()
106 desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU; in buffer_offset()
110 static inline void sca_set_carrier(port_t *port) in sca_set_carrier() argument
112 if (!(sca_in(get_msci(port) + ST3, port->card) & ST3_DCD)) { in sca_set_carrier()
115 port->netdev.name); in sca_set_carrier()
117 netif_carrier_on(port->netdev); in sca_set_carrier()
121 port->netdev.name); in sca_set_carrier()
123 netif_carrier_off(port->netdev); in sca_set_carrier()
128 static void sca_init_port(port_t *port) in sca_init_port() argument
130 card_t *card = port->card; in sca_init_port()
131 u16 dmac_rx = get_dmac_rx(port), dmac_tx = get_dmac_tx(port); in sca_init_port()
134 port->rxin = 0; in sca_init_port()
135 port->txin = 0; in sca_init_port()
136 port->txlast = 0; in sca_init_port()
143 pkt_desc __iomem *desc = desc_address(port, i, transmit); in sca_init_port()
144 u16 chain_off = desc_offset(port, i + 1, transmit); in sca_init_port()
145 u32 buff_off = buffer_offset(port, i, transmit); in sca_init_port()
155 sca_out(0, DSR_RX(port->chan), card); in sca_init_port()
156 sca_out(0, DSR_TX(port->chan), card); in sca_init_port()
159 sca_out(DCR_ABORT, DCR_RX(port->chan), card); in sca_init_port()
160 sca_out(DCR_ABORT, DCR_TX(port->chan), card); in sca_init_port()
163 sca_outl(desc_offset(port, 0, 0), dmac_rx + CDAL, card); in sca_init_port()
164 sca_outl(desc_offset(port, card->tx_ring_buffers - 1, 0), in sca_init_port()
166 sca_outl(desc_offset(port, 0, 1), dmac_tx + CDAL, card); in sca_init_port()
167 sca_outl(desc_offset(port, 0, 1), dmac_tx + EDAL, card); in sca_init_port()
170 sca_out(DCR_CLEAR_EOF, DCR_RX(port->chan), card); in sca_init_port()
171 sca_out(DCR_CLEAR_EOF, DCR_TX(port->chan), card); in sca_init_port()
175 sca_out(0x14, DMR_RX(port->chan), card); /* Chain mode, Multi-frame */ in sca_init_port()
176 sca_out(DIR_EOME, DIR_RX(port->chan), card); /* enable interrupts */ in sca_init_port()
177 sca_out(DSR_DE, DSR_RX(port->chan), card); /* DMA enable */ in sca_init_port()
180 sca_out(0x14, DMR_TX(port->chan), card); /* Chain mode, Multi-frame */ in sca_init_port()
181 sca_out(DIR_EOME, DIR_TX(port->chan), card); /* enable interrupts */ in sca_init_port()
183 sca_set_carrier(port); in sca_init_port()
184 netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT); in sca_init_port()
189 static inline void sca_msci_intr(port_t *port) in sca_msci_intr() argument
191 u16 msci = get_msci(port); in sca_msci_intr()
192 card_t* card = port->card; in sca_msci_intr()
197 sca_set_carrier(port); in sca_msci_intr()
202 static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, in sca_rx() argument
205 struct net_device *dev = port->netdev; in sca_rx()
217 buff = buffer_offset(port, rxin, 0); in sca_rx()
233 static inline int sca_rx_done(port_t *port, int budget) in sca_rx_done() argument
235 struct net_device *dev = port->netdev; in sca_rx_done()
236 u16 dmac = get_dmac_rx(port); in sca_rx_done()
237 card_t *card = port->card; in sca_rx_done()
238 u8 stat = sca_in(DSR_RX(port->chan), card); /* read DMA Status */ in sca_rx_done()
243 DSR_RX(port->chan), card); in sca_rx_done()
250 u32 desc_off = desc_offset(port, port->rxin, 0); in sca_rx_done()
257 desc = desc_address(port, port->rxin, 0); in sca_rx_done()
260 port->rxpart = 1; /* partial frame received */ in sca_rx_done()
261 else if ((stat & ST_ERROR_MASK) || port->rxpart) { in sca_rx_done()
266 ST_RX_RESBIT)) || port->rxpart) in sca_rx_done()
271 port->rxpart = 0; /* received last fragment */ in sca_rx_done()
273 sca_rx(card, port, desc, port->rxin); in sca_rx_done()
279 port->rxin = (port->rxin + 1) % card->rx_ring_buffers; in sca_rx_done()
283 sca_out(DSR_DE, DSR_RX(port->chan), card); in sca_rx_done()
289 static inline void sca_tx_done(port_t *port) in sca_tx_done() argument
291 struct net_device *dev = port->netdev; in sca_tx_done()
292 card_t* card = port->card; in sca_tx_done()
296 spin_lock(&port->lock); in sca_tx_done()
298 stat = sca_in(DSR_TX(port->chan), card); /* read DMA Status */ in sca_tx_done()
302 DSR_TX(port->chan), card); in sca_tx_done()
305 pkt_desc __iomem *desc = desc_address(port, port->txlast, 1); in sca_tx_done()
319 port->txlast = (port->txlast + 1) % card->tx_ring_buffers; in sca_tx_done()
324 spin_unlock(&port->lock); in sca_tx_done()
330 port_t *port = container_of(napi, port_t, napi); in sca_poll() local
331 u32 isr0 = sca_inl(ISR0, port->card); in sca_poll()
334 if (isr0 & (port->chan ? 0x08000000 : 0x00080000)) in sca_poll()
335 sca_msci_intr(port); in sca_poll()
337 if (isr0 & (port->chan ? 0x00002000 : 0x00000020)) in sca_poll()
338 sca_tx_done(port); in sca_poll()
340 if (isr0 & (port->chan ? 0x00000200 : 0x00000002)) in sca_poll()
341 received = sca_rx_done(port, budget); in sca_poll()
345 enable_intr(port); in sca_poll()
358 port_t *port = get_port(card, i); in sca_intr() local
359 if (port && (isr0 & (i ? 0x08002200 : 0x00080022))) { in sca_intr()
361 disable_intr(port); in sca_intr()
362 napi_schedule(&port->napi); in sca_intr()
370 static void sca_set_port(port_t *port) in sca_set_port() argument
372 card_t* card = port->card; in sca_set_port()
373 u16 msci = get_msci(port); in sca_set_port()
378 if (port->settings.clock_rate > 0) { in sca_set_port()
385 tmc = CLOCK_BASE / brv / port->settings.clock_rate; in sca_set_port()
395 port->settings.clock_rate = CLOCK_BASE / brv / tmc; in sca_set_port()
399 port->settings.clock_rate = CLOCK_BASE / (256 * 512); in sca_set_port()
402 port->rxs = (port->rxs & ~CLK_BRG_MASK) | br; in sca_set_port()
403 port->txs = (port->txs & ~CLK_BRG_MASK) | br; in sca_set_port()
404 port->tmc = tmc; in sca_set_port()
407 sca_out(port->tmc, msci + TMCR, card); in sca_set_port()
408 sca_out(port->tmc, msci + TMCT, card); in sca_set_port()
411 sca_out(port->rxs, msci + RXS, card); in sca_set_port()
412 sca_out(port->txs, msci + TXS, card); in sca_set_port()
414 if (port->settings.loopback) in sca_set_port()
426 port_t *port = dev_to_port(dev); in sca_open() local
427 card_t* card = port->card; in sca_open()
428 u16 msci = get_msci(port); in sca_open()
431 switch(port->encoding) { in sca_open()
439 if (port->settings.loopback) in sca_open()
442 switch(port->parity) { in sca_open()
469 sca_out(port->tmc, msci + TMCR, card); in sca_open()
470 sca_out(port->tmc, msci + TMCT, card); in sca_open()
471 sca_out(port->rxs, msci + RXS, card); in sca_open()
472 sca_out(port->txs, msci + TXS, card); in sca_open()
476 sca_set_carrier(port); in sca_open()
477 enable_intr(port); in sca_open()
478 napi_enable(&port->napi); in sca_open()
485 port_t *port = dev_to_port(dev); in sca_close() local
488 sca_out(CMD_RESET, get_msci(port) + CMD, port->card); in sca_close()
489 disable_intr(port); in sca_close()
490 napi_disable(&port->napi); in sca_close()
521 port_t *port = dev_to_port(dev); in sca_dump_rings() local
522 card_t *card = port->card; in sca_dump_rings()
526 sca_inl(get_dmac_rx(port) + CDAL, card), in sca_dump_rings()
527 sca_inl(get_dmac_rx(port) + EDAL, card), in sca_dump_rings()
528 sca_in(DSR_RX(port->chan), card), port->rxin, in sca_dump_rings()
529 sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in"); in sca_dump_rings()
530 for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++) in sca_dump_rings()
531 pr_cont(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); in sca_dump_rings()
536 sca_inl(get_dmac_tx(port) + CDAL, card), in sca_dump_rings()
537 sca_inl(get_dmac_tx(port) + EDAL, card), in sca_dump_rings()
538 sca_in(DSR_TX(port->chan), card), port->txin, port->txlast, in sca_dump_rings()
539 sca_in(DSR_TX(port->chan), card) & DSR_DE ? "" : "in"); in sca_dump_rings()
541 for (cnt = 0; cnt < port->card->tx_ring_buffers; cnt++) in sca_dump_rings()
542 pr_cont(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); in sca_dump_rings()
547 sca_in(get_msci(port) + MD0, card), in sca_dump_rings()
548 sca_in(get_msci(port) + MD1, card), in sca_dump_rings()
549 sca_in(get_msci(port) + MD2, card), in sca_dump_rings()
550 sca_in(get_msci(port) + ST0, card), in sca_dump_rings()
551 sca_in(get_msci(port) + ST1, card), in sca_dump_rings()
552 sca_in(get_msci(port) + ST2, card), in sca_dump_rings()
553 sca_in(get_msci(port) + ST3, card), in sca_dump_rings()
554 sca_in(get_msci(port) + ST4, card), in sca_dump_rings()
555 sca_in(get_msci(port) + FST, card), in sca_dump_rings()
556 sca_in(get_msci(port) + CST0, card), in sca_dump_rings()
557 sca_in(get_msci(port) + CST1, card)); in sca_dump_rings()
567 port_t *port = dev_to_port(dev); in sca_xmit() local
568 card_t *card = port->card; in sca_xmit()
572 spin_lock_irq(&port->lock); in sca_xmit()
574 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
582 desc = desc_address(port, port->txin, 1); in sca_xmit()
583 buff = buffer_offset(port, port->txin, 1); in sca_xmit()
590 port->txin = (port->txin + 1) % card->tx_ring_buffers; in sca_xmit()
591 sca_outl(desc_offset(port, port->txin, 1), in sca_xmit()
592 get_dmac_tx(port) + EDAL, card); in sca_xmit()
594 sca_out(DSR_DE, DSR_TX(port->chan), card); /* Enable TX DMA */ in sca_xmit()
596 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
600 spin_unlock_irq(&port->lock); in sca_xmit()