Lines Matching refs:scc

202 static void init_channel(struct scc_channel *scc);
203 static void scc_key_trx (struct scc_channel *scc, char tx);
204 static void scc_init_timer(struct scc_channel *scc);
206 static int scc_net_alloc(const char *name, struct scc_channel *scc);
210 static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb);
277 static inline void wr(struct scc_channel *scc, unsigned char reg, in wr() argument
280 OutReg(scc->ctrl, reg, (scc->wreg[reg] = val)); in wr()
283 static inline void or(struct scc_channel *scc, unsigned char reg, unsigned char val) in or() argument
285 OutReg(scc->ctrl, reg, (scc->wreg[reg] |= val)); in or()
288 static inline void cl(struct scc_channel *scc, unsigned char reg, unsigned char val) in cl() argument
290 OutReg(scc->ctrl, reg, (scc->wreg[reg] &= ~val)); in cl()
297 static inline void scc_discard_buffers(struct scc_channel *scc) in scc_discard_buffers() argument
301 spin_lock_irqsave(&scc->lock, flags); in scc_discard_buffers()
302 if (scc->tx_buff != NULL) in scc_discard_buffers()
304 dev_kfree_skb(scc->tx_buff); in scc_discard_buffers()
305 scc->tx_buff = NULL; in scc_discard_buffers()
308 while (!skb_queue_empty(&scc->tx_queue)) in scc_discard_buffers()
309 dev_kfree_skb(skb_dequeue(&scc->tx_queue)); in scc_discard_buffers()
311 spin_unlock_irqrestore(&scc->lock, flags); in scc_discard_buffers()
323 static inline void scc_notify(struct scc_channel *scc, int event) in scc_notify() argument
328 if (scc->kiss.fulldup != KISS_DUPLEX_OPTIMA) in scc_notify()
337 scc_net_rx(scc, skb); in scc_notify()
339 scc->stat.nospace++; in scc_notify()
342 static inline void flush_rx_FIFO(struct scc_channel *scc) in flush_rx_FIFO() argument
347 Inb(scc->data); in flush_rx_FIFO()
349 if(scc->rx_buff != NULL) /* did we receive something? */ in flush_rx_FIFO()
351 scc->stat.rxerrs++; /* then count it as an error */ in flush_rx_FIFO()
352 dev_kfree_skb_irq(scc->rx_buff); in flush_rx_FIFO()
353 scc->rx_buff = NULL; in flush_rx_FIFO()
357 static void start_hunt(struct scc_channel *scc) in start_hunt() argument
359 if ((scc->modem.clocksrc != CLK_EXTERNAL)) in start_hunt()
360 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */ in start_hunt()
361 or(scc,R3,ENT_HM|RxENABLE); /* enable the receiver, hunt mode */ in start_hunt()
368 static inline void scc_txint(struct scc_channel *scc) in scc_txint() argument
372 scc->stat.txints++; in scc_txint()
373 skb = scc->tx_buff; in scc_txint()
379 skb = skb_dequeue(&scc->tx_queue); in scc_txint()
380 scc->tx_buff = skb; in scc_txint()
381 netif_wake_queue(scc->dev); in scc_txint()
385 scc_tx_done(scc); in scc_txint()
386 Outb(scc->ctrl, RES_Tx_P); in scc_txint()
393 scc->tx_buff = NULL; in scc_txint()
394 scc_tx_done(scc); in scc_txint()
395 Outb(scc->ctrl, RES_Tx_P); in scc_txint()
399 scc->stat.tx_state = TXS_ACTIVE; in scc_txint()
401 OutReg(scc->ctrl, R0, RES_Tx_CRC); in scc_txint()
403 or(scc,R10,ABUNDER); /* re-install underrun protection */ in scc_txint()
404 Outb(scc->data,*skb->data); /* send byte */ in scc_txint()
407 if (!scc->enhanced) /* reset EOM latch */ in scc_txint()
408 Outb(scc->ctrl,RES_EOM_L); in scc_txint()
416 Outb(scc->ctrl, RES_Tx_P); /* reset pending int */ in scc_txint()
417 cl(scc, R10, ABUNDER); /* send CRC */ in scc_txint()
419 scc->tx_buff = NULL; in scc_txint()
420 scc->stat.tx_state = TXS_NEWFRAME; /* next frame... */ in scc_txint()
426 Outb(scc->data,*skb->data); in scc_txint()
432 static inline void scc_exint(struct scc_channel *scc) in scc_exint() argument
436 scc->stat.exints++; in scc_exint()
438 status = InReg(scc->ctrl,R0); in scc_exint()
439 changes = status ^ scc->status; in scc_exint()
445 flush_rx_FIFO(scc); in scc_exint()
449 if ((changes & SYNC_HUNT) && scc->kiss.softdcd) in scc_exint()
453 scc->dcd = 0; in scc_exint()
454 flush_rx_FIFO(scc); in scc_exint()
455 if ((scc->modem.clocksrc != CLK_EXTERNAL)) in scc_exint()
456 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */ in scc_exint()
458 scc->dcd = 1; in scc_exint()
461 scc_notify(scc, scc->dcd? HWEV_DCD_OFF:HWEV_DCD_ON); in scc_exint()
467 if((changes & DCD) && !scc->kiss.softdcd) /* DCD input changed state */ in scc_exint()
471 start_hunt(scc); in scc_exint()
472 scc->dcd = 1; in scc_exint()
474 cl(scc,R3,ENT_HM|RxENABLE); /* disable the receiver */ in scc_exint()
475 flush_rx_FIFO(scc); in scc_exint()
476 scc->dcd = 0; in scc_exint()
479 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF); in scc_exint()
491 if (scc->kiss.txdelay == 0) /* zero TXDELAY = wait for CTS */ in scc_exint()
492 scc_start_tx_timer(scc, t_txdelay, 0); in scc_exint()
496 if (scc->stat.tx_state == TXS_ACTIVE && (status & TxEOM)) in scc_exint()
498 scc->stat.tx_under++; /* oops, an underrun! count 'em */ in scc_exint()
499 Outb(scc->ctrl, RES_EXT_INT); /* reset ext/status interrupts */ in scc_exint()
501 if (scc->tx_buff != NULL) in scc_exint()
503 dev_kfree_skb_irq(scc->tx_buff); in scc_exint()
504 scc->tx_buff = NULL; in scc_exint()
507 or(scc,R10,ABUNDER); in scc_exint()
508 scc_start_tx_timer(scc, t_txdelay, 0); /* restart transmission */ in scc_exint()
511 scc->status = status; in scc_exint()
512 Outb(scc->ctrl,RES_EXT_INT); in scc_exint()
517 static inline void scc_rxint(struct scc_channel *scc) in scc_rxint() argument
521 scc->stat.rxints++; in scc_rxint()
523 if((scc->wreg[5] & RTS) && scc->kiss.fulldup == KISS_DUPLEX_HALF) in scc_rxint()
525 Inb(scc->data); /* discard char */ in scc_rxint()
526 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */ in scc_rxint()
530 skb = scc->rx_buff; in scc_rxint()
534 skb = dev_alloc_skb(scc->stat.bufsize); in scc_rxint()
537 scc->dev_stat.rx_dropped++; in scc_rxint()
538 scc->stat.nospace++; in scc_rxint()
539 Inb(scc->data); in scc_rxint()
540 or(scc, R3, ENT_HM); in scc_rxint()
544 scc->rx_buff = skb; in scc_rxint()
548 if (skb->len >= scc->stat.bufsize) in scc_rxint()
554 scc->rx_buff = NULL; in scc_rxint()
555 Inb(scc->data); in scc_rxint()
556 or(scc, R3, ENT_HM); in scc_rxint()
560 skb_put_u8(skb, Inb(scc->data)); in scc_rxint()
565 static inline void scc_spint(struct scc_channel *scc) in scc_spint() argument
570 scc->stat.spints++; in scc_spint()
572 status = InReg(scc->ctrl,R1); /* read receiver status */ in scc_spint()
574 Inb(scc->data); /* throw away Rx byte */ in scc_spint()
575 skb = scc->rx_buff; in scc_spint()
579 scc->stat.rx_over++; /* count them */ in scc_spint()
580 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */ in scc_spint()
584 scc->rx_buff = skb = NULL; in scc_spint()
595 scc_net_rx(scc, skb); in scc_spint()
596 scc->rx_buff = NULL; in scc_spint()
597 scc->stat.rxframes++; in scc_spint()
600 scc->rx_buff = NULL; in scc_spint()
601 scc->stat.rxerrs++; in scc_spint()
605 Outb(scc->ctrl,ERR_RES); in scc_spint()
611 static void scc_isr_dispatch(struct scc_channel *scc, int vector) in scc_isr_dispatch() argument
613 spin_lock(&scc->lock); in scc_isr_dispatch()
616 case TXINT: scc_txint(scc); break; in scc_isr_dispatch()
617 case EXINT: scc_exint(scc); break; in scc_isr_dispatch()
618 case RXINT: scc_rxint(scc); break; in scc_isr_dispatch()
619 case SPINT: scc_spint(scc); break; in scc_isr_dispatch()
621 spin_unlock(&scc->lock); in scc_isr_dispatch()
635 struct scc_channel *scc; in scc_isr() local
649 scc=&SCC_Info[vector >> 3 ^ 0x01]; in scc_isr()
650 if (!scc->dev) break; in scc_isr()
652 scc_isr_dispatch(scc, vector); in scc_isr()
654 OutReg(scc->ctrl,R0,RES_H_IUS); /* Reset Highest IUS */ in scc_isr()
676 scc = NULL; in scc_isr()
682 scc = &SCC_Info[vector >> 3 ^ 0x01]; in scc_isr()
683 if (!scc->dev) break; in scc_isr()
685 scc_isr_dispatch(scc, vector); in scc_isr()
701 if (scc != NULL) in scc_isr()
703 OutReg(scc->ctrl,R0,RES_H_IUS); in scc_isr()
720 static inline void set_brg(struct scc_channel *scc, unsigned int tc) in set_brg() argument
722 cl(scc,R14,BRENABL); /* disable baudrate generator */ in set_brg()
723 wr(scc,R12,tc & 255); /* brg rate LOW */ in set_brg()
724 wr(scc,R13,tc >> 8); /* brg rate HIGH */ in set_brg()
725 or(scc,R14,BRENABL); /* enable baudrate generator */ in set_brg()
728 static inline void set_speed(struct scc_channel *scc) in set_speed() argument
731 spin_lock_irqsave(&scc->lock, flags); in set_speed()
733 if (scc->modem.speed > 0) /* paranoia... */ in set_speed()
734 set_brg(scc, (unsigned) (scc->clock / (scc->modem.speed * 64)) - 2); in set_speed()
736 spin_unlock_irqrestore(&scc->lock, flags); in set_speed()
742 static inline void init_brg(struct scc_channel *scc) in init_brg() argument
744 wr(scc, R14, BRSRC); /* BRG source = PCLK */ in init_brg()
745 OutReg(scc->ctrl, R14, SSBR|scc->wreg[R14]); /* DPLL source = BRG */ in init_brg()
746 OutReg(scc->ctrl, R14, SNRZI|scc->wreg[R14]); /* DPLL NRZI mode */ in init_brg()
794 static void init_channel(struct scc_channel *scc) in init_channel() argument
796 del_timer(&scc->tx_t); in init_channel()
797 del_timer(&scc->tx_wdog); in init_channel()
799 disable_irq(scc->irq); in init_channel()
801 wr(scc,R4,X1CLK|SDLC); /* *1 clock, SDLC mode */ in init_channel()
802 wr(scc,R1,0); /* no W/REQ operation */ in init_channel()
803 wr(scc,R3,Rx8|RxCRC_ENAB); /* RX 8 bits/char, CRC, disabled */ in init_channel()
804 wr(scc,R5,Tx8|DTR|TxCRC_ENAB); /* TX 8 bits/char, disabled, DTR */ in init_channel()
805 wr(scc,R6,0); /* SDLC address zero (not used) */ in init_channel()
806 wr(scc,R7,FLAG); /* SDLC flag value */ in init_channel()
807 wr(scc,R9,VIS); /* vector includes status */ in init_channel()
808 …wr(scc,R10,(scc->modem.nrz? NRZ : NRZI)|CRCPS|ABUNDER); /* abort on underrun, preset CRC generator… in init_channel()
809 wr(scc,R14, 0); in init_channel()
838 switch(scc->modem.clocksrc) in init_channel()
841 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP); in init_channel()
842 init_brg(scc); in init_channel()
846 wr(scc, R11, ((scc->brand & BAYCOM)? TRxCDP : TRxCBR) | RCDPLL|TCRTxCP|TRxCOI); in init_channel()
847 init_brg(scc); in init_channel()
851 wr(scc, R11, (scc->brand & BAYCOM)? RCTRxCP|TCRTxCP : RCRTxCP|TCTRxCP); in init_channel()
852 OutReg(scc->ctrl, R14, DISDPLL); in init_channel()
857 set_speed(scc); /* set baudrate */ in init_channel()
859 if(scc->enhanced) in init_channel()
861 or(scc,R15,SHDLCE|FIFOE); /* enable FIFO, SDLC/HDLC Enhancements (From now R7 is R7') */ in init_channel()
862 wr(scc,R7,AUTOEOM); in init_channel()
865 if(scc->kiss.softdcd || (InReg(scc->ctrl,R0) & DCD)) in init_channel()
868 start_hunt(scc); in init_channel()
873 wr(scc,R15, BRKIE|TxUIE|(scc->kiss.softdcd? SYNCIE:DCDIE)); in init_channel()
875 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in init_channel()
876 Outb(scc->ctrl,RES_EXT_INT); /* must be done twice */ in init_channel()
878 or(scc,R1,INT_ALL_Rx|TxINT_ENAB|EXT_INT_ENAB); /* enable interrupts */ in init_channel()
880 scc->status = InReg(scc->ctrl,R0); /* read initial status */ in init_channel()
882 or(scc,R9,MIE); /* master interrupt enable */ in init_channel()
884 scc_init_timer(scc); in init_channel()
886 enable_irq(scc->irq); in init_channel()
900 static void scc_key_trx(struct scc_channel *scc, char tx) in scc_key_trx() argument
904 if (scc->brand & PRIMUS) in scc_key_trx()
905 Outb(scc->ctrl + 4, scc->option | (tx? 0x80 : 0)); in scc_key_trx()
907 if (scc->modem.speed < 300) in scc_key_trx()
908 scc->modem.speed = 1200; in scc_key_trx()
910 time_const = (unsigned) (scc->clock / (scc->modem.speed * (tx? 2:64))) - 2; in scc_key_trx()
912 disable_irq(scc->irq); in scc_key_trx()
916 or(scc, R1, TxINT_ENAB); /* t_maxkeyup may have reset these */ in scc_key_trx()
917 or(scc, R15, TxUIE); in scc_key_trx()
920 if (scc->modem.clocksrc == CLK_DPLL) in scc_key_trx()
925 cl(scc, R3, RxENABLE|ENT_HM); /* switch off receiver */ in scc_key_trx()
926 cl(scc, R15, DCDIE|SYNCIE); /* No DCD changes, please */ in scc_key_trx()
928 set_brg(scc, time_const); /* reprogram baudrate generator */ in scc_key_trx()
931 wr(scc, R11, RCDPLL|TCBR|TRxCOI|TRxCBR); in scc_key_trx()
934 if (scc->kiss.tx_inhibit) in scc_key_trx()
936 or(scc,R5, TxENAB); in scc_key_trx()
937 scc->wreg[R5] |= RTS; in scc_key_trx()
939 or(scc,R5,RTS|TxENAB); /* set the RTS line and enable TX */ in scc_key_trx()
942 cl(scc,R5,RTS|TxENAB); in scc_key_trx()
944 set_brg(scc, time_const); /* reprogram baudrate generator */ in scc_key_trx()
947 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP); in scc_key_trx()
950 if (scc->kiss.softdcd) in scc_key_trx()
953 or(scc,R15, scc->kiss.softdcd? SYNCIE:DCDIE); in scc_key_trx()
954 start_hunt(scc); in scc_key_trx()
961 if (scc->kiss.fulldup == KISS_DUPLEX_HALF) in scc_key_trx()
963 cl(scc, R3, RxENABLE); in scc_key_trx()
964 cl(scc, R15, DCDIE|SYNCIE); in scc_key_trx()
968 if (scc->kiss.tx_inhibit) in scc_key_trx()
970 or(scc,R5, TxENAB); in scc_key_trx()
971 scc->wreg[R5] |= RTS; in scc_key_trx()
973 or(scc,R5,RTS|TxENAB); /* enable tx */ in scc_key_trx()
976 cl(scc,R5,RTS|TxENAB); /* disable tx */ in scc_key_trx()
978 if ((scc->kiss.fulldup == KISS_DUPLEX_HALF) && in scc_key_trx()
980 scc->kiss.softdcd) in scc_key_trx()
985 or(scc, R15, scc->kiss.softdcd? SYNCIE:DCDIE); in scc_key_trx()
986 start_hunt(scc); in scc_key_trx()
991 enable_irq(scc->irq); in scc_key_trx()
997 static void __scc_start_tx_timer(struct scc_channel *scc, in __scc_start_tx_timer() argument
1001 del_timer(&scc->tx_t); in __scc_start_tx_timer()
1005 handler(&scc->tx_t); in __scc_start_tx_timer()
1009 scc->tx_t.function = handler; in __scc_start_tx_timer()
1010 scc->tx_t.expires = jiffies + (when*HZ)/100; in __scc_start_tx_timer()
1011 add_timer(&scc->tx_t); in __scc_start_tx_timer()
1015 static void scc_start_tx_timer(struct scc_channel *scc, in scc_start_tx_timer() argument
1021 spin_lock_irqsave(&scc->lock, flags); in scc_start_tx_timer()
1022 __scc_start_tx_timer(scc, handler, when); in scc_start_tx_timer()
1023 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_tx_timer()
1026 static void scc_start_defer(struct scc_channel *scc) in scc_start_defer() argument
1030 spin_lock_irqsave(&scc->lock, flags); in scc_start_defer()
1031 del_timer(&scc->tx_wdog); in scc_start_defer()
1033 if (scc->kiss.maxdefer != 0 && scc->kiss.maxdefer != TIMER_OFF) in scc_start_defer()
1035 scc->tx_wdog.function = t_busy; in scc_start_defer()
1036 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxdefer; in scc_start_defer()
1037 add_timer(&scc->tx_wdog); in scc_start_defer()
1039 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_defer()
1042 static void scc_start_maxkeyup(struct scc_channel *scc) in scc_start_maxkeyup() argument
1046 spin_lock_irqsave(&scc->lock, flags); in scc_start_maxkeyup()
1047 del_timer(&scc->tx_wdog); in scc_start_maxkeyup()
1049 if (scc->kiss.maxkeyup != 0 && scc->kiss.maxkeyup != TIMER_OFF) in scc_start_maxkeyup()
1051 scc->tx_wdog.function = t_maxkeyup; in scc_start_maxkeyup()
1052 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxkeyup; in scc_start_maxkeyup()
1053 add_timer(&scc->tx_wdog); in scc_start_maxkeyup()
1055 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_maxkeyup()
1063 static void scc_tx_done(struct scc_channel *scc) in scc_tx_done() argument
1069 switch (scc->kiss.fulldup) in scc_tx_done()
1072 scc->stat.tx_state = TXS_IDLE2; in scc_tx_done()
1073 if (scc->kiss.idletime != TIMER_OFF) in scc_tx_done()
1074 scc_start_tx_timer(scc, t_idle, in scc_tx_done()
1075 scc->kiss.idletime*100); in scc_tx_done()
1078 scc_notify(scc, HWEV_ALL_SENT); in scc_tx_done()
1081 scc->stat.tx_state = TXS_BUSY; in scc_tx_done()
1082 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in scc_tx_done()
1085 netif_wake_queue(scc->dev); in scc_tx_done()
1091 static inline int is_grouped(struct scc_channel *scc) in is_grouped() argument
1097 grp1 = scc->kiss.group; in is_grouped()
1104 if (scc2 == scc || !(scc2->dev && grp2)) in is_grouped()
1129 struct scc_channel *scc = from_timer(scc, t, tx_t); in t_dwait() local
1131 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */ in t_dwait()
1133 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */ in t_dwait()
1134 scc->stat.tx_state = TXS_IDLE; in t_dwait()
1135 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */ in t_dwait()
1139 scc->stat.tx_state = TXS_BUSY; in t_dwait()
1142 if (scc->kiss.fulldup == KISS_DUPLEX_HALF) in t_dwait()
1146 if (scc->dcd || (scc->kiss.persist) < Rand || (scc->kiss.group && is_grouped(scc)) ) in t_dwait()
1148 scc_start_defer(scc); in t_dwait()
1149 scc_start_tx_timer(scc, t_dwait, scc->kiss.slottime); in t_dwait()
1154 if ( !(scc->wreg[R5] & RTS) ) in t_dwait()
1156 scc_key_trx(scc, TX_ON); in t_dwait()
1157 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay); in t_dwait()
1159 scc_start_tx_timer(scc, t_txdelay, 0); in t_dwait()
1171 struct scc_channel *scc = from_timer(scc, t, tx_t); in t_txdelay() local
1173 scc_start_maxkeyup(scc); in t_txdelay()
1175 if (scc->tx_buff == NULL) in t_txdelay()
1177 disable_irq(scc->irq); in t_txdelay()
1178 scc_txint(scc); in t_txdelay()
1179 enable_irq(scc->irq); in t_txdelay()
1192 struct scc_channel *scc = from_timer(scc, t, tx_t); in t_tail() local
1195 spin_lock_irqsave(&scc->lock, flags); in t_tail()
1196 del_timer(&scc->tx_wdog); in t_tail()
1197 scc_key_trx(scc, TX_OFF); in t_tail()
1198 spin_unlock_irqrestore(&scc->lock, flags); in t_tail()
1200 if (scc->stat.tx_state == TXS_TIMEOUT) /* we had a timeout? */ in t_tail()
1202 scc->stat.tx_state = TXS_WAIT; in t_tail()
1203 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100); in t_tail()
1207 scc->stat.tx_state = TXS_IDLE; in t_tail()
1208 netif_wake_queue(scc->dev); in t_tail()
1219 struct scc_channel *scc = from_timer(scc, t, tx_wdog); in t_busy() local
1221 del_timer(&scc->tx_t); in t_busy()
1222 netif_stop_queue(scc->dev); /* don't pile on the wabbit! */ in t_busy()
1224 scc_discard_buffers(scc); in t_busy()
1225 scc->stat.txerrs++; in t_busy()
1226 scc->stat.tx_state = TXS_IDLE; in t_busy()
1228 netif_wake_queue(scc->dev); in t_busy()
1238 struct scc_channel *scc = from_timer(scc, t, tx_wdog); in t_maxkeyup() local
1241 spin_lock_irqsave(&scc->lock, flags); in t_maxkeyup()
1247 netif_stop_queue(scc->dev); in t_maxkeyup()
1248 scc_discard_buffers(scc); in t_maxkeyup()
1250 del_timer(&scc->tx_t); in t_maxkeyup()
1252 cl(scc, R1, TxINT_ENAB); /* force an ABORT, but don't */ in t_maxkeyup()
1253 cl(scc, R15, TxUIE); /* count it. */ in t_maxkeyup()
1254 OutReg(scc->ctrl, R0, RES_Tx_P); in t_maxkeyup()
1256 spin_unlock_irqrestore(&scc->lock, flags); in t_maxkeyup()
1258 scc->stat.txerrs++; in t_maxkeyup()
1259 scc->stat.tx_state = TXS_TIMEOUT; in t_maxkeyup()
1260 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in t_maxkeyup()
1272 struct scc_channel *scc = from_timer(scc, t, tx_t); in t_idle() local
1274 del_timer(&scc->tx_wdog); in t_idle()
1276 scc_key_trx(scc, TX_OFF); in t_idle()
1277 if(scc->kiss.mintime) in t_idle()
1278 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100); in t_idle()
1279 scc->stat.tx_state = TXS_WAIT; in t_idle()
1282 static void scc_init_timer(struct scc_channel *scc) in scc_init_timer() argument
1286 spin_lock_irqsave(&scc->lock, flags); in scc_init_timer()
1287 scc->stat.tx_state = TXS_IDLE; in scc_init_timer()
1288 spin_unlock_irqrestore(&scc->lock, flags); in scc_init_timer()
1303 static unsigned int scc_set_param(struct scc_channel *scc, unsigned int cmd, unsigned int arg) in scc_set_param() argument
1307 case PARAM_TXDELAY: scc->kiss.txdelay=arg; break; in scc_set_param()
1308 case PARAM_PERSIST: scc->kiss.persist=arg; break; in scc_set_param()
1309 case PARAM_SLOTTIME: scc->kiss.slottime=arg; break; in scc_set_param()
1310 case PARAM_TXTAIL: scc->kiss.tailtime=arg; break; in scc_set_param()
1311 case PARAM_FULLDUP: scc->kiss.fulldup=arg; break; in scc_set_param()
1313 case PARAM_GROUP: scc->kiss.group=arg; break; in scc_set_param()
1314 case PARAM_IDLE: scc->kiss.idletime=arg; break; in scc_set_param()
1315 case PARAM_MIN: scc->kiss.mintime=arg; break; in scc_set_param()
1316 case PARAM_MAXKEY: scc->kiss.maxkeyup=arg; break; in scc_set_param()
1317 case PARAM_WAIT: scc->kiss.waittime=arg; break; in scc_set_param()
1318 case PARAM_MAXDEFER: scc->kiss.maxdefer=arg; break; in scc_set_param()
1319 case PARAM_TX: scc->kiss.tx_inhibit=arg; break; in scc_set_param()
1322 scc->kiss.softdcd=arg; in scc_set_param()
1325 or(scc, R15, SYNCIE); in scc_set_param()
1326 cl(scc, R15, DCDIE); in scc_set_param()
1327 start_hunt(scc); in scc_set_param()
1329 or(scc, R15, DCDIE); in scc_set_param()
1330 cl(scc, R15, SYNCIE); in scc_set_param()
1336 scc->modem.speed=arg*100; in scc_set_param()
1338 scc->modem.speed=arg; in scc_set_param()
1340 if (scc->stat.tx_state == 0) /* only switch baudrate on rx... ;-) */ in scc_set_param()
1341 set_speed(scc); in scc_set_param()
1345 if ( !(scc->wreg[R5] & RTS) ) in scc_set_param()
1348 scc_key_trx(scc, TX_ON); in scc_set_param()
1349 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay); in scc_set_param()
1354 scc->stat.tx_state = TXS_BUSY; in scc_set_param()
1355 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in scc_set_param()
1361 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF); in scc_set_param()
1372 static unsigned long scc_get_param(struct scc_channel *scc, unsigned int cmd) in scc_get_param() argument
1376 case PARAM_TXDELAY: return CAST(scc->kiss.txdelay); in scc_get_param()
1377 case PARAM_PERSIST: return CAST(scc->kiss.persist); in scc_get_param()
1378 case PARAM_SLOTTIME: return CAST(scc->kiss.slottime); in scc_get_param()
1379 case PARAM_TXTAIL: return CAST(scc->kiss.tailtime); in scc_get_param()
1380 case PARAM_FULLDUP: return CAST(scc->kiss.fulldup); in scc_get_param()
1381 case PARAM_SOFTDCD: return CAST(scc->kiss.softdcd); in scc_get_param()
1382 case PARAM_DTR: return CAST((scc->wreg[R5] & DTR)? 1:0); in scc_get_param()
1383 case PARAM_RTS: return CAST((scc->wreg[R5] & RTS)? 1:0); in scc_get_param()
1384 case PARAM_SPEED: return CAST(scc->modem.speed); in scc_get_param()
1385 case PARAM_GROUP: return CAST(scc->kiss.group); in scc_get_param()
1386 case PARAM_IDLE: return CAST(scc->kiss.idletime); in scc_get_param()
1387 case PARAM_MIN: return CAST(scc->kiss.mintime); in scc_get_param()
1388 case PARAM_MAXKEY: return CAST(scc->kiss.maxkeyup); in scc_get_param()
1389 case PARAM_WAIT: return CAST(scc->kiss.waittime); in scc_get_param()
1390 case PARAM_MAXDEFER: return CAST(scc->kiss.maxdefer); in scc_get_param()
1391 case PARAM_TX: return CAST(scc->kiss.tx_inhibit); in scc_get_param()
1405 struct scc_channel *scc = from_timer(scc, t, tx_wdog); in scc_stop_calibrate() local
1408 spin_lock_irqsave(&scc->lock, flags); in scc_stop_calibrate()
1409 del_timer(&scc->tx_wdog); in scc_stop_calibrate()
1410 scc_key_trx(scc, TX_OFF); in scc_stop_calibrate()
1411 wr(scc, R6, 0); in scc_stop_calibrate()
1412 wr(scc, R7, FLAG); in scc_stop_calibrate()
1413 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in scc_stop_calibrate()
1414 Outb(scc->ctrl,RES_EXT_INT); in scc_stop_calibrate()
1416 netif_wake_queue(scc->dev); in scc_stop_calibrate()
1417 spin_unlock_irqrestore(&scc->lock, flags); in scc_stop_calibrate()
1422 scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern) in scc_start_calibrate() argument
1426 spin_lock_irqsave(&scc->lock, flags); in scc_start_calibrate()
1427 netif_stop_queue(scc->dev); in scc_start_calibrate()
1428 scc_discard_buffers(scc); in scc_start_calibrate()
1430 del_timer(&scc->tx_wdog); in scc_start_calibrate()
1432 scc->tx_wdog.function = scc_stop_calibrate; in scc_start_calibrate()
1433 scc->tx_wdog.expires = jiffies + HZ*duration; in scc_start_calibrate()
1434 add_timer(&scc->tx_wdog); in scc_start_calibrate()
1437 wr(scc, R6, 0); in scc_start_calibrate()
1438 wr(scc, R7, pattern); in scc_start_calibrate()
1445 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in scc_start_calibrate()
1446 Outb(scc->ctrl,RES_EXT_INT); in scc_start_calibrate()
1448 scc_key_trx(scc, TX_ON); in scc_start_calibrate()
1449 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_calibrate()
1462 struct scc_channel *scc; in z8530_init() local
1483 scc=&SCC_Info[2*chip]; in z8530_init()
1484 if (!scc->ctrl) continue; in z8530_init()
1488 if(scc->brand & EAGLE) /* this is an EAGLE card */ in z8530_init()
1489 Outb(scc->special,0x08); /* enable interrupt on the board */ in z8530_init()
1491 if(scc->brand & (PC100 | PRIMUS)) /* this is a PC100/PRIMUS card */ in z8530_init()
1492 Outb(scc->special,scc->option); /* set the MODEM mode (0x22) */ in z8530_init()
1497 spin_lock_irqsave(&scc->lock, flags); in z8530_init()
1499 Outb(scc->ctrl, 0); in z8530_init()
1500 OutReg(scc->ctrl,R9,FHWRES); /* force hardware reset */ in z8530_init()
1502 wr(scc, R2, chip*16); /* interrupt vector */ in z8530_init()
1503 wr(scc, R9, VIS); /* vector includes status */ in z8530_init()
1504 spin_unlock_irqrestore(&scc->lock, flags); in z8530_init()
1515 static int scc_net_alloc(const char *name, struct scc_channel *scc) in scc_net_alloc() argument
1524 dev->ml_priv = scc; in scc_net_alloc()
1525 scc->dev = dev; in scc_net_alloc()
1526 spin_lock_init(&scc->lock); in scc_net_alloc()
1527 timer_setup(&scc->tx_t, NULL, 0); in scc_net_alloc()
1528 timer_setup(&scc->tx_wdog, NULL, 0); in scc_net_alloc()
1535 scc->dev = NULL; in scc_net_alloc()
1582 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_open() local
1584 if (!scc->init) in scc_net_open()
1587 scc->tx_buff = NULL; in scc_net_open()
1588 skb_queue_head_init(&scc->tx_queue); in scc_net_open()
1590 init_channel(scc); in scc_net_open()
1600 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_close() local
1605 spin_lock_irqsave(&scc->lock, flags); in scc_net_close()
1606 Outb(scc->ctrl,0); /* Make sure pointer is written */ in scc_net_close()
1607 wr(scc,R1,0); /* disable interrupts */ in scc_net_close()
1608 wr(scc,R3,0); in scc_net_close()
1609 spin_unlock_irqrestore(&scc->lock, flags); in scc_net_close()
1611 del_timer_sync(&scc->tx_t); in scc_net_close()
1612 del_timer_sync(&scc->tx_wdog); in scc_net_close()
1614 scc_discard_buffers(scc); in scc_net_close()
1621 static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb) in scc_net_rx() argument
1628 scc->dev_stat.rx_packets++; in scc_net_rx()
1629 scc->dev_stat.rx_bytes += skb->len; in scc_net_rx()
1631 skb->protocol = ax25_type_trans(skb, scc->dev); in scc_net_rx()
1640 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_tx() local
1647 if (skb->len > scc->stat.bufsize || skb->len < 2) { in scc_net_tx()
1648 scc->dev_stat.tx_dropped++; /* bogus frame */ in scc_net_tx()
1653 scc->dev_stat.tx_packets++; in scc_net_tx()
1654 scc->dev_stat.tx_bytes += skb->len; in scc_net_tx()
1655 scc->stat.txframes++; in scc_net_tx()
1661 scc_set_param(scc, kisscmd, *skb->data); in scc_net_tx()
1666 spin_lock_irqsave(&scc->lock, flags); in scc_net_tx()
1668 if (skb_queue_len(&scc->tx_queue) > scc->dev->tx_queue_len) { in scc_net_tx()
1670 skb_del = skb_dequeue(&scc->tx_queue); in scc_net_tx()
1673 skb_queue_tail(&scc->tx_queue, skb); in scc_net_tx()
1683 if(scc->stat.tx_state == TXS_IDLE || scc->stat.tx_state == TXS_IDLE2) { in scc_net_tx()
1684 scc->stat.tx_state = TXS_BUSY; in scc_net_tx()
1685 if (scc->kiss.fulldup == KISS_DUPLEX_HALF) in scc_net_tx()
1686 __scc_start_tx_timer(scc, t_dwait, scc->kiss.waittime); in scc_net_tx()
1688 __scc_start_tx_timer(scc, t_dwait, 0); in scc_net_tx()
1690 spin_unlock_irqrestore(&scc->lock, flags); in scc_net_tx()
1714 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_siocdevprivate() local
1851 if (!scc->init) in scc_net_siocdevprivate()
1858 scc->stat.bufsize = SCC_BUFSIZE; in scc_net_siocdevprivate()
1860 if (copy_from_user(&scc->modem, arg, sizeof(struct scc_modem))) in scc_net_siocdevprivate()
1865 if (scc->modem.speed < 4800) in scc_net_siocdevprivate()
1867 scc->kiss.txdelay = 36; /* 360 ms */ in scc_net_siocdevprivate()
1868 scc->kiss.persist = 42; /* 25% persistence */ /* was 25 */ in scc_net_siocdevprivate()
1869 scc->kiss.slottime = 16; /* 160 ms */ in scc_net_siocdevprivate()
1870 scc->kiss.tailtime = 4; /* minimal reasonable value */ in scc_net_siocdevprivate()
1871 scc->kiss.fulldup = 0; /* CSMA */ in scc_net_siocdevprivate()
1872 scc->kiss.waittime = 50; /* 500 ms */ in scc_net_siocdevprivate()
1873 scc->kiss.maxkeyup = 10; /* 10 s */ in scc_net_siocdevprivate()
1874 scc->kiss.mintime = 3; /* 3 s */ in scc_net_siocdevprivate()
1875 scc->kiss.idletime = 30; /* 30 s */ in scc_net_siocdevprivate()
1876 scc->kiss.maxdefer = 120; /* 2 min */ in scc_net_siocdevprivate()
1877 scc->kiss.softdcd = 0; /* hardware dcd */ in scc_net_siocdevprivate()
1879 scc->kiss.txdelay = 10; /* 100 ms */ in scc_net_siocdevprivate()
1880 scc->kiss.persist = 64; /* 25% persistence */ /* was 25 */ in scc_net_siocdevprivate()
1881 scc->kiss.slottime = 8; /* 160 ms */ in scc_net_siocdevprivate()
1882 scc->kiss.tailtime = 1; /* minimal reasonable value */ in scc_net_siocdevprivate()
1883 scc->kiss.fulldup = 0; /* CSMA */ in scc_net_siocdevprivate()
1884 scc->kiss.waittime = 50; /* 500 ms */ in scc_net_siocdevprivate()
1885 scc->kiss.maxkeyup = 7; /* 7 s */ in scc_net_siocdevprivate()
1886 scc->kiss.mintime = 3; /* 3 s */ in scc_net_siocdevprivate()
1887 scc->kiss.idletime = 30; /* 30 s */ in scc_net_siocdevprivate()
1888 scc->kiss.maxdefer = 120; /* 2 min */ in scc_net_siocdevprivate()
1889 scc->kiss.softdcd = 0; /* hardware dcd */ in scc_net_siocdevprivate()
1892 scc->tx_buff = NULL; in scc_net_siocdevprivate()
1893 skb_queue_head_init(&scc->tx_queue); in scc_net_siocdevprivate()
1894 scc->init = 1; in scc_net_siocdevprivate()
1911 scc->stat.bufsize = memcfg.bufsize; in scc_net_siocdevprivate()
1915 if (!arg || copy_to_user(arg, &scc->stat, sizeof(scc->stat))) in scc_net_siocdevprivate()
1922 kiss_cmd.param = scc_get_param(scc, kiss_cmd.command); in scc_net_siocdevprivate()
1931 return scc_set_param(scc, kiss_cmd.command, kiss_cmd.param); in scc_net_siocdevprivate()
1938 scc_start_calibrate(scc, cal.time, cal.pattern); in scc_net_siocdevprivate()
1962 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_get_stats() local
1964 scc->dev_stat.rx_errors = scc->stat.rxerrs + scc->stat.rx_over; in scc_net_get_stats()
1965 scc->dev_stat.tx_errors = scc->stat.txerrs + scc->stat.tx_under; in scc_net_get_stats()
1966 scc->dev_stat.rx_fifo_errors = scc->stat.rx_over; in scc_net_get_stats()
1967 scc->dev_stat.tx_fifo_errors = scc->stat.tx_under; in scc_net_get_stats()
1969 return &scc->dev_stat; in scc_net_get_stats()
2000 struct scc_channel *scc = v; in scc_net_seq_next() local
2003 for (k = (v == SEQ_START_TOKEN) ? 0 : (scc - SCC_Info)+1; in scc_net_seq_next()
2024 const struct scc_channel *scc = v; in scc_net_seq_show() local
2025 const struct scc_stat *stat = &scc->stat; in scc_net_seq_show()
2026 const struct scc_kiss *kiss = &scc->kiss; in scc_net_seq_show()
2039 scc->dev->name, in scc_net_seq_show()
2040 scc->data, scc->ctrl, scc->irq, scc->clock, scc->brand, in scc_net_seq_show()
2041 scc->enhanced, Vector_Latch, scc->special, in scc_net_seq_show()
2042 scc->option); in scc_net_seq_show()
2044 scc->modem.speed, scc->modem.nrz, in scc_net_seq_show()
2045 scc->modem.clocksrc, kiss->softdcd, in scc_net_seq_show()
2066 seq_printf(seq, "%2.2x ", scc->wreg[reg]); in scc_net_seq_show()
2069 seq_printf(seq, "\tR %2.2x %2.2x XX ", InReg(scc->ctrl,R0), InReg(scc->ctrl,R1)); in scc_net_seq_show()
2071 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg)); in scc_net_seq_show()
2074 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg)); in scc_net_seq_show()
2122 struct scc_channel *scc; in scc_cleanup_driver() local
2151 scc = &SCC_Info[k]; in scc_cleanup_driver()
2152 if (scc->ctrl) in scc_cleanup_driver()
2154 release_region(scc->ctrl, 1); in scc_cleanup_driver()
2155 release_region(scc->data, 1); in scc_cleanup_driver()
2157 if (scc->dev) in scc_cleanup_driver()
2159 unregister_netdev(scc->dev); in scc_cleanup_driver()
2160 free_netdev(scc->dev); in scc_cleanup_driver()