Lines Matching refs:scc
1 #define RCS_ID "$Id: scc.c,v 1.75 1998/11/04 15:15:01 jreuter Exp jreuter $"
170 #include <linux/scc.h>
203 static void init_channel(struct scc_channel *scc);
204 static void scc_key_trx (struct scc_channel *scc, char tx);
205 static void scc_init_timer(struct scc_channel *scc);
207 static int scc_net_alloc(const char *name, struct scc_channel *scc);
211 static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb);
219 static unsigned char SCC_DriverName[] = "scc";
278 static inline void wr(struct scc_channel *scc, unsigned char reg,
281 OutReg(scc->ctrl, reg, (scc->wreg[reg] = val));
284 static inline void or(struct scc_channel *scc, unsigned char reg, unsigned char val)
286 OutReg(scc->ctrl, reg, (scc->wreg[reg] |= val));
289 static inline void cl(struct scc_channel *scc, unsigned char reg, unsigned char val)
291 OutReg(scc->ctrl, reg, (scc->wreg[reg] &= ~val));
298 static inline void scc_discard_buffers(struct scc_channel *scc)
302 spin_lock_irqsave(&scc->lock, flags);
303 if (scc->tx_buff != NULL)
305 dev_kfree_skb_irq(scc->tx_buff);
306 scc->tx_buff = NULL;
309 while (!skb_queue_empty(&scc->tx_queue))
310 dev_kfree_skb_irq(skb_dequeue(&scc->tx_queue));
312 spin_unlock_irqrestore(&scc->lock, flags);
324 static inline void scc_notify(struct scc_channel *scc, int event)
329 if (scc->kiss.fulldup != KISS_DUPLEX_OPTIMA)
338 scc_net_rx(scc, skb);
340 scc->stat.nospace++;
343 static inline void flush_rx_FIFO(struct scc_channel *scc)
348 Inb(scc->data);
350 if(scc->rx_buff != NULL) /* did we receive something? */
352 scc->stat.rxerrs++; /* then count it as an error */
353 dev_kfree_skb_irq(scc->rx_buff);
354 scc->rx_buff = NULL;
358 static void start_hunt(struct scc_channel *scc)
360 if ((scc->modem.clocksrc != CLK_EXTERNAL))
361 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */
362 or(scc,R3,ENT_HM|RxENABLE); /* enable the receiver, hunt mode */
369 static inline void scc_txint(struct scc_channel *scc)
373 scc->stat.txints++;
374 skb = scc->tx_buff;
380 skb = skb_dequeue(&scc->tx_queue);
381 scc->tx_buff = skb;
382 netif_wake_queue(scc->dev);
386 scc_tx_done(scc);
387 Outb(scc->ctrl, RES_Tx_P);
394 scc->tx_buff = NULL;
395 scc_tx_done(scc);
396 Outb(scc->ctrl, RES_Tx_P);
400 scc->stat.tx_state = TXS_ACTIVE;
402 OutReg(scc->ctrl, R0, RES_Tx_CRC);
404 or(scc,R10,ABUNDER); /* re-install underrun protection */
405 Outb(scc->data,*skb->data); /* send byte */
408 if (!scc->enhanced) /* reset EOM latch */
409 Outb(scc->ctrl,RES_EOM_L);
417 Outb(scc->ctrl, RES_Tx_P); /* reset pending int */
418 cl(scc, R10, ABUNDER); /* send CRC */
420 scc->tx_buff = NULL;
421 scc->stat.tx_state = TXS_NEWFRAME; /* next frame... */
427 Outb(scc->data,*skb->data);
433 static inline void scc_exint(struct scc_channel *scc)
437 scc->stat.exints++;
439 status = InReg(scc->ctrl,R0);
440 changes = status ^ scc->status;
446 flush_rx_FIFO(scc);
450 if ((changes & SYNC_HUNT) && scc->kiss.softdcd)
454 scc->dcd = 0;
455 flush_rx_FIFO(scc);
456 if ((scc->modem.clocksrc != CLK_EXTERNAL))
457 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */
459 scc->dcd = 1;
462 scc_notify(scc, scc->dcd? HWEV_DCD_OFF:HWEV_DCD_ON);
468 if((changes & DCD) && !scc->kiss.softdcd) /* DCD input changed state */
472 start_hunt(scc);
473 scc->dcd = 1;
475 cl(scc,R3,ENT_HM|RxENABLE); /* disable the receiver */
476 flush_rx_FIFO(scc);
477 scc->dcd = 0;
480 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF);
492 if (scc->kiss.txdelay == 0) /* zero TXDELAY = wait for CTS */
493 scc_start_tx_timer(scc, t_txdelay, 0);
497 if (scc->stat.tx_state == TXS_ACTIVE && (status & TxEOM))
499 scc->stat.tx_under++; /* oops, an underrun! count 'em */
500 Outb(scc->ctrl, RES_EXT_INT); /* reset ext/status interrupts */
502 if (scc->tx_buff != NULL)
504 dev_kfree_skb_irq(scc->tx_buff);
505 scc->tx_buff = NULL;
508 or(scc,R10,ABUNDER);
509 scc_start_tx_timer(scc, t_txdelay, 0); /* restart transmission */
512 scc->status = status;
513 Outb(scc->ctrl,RES_EXT_INT);
518 static inline void scc_rxint(struct scc_channel *scc)
522 scc->stat.rxints++;
524 if((scc->wreg[5] & RTS) && scc->kiss.fulldup == KISS_DUPLEX_HALF)
526 Inb(scc->data); /* discard char */
527 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */
531 skb = scc->rx_buff;
535 skb = dev_alloc_skb(scc->stat.bufsize);
538 scc->dev_stat.rx_dropped++;
539 scc->stat.nospace++;
540 Inb(scc->data);
541 or(scc, R3, ENT_HM);
545 scc->rx_buff = skb;
549 if (skb->len >= scc->stat.bufsize)
555 scc->rx_buff = NULL;
556 Inb(scc->data);
557 or(scc, R3, ENT_HM);
561 skb_put_u8(skb, Inb(scc->data));
566 static inline void scc_spint(struct scc_channel *scc)
571 scc->stat.spints++;
573 status = InReg(scc->ctrl,R1); /* read receiver status */
575 Inb(scc->data); /* throw away Rx byte */
576 skb = scc->rx_buff;
580 scc->stat.rx_over++; /* count them */
581 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */
585 scc->rx_buff = skb = NULL;
596 scc_net_rx(scc, skb);
597 scc->rx_buff = NULL;
598 scc->stat.rxframes++;
601 scc->rx_buff = NULL;
602 scc->stat.rxerrs++;
606 Outb(scc->ctrl,ERR_RES);
612 static void scc_isr_dispatch(struct scc_channel *scc, int vector)
614 spin_lock(&scc->lock);
617 case TXINT: scc_txint(scc); break;
618 case EXINT: scc_exint(scc); break;
619 case RXINT: scc_rxint(scc); break;
620 case SPINT: scc_spint(scc); break;
622 spin_unlock(&scc->lock);
636 struct scc_channel *scc;
650 scc=&SCC_Info[vector >> 3 ^ 0x01];
651 if (!scc->dev) break;
653 scc_isr_dispatch(scc, vector);
655 OutReg(scc->ctrl,R0,RES_H_IUS); /* Reset Highest IUS */
677 scc = NULL;
683 scc = &SCC_Info[vector >> 3 ^ 0x01];
684 if (!scc->dev) break;
686 scc_isr_dispatch(scc, vector);
702 if (scc != NULL)
704 OutReg(scc->ctrl,R0,RES_H_IUS);
721 static inline void set_brg(struct scc_channel *scc, unsigned int tc)
723 cl(scc,R14,BRENABL); /* disable baudrate generator */
724 wr(scc,R12,tc & 255); /* brg rate LOW */
725 wr(scc,R13,tc >> 8); /* brg rate HIGH */
726 or(scc,R14,BRENABL); /* enable baudrate generator */
729 static inline void set_speed(struct scc_channel *scc)
732 spin_lock_irqsave(&scc->lock, flags);
734 if (scc->modem.speed > 0) /* paranoia... */
735 set_brg(scc, (unsigned) (scc->clock / (scc->modem.speed * 64)) - 2);
737 spin_unlock_irqrestore(&scc->lock, flags);
743 static inline void init_brg(struct scc_channel *scc)
745 wr(scc, R14, BRSRC); /* BRG source = PCLK */
746 OutReg(scc->ctrl, R14, SSBR|scc->wreg[R14]); /* DPLL source = BRG */
747 OutReg(scc->ctrl, R14, SNRZI|scc->wreg[R14]); /* DPLL NRZI mode */
795 static void init_channel(struct scc_channel *scc)
797 timer_delete(&scc->tx_t);
798 timer_delete(&scc->tx_wdog);
800 disable_irq(scc->irq);
802 wr(scc,R4,X1CLK|SDLC); /* *1 clock, SDLC mode */
803 wr(scc,R1,0); /* no W/REQ operation */
804 wr(scc,R3,Rx8|RxCRC_ENAB); /* RX 8 bits/char, CRC, disabled */
805 wr(scc,R5,Tx8|DTR|TxCRC_ENAB); /* TX 8 bits/char, disabled, DTR */
806 wr(scc,R6,0); /* SDLC address zero (not used) */
807 wr(scc,R7,FLAG); /* SDLC flag value */
808 wr(scc,R9,VIS); /* vector includes status */
809 wr(scc,R10,(scc->modem.nrz? NRZ : NRZI)|CRCPS|ABUNDER); /* abort on underrun, preset CRC generator, NRZ(I) */
810 wr(scc,R14, 0);
839 switch(scc->modem.clocksrc)
842 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP);
843 init_brg(scc);
847 wr(scc, R11, ((scc->brand & BAYCOM)? TRxCDP : TRxCBR) | RCDPLL|TCRTxCP|TRxCOI);
848 init_brg(scc);
852 wr(scc, R11, (scc->brand & BAYCOM)? RCTRxCP|TCRTxCP : RCRTxCP|TCTRxCP);
853 OutReg(scc->ctrl, R14, DISDPLL);
858 set_speed(scc); /* set baudrate */
860 if(scc->enhanced)
862 or(scc,R15,SHDLCE|FIFOE); /* enable FIFO, SDLC/HDLC Enhancements (From now R7 is R7') */
863 wr(scc,R7,AUTOEOM);
866 if(scc->kiss.softdcd || (InReg(scc->ctrl,R0) & DCD))
869 start_hunt(scc);
874 wr(scc,R15, BRKIE|TxUIE|(scc->kiss.softdcd? SYNCIE:DCDIE));
876 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
877 Outb(scc->ctrl,RES_EXT_INT); /* must be done twice */
879 or(scc,R1,INT_ALL_Rx|TxINT_ENAB|EXT_INT_ENAB); /* enable interrupts */
881 scc->status = InReg(scc->ctrl,R0); /* read initial status */
883 or(scc,R9,MIE); /* master interrupt enable */
885 scc_init_timer(scc);
887 enable_irq(scc->irq);
901 static void scc_key_trx(struct scc_channel *scc, char tx)
905 if (scc->brand & PRIMUS)
906 Outb(scc->ctrl + 4, scc->option | (tx? 0x80 : 0));
908 if (scc->modem.speed < 300)
909 scc->modem.speed = 1200;
911 time_const = (unsigned) (scc->clock / (scc->modem.speed * (tx? 2:64))) - 2;
913 disable_irq(scc->irq);
917 or(scc, R1, TxINT_ENAB); /* t_maxkeyup may have reset these */
918 or(scc, R15, TxUIE);
921 if (scc->modem.clocksrc == CLK_DPLL)
926 cl(scc, R3, RxENABLE|ENT_HM); /* switch off receiver */
927 cl(scc, R15, DCDIE|SYNCIE); /* No DCD changes, please */
929 set_brg(scc, time_const); /* reprogram baudrate generator */
932 wr(scc, R11, RCDPLL|TCBR|TRxCOI|TRxCBR);
935 if (scc->kiss.tx_inhibit)
937 or(scc,R5, TxENAB);
938 scc->wreg[R5] |= RTS;
940 or(scc,R5,RTS|TxENAB); /* set the RTS line and enable TX */
943 cl(scc,R5,RTS|TxENAB);
945 set_brg(scc, time_const); /* reprogram baudrate generator */
948 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP);
951 if (scc->kiss.softdcd)
954 or(scc,R15, scc->kiss.softdcd? SYNCIE:DCDIE);
955 start_hunt(scc);
962 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
964 cl(scc, R3, RxENABLE);
965 cl(scc, R15, DCDIE|SYNCIE);
969 if (scc->kiss.tx_inhibit)
971 or(scc,R5, TxENAB);
972 scc->wreg[R5] |= RTS;
974 or(scc,R5,RTS|TxENAB); /* enable tx */
977 cl(scc,R5,RTS|TxENAB); /* disable tx */
979 if ((scc->kiss.fulldup == KISS_DUPLEX_HALF) &&
981 scc->kiss.softdcd)
986 or(scc, R15, scc->kiss.softdcd? SYNCIE:DCDIE);
987 start_hunt(scc);
992 enable_irq(scc->irq);
998 static void __scc_start_tx_timer(struct scc_channel *scc,
1002 timer_delete(&scc->tx_t);
1006 handler(&scc->tx_t);
1010 scc->tx_t.function = handler;
1011 scc->tx_t.expires = jiffies + (when*HZ)/100;
1012 add_timer(&scc->tx_t);
1016 static void scc_start_tx_timer(struct scc_channel *scc,
1022 spin_lock_irqsave(&scc->lock, flags);
1023 __scc_start_tx_timer(scc, handler, when);
1024 spin_unlock_irqrestore(&scc->lock, flags);
1027 static void scc_start_defer(struct scc_channel *scc)
1031 spin_lock_irqsave(&scc->lock, flags);
1032 timer_delete(&scc->tx_wdog);
1034 if (scc->kiss.maxdefer != 0 && scc->kiss.maxdefer != TIMER_OFF)
1036 scc->tx_wdog.function = t_busy;
1037 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxdefer;
1038 add_timer(&scc->tx_wdog);
1040 spin_unlock_irqrestore(&scc->lock, flags);
1043 static void scc_start_maxkeyup(struct scc_channel *scc)
1047 spin_lock_irqsave(&scc->lock, flags);
1048 timer_delete(&scc->tx_wdog);
1050 if (scc->kiss.maxkeyup != 0 && scc->kiss.maxkeyup != TIMER_OFF)
1052 scc->tx_wdog.function = t_maxkeyup;
1053 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxkeyup;
1054 add_timer(&scc->tx_wdog);
1056 spin_unlock_irqrestore(&scc->lock, flags);
1064 static void scc_tx_done(struct scc_channel *scc)
1070 switch (scc->kiss.fulldup)
1073 scc->stat.tx_state = TXS_IDLE2;
1074 if (scc->kiss.idletime != TIMER_OFF)
1075 scc_start_tx_timer(scc, t_idle,
1076 scc->kiss.idletime*100);
1079 scc_notify(scc, HWEV_ALL_SENT);
1082 scc->stat.tx_state = TXS_BUSY;
1083 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1086 netif_wake_queue(scc->dev);
1092 static inline int is_grouped(struct scc_channel *scc)
1098 grp1 = scc->kiss.group;
1105 if (scc2 == scc || !(scc2->dev && grp2))
1130 struct scc_channel *scc = timer_container_of(scc, t, tx_t);
1132 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */
1134 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */
1135 scc->stat.tx_state = TXS_IDLE;
1136 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
1140 scc->stat.tx_state = TXS_BUSY;
1143 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
1147 if (scc->dcd || (scc->kiss.persist) < Rand || (scc->kiss.group && is_grouped(scc)) )
1149 scc_start_defer(scc);
1150 scc_start_tx_timer(scc, t_dwait, scc->kiss.slottime);
1155 if ( !(scc->wreg[R5] & RTS) )
1157 scc_key_trx(scc, TX_ON);
1158 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay);
1160 scc_start_tx_timer(scc, t_txdelay, 0);
1167 * kick transmission by a fake scc_txint(scc), start 'maxkeyup' watchdog.
1172 struct scc_channel *scc = timer_container_of(scc, t, tx_t);
1174 scc_start_maxkeyup(scc);
1176 if (scc->tx_buff == NULL)
1178 disable_irq(scc->irq);
1179 scc_txint(scc);
1180 enable_irq(scc->irq);
1193 struct scc_channel *scc = timer_container_of(scc, t, tx_t);
1196 spin_lock_irqsave(&scc->lock, flags);
1197 timer_delete(&scc->tx_wdog);
1198 scc_key_trx(scc, TX_OFF);
1199 spin_unlock_irqrestore(&scc->lock, flags);
1201 if (scc->stat.tx_state == TXS_TIMEOUT) /* we had a timeout? */
1203 scc->stat.tx_state = TXS_WAIT;
1204 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100);
1208 scc->stat.tx_state = TXS_IDLE;
1209 netif_wake_queue(scc->dev);
1220 struct scc_channel *scc = timer_container_of(scc, t, tx_wdog);
1222 timer_delete(&scc->tx_t);
1223 netif_stop_queue(scc->dev); /* don't pile on the wabbit! */
1225 scc_discard_buffers(scc);
1226 scc->stat.txerrs++;
1227 scc->stat.tx_state = TXS_IDLE;
1229 netif_wake_queue(scc->dev);
1239 struct scc_channel *scc = timer_container_of(scc, t, tx_wdog);
1242 spin_lock_irqsave(&scc->lock, flags);
1248 netif_stop_queue(scc->dev);
1249 scc_discard_buffers(scc);
1251 timer_delete(&scc->tx_t);
1253 cl(scc, R1, TxINT_ENAB); /* force an ABORT, but don't */
1254 cl(scc, R15, TxUIE); /* count it. */
1255 OutReg(scc->ctrl, R0, RES_Tx_P);
1257 spin_unlock_irqrestore(&scc->lock, flags);
1259 scc->stat.txerrs++;
1260 scc->stat.tx_state = TXS_TIMEOUT;
1261 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1273 struct scc_channel *scc = timer_container_of(scc, t, tx_t);
1275 timer_delete(&scc->tx_wdog);
1277 scc_key_trx(scc, TX_OFF);
1278 if(scc->kiss.mintime)
1279 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100);
1280 scc->stat.tx_state = TXS_WAIT;
1283 static void scc_init_timer(struct scc_channel *scc)
1287 spin_lock_irqsave(&scc->lock, flags);
1288 scc->stat.tx_state = TXS_IDLE;
1289 spin_unlock_irqrestore(&scc->lock, flags);
1304 static unsigned int scc_set_param(struct scc_channel *scc, unsigned int cmd, unsigned int arg)
1308 case PARAM_TXDELAY: scc->kiss.txdelay=arg; break;
1309 case PARAM_PERSIST: scc->kiss.persist=arg; break;
1310 case PARAM_SLOTTIME: scc->kiss.slottime=arg; break;
1311 case PARAM_TXTAIL: scc->kiss.tailtime=arg; break;
1312 case PARAM_FULLDUP: scc->kiss.fulldup=arg; break;
1314 case PARAM_GROUP: scc->kiss.group=arg; break;
1315 case PARAM_IDLE: scc->kiss.idletime=arg; break;
1316 case PARAM_MIN: scc->kiss.mintime=arg; break;
1317 case PARAM_MAXKEY: scc->kiss.maxkeyup=arg; break;
1318 case PARAM_WAIT: scc->kiss.waittime=arg; break;
1319 case PARAM_MAXDEFER: scc->kiss.maxdefer=arg; break;
1320 case PARAM_TX: scc->kiss.tx_inhibit=arg; break;
1323 scc->kiss.softdcd=arg;
1326 or(scc, R15, SYNCIE);
1327 cl(scc, R15, DCDIE);
1328 start_hunt(scc);
1330 or(scc, R15, DCDIE);
1331 cl(scc, R15, SYNCIE);
1337 scc->modem.speed=arg*100;
1339 scc->modem.speed=arg;
1341 if (scc->stat.tx_state == 0) /* only switch baudrate on rx... ;-) */
1342 set_speed(scc);
1346 if ( !(scc->wreg[R5] & RTS) )
1349 scc_key_trx(scc, TX_ON);
1350 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay);
1355 scc->stat.tx_state = TXS_BUSY;
1356 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1362 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF);
1373 static unsigned long scc_get_param(struct scc_channel *scc, unsigned int cmd)
1377 case PARAM_TXDELAY: return CAST(scc->kiss.txdelay);
1378 case PARAM_PERSIST: return CAST(scc->kiss.persist);
1379 case PARAM_SLOTTIME: return CAST(scc->kiss.slottime);
1380 case PARAM_TXTAIL: return CAST(scc->kiss.tailtime);
1381 case PARAM_FULLDUP: return CAST(scc->kiss.fulldup);
1382 case PARAM_SOFTDCD: return CAST(scc->kiss.softdcd);
1383 case PARAM_DTR: return CAST((scc->wreg[R5] & DTR)? 1:0);
1384 case PARAM_RTS: return CAST((scc->wreg[R5] & RTS)? 1:0);
1385 case PARAM_SPEED: return CAST(scc->modem.speed);
1386 case PARAM_GROUP: return CAST(scc->kiss.group);
1387 case PARAM_IDLE: return CAST(scc->kiss.idletime);
1388 case PARAM_MIN: return CAST(scc->kiss.mintime);
1389 case PARAM_MAXKEY: return CAST(scc->kiss.maxkeyup);
1390 case PARAM_WAIT: return CAST(scc->kiss.waittime);
1391 case PARAM_MAXDEFER: return CAST(scc->kiss.maxdefer);
1392 case PARAM_TX: return CAST(scc->kiss.tx_inhibit);
1406 struct scc_channel *scc = timer_container_of(scc, t, tx_wdog);
1409 spin_lock_irqsave(&scc->lock, flags);
1410 timer_delete(&scc->tx_wdog);
1411 scc_key_trx(scc, TX_OFF);
1412 wr(scc, R6, 0);
1413 wr(scc, R7, FLAG);
1414 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
1415 Outb(scc->ctrl,RES_EXT_INT);
1417 netif_wake_queue(scc->dev);
1418 spin_unlock_irqrestore(&scc->lock, flags);
1423 scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern)
1427 spin_lock_irqsave(&scc->lock, flags);
1428 netif_stop_queue(scc->dev);
1429 scc_discard_buffers(scc);
1431 timer_delete(&scc->tx_wdog);
1433 scc->tx_wdog.function = scc_stop_calibrate;
1434 scc->tx_wdog.expires = jiffies + HZ*duration;
1435 add_timer(&scc->tx_wdog);
1438 wr(scc, R6, 0);
1439 wr(scc, R7, pattern);
1446 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
1447 Outb(scc->ctrl,RES_EXT_INT);
1449 scc_key_trx(scc, TX_ON);
1450 spin_unlock_irqrestore(&scc->lock, flags);
1464 struct scc_channel *scc;
1485 scc=&SCC_Info[2*chip];
1486 if (!scc->ctrl) continue;
1490 if(scc->brand & EAGLE) /* this is an EAGLE card */
1491 Outb(scc->special,0x08); /* enable interrupt on the board */
1493 if(scc->brand & (PC100 | PRIMUS)) /* this is a PC100/PRIMUS card */
1494 Outb(scc->special,scc->option); /* set the MODEM mode (0x22) */
1499 spin_lock_irqsave(&scc->lock, flags);
1501 Outb(scc->ctrl, 0);
1502 OutReg(scc->ctrl,R9,FHWRES); /* force hardware reset */
1504 wr(scc, R2, chip*16); /* interrupt vector */
1505 wr(scc, R9, VIS); /* vector includes status */
1506 spin_unlock_irqrestore(&scc->lock, flags);
1517 static int scc_net_alloc(const char *name, struct scc_channel *scc)
1526 dev->ml_priv = scc;
1527 scc->dev = dev;
1528 spin_lock_init(&scc->lock);
1529 timer_setup(&scc->tx_t, NULL, 0);
1530 timer_setup(&scc->tx_wdog, NULL, 0);
1537 scc->dev = NULL;
1583 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1585 if (!scc->init)
1588 scc->tx_buff = NULL;
1589 skb_queue_head_init(&scc->tx_queue);
1591 init_channel(scc);
1601 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1606 spin_lock_irqsave(&scc->lock, flags);
1607 Outb(scc->ctrl,0); /* Make sure pointer is written */
1608 wr(scc,R1,0); /* disable interrupts */
1609 wr(scc,R3,0);
1610 spin_unlock_irqrestore(&scc->lock, flags);
1612 timer_delete_sync(&scc->tx_t);
1613 timer_delete_sync(&scc->tx_wdog);
1615 scc_discard_buffers(scc);
1622 static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
1629 scc->dev_stat.rx_packets++;
1630 scc->dev_stat.rx_bytes += skb->len;
1632 skb->protocol = ax25_type_trans(skb, scc->dev);
1641 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1648 if (skb->len > scc->stat.bufsize || skb->len < 2) {
1649 scc->dev_stat.tx_dropped++; /* bogus frame */
1654 scc->dev_stat.tx_packets++;
1655 scc->dev_stat.tx_bytes += skb->len;
1656 scc->stat.txframes++;
1662 scc_set_param(scc, kisscmd, *skb->data);
1667 spin_lock_irqsave(&scc->lock, flags);
1669 if (skb_queue_len(&scc->tx_queue) > scc->dev->tx_queue_len) {
1671 skb_del = skb_dequeue(&scc->tx_queue);
1674 skb_queue_tail(&scc->tx_queue, skb);
1684 if(scc->stat.tx_state == TXS_IDLE || scc->stat.tx_state == TXS_IDLE2) {
1685 scc->stat.tx_state = TXS_BUSY;
1686 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
1687 __scc_start_tx_timer(scc, t_dwait, scc->kiss.waittime);
1689 __scc_start_tx_timer(scc, t_dwait, 0);
1691 spin_unlock_irqrestore(&scc->lock, flags);
1715 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1753 if (!request_region(hwcfg.vector_latch, 1, "scc vector latch"))
1764 if(request_region(hwcfg.ctrl_a, 1, "scc-probe"))
1823 request_region(SCC_Info[2*Nchips+chan].ctrl, 1, "scc ctrl");
1824 request_region(SCC_Info[2*Nchips+chan].data, 1, "scc data");
1852 if (!scc->init)
1859 scc->stat.bufsize = SCC_BUFSIZE;
1861 if (copy_from_user(&scc->modem, arg, sizeof(struct scc_modem)))
1866 if (scc->modem.speed < 4800)
1868 scc->kiss.txdelay = 36; /* 360 ms */
1869 scc->kiss.persist = 42; /* 25% persistence */ /* was 25 */
1870 scc->kiss.slottime = 16; /* 160 ms */
1871 scc->kiss.tailtime = 4; /* minimal reasonable value */
1872 scc->kiss.fulldup = 0; /* CSMA */
1873 scc->kiss.waittime = 50; /* 500 ms */
1874 scc->kiss.maxkeyup = 10; /* 10 s */
1875 scc->kiss.mintime = 3; /* 3 s */
1876 scc->kiss.idletime = 30; /* 30 s */
1877 scc->kiss.maxdefer = 120; /* 2 min */
1878 scc->kiss.softdcd = 0; /* hardware dcd */
1880 scc->kiss.txdelay = 10; /* 100 ms */
1881 scc->kiss.persist = 64; /* 25% persistence */ /* was 25 */
1882 scc->kiss.slottime = 8; /* 160 ms */
1883 scc->kiss.tailtime = 1; /* minimal reasonable value */
1884 scc->kiss.fulldup = 0; /* CSMA */
1885 scc->kiss.waittime = 50; /* 500 ms */
1886 scc->kiss.maxkeyup = 7; /* 7 s */
1887 scc->kiss.mintime = 3; /* 3 s */
1888 scc->kiss.idletime = 30; /* 30 s */
1889 scc->kiss.maxdefer = 120; /* 2 min */
1890 scc->kiss.softdcd = 0; /* hardware dcd */
1893 scc->tx_buff = NULL;
1894 skb_queue_head_init(&scc->tx_queue);
1895 scc->init = 1;
1912 scc->stat.bufsize = memcfg.bufsize;
1916 if (!arg || copy_to_user(arg, &scc->stat, sizeof(scc->stat)))
1923 kiss_cmd.param = scc_get_param(scc, kiss_cmd.command);
1932 return scc_set_param(scc, kiss_cmd.command, kiss_cmd.param);
1939 scc_start_calibrate(scc, cal.time, cal.pattern);
1963 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1965 scc->dev_stat.rx_errors = scc->stat.rxerrs + scc->stat.rx_over;
1966 scc->dev_stat.tx_errors = scc->stat.txerrs + scc->stat.tx_under;
1967 scc->dev_stat.rx_fifo_errors = scc->stat.rx_over;
1968 scc->dev_stat.tx_fifo_errors = scc->stat.tx_under;
1970 return &scc->dev_stat;
2001 struct scc_channel *scc = v;
2004 for (k = (v == SEQ_START_TOKEN) ? 0 : (scc - SCC_Info)+1;
2025 const struct scc_channel *scc = v;
2026 const struct scc_stat *stat = &scc->stat;
2027 const struct scc_kiss *kiss = &scc->kiss;
2040 scc->dev->name,
2041 scc->data, scc->ctrl, scc->irq, scc->clock, scc->brand,
2042 scc->enhanced, Vector_Latch, scc->special,
2043 scc->option);
2045 scc->modem.speed, scc->modem.nrz,
2046 scc->modem.clocksrc, kiss->softdcd,
2067 seq_printf(seq, "%2.2x ", scc->wreg[reg]);
2070 seq_printf(seq, "\tR %2.2x %2.2x XX ", InReg(scc->ctrl,R0), InReg(scc->ctrl,R1));
2072 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg));
2075 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg));
2124 struct scc_channel *scc;
2153 scc = &SCC_Info[k];
2154 if (scc->ctrl)
2156 release_region(scc->ctrl, 1);
2157 release_region(scc->data, 1);
2159 if (scc->dev)
2161 unregister_netdev(scc->dev);
2162 free_netdev(scc->dev);