Lines Matching +full:tx +full:- +full:d +full:- +full:cal

6  * Please use z8530drv-utils-3.0 with this version.
7 * ------------------
15 * SCC.C - Linux driver for Z8530 based HDLC cards for AX.25 *
28 The code is likely to fail, and so your kernel could --- even
38 ! receive. The GPL allows you to use the d r i v e r, NOT the RADIO! !
40 For non-Amateur-Radio use please note that you might need a special
60 -------------------------------
62 1994-09-13 started to write the driver, rescued most of my own
71 1995-01-31 changed copyright notice to GPL without limitations.
77 1996-10-05 New semester, new driver...
85 * Invents brand new bugs... ;-)
90 1996-12-13 Fixed for Linux networking changes. (G4KLX)
91 1997-01-08 Fixed the remaining problems.
92 1997-04-02 Hopefully fixed the problems with the new *_timer()
94 1997-10-12 Made SCC_DELAY a CONFIG option, added CONFIG_SCC_TRXECHO
95 1998-01-29 Small fix to avoid lock-up on initialization
96 1998-09-29 Fixed the "grouping" bugs, tx_inhibit works again,
97 using dev->tx_queue_len now instead of MAXQUEUE now.
98 1998-10-21 Postponed the spinlock changes, would need a lot of
101 1998-11-04 Softdcd does not work correctly in DPLL mode, in fact it
106 2000-02-13 Fixed for new network driver interface changes, still
107 does TX timeouts itself since it uses its own queue
113 NB -- if you find errors, change something, please let me know
121 New versions of the driver will be announced on the linux-hams
122 mailing list on vger.kernel.org. To subscribe send an e-mail
126 subscribe linux-hams
131 Joerg Reuter ampr-net: dl1bke@db0pra.ampr.org
132 AX-25 : DL1BKE @ DB0ABH.#BAY.DEU.EU
137 /* ----------------------------------------------------------------------- */
149 /* ----------------------------------------------------------------------- */
204 static void scc_key_trx (struct scc_channel *scc, char tx);
240 /* These provide interrupt save 2-step access to the Z8530 registers */
281 OutReg(scc->ctrl, reg, (scc->wreg[reg] = val)); in wr()
286 OutReg(scc->ctrl, reg, (scc->wreg[reg] |= val)); in or()
291 OutReg(scc->ctrl, reg, (scc->wreg[reg] &= ~val)); in cl()
302 spin_lock_irqsave(&scc->lock, flags); in scc_discard_buffers()
303 if (scc->tx_buff != NULL) in scc_discard_buffers()
305 dev_kfree_skb_irq(scc->tx_buff); in scc_discard_buffers()
306 scc->tx_buff = NULL; in scc_discard_buffers()
309 while (!skb_queue_empty(&scc->tx_queue)) in scc_discard_buffers()
310 dev_kfree_skb_irq(skb_dequeue(&scc->tx_queue)); in scc_discard_buffers()
312 spin_unlock_irqrestore(&scc->lock, flags); in scc_discard_buffers()
322 /* ----> subroutines for the interrupt handlers <---- */
329 if (scc->kiss.fulldup != KISS_DUPLEX_OPTIMA) in scc_notify()
340 scc->stat.nospace++; in scc_notify()
348 Inb(scc->data); in flush_rx_FIFO()
350 if(scc->rx_buff != NULL) /* did we receive something? */ in flush_rx_FIFO()
352 scc->stat.rxerrs++; /* then count it as an error */ in flush_rx_FIFO()
353 dev_kfree_skb_irq(scc->rx_buff); in flush_rx_FIFO()
354 scc->rx_buff = NULL; in flush_rx_FIFO()
360 if ((scc->modem.clocksrc != CLK_EXTERNAL)) in start_hunt()
361 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */ in start_hunt()
365 /* ----> four different interrupt handlers for Tx, Rx, changing of */
366 /* DCD/CTS and Rx/Tx errors */
373 scc->stat.txints++; in scc_txint()
374 skb = scc->tx_buff; in scc_txint()
380 skb = skb_dequeue(&scc->tx_queue); in scc_txint()
381 scc->tx_buff = skb; in scc_txint()
382 netif_wake_queue(scc->dev); in scc_txint()
387 Outb(scc->ctrl, RES_Tx_P); in scc_txint()
391 if (skb->len == 0) /* Paranoia... */ in scc_txint()
394 scc->tx_buff = NULL; in scc_txint()
396 Outb(scc->ctrl, RES_Tx_P); in scc_txint()
400 scc->stat.tx_state = TXS_ACTIVE; in scc_txint()
402 OutReg(scc->ctrl, R0, RES_Tx_CRC); in scc_txint()
404 or(scc,R10,ABUNDER); /* re-install underrun protection */ in scc_txint()
405 Outb(scc->data,*skb->data); /* send byte */ in scc_txint()
408 if (!scc->enhanced) /* reset EOM latch */ in scc_txint()
409 Outb(scc->ctrl,RES_EOM_L); in scc_txint()
415 if (skb->len == 0) in scc_txint()
417 Outb(scc->ctrl, RES_Tx_P); /* reset pending int */ in scc_txint()
420 scc->tx_buff = NULL; in scc_txint()
421 scc->stat.tx_state = TXS_NEWFRAME; /* next frame... */ in scc_txint()
427 Outb(scc->data,*skb->data); in scc_txint()
437 scc->stat.exints++; in scc_exint()
439 status = InReg(scc->ctrl,R0); in scc_exint()
440 changes = status ^ scc->status; in scc_exint()
450 if ((changes & SYNC_HUNT) && scc->kiss.softdcd) in scc_exint()
454 scc->dcd = 0; in scc_exint()
456 if ((scc->modem.clocksrc != CLK_EXTERNAL)) in scc_exint()
457 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */ in scc_exint()
459 scc->dcd = 1; in scc_exint()
462 scc_notify(scc, scc->dcd? HWEV_DCD_OFF:HWEV_DCD_ON); in scc_exint()
468 if((changes & DCD) && !scc->kiss.softdcd) /* DCD input changed state */ in scc_exint()
473 scc->dcd = 1; in scc_exint()
477 scc->dcd = 0; in scc_exint()
480 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF); in scc_exint()
492 if (scc->kiss.txdelay == 0) /* zero TXDELAY = wait for CTS */ in scc_exint()
497 if (scc->stat.tx_state == TXS_ACTIVE && (status & TxEOM)) in scc_exint()
499 scc->stat.tx_under++; /* oops, an underrun! count 'em */ in scc_exint()
500 Outb(scc->ctrl, RES_EXT_INT); /* reset ext/status interrupts */ in scc_exint()
502 if (scc->tx_buff != NULL) in scc_exint()
504 dev_kfree_skb_irq(scc->tx_buff); in scc_exint()
505 scc->tx_buff = NULL; in scc_exint()
512 scc->status = status; in scc_exint()
513 Outb(scc->ctrl,RES_EXT_INT); in scc_exint()
522 scc->stat.rxints++; in scc_rxint()
524 if((scc->wreg[5] & RTS) && scc->kiss.fulldup == KISS_DUPLEX_HALF) in scc_rxint()
526 Inb(scc->data); /* discard char */ in scc_rxint()
531 skb = scc->rx_buff; in scc_rxint()
535 skb = dev_alloc_skb(scc->stat.bufsize); in scc_rxint()
538 scc->dev_stat.rx_dropped++; in scc_rxint()
539 scc->stat.nospace++; in scc_rxint()
540 Inb(scc->data); in scc_rxint()
545 scc->rx_buff = skb; in scc_rxint()
549 if (skb->len >= scc->stat.bufsize) in scc_rxint()
555 scc->rx_buff = NULL; in scc_rxint()
556 Inb(scc->data); in scc_rxint()
561 skb_put_u8(skb, Inb(scc->data)); in scc_rxint()
571 scc->stat.spints++; in scc_spint()
573 status = InReg(scc->ctrl,R1); /* read receiver status */ in scc_spint()
575 Inb(scc->data); /* throw away Rx byte */ in scc_spint()
576 skb = scc->rx_buff; in scc_spint()
580 scc->stat.rx_over++; /* count them */ in scc_spint()
585 scc->rx_buff = skb = NULL; in scc_spint()
592 if (!(status & CRC_ERR) && (status & 0xe) == RES8 && skb->len > 0) in scc_spint()
595 skb_trim(skb, skb->len-1); in scc_spint()
597 scc->rx_buff = NULL; in scc_spint()
598 scc->stat.rxframes++; in scc_spint()
601 scc->rx_buff = NULL; in scc_spint()
602 scc->stat.rxerrs++; in scc_spint()
606 Outb(scc->ctrl,ERR_RES); in scc_spint()
610 /* ----> interrupt service routine for the Z8530 <---- */
614 spin_lock(&scc->lock); in scc_isr_dispatch()
622 spin_unlock(&scc->lock); in scc_isr_dispatch()
651 if (!scc->dev) break; in scc_isr()
655 OutReg(scc->ctrl,R0,RES_H_IUS); /* Reset Highest IUS */ in scc_isr()
669 while (ctrl->chan_A) in scc_isr()
671 if (ctrl->irq != chip_irq) in scc_isr()
678 for (k = 0; InReg(ctrl->chan_A,R3) && k < SCC_IRQTIMEOUT; k++) in scc_isr()
680 vector=InReg(ctrl->chan_B,R2); /* Read the vector */ in scc_isr()
684 if (!scc->dev) break; in scc_isr()
704 OutReg(scc->ctrl,R0,RES_H_IUS); in scc_isr()
719 /* ----> set SCC channel speed <---- */
732 spin_lock_irqsave(&scc->lock, flags); in set_speed()
734 if (scc->modem.speed > 0) /* paranoia... */ in set_speed()
735 set_brg(scc, (unsigned) (scc->clock / (scc->modem.speed * 64)) - 2); in set_speed()
737 spin_unlock_irqrestore(&scc->lock, flags); in set_speed()
741 /* ----> initialize a SCC channel <---- */
746 OutReg(scc->ctrl, R14, SSBR|scc->wreg[R14]); /* DPLL source = BRG */ in init_brg()
747 OutReg(scc->ctrl, R14, SNRZI|scc->wreg[R14]); /* DPLL NRZI mode */ in init_brg()
751 * Initialization according to the Z8530 manual (SGS-Thomson's version):
756 * WR4 XXXXXXXX Tx/Rx control, async or sync mode
760 * WR5 XXXX0XXX select Tx control
775 * WR5 SSSS1SSS Tx enable
776 * WR0 10000000 reset Tx CRG (optional)
784 * WR1 SSSXXSXX enable Rx, Tx and Ext/status
797 del_timer(&scc->tx_t); in init_channel()
798 del_timer(&scc->tx_wdog); in init_channel()
800 disable_irq(scc->irq); in init_channel()
805 wr(scc,R5,Tx8|DTR|TxCRC_ENAB); /* TX 8 bits/char, disabled, DTR */ in init_channel()
809 …wr(scc,R10,(scc->modem.nrz? NRZ : NRZI)|CRCPS|ABUNDER); /* abort on underrun, preset CRC generator… in init_channel()
839 switch(scc->modem.clocksrc) in init_channel()
847 wr(scc, R11, ((scc->brand & BAYCOM)? TRxCDP : TRxCBR) | RCDPLL|TCRTxCP|TRxCOI); in init_channel()
852 wr(scc, R11, (scc->brand & BAYCOM)? RCTRxCP|TCRTxCP : RCRTxCP|TCTRxCP); in init_channel()
853 OutReg(scc->ctrl, R14, DISDPLL); in init_channel()
860 if(scc->enhanced) in init_channel()
866 if(scc->kiss.softdcd || (InReg(scc->ctrl,R0) & DCD)) in init_channel()
874 wr(scc,R15, BRKIE|TxUIE|(scc->kiss.softdcd? SYNCIE:DCDIE)); in init_channel()
876 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in init_channel()
877 Outb(scc->ctrl,RES_EXT_INT); /* must be done twice */ in init_channel()
881 scc->status = InReg(scc->ctrl,R0); /* read initial status */ in init_channel()
887 enable_irq(scc->irq); in init_channel()
898 /* ----> scc_key_trx sets the time constant for the baudrate
899 generator and keys the transmitter <---- */
901 static void scc_key_trx(struct scc_channel *scc, char tx) in scc_key_trx() argument
905 if (scc->brand & PRIMUS) in scc_key_trx()
906 Outb(scc->ctrl + 4, scc->option | (tx? 0x80 : 0)); in scc_key_trx()
908 if (scc->modem.speed < 300) in scc_key_trx()
909 scc->modem.speed = 1200; in scc_key_trx()
911 time_const = (unsigned) (scc->clock / (scc->modem.speed * (tx? 2:64))) - 2; in scc_key_trx()
913 disable_irq(scc->irq); in scc_key_trx()
915 if (tx) in scc_key_trx()
921 if (scc->modem.clocksrc == CLK_DPLL) in scc_key_trx()
923 if (tx) in scc_key_trx()
931 /* DPLL -> Rx clk, BRG -> Tx CLK, TRxC mode output, TRxC = BRG */ in scc_key_trx()
935 if (scc->kiss.tx_inhibit) in scc_key_trx()
938 scc->wreg[R5] |= RTS; in scc_key_trx()
940 or(scc,R5,RTS|TxENAB); /* set the RTS line and enable TX */ in scc_key_trx()
947 /* DPLL -> Rx clk, DPLL -> Tx CLK, TRxC mode output, TRxC = DPLL */ in scc_key_trx()
951 if (scc->kiss.softdcd) in scc_key_trx()
954 or(scc,R15, scc->kiss.softdcd? SYNCIE:DCDIE); in scc_key_trx()
959 if (tx) in scc_key_trx()
962 if (scc->kiss.fulldup == KISS_DUPLEX_HALF) in scc_key_trx()
969 if (scc->kiss.tx_inhibit) in scc_key_trx()
972 scc->wreg[R5] |= RTS; in scc_key_trx()
974 or(scc,R5,RTS|TxENAB); /* enable tx */ in scc_key_trx()
977 cl(scc,R5,RTS|TxENAB); /* disable tx */ in scc_key_trx()
979 if ((scc->kiss.fulldup == KISS_DUPLEX_HALF) && in scc_key_trx()
981 scc->kiss.softdcd) in scc_key_trx()
986 or(scc, R15, scc->kiss.softdcd? SYNCIE:DCDIE); in scc_key_trx()
992 enable_irq(scc->irq); in scc_key_trx()
996 /* ----> SCC timer interrupt handler and friends. <---- */
1002 del_timer(&scc->tx_t); in __scc_start_tx_timer()
1006 handler(&scc->tx_t); in __scc_start_tx_timer()
1010 scc->tx_t.function = handler; in __scc_start_tx_timer()
1011 scc->tx_t.expires = jiffies + (when*HZ)/100; in __scc_start_tx_timer()
1012 add_timer(&scc->tx_t); in __scc_start_tx_timer()
1022 spin_lock_irqsave(&scc->lock, flags); in scc_start_tx_timer()
1024 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_tx_timer()
1031 spin_lock_irqsave(&scc->lock, flags); in scc_start_defer()
1032 del_timer(&scc->tx_wdog); in scc_start_defer()
1034 if (scc->kiss.maxdefer != 0 && scc->kiss.maxdefer != TIMER_OFF) in scc_start_defer()
1036 scc->tx_wdog.function = t_busy; in scc_start_defer()
1037 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxdefer; in scc_start_defer()
1038 add_timer(&scc->tx_wdog); in scc_start_defer()
1040 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_defer()
1047 spin_lock_irqsave(&scc->lock, flags); in scc_start_maxkeyup()
1048 del_timer(&scc->tx_wdog); in scc_start_maxkeyup()
1050 if (scc->kiss.maxkeyup != 0 && scc->kiss.maxkeyup != TIMER_OFF) in scc_start_maxkeyup()
1052 scc->tx_wdog.function = t_maxkeyup; in scc_start_maxkeyup()
1053 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxkeyup; in scc_start_maxkeyup()
1054 add_timer(&scc->tx_wdog); in scc_start_maxkeyup()
1056 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_maxkeyup()
1070 switch (scc->kiss.fulldup) in scc_tx_done()
1073 scc->stat.tx_state = TXS_IDLE2; in scc_tx_done()
1074 if (scc->kiss.idletime != TIMER_OFF) in scc_tx_done()
1076 scc->kiss.idletime*100); in scc_tx_done()
1082 scc->stat.tx_state = TXS_BUSY; in scc_tx_done()
1083 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in scc_tx_done()
1086 netif_wake_queue(scc->dev); in scc_tx_done()
1098 grp1 = scc->kiss.group; in is_grouped()
1103 grp2 = scc2->kiss.group; in is_grouped()
1105 if (scc2 == scc || !(scc2->dev && grp2)) in is_grouped()
1110 if ( (grp1 & TXGROUP) && (scc2->wreg[R5] & RTS) ) in is_grouped()
1113 if ( (grp1 & RXGROUP) && scc2->dcd ) in is_grouped()
1122 * fulldup == 0: DCD is active or Rand > P-persistence: start t_busy timer
1132 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */ in t_dwait()
1134 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */ in t_dwait()
1135 scc->stat.tx_state = TXS_IDLE; in t_dwait()
1136 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */ in t_dwait()
1140 scc->stat.tx_state = TXS_BUSY; in t_dwait()
1143 if (scc->kiss.fulldup == KISS_DUPLEX_HALF) in t_dwait()
1147 if (scc->dcd || (scc->kiss.persist) < Rand || (scc->kiss.group && is_grouped(scc)) ) in t_dwait()
1150 scc_start_tx_timer(scc, t_dwait, scc->kiss.slottime); in t_dwait()
1155 if ( !(scc->wreg[R5] & RTS) ) in t_dwait()
1158 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay); in t_dwait()
1176 if (scc->tx_buff == NULL) in t_txdelay()
1178 disable_irq(scc->irq); in t_txdelay()
1180 enable_irq(scc->irq); in t_txdelay()
1196 spin_lock_irqsave(&scc->lock, flags); in t_tail()
1197 del_timer(&scc->tx_wdog); in t_tail()
1199 spin_unlock_irqrestore(&scc->lock, flags); in t_tail()
1201 if (scc->stat.tx_state == TXS_TIMEOUT) /* we had a timeout? */ in t_tail()
1203 scc->stat.tx_state = TXS_WAIT; in t_tail()
1204 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100); in t_tail()
1208 scc->stat.tx_state = TXS_IDLE; in t_tail()
1209 netif_wake_queue(scc->dev); in t_tail()
1222 del_timer(&scc->tx_t); in t_busy()
1223 netif_stop_queue(scc->dev); /* don't pile on the wabbit! */ in t_busy()
1226 scc->stat.txerrs++; in t_busy()
1227 scc->stat.tx_state = TXS_IDLE; in t_busy()
1229 netif_wake_queue(scc->dev); in t_busy()
1242 spin_lock_irqsave(&scc->lock, flags); in t_maxkeyup()
1248 netif_stop_queue(scc->dev); in t_maxkeyup()
1251 del_timer(&scc->tx_t); in t_maxkeyup()
1255 OutReg(scc->ctrl, R0, RES_Tx_P); in t_maxkeyup()
1257 spin_unlock_irqrestore(&scc->lock, flags); in t_maxkeyup()
1259 scc->stat.txerrs++; in t_maxkeyup()
1260 scc->stat.tx_state = TXS_TIMEOUT; in t_maxkeyup()
1261 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in t_maxkeyup()
1275 del_timer(&scc->tx_wdog); in t_idle()
1278 if(scc->kiss.mintime) in t_idle()
1279 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100); in t_idle()
1280 scc->stat.tx_state = TXS_WAIT; in t_idle()
1287 spin_lock_irqsave(&scc->lock, flags); in scc_init_timer()
1288 scc->stat.tx_state = TXS_IDLE; in scc_init_timer()
1289 spin_unlock_irqrestore(&scc->lock, flags); in scc_init_timer()
1308 case PARAM_TXDELAY: scc->kiss.txdelay=arg; break; in scc_set_param()
1309 case PARAM_PERSIST: scc->kiss.persist=arg; break; in scc_set_param()
1310 case PARAM_SLOTTIME: scc->kiss.slottime=arg; break; in scc_set_param()
1311 case PARAM_TXTAIL: scc->kiss.tailtime=arg; break; in scc_set_param()
1312 case PARAM_FULLDUP: scc->kiss.fulldup=arg; break; in scc_set_param()
1314 case PARAM_GROUP: scc->kiss.group=arg; break; in scc_set_param()
1315 case PARAM_IDLE: scc->kiss.idletime=arg; break; in scc_set_param()
1316 case PARAM_MIN: scc->kiss.mintime=arg; break; in scc_set_param()
1317 case PARAM_MAXKEY: scc->kiss.maxkeyup=arg; break; in scc_set_param()
1318 case PARAM_WAIT: scc->kiss.waittime=arg; break; in scc_set_param()
1319 case PARAM_MAXDEFER: scc->kiss.maxdefer=arg; break; in scc_set_param()
1320 case PARAM_TX: scc->kiss.tx_inhibit=arg; break; in scc_set_param()
1323 scc->kiss.softdcd=arg; in scc_set_param()
1337 scc->modem.speed=arg*100; in scc_set_param()
1339 scc->modem.speed=arg; in scc_set_param()
1341 if (scc->stat.tx_state == 0) /* only switch baudrate on rx... ;-) */ in scc_set_param()
1346 if ( !(scc->wreg[R5] & RTS) ) in scc_set_param()
1350 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay); in scc_set_param()
1355 scc->stat.tx_state = TXS_BUSY; in scc_set_param()
1356 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime); in scc_set_param()
1362 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF); in scc_set_param()
1365 default: return -EINVAL; in scc_set_param()
1377 case PARAM_TXDELAY: return CAST(scc->kiss.txdelay); in scc_get_param()
1378 case PARAM_PERSIST: return CAST(scc->kiss.persist); in scc_get_param()
1379 case PARAM_SLOTTIME: return CAST(scc->kiss.slottime); in scc_get_param()
1380 case PARAM_TXTAIL: return CAST(scc->kiss.tailtime); in scc_get_param()
1381 case PARAM_FULLDUP: return CAST(scc->kiss.fulldup); in scc_get_param()
1382 case PARAM_SOFTDCD: return CAST(scc->kiss.softdcd); in scc_get_param()
1383 case PARAM_DTR: return CAST((scc->wreg[R5] & DTR)? 1:0); in scc_get_param()
1384 case PARAM_RTS: return CAST((scc->wreg[R5] & RTS)? 1:0); in scc_get_param()
1385 case PARAM_SPEED: return CAST(scc->modem.speed); in scc_get_param()
1386 case PARAM_GROUP: return CAST(scc->kiss.group); in scc_get_param()
1387 case PARAM_IDLE: return CAST(scc->kiss.idletime); in scc_get_param()
1388 case PARAM_MIN: return CAST(scc->kiss.mintime); in scc_get_param()
1389 case PARAM_MAXKEY: return CAST(scc->kiss.maxkeyup); in scc_get_param()
1390 case PARAM_WAIT: return CAST(scc->kiss.waittime); in scc_get_param()
1391 case PARAM_MAXDEFER: return CAST(scc->kiss.maxdefer); in scc_get_param()
1392 case PARAM_TX: return CAST(scc->kiss.tx_inhibit); in scc_get_param()
1409 spin_lock_irqsave(&scc->lock, flags); in scc_stop_calibrate()
1410 del_timer(&scc->tx_wdog); in scc_stop_calibrate()
1414 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in scc_stop_calibrate()
1415 Outb(scc->ctrl,RES_EXT_INT); in scc_stop_calibrate()
1417 netif_wake_queue(scc->dev); in scc_stop_calibrate()
1418 spin_unlock_irqrestore(&scc->lock, flags); in scc_stop_calibrate()
1427 spin_lock_irqsave(&scc->lock, flags); in scc_start_calibrate()
1428 netif_stop_queue(scc->dev); in scc_start_calibrate()
1431 del_timer(&scc->tx_wdog); in scc_start_calibrate()
1433 scc->tx_wdog.function = scc_stop_calibrate; in scc_start_calibrate()
1434 scc->tx_wdog.expires = jiffies + HZ*duration; in scc_start_calibrate()
1435 add_timer(&scc->tx_wdog); in scc_start_calibrate()
1446 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */ in scc_start_calibrate()
1447 Outb(scc->ctrl,RES_EXT_INT); in scc_start_calibrate()
1450 spin_unlock_irqrestore(&scc->lock, flags); in scc_start_calibrate()
1475 printk("%s%d", flag, k); in z8530_init()
1481 /* reset and pre-init all chips in the system */ in z8530_init()
1485 if (!scc->ctrl) continue; in z8530_init()
1489 if(scc->brand & EAGLE) /* this is an EAGLE card */ in z8530_init()
1490 Outb(scc->special,0x08); /* enable interrupt on the board */ in z8530_init()
1492 if(scc->brand & (PC100 | PRIMUS)) /* this is a PC100/PRIMUS card */ in z8530_init()
1493 Outb(scc->special,scc->option); /* set the MODEM mode (0x22) */ in z8530_init()
1496 /* Reset and pre-init Z8530 */ in z8530_init()
1498 spin_lock_irqsave(&scc->lock, flags); in z8530_init()
1500 Outb(scc->ctrl, 0); in z8530_init()
1501 OutReg(scc->ctrl,R9,FHWRES); /* force hardware reset */ in z8530_init()
1505 spin_unlock_irqrestore(&scc->lock, flags); in z8530_init()
1523 return -ENOMEM; in scc_net_alloc()
1525 dev->ml_priv = scc; in scc_net_alloc()
1526 scc->dev = dev; in scc_net_alloc()
1527 spin_lock_init(&scc->lock); in scc_net_alloc()
1528 timer_setup(&scc->tx_t, NULL, 0); in scc_net_alloc()
1529 timer_setup(&scc->tx_wdog, NULL, 0); in scc_net_alloc()
1533 printk(KERN_ERR "%s: can't register network device (%d)\n", in scc_net_alloc()
1536 scc->dev = NULL; in scc_net_alloc()
1558 /* ----> Initialize device <----- */
1562 dev->tx_queue_len = 16; /* should be enough... */ in scc_net_setup()
1564 dev->netdev_ops = &scc_netdev_ops; in scc_net_setup()
1565 dev->header_ops = &ax25_header_ops; in scc_net_setup()
1567 dev->flags = 0; in scc_net_setup()
1569 dev->type = ARPHRD_AX25; in scc_net_setup()
1570 dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN; in scc_net_setup()
1571 dev->mtu = AX25_DEF_PACLEN; in scc_net_setup()
1572 dev->addr_len = AX25_ADDR_LEN; in scc_net_setup()
1574 memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); in scc_net_setup()
1578 /* ----> open network device <---- */
1582 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_open()
1584 if (!scc->init) in scc_net_open()
1585 return -EINVAL; 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()
1596 /* ----> close network device <---- */
1600 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_close()
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()
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()
1619 /* ----> receive frame, called from scc_rxint() <---- */
1623 if (skb->len == 0) { in scc_net_rx()
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()
1636 /* ----> transmit frame <---- */
1640 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_tx()
1644 if (skb->protocol == htons(ETH_P_IP)) in scc_net_tx()
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()
1657 kisscmd = *skb->data & 0x1f; 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()
1690 spin_unlock_irqrestore(&scc->lock, flags); in scc_net_tx()
1694 /* ----> ioctl functions <---- */
1697 * SIOCSCCCFG - configure driver arg: (struct scc_hw_config *) arg
1698 * SIOCSCCINI - initialize driver arg: ---
1699 * SIOCSCCCHANINI - initialize channel arg: (struct scc_modem *) arg
1700 * SIOCSCCSMEM - set memory arg: (struct scc_mem_config *) arg
1701 * SIOCSCCGKISS - get level 1 parameter arg: (struct scc_kiss_cmd *) arg
1702 * SIOCSCCSKISS - set level 1 parameter arg: (struct scc_kiss_cmd *) arg
1703 * SIOCSCCGSTAT - get driver status arg: (struct scc_stat *) arg
1704 * SIOCSCCCAL - send calib. pattern arg: (struct scc_calibrate *) arg
1713 struct scc_calibrate cal; in scc_net_siocdevprivate() local
1714 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_siocdevprivate()
1724 if (!capable(CAP_SYS_RAWIO)) return -EPERM; in scc_net_siocdevprivate()
1726 return -EOPNOTSUPP; in scc_net_siocdevprivate()
1728 if (!arg) return -EFAULT; in scc_net_siocdevprivate()
1731 return -EINVAL; in scc_net_siocdevprivate()
1734 return -EFAULT; in scc_net_siocdevprivate()
1739 return -EINVAL; in scc_net_siocdevprivate()
1746 printk(KERN_WARNING "z8530drv: warning, cannot get IRQ %d\n", hwcfg.irq); in scc_net_siocdevprivate()
1763 if(request_region(hwcfg.ctrl_a, 1, "scc-probe")) in scc_net_siocdevprivate()
1813 printk(KERN_INFO "%s: data port = 0x%3.3lx control port = 0x%3.3lx -- %s\n", in scc_net_siocdevprivate()
1827 return -EINVAL; in scc_net_siocdevprivate()
1839 return -EPERM; in scc_net_siocdevprivate()
1842 return -EINVAL; in scc_net_siocdevprivate()
1848 return -EINVAL; /* confuse the user */ in scc_net_siocdevprivate()
1851 if (!scc->init) in scc_net_siocdevprivate()
1855 if (!capable(CAP_NET_ADMIN)) return -EPERM; in scc_net_siocdevprivate()
1856 if (!arg) return -EINVAL; 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()
1861 return -EINVAL; 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()
1899 return -EINVAL; in scc_net_siocdevprivate()
1905 return -ENOIOCTLCMD; in scc_net_siocdevprivate()
1908 if (!capable(CAP_SYS_RAWIO)) return -EPERM; in scc_net_siocdevprivate()
1910 return -EINVAL; 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()
1916 return -EINVAL; in scc_net_siocdevprivate()
1921 return -EINVAL; in scc_net_siocdevprivate()
1924 return -EINVAL; in scc_net_siocdevprivate()
1928 if (!capable(CAP_NET_ADMIN)) return -EPERM; in scc_net_siocdevprivate()
1930 return -EINVAL; in scc_net_siocdevprivate()
1934 if (!capable(CAP_SYS_RAWIO)) return -EPERM; in scc_net_siocdevprivate()
1935 if (!arg || copy_from_user(&cal, arg, sizeof(cal)) || cal.time == 0) in scc_net_siocdevprivate()
1936 return -EINVAL; in scc_net_siocdevprivate()
1938 scc_start_calibrate(scc, cal.time, cal.pattern); in scc_net_siocdevprivate()
1942 return -ENOIOCTLCMD; in scc_net_siocdevprivate()
1946 return -EINVAL; in scc_net_siocdevprivate()
1949 /* ----> set interface callsign <---- */
1954 dev_addr_set(dev, sa->sa_data); in scc_net_set_mac_address()
1958 /* ----> get statistics <---- */
1962 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv; in scc_net_get_stats()
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()
1985 if (pos-- == 0) in scc_net_seq_idx()
1993 return *pos ? scc_net_seq_idx(*pos - 1) : SEQ_START_TOKEN; in scc_net_seq_start()
2003 for (k = (v == SEQ_START_TOKEN) ? 0 : (scc - SCC_Info)+1; in scc_net_seq_next()
2018 seq_puts(seq, "z8530drv-"VERSION"\n"); in scc_net_seq_show()
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()
2038 seq_printf(seq, "%s\t%3.3lx %3.3lx %d %lu %2.2x %d %3.3lx %3.3lx %d\n", 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()
2043 seq_printf(seq, "\t%lu %d %d %d %d\n", 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()
2046 stat->bufsize); in scc_net_seq_show()
2048 stat->rxints, stat->txints, stat->exints, stat->spints); in scc_net_seq_show()
2049 seq_printf(seq, "\t%lu %lu %d / %lu %lu %d / %d %d\n", in scc_net_seq_show()
2050 stat->rxframes, stat->rxerrs, stat->rx_over, in scc_net_seq_show()
2051 stat->txframes, stat->txerrs, stat->tx_under, in scc_net_seq_show()
2052 stat->nospace, stat->tx_state); in scc_net_seq_show()
2054 #define K(x) kiss->x in scc_net_seq_show()
2055 seq_printf(seq, "\t%d %d %d %d %d %d %d %d %d %d %d %d\n", 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()
2109 return -EIO; in scc_init_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()