Lines Matching refs:port
44 #define get_msci(port) ((port)->chan ? MSCI1_OFFSET : MSCI0_OFFSET) argument
45 #define get_dmac_rx(port) ((port)->chan ? DMAC1RX_OFFSET : DMAC0RX_OFFSET) argument
46 #define get_dmac_tx(port) ((port)->chan ? DMAC1TX_OFFSET : DMAC0TX_OFFSET) argument
62 static inline void enable_intr(port_t *port) in enable_intr() argument
65 sca_outl(sca_inl(IER0, port->card) | in enable_intr()
66 (port->chan ? 0x08002200 : 0x00080022), IER0, port->card); in enable_intr()
69 static inline void disable_intr(port_t *port) in disable_intr() argument
71 sca_outl(sca_inl(IER0, port->card) & in disable_intr()
72 (port->chan ? 0x00FF00FF : 0xFF00FF00), IER0, port->card); in disable_intr()
75 static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) in desc_abs_number() argument
77 u16 rx_buffs = port->card->rx_ring_buffers; in desc_abs_number()
78 u16 tx_buffs = port->card->tx_ring_buffers; in desc_abs_number()
81 return port->chan * (rx_buffs + tx_buffs) + transmit * rx_buffs + desc; in desc_abs_number()
84 static inline u16 desc_offset(port_t *port, u16 desc, int transmit) in desc_offset() argument
87 return desc_abs_number(port, desc, transmit) * sizeof(pkt_desc); in desc_offset()
90 static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, in desc_address() argument
93 return (pkt_desc __iomem *)(port->card->rambase + in desc_address()
94 desc_offset(port, desc, transmit)); in desc_address()
97 static inline u32 buffer_offset(port_t *port, u16 desc, int transmit) in buffer_offset() argument
99 return port->card->buff_offset + in buffer_offset()
100 desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU; in buffer_offset()
103 static inline void sca_set_carrier(port_t *port) in sca_set_carrier() argument
105 if (!(sca_in(get_msci(port) + ST3, port->card) & ST3_DCD)) { in sca_set_carrier()
108 port->netdev.name); in sca_set_carrier()
110 netif_carrier_on(port->netdev); in sca_set_carrier()
114 port->netdev.name); in sca_set_carrier()
116 netif_carrier_off(port->netdev); in sca_set_carrier()
120 static void sca_init_port(port_t *port) in sca_init_port() argument
122 card_t *card = port->card; in sca_init_port()
123 u16 dmac_rx = get_dmac_rx(port), dmac_tx = get_dmac_tx(port); in sca_init_port()
126 port->rxin = 0; in sca_init_port()
127 port->txin = 0; in sca_init_port()
128 port->txlast = 0; in sca_init_port()
135 pkt_desc __iomem *desc = desc_address(port, i, transmit); in sca_init_port()
136 u16 chain_off = desc_offset(port, i + 1, transmit); in sca_init_port()
137 u32 buff_off = buffer_offset(port, i, transmit); in sca_init_port()
147 sca_out(0, DSR_RX(port->chan), card); in sca_init_port()
148 sca_out(0, DSR_TX(port->chan), card); in sca_init_port()
151 sca_out(DCR_ABORT, DCR_RX(port->chan), card); in sca_init_port()
152 sca_out(DCR_ABORT, DCR_TX(port->chan), card); in sca_init_port()
155 sca_outl(desc_offset(port, 0, 0), dmac_rx + CDAL, card); in sca_init_port()
156 sca_outl(desc_offset(port, card->tx_ring_buffers - 1, 0), in sca_init_port()
158 sca_outl(desc_offset(port, 0, 1), dmac_tx + CDAL, card); in sca_init_port()
159 sca_outl(desc_offset(port, 0, 1), dmac_tx + EDAL, card); in sca_init_port()
162 sca_out(DCR_CLEAR_EOF, DCR_RX(port->chan), card); in sca_init_port()
163 sca_out(DCR_CLEAR_EOF, DCR_TX(port->chan), card); in sca_init_port()
167 sca_out(0x14, DMR_RX(port->chan), card); /* Chain mode, Multi-frame */ in sca_init_port()
168 sca_out(DIR_EOME, DIR_RX(port->chan), card); /* enable interrupts */ in sca_init_port()
169 sca_out(DSR_DE, DSR_RX(port->chan), card); /* DMA enable */ in sca_init_port()
172 sca_out(0x14, DMR_TX(port->chan), card); /* Chain mode, Multi-frame */ in sca_init_port()
173 sca_out(DIR_EOME, DIR_TX(port->chan), card); /* enable interrupts */ in sca_init_port()
175 sca_set_carrier(port); in sca_init_port()
176 netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT); in sca_init_port()
180 static inline void sca_msci_intr(port_t *port) in sca_msci_intr() argument
182 u16 msci = get_msci(port); in sca_msci_intr()
183 card_t *card = port->card; in sca_msci_intr()
188 sca_set_carrier(port); in sca_msci_intr()
192 static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, in sca_rx() argument
195 struct net_device *dev = port->netdev; in sca_rx()
207 buff = buffer_offset(port, rxin, 0); in sca_rx()
222 static inline int sca_rx_done(port_t *port, int budget) in sca_rx_done() argument
224 struct net_device *dev = port->netdev; in sca_rx_done()
225 u16 dmac = get_dmac_rx(port); in sca_rx_done()
226 card_t *card = port->card; in sca_rx_done()
227 u8 stat = sca_in(DSR_RX(port->chan), card); /* read DMA Status */ in sca_rx_done()
232 DSR_RX(port->chan), card); in sca_rx_done()
239 u32 desc_off = desc_offset(port, port->rxin, 0); in sca_rx_done()
246 desc = desc_address(port, port->rxin, 0); in sca_rx_done()
249 port->rxpart = 1; /* partial frame received */ in sca_rx_done()
250 else if ((stat & ST_ERROR_MASK) || port->rxpart) { in sca_rx_done()
255 ST_RX_RESBIT)) || port->rxpart) in sca_rx_done()
260 port->rxpart = 0; /* received last fragment */ in sca_rx_done()
262 sca_rx(card, port, desc, port->rxin); in sca_rx_done()
268 port->rxin = (port->rxin + 1) % card->rx_ring_buffers; in sca_rx_done()
272 sca_out(DSR_DE, DSR_RX(port->chan), card); in sca_rx_done()
277 static inline void sca_tx_done(port_t *port) in sca_tx_done() argument
279 struct net_device *dev = port->netdev; in sca_tx_done()
280 card_t *card = port->card; in sca_tx_done()
284 spin_lock(&port->lock); in sca_tx_done()
286 stat = sca_in(DSR_TX(port->chan), card); /* read DMA Status */ in sca_tx_done()
290 DSR_TX(port->chan), card); in sca_tx_done()
293 pkt_desc __iomem *desc = desc_address(port, port->txlast, 1); in sca_tx_done()
307 port->txlast = (port->txlast + 1) % card->tx_ring_buffers; in sca_tx_done()
312 spin_unlock(&port->lock); in sca_tx_done()
317 port_t *port = container_of(napi, port_t, napi); in sca_poll() local
318 u32 isr0 = sca_inl(ISR0, port->card); in sca_poll()
321 if (isr0 & (port->chan ? 0x08000000 : 0x00080000)) in sca_poll()
322 sca_msci_intr(port); in sca_poll()
324 if (isr0 & (port->chan ? 0x00002000 : 0x00000020)) in sca_poll()
325 sca_tx_done(port); in sca_poll()
327 if (isr0 & (port->chan ? 0x00000200 : 0x00000002)) in sca_poll()
328 received = sca_rx_done(port, budget); in sca_poll()
332 enable_intr(port); in sca_poll()
345 port_t *port = get_port(card, i); in sca_intr() local
346 if (port && (isr0 & (i ? 0x08002200 : 0x00080022))) { in sca_intr()
348 disable_intr(port); in sca_intr()
349 napi_schedule(&port->napi); in sca_intr()
356 static void sca_set_port(port_t *port) in sca_set_port() argument
358 card_t *card = port->card; in sca_set_port()
359 u16 msci = get_msci(port); in sca_set_port()
363 if (port->settings.clock_rate > 0) { in sca_set_port()
370 tmc = CLOCK_BASE / brv / port->settings.clock_rate; in sca_set_port()
381 port->settings.clock_rate = CLOCK_BASE / brv / tmc; in sca_set_port()
385 port->settings.clock_rate = CLOCK_BASE / (256 * 512); in sca_set_port()
388 port->rxs = (port->rxs & ~CLK_BRG_MASK) | br; in sca_set_port()
389 port->txs = (port->txs & ~CLK_BRG_MASK) | br; in sca_set_port()
390 port->tmc = tmc; in sca_set_port()
393 sca_out(port->tmc, msci + TMCR, card); in sca_set_port()
394 sca_out(port->tmc, msci + TMCT, card); in sca_set_port()
397 sca_out(port->rxs, msci + RXS, card); in sca_set_port()
398 sca_out(port->txs, msci + TXS, card); in sca_set_port()
400 if (port->settings.loopback) in sca_set_port()
410 port_t *port = dev_to_port(dev); in sca_open() local
411 card_t *card = port->card; in sca_open()
412 u16 msci = get_msci(port); in sca_open()
415 switch (port->encoding) { in sca_open()
432 if (port->settings.loopback) in sca_open()
435 switch (port->parity) { in sca_open()
471 sca_out(port->tmc, msci + TMCR, card); in sca_open()
472 sca_out(port->tmc, msci + TMCT, card); in sca_open()
473 sca_out(port->rxs, msci + RXS, card); in sca_open()
474 sca_out(port->txs, msci + TXS, card); in sca_open()
478 sca_set_carrier(port); in sca_open()
479 enable_intr(port); in sca_open()
480 napi_enable(&port->napi); in sca_open()
486 port_t *port = dev_to_port(dev); in sca_close() local
489 sca_out(CMD_RESET, get_msci(port) + CMD, port->card); in sca_close()
490 disable_intr(port); in sca_close()
491 napi_disable(&port->napi); in sca_close()
520 port_t *port = dev_to_port(dev); in sca_dump_rings() local
521 card_t *card = port->card; in sca_dump_rings()
525 sca_inl(get_dmac_rx(port) + CDAL, card), in sca_dump_rings()
526 sca_inl(get_dmac_rx(port) + EDAL, card), in sca_dump_rings()
527 sca_in(DSR_RX(port->chan), card), port->rxin, in sca_dump_rings()
528 sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in"); in sca_dump_rings()
529 for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++) in sca_dump_rings()
530 pr_cont(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); in sca_dump_rings()
535 sca_inl(get_dmac_tx(port) + CDAL, card), in sca_dump_rings()
536 sca_inl(get_dmac_tx(port) + EDAL, card), in sca_dump_rings()
537 sca_in(DSR_TX(port->chan), card), port->txin, port->txlast, in sca_dump_rings()
538 sca_in(DSR_TX(port->chan), card) & DSR_DE ? "" : "in"); in sca_dump_rings()
540 for (cnt = 0; cnt < port->card->tx_ring_buffers; cnt++) in sca_dump_rings()
541 pr_cont(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); in sca_dump_rings()
546 sca_in(get_msci(port) + MD0, card), in sca_dump_rings()
547 sca_in(get_msci(port) + MD1, card), in sca_dump_rings()
548 sca_in(get_msci(port) + MD2, card), in sca_dump_rings()
549 sca_in(get_msci(port) + ST0, card), in sca_dump_rings()
550 sca_in(get_msci(port) + ST1, card), in sca_dump_rings()
551 sca_in(get_msci(port) + ST2, card), in sca_dump_rings()
552 sca_in(get_msci(port) + ST3, card), in sca_dump_rings()
553 sca_in(get_msci(port) + ST4, card), in sca_dump_rings()
554 sca_in(get_msci(port) + FST, card), in sca_dump_rings()
555 sca_in(get_msci(port) + CST0, card), in sca_dump_rings()
556 sca_in(get_msci(port) + CST1, card)); in sca_dump_rings()
565 port_t *port = dev_to_port(dev); in sca_xmit() local
566 card_t *card = port->card; in sca_xmit()
570 spin_lock_irq(&port->lock); in sca_xmit()
572 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
580 desc = desc_address(port, port->txin, 1); in sca_xmit()
581 buff = buffer_offset(port, port->txin, 1); in sca_xmit()
588 port->txin = (port->txin + 1) % card->tx_ring_buffers; in sca_xmit()
589 sca_outl(desc_offset(port, port->txin, 1), in sca_xmit()
590 get_dmac_tx(port) + EDAL, card); in sca_xmit()
592 sca_out(DSR_DE, DSR_TX(port->chan), card); /* Enable TX DMA */ in sca_xmit()
594 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
598 spin_unlock_irq(&port->lock); in sca_xmit()