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_weight(port->netdev, &port->napi, sca_poll, in sca_init_port()
181 static inline void sca_msci_intr(port_t *port) in sca_msci_intr() argument
183 u16 msci = get_msci(port); in sca_msci_intr()
184 card_t *card = port->card; in sca_msci_intr()
189 sca_set_carrier(port); in sca_msci_intr()
193 static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, in sca_rx() argument
196 struct net_device *dev = port->netdev; in sca_rx()
208 buff = buffer_offset(port, rxin, 0); in sca_rx()
223 static inline int sca_rx_done(port_t *port, int budget) in sca_rx_done() argument
225 struct net_device *dev = port->netdev; in sca_rx_done()
226 u16 dmac = get_dmac_rx(port); in sca_rx_done()
227 card_t *card = port->card; in sca_rx_done()
228 u8 stat = sca_in(DSR_RX(port->chan), card); /* read DMA Status */ in sca_rx_done()
233 DSR_RX(port->chan), card); in sca_rx_done()
240 u32 desc_off = desc_offset(port, port->rxin, 0); in sca_rx_done()
247 desc = desc_address(port, port->rxin, 0); in sca_rx_done()
250 port->rxpart = 1; /* partial frame received */ in sca_rx_done()
251 else if ((stat & ST_ERROR_MASK) || port->rxpart) { in sca_rx_done()
256 ST_RX_RESBIT)) || port->rxpart) in sca_rx_done()
261 port->rxpart = 0; /* received last fragment */ in sca_rx_done()
263 sca_rx(card, port, desc, port->rxin); in sca_rx_done()
269 port->rxin = (port->rxin + 1) % card->rx_ring_buffers; in sca_rx_done()
273 sca_out(DSR_DE, DSR_RX(port->chan), card); in sca_rx_done()
278 static inline void sca_tx_done(port_t *port) in sca_tx_done() argument
280 struct net_device *dev = port->netdev; in sca_tx_done()
281 card_t *card = port->card; in sca_tx_done()
285 spin_lock(&port->lock); in sca_tx_done()
287 stat = sca_in(DSR_TX(port->chan), card); /* read DMA Status */ in sca_tx_done()
291 DSR_TX(port->chan), card); in sca_tx_done()
294 pkt_desc __iomem *desc = desc_address(port, port->txlast, 1); in sca_tx_done()
308 port->txlast = (port->txlast + 1) % card->tx_ring_buffers; in sca_tx_done()
313 spin_unlock(&port->lock); in sca_tx_done()
318 port_t *port = container_of(napi, port_t, napi); in sca_poll() local
319 u32 isr0 = sca_inl(ISR0, port->card); in sca_poll()
322 if (isr0 & (port->chan ? 0x08000000 : 0x00080000)) in sca_poll()
323 sca_msci_intr(port); in sca_poll()
325 if (isr0 & (port->chan ? 0x00002000 : 0x00000020)) in sca_poll()
326 sca_tx_done(port); in sca_poll()
328 if (isr0 & (port->chan ? 0x00000200 : 0x00000002)) in sca_poll()
329 received = sca_rx_done(port, budget); in sca_poll()
333 enable_intr(port); in sca_poll()
346 port_t *port = get_port(card, i); in sca_intr() local
347 if (port && (isr0 & (i ? 0x08002200 : 0x00080022))) { in sca_intr()
349 disable_intr(port); in sca_intr()
350 napi_schedule(&port->napi); in sca_intr()
357 static void sca_set_port(port_t *port) in sca_set_port() argument
359 card_t *card = port->card; in sca_set_port()
360 u16 msci = get_msci(port); in sca_set_port()
364 if (port->settings.clock_rate > 0) { in sca_set_port()
371 tmc = CLOCK_BASE / brv / port->settings.clock_rate; in sca_set_port()
382 port->settings.clock_rate = CLOCK_BASE / brv / tmc; in sca_set_port()
386 port->settings.clock_rate = CLOCK_BASE / (256 * 512); in sca_set_port()
389 port->rxs = (port->rxs & ~CLK_BRG_MASK) | br; in sca_set_port()
390 port->txs = (port->txs & ~CLK_BRG_MASK) | br; in sca_set_port()
391 port->tmc = tmc; in sca_set_port()
394 sca_out(port->tmc, msci + TMCR, card); in sca_set_port()
395 sca_out(port->tmc, msci + TMCT, card); in sca_set_port()
398 sca_out(port->rxs, msci + RXS, card); in sca_set_port()
399 sca_out(port->txs, msci + TXS, card); in sca_set_port()
401 if (port->settings.loopback) in sca_set_port()
411 port_t *port = dev_to_port(dev); in sca_open() local
412 card_t *card = port->card; in sca_open()
413 u16 msci = get_msci(port); in sca_open()
416 switch (port->encoding) { in sca_open()
433 if (port->settings.loopback) in sca_open()
436 switch (port->parity) { in sca_open()
472 sca_out(port->tmc, msci + TMCR, card); in sca_open()
473 sca_out(port->tmc, msci + TMCT, card); in sca_open()
474 sca_out(port->rxs, msci + RXS, card); in sca_open()
475 sca_out(port->txs, msci + TXS, card); in sca_open()
479 sca_set_carrier(port); in sca_open()
480 enable_intr(port); in sca_open()
481 napi_enable(&port->napi); in sca_open()
487 port_t *port = dev_to_port(dev); in sca_close() local
490 sca_out(CMD_RESET, get_msci(port) + CMD, port->card); in sca_close()
491 disable_intr(port); in sca_close()
492 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()
566 port_t *port = dev_to_port(dev); in sca_xmit() local
567 card_t *card = port->card; in sca_xmit()
571 spin_lock_irq(&port->lock); in sca_xmit()
573 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
581 desc = desc_address(port, port->txin, 1); in sca_xmit()
582 buff = buffer_offset(port, port->txin, 1); in sca_xmit()
589 port->txin = (port->txin + 1) % card->tx_ring_buffers; in sca_xmit()
590 sca_outl(desc_offset(port, port->txin, 1), in sca_xmit()
591 get_dmac_tx(port) + EDAL, card); in sca_xmit()
593 sca_out(DSR_DE, DSR_TX(port->chan), card); /* Enable TX DMA */ in sca_xmit()
595 desc = desc_address(port, port->txin + 1, 1); in sca_xmit()
599 spin_unlock_irq(&port->lock); in sca_xmit()