Lines Matching refs:scc
1 #define RCS_ID "$Id: scc.c,v 1.75 1998/11/04 15:15:01 jreuter Exp jreuter $"
169 #include <linux/scc.h>
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);
217 static unsigned char SCC_DriverName[] = "scc";
276 static inline void wr(struct scc_channel *scc, unsigned char reg,
279 OutReg(scc->ctrl, reg, (scc->wreg[reg] = val));
282 static inline void or(struct scc_channel *scc, unsigned char reg, unsigned char val)
284 OutReg(scc->ctrl, reg, (scc->wreg[reg] |= val));
287 static inline void cl(struct scc_channel *scc, unsigned char reg, unsigned char val)
289 OutReg(scc->ctrl, reg, (scc->wreg[reg] &= ~val));
296 static inline void scc_discard_buffers(struct scc_channel *scc)
300 spin_lock_irqsave(&scc->lock, flags);
301 if (scc->tx_buff != NULL)
303 dev_kfree_skb_irq(scc->tx_buff);
304 scc->tx_buff = NULL;
307 while (!skb_queue_empty(&scc->tx_queue))
308 dev_kfree_skb_irq(skb_dequeue(&scc->tx_queue));
310 spin_unlock_irqrestore(&scc->lock, flags);
322 static inline void scc_notify(struct scc_channel *scc, int event)
327 if (scc->kiss.fulldup != KISS_DUPLEX_OPTIMA)
336 scc_net_rx(scc, skb);
338 scc->stat.nospace++;
341 static inline void flush_rx_FIFO(struct scc_channel *scc)
346 Inb(scc->data);
348 if(scc->rx_buff != NULL) /* did we receive something? */
350 scc->stat.rxerrs++; /* then count it as an error */
351 dev_kfree_skb_irq(scc->rx_buff);
352 scc->rx_buff = NULL;
356 static void start_hunt(struct scc_channel *scc)
358 if ((scc->modem.clocksrc != CLK_EXTERNAL))
359 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */
360 or(scc,R3,ENT_HM|RxENABLE); /* enable the receiver, hunt mode */
367 static inline void scc_txint(struct scc_channel *scc)
371 scc->stat.txints++;
372 skb = scc->tx_buff;
378 skb = skb_dequeue(&scc->tx_queue);
379 scc->tx_buff = skb;
380 netif_wake_queue(scc->dev);
384 scc_tx_done(scc);
385 Outb(scc->ctrl, RES_Tx_P);
392 scc->tx_buff = NULL;
393 scc_tx_done(scc);
394 Outb(scc->ctrl, RES_Tx_P);
398 scc->stat.tx_state = TXS_ACTIVE;
400 OutReg(scc->ctrl, R0, RES_Tx_CRC);
402 or(scc,R10,ABUNDER); /* re-install underrun protection */
403 Outb(scc->data,*skb->data); /* send byte */
406 if (!scc->enhanced) /* reset EOM latch */
407 Outb(scc->ctrl,RES_EOM_L);
415 Outb(scc->ctrl, RES_Tx_P); /* reset pending int */
416 cl(scc, R10, ABUNDER); /* send CRC */
418 scc->tx_buff = NULL;
419 scc->stat.tx_state = TXS_NEWFRAME; /* next frame... */
425 Outb(scc->data,*skb->data);
431 static inline void scc_exint(struct scc_channel *scc)
435 scc->stat.exints++;
437 status = InReg(scc->ctrl,R0);
438 changes = status ^ scc->status;
444 flush_rx_FIFO(scc);
448 if ((changes & SYNC_HUNT) && scc->kiss.softdcd)
452 scc->dcd = 0;
453 flush_rx_FIFO(scc);
454 if ((scc->modem.clocksrc != CLK_EXTERNAL))
455 OutReg(scc->ctrl,R14,SEARCH|scc->wreg[R14]); /* DPLL: enter search mode */
457 scc->dcd = 1;
460 scc_notify(scc, scc->dcd? HWEV_DCD_OFF:HWEV_DCD_ON);
466 if((changes & DCD) && !scc->kiss.softdcd) /* DCD input changed state */
470 start_hunt(scc);
471 scc->dcd = 1;
473 cl(scc,R3,ENT_HM|RxENABLE); /* disable the receiver */
474 flush_rx_FIFO(scc);
475 scc->dcd = 0;
478 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF);
490 if (scc->kiss.txdelay == 0) /* zero TXDELAY = wait for CTS */
491 scc_start_tx_timer(scc, t_txdelay, 0);
495 if (scc->stat.tx_state == TXS_ACTIVE && (status & TxEOM))
497 scc->stat.tx_under++; /* oops, an underrun! count 'em */
498 Outb(scc->ctrl, RES_EXT_INT); /* reset ext/status interrupts */
500 if (scc->tx_buff != NULL)
502 dev_kfree_skb_irq(scc->tx_buff);
503 scc->tx_buff = NULL;
506 or(scc,R10,ABUNDER);
507 scc_start_tx_timer(scc, t_txdelay, 0); /* restart transmission */
510 scc->status = status;
511 Outb(scc->ctrl,RES_EXT_INT);
516 static inline void scc_rxint(struct scc_channel *scc)
520 scc->stat.rxints++;
522 if((scc->wreg[5] & RTS) && scc->kiss.fulldup == KISS_DUPLEX_HALF)
524 Inb(scc->data); /* discard char */
525 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */
529 skb = scc->rx_buff;
533 skb = dev_alloc_skb(scc->stat.bufsize);
536 scc->dev_stat.rx_dropped++;
537 scc->stat.nospace++;
538 Inb(scc->data);
539 or(scc, R3, ENT_HM);
543 scc->rx_buff = skb;
547 if (skb->len >= scc->stat.bufsize)
553 scc->rx_buff = NULL;
554 Inb(scc->data);
555 or(scc, R3, ENT_HM);
559 skb_put_u8(skb, Inb(scc->data));
564 static inline void scc_spint(struct scc_channel *scc)
569 scc->stat.spints++;
571 status = InReg(scc->ctrl,R1); /* read receiver status */
573 Inb(scc->data); /* throw away Rx byte */
574 skb = scc->rx_buff;
578 scc->stat.rx_over++; /* count them */
579 or(scc,R3,ENT_HM); /* enter hunt mode for next flag */
583 scc->rx_buff = skb = NULL;
594 scc_net_rx(scc, skb);
595 scc->rx_buff = NULL;
596 scc->stat.rxframes++;
599 scc->rx_buff = NULL;
600 scc->stat.rxerrs++;
604 Outb(scc->ctrl,ERR_RES);
610 static void scc_isr_dispatch(struct scc_channel *scc, int vector)
612 spin_lock(&scc->lock);
615 case TXINT: scc_txint(scc); break;
616 case EXINT: scc_exint(scc); break;
617 case RXINT: scc_rxint(scc); break;
618 case SPINT: scc_spint(scc); break;
620 spin_unlock(&scc->lock);
634 struct scc_channel *scc;
648 scc=&SCC_Info[vector >> 3 ^ 0x01];
649 if (!scc->dev) break;
651 scc_isr_dispatch(scc, vector);
653 OutReg(scc->ctrl,R0,RES_H_IUS); /* Reset Highest IUS */
675 scc = NULL;
681 scc = &SCC_Info[vector >> 3 ^ 0x01];
682 if (!scc->dev) break;
684 scc_isr_dispatch(scc, vector);
700 if (scc != NULL)
702 OutReg(scc->ctrl,R0,RES_H_IUS);
719 static inline void set_brg(struct scc_channel *scc, unsigned int tc)
721 cl(scc,R14,BRENABL); /* disable baudrate generator */
722 wr(scc,R12,tc & 255); /* brg rate LOW */
723 wr(scc,R13,tc >> 8); /* brg rate HIGH */
724 or(scc,R14,BRENABL); /* enable baudrate generator */
727 static inline void set_speed(struct scc_channel *scc)
730 spin_lock_irqsave(&scc->lock, flags);
732 if (scc->modem.speed > 0) /* paranoia... */
733 set_brg(scc, (unsigned) (scc->clock / (scc->modem.speed * 64)) - 2);
735 spin_unlock_irqrestore(&scc->lock, flags);
741 static inline void init_brg(struct scc_channel *scc)
743 wr(scc, R14, BRSRC); /* BRG source = PCLK */
744 OutReg(scc->ctrl, R14, SSBR|scc->wreg[R14]); /* DPLL source = BRG */
745 OutReg(scc->ctrl, R14, SNRZI|scc->wreg[R14]); /* DPLL NRZI mode */
793 static void init_channel(struct scc_channel *scc)
795 del_timer(&scc->tx_t);
796 del_timer(&scc->tx_wdog);
798 disable_irq(scc->irq);
800 wr(scc,R4,X1CLK|SDLC); /* *1 clock, SDLC mode */
801 wr(scc,R1,0); /* no W/REQ operation */
802 wr(scc,R3,Rx8|RxCRC_ENAB); /* RX 8 bits/char, CRC, disabled */
803 wr(scc,R5,Tx8|DTR|TxCRC_ENAB); /* TX 8 bits/char, disabled, DTR */
804 wr(scc,R6,0); /* SDLC address zero (not used) */
805 wr(scc,R7,FLAG); /* SDLC flag value */
806 wr(scc,R9,VIS); /* vector includes status */
807 wr(scc,R10,(scc->modem.nrz? NRZ : NRZI)|CRCPS|ABUNDER); /* abort on underrun, preset CRC generator, NRZ(I) */
808 wr(scc,R14, 0);
837 switch(scc->modem.clocksrc)
840 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP);
841 init_brg(scc);
845 wr(scc, R11, ((scc->brand & BAYCOM)? TRxCDP : TRxCBR) | RCDPLL|TCRTxCP|TRxCOI);
846 init_brg(scc);
850 wr(scc, R11, (scc->brand & BAYCOM)? RCTRxCP|TCRTxCP : RCRTxCP|TCTRxCP);
851 OutReg(scc->ctrl, R14, DISDPLL);
856 set_speed(scc); /* set baudrate */
858 if(scc->enhanced)
860 or(scc,R15,SHDLCE|FIFOE); /* enable FIFO, SDLC/HDLC Enhancements (From now R7 is R7') */
861 wr(scc,R7,AUTOEOM);
864 if(scc->kiss.softdcd || (InReg(scc->ctrl,R0) & DCD))
867 start_hunt(scc);
872 wr(scc,R15, BRKIE|TxUIE|(scc->kiss.softdcd? SYNCIE:DCDIE));
874 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
875 Outb(scc->ctrl,RES_EXT_INT); /* must be done twice */
877 or(scc,R1,INT_ALL_Rx|TxINT_ENAB|EXT_INT_ENAB); /* enable interrupts */
879 scc->status = InReg(scc->ctrl,R0); /* read initial status */
881 or(scc,R9,MIE); /* master interrupt enable */
883 scc_init_timer(scc);
885 enable_irq(scc->irq);
899 static void scc_key_trx(struct scc_channel *scc, char tx)
903 if (scc->brand & PRIMUS)
904 Outb(scc->ctrl + 4, scc->option | (tx? 0x80 : 0));
906 if (scc->modem.speed < 300)
907 scc->modem.speed = 1200;
909 time_const = (unsigned) (scc->clock / (scc->modem.speed * (tx? 2:64))) - 2;
911 disable_irq(scc->irq);
915 or(scc, R1, TxINT_ENAB); /* t_maxkeyup may have reset these */
916 or(scc, R15, TxUIE);
919 if (scc->modem.clocksrc == CLK_DPLL)
924 cl(scc, R3, RxENABLE|ENT_HM); /* switch off receiver */
925 cl(scc, R15, DCDIE|SYNCIE); /* No DCD changes, please */
927 set_brg(scc, time_const); /* reprogram baudrate generator */
930 wr(scc, R11, RCDPLL|TCBR|TRxCOI|TRxCBR);
933 if (scc->kiss.tx_inhibit)
935 or(scc,R5, TxENAB);
936 scc->wreg[R5] |= RTS;
938 or(scc,R5,RTS|TxENAB); /* set the RTS line and enable TX */
941 cl(scc,R5,RTS|TxENAB);
943 set_brg(scc, time_const); /* reprogram baudrate generator */
946 wr(scc, R11, RCDPLL|TCDPLL|TRxCOI|TRxCDP);
949 if (scc->kiss.softdcd)
952 or(scc,R15, scc->kiss.softdcd? SYNCIE:DCDIE);
953 start_hunt(scc);
960 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
962 cl(scc, R3, RxENABLE);
963 cl(scc, R15, DCDIE|SYNCIE);
967 if (scc->kiss.tx_inhibit)
969 or(scc,R5, TxENAB);
970 scc->wreg[R5] |= RTS;
972 or(scc,R5,RTS|TxENAB); /* enable tx */
975 cl(scc,R5,RTS|TxENAB); /* disable tx */
977 if ((scc->kiss.fulldup == KISS_DUPLEX_HALF) &&
979 scc->kiss.softdcd)
984 or(scc, R15, scc->kiss.softdcd? SYNCIE:DCDIE);
985 start_hunt(scc);
990 enable_irq(scc->irq);
996 static void __scc_start_tx_timer(struct scc_channel *scc,
1000 del_timer(&scc->tx_t);
1004 handler(&scc->tx_t);
1008 scc->tx_t.function = handler;
1009 scc->tx_t.expires = jiffies + (when*HZ)/100;
1010 add_timer(&scc->tx_t);
1014 static void scc_start_tx_timer(struct scc_channel *scc,
1020 spin_lock_irqsave(&scc->lock, flags);
1021 __scc_start_tx_timer(scc, handler, when);
1022 spin_unlock_irqrestore(&scc->lock, flags);
1025 static void scc_start_defer(struct scc_channel *scc)
1029 spin_lock_irqsave(&scc->lock, flags);
1030 del_timer(&scc->tx_wdog);
1032 if (scc->kiss.maxdefer != 0 && scc->kiss.maxdefer != TIMER_OFF)
1034 scc->tx_wdog.function = t_busy;
1035 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxdefer;
1036 add_timer(&scc->tx_wdog);
1038 spin_unlock_irqrestore(&scc->lock, flags);
1041 static void scc_start_maxkeyup(struct scc_channel *scc)
1045 spin_lock_irqsave(&scc->lock, flags);
1046 del_timer(&scc->tx_wdog);
1048 if (scc->kiss.maxkeyup != 0 && scc->kiss.maxkeyup != TIMER_OFF)
1050 scc->tx_wdog.function = t_maxkeyup;
1051 scc->tx_wdog.expires = jiffies + HZ*scc->kiss.maxkeyup;
1052 add_timer(&scc->tx_wdog);
1054 spin_unlock_irqrestore(&scc->lock, flags);
1062 static void scc_tx_done(struct scc_channel *scc)
1068 switch (scc->kiss.fulldup)
1071 scc->stat.tx_state = TXS_IDLE2;
1072 if (scc->kiss.idletime != TIMER_OFF)
1073 scc_start_tx_timer(scc, t_idle,
1074 scc->kiss.idletime*100);
1077 scc_notify(scc, HWEV_ALL_SENT);
1080 scc->stat.tx_state = TXS_BUSY;
1081 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1084 netif_wake_queue(scc->dev);
1090 static inline int is_grouped(struct scc_channel *scc)
1096 grp1 = scc->kiss.group;
1103 if (scc2 == scc || !(scc2->dev && grp2))
1128 struct scc_channel *scc = from_timer(scc, t, tx_t);
1130 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */
1132 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */
1133 scc->stat.tx_state = TXS_IDLE;
1134 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
1138 scc->stat.tx_state = TXS_BUSY;
1141 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
1145 if (scc->dcd || (scc->kiss.persist) < Rand || (scc->kiss.group && is_grouped(scc)) )
1147 scc_start_defer(scc);
1148 scc_start_tx_timer(scc, t_dwait, scc->kiss.slottime);
1153 if ( !(scc->wreg[R5] & RTS) )
1155 scc_key_trx(scc, TX_ON);
1156 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay);
1158 scc_start_tx_timer(scc, t_txdelay, 0);
1165 * kick transmission by a fake scc_txint(scc), start 'maxkeyup' watchdog.
1170 struct scc_channel *scc = from_timer(scc, t, tx_t);
1172 scc_start_maxkeyup(scc);
1174 if (scc->tx_buff == NULL)
1176 disable_irq(scc->irq);
1177 scc_txint(scc);
1178 enable_irq(scc->irq);
1191 struct scc_channel *scc = from_timer(scc, t, tx_t);
1194 spin_lock_irqsave(&scc->lock, flags);
1195 del_timer(&scc->tx_wdog);
1196 scc_key_trx(scc, TX_OFF);
1197 spin_unlock_irqrestore(&scc->lock, flags);
1199 if (scc->stat.tx_state == TXS_TIMEOUT) /* we had a timeout? */
1201 scc->stat.tx_state = TXS_WAIT;
1202 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100);
1206 scc->stat.tx_state = TXS_IDLE;
1207 netif_wake_queue(scc->dev);
1218 struct scc_channel *scc = from_timer(scc, t, tx_wdog);
1220 del_timer(&scc->tx_t);
1221 netif_stop_queue(scc->dev); /* don't pile on the wabbit! */
1223 scc_discard_buffers(scc);
1224 scc->stat.txerrs++;
1225 scc->stat.tx_state = TXS_IDLE;
1227 netif_wake_queue(scc->dev);
1237 struct scc_channel *scc = from_timer(scc, t, tx_wdog);
1240 spin_lock_irqsave(&scc->lock, flags);
1246 netif_stop_queue(scc->dev);
1247 scc_discard_buffers(scc);
1249 del_timer(&scc->tx_t);
1251 cl(scc, R1, TxINT_ENAB); /* force an ABORT, but don't */
1252 cl(scc, R15, TxUIE); /* count it. */
1253 OutReg(scc->ctrl, R0, RES_Tx_P);
1255 spin_unlock_irqrestore(&scc->lock, flags);
1257 scc->stat.txerrs++;
1258 scc->stat.tx_state = TXS_TIMEOUT;
1259 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1271 struct scc_channel *scc = from_timer(scc, t, tx_t);
1273 del_timer(&scc->tx_wdog);
1275 scc_key_trx(scc, TX_OFF);
1276 if(scc->kiss.mintime)
1277 scc_start_tx_timer(scc, t_dwait, scc->kiss.mintime*100);
1278 scc->stat.tx_state = TXS_WAIT;
1281 static void scc_init_timer(struct scc_channel *scc)
1285 spin_lock_irqsave(&scc->lock, flags);
1286 scc->stat.tx_state = TXS_IDLE;
1287 spin_unlock_irqrestore(&scc->lock, flags);
1302 static unsigned int scc_set_param(struct scc_channel *scc, unsigned int cmd, unsigned int arg)
1306 case PARAM_TXDELAY: scc->kiss.txdelay=arg; break;
1307 case PARAM_PERSIST: scc->kiss.persist=arg; break;
1308 case PARAM_SLOTTIME: scc->kiss.slottime=arg; break;
1309 case PARAM_TXTAIL: scc->kiss.tailtime=arg; break;
1310 case PARAM_FULLDUP: scc->kiss.fulldup=arg; break;
1312 case PARAM_GROUP: scc->kiss.group=arg; break;
1313 case PARAM_IDLE: scc->kiss.idletime=arg; break;
1314 case PARAM_MIN: scc->kiss.mintime=arg; break;
1315 case PARAM_MAXKEY: scc->kiss.maxkeyup=arg; break;
1316 case PARAM_WAIT: scc->kiss.waittime=arg; break;
1317 case PARAM_MAXDEFER: scc->kiss.maxdefer=arg; break;
1318 case PARAM_TX: scc->kiss.tx_inhibit=arg; break;
1321 scc->kiss.softdcd=arg;
1324 or(scc, R15, SYNCIE);
1325 cl(scc, R15, DCDIE);
1326 start_hunt(scc);
1328 or(scc, R15, DCDIE);
1329 cl(scc, R15, SYNCIE);
1335 scc->modem.speed=arg*100;
1337 scc->modem.speed=arg;
1339 if (scc->stat.tx_state == 0) /* only switch baudrate on rx... ;-) */
1340 set_speed(scc);
1344 if ( !(scc->wreg[R5] & RTS) )
1347 scc_key_trx(scc, TX_ON);
1348 scc_start_tx_timer(scc, t_txdelay, scc->kiss.txdelay);
1353 scc->stat.tx_state = TXS_BUSY;
1354 scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
1360 scc_notify(scc, scc->dcd? HWEV_DCD_ON:HWEV_DCD_OFF);
1371 static unsigned long scc_get_param(struct scc_channel *scc, unsigned int cmd)
1375 case PARAM_TXDELAY: return CAST(scc->kiss.txdelay);
1376 case PARAM_PERSIST: return CAST(scc->kiss.persist);
1377 case PARAM_SLOTTIME: return CAST(scc->kiss.slottime);
1378 case PARAM_TXTAIL: return CAST(scc->kiss.tailtime);
1379 case PARAM_FULLDUP: return CAST(scc->kiss.fulldup);
1380 case PARAM_SOFTDCD: return CAST(scc->kiss.softdcd);
1381 case PARAM_DTR: return CAST((scc->wreg[R5] & DTR)? 1:0);
1382 case PARAM_RTS: return CAST((scc->wreg[R5] & RTS)? 1:0);
1383 case PARAM_SPEED: return CAST(scc->modem.speed);
1384 case PARAM_GROUP: return CAST(scc->kiss.group);
1385 case PARAM_IDLE: return CAST(scc->kiss.idletime);
1386 case PARAM_MIN: return CAST(scc->kiss.mintime);
1387 case PARAM_MAXKEY: return CAST(scc->kiss.maxkeyup);
1388 case PARAM_WAIT: return CAST(scc->kiss.waittime);
1389 case PARAM_MAXDEFER: return CAST(scc->kiss.maxdefer);
1390 case PARAM_TX: return CAST(scc->kiss.tx_inhibit);
1404 struct scc_channel *scc = from_timer(scc, t, tx_wdog);
1407 spin_lock_irqsave(&scc->lock, flags);
1408 del_timer(&scc->tx_wdog);
1409 scc_key_trx(scc, TX_OFF);
1410 wr(scc, R6, 0);
1411 wr(scc, R7, FLAG);
1412 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
1413 Outb(scc->ctrl,RES_EXT_INT);
1415 netif_wake_queue(scc->dev);
1416 spin_unlock_irqrestore(&scc->lock, flags);
1421 scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern)
1425 spin_lock_irqsave(&scc->lock, flags);
1426 netif_stop_queue(scc->dev);
1427 scc_discard_buffers(scc);
1429 del_timer(&scc->tx_wdog);
1431 scc->tx_wdog.function = scc_stop_calibrate;
1432 scc->tx_wdog.expires = jiffies + HZ*duration;
1433 add_timer(&scc->tx_wdog);
1436 wr(scc, R6, 0);
1437 wr(scc, R7, pattern);
1444 Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
1445 Outb(scc->ctrl,RES_EXT_INT);
1447 scc_key_trx(scc, TX_ON);
1448 spin_unlock_irqrestore(&scc->lock, flags);
1461 struct scc_channel *scc;
1482 scc=&SCC_Info[2*chip];
1483 if (!scc->ctrl) continue;
1487 if(scc->brand & EAGLE) /* this is an EAGLE card */
1488 Outb(scc->special,0x08); /* enable interrupt on the board */
1490 if(scc->brand & (PC100 | PRIMUS)) /* this is a PC100/PRIMUS card */
1491 Outb(scc->special,scc->option); /* set the MODEM mode (0x22) */
1496 spin_lock_irqsave(&scc->lock, flags);
1498 Outb(scc->ctrl, 0);
1499 OutReg(scc->ctrl,R9,FHWRES); /* force hardware reset */
1501 wr(scc, R2, chip*16); /* interrupt vector */
1502 wr(scc, R9, VIS); /* vector includes status */
1503 spin_unlock_irqrestore(&scc->lock, flags);
1514 static int scc_net_alloc(const char *name, struct scc_channel *scc)
1523 dev->ml_priv = scc;
1524 scc->dev = dev;
1525 spin_lock_init(&scc->lock);
1526 timer_setup(&scc->tx_t, NULL, 0);
1527 timer_setup(&scc->tx_wdog, NULL, 0);
1534 scc->dev = NULL;
1581 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1583 if (!scc->init)
1586 scc->tx_buff = NULL;
1587 skb_queue_head_init(&scc->tx_queue);
1589 init_channel(scc);
1599 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1604 spin_lock_irqsave(&scc->lock, flags);
1605 Outb(scc->ctrl,0); /* Make sure pointer is written */
1606 wr(scc,R1,0); /* disable interrupts */
1607 wr(scc,R3,0);
1608 spin_unlock_irqrestore(&scc->lock, flags);
1610 del_timer_sync(&scc->tx_t);
1611 del_timer_sync(&scc->tx_wdog);
1613 scc_discard_buffers(scc);
1620 static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
1627 scc->dev_stat.rx_packets++;
1628 scc->dev_stat.rx_bytes += skb->len;
1630 skb->protocol = ax25_type_trans(skb, scc->dev);
1639 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1646 if (skb->len > scc->stat.bufsize || skb->len < 2) {
1647 scc->dev_stat.tx_dropped++; /* bogus frame */
1652 scc->dev_stat.tx_packets++;
1653 scc->dev_stat.tx_bytes += skb->len;
1654 scc->stat.txframes++;
1660 scc_set_param(scc, kisscmd, *skb->data);
1665 spin_lock_irqsave(&scc->lock, flags);
1667 if (skb_queue_len(&scc->tx_queue) > scc->dev->tx_queue_len) {
1669 skb_del = skb_dequeue(&scc->tx_queue);
1672 skb_queue_tail(&scc->tx_queue, skb);
1682 if(scc->stat.tx_state == TXS_IDLE || scc->stat.tx_state == TXS_IDLE2) {
1683 scc->stat.tx_state = TXS_BUSY;
1684 if (scc->kiss.fulldup == KISS_DUPLEX_HALF)
1685 __scc_start_tx_timer(scc, t_dwait, scc->kiss.waittime);
1687 __scc_start_tx_timer(scc, t_dwait, 0);
1689 spin_unlock_irqrestore(&scc->lock, flags);
1712 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1749 if (!request_region(hwcfg.vector_latch, 1, "scc vector latch"))
1760 if(request_region(hwcfg.ctrl_a, 1, "scc-probe"))
1819 request_region(SCC_Info[2*Nchips+chan].ctrl, 1, "scc ctrl");
1820 request_region(SCC_Info[2*Nchips+chan].data, 1, "scc data");
1848 if (!scc->init)
1855 scc->stat.bufsize = SCC_BUFSIZE;
1857 if (copy_from_user(&scc->modem, arg, sizeof(struct scc_modem)))
1862 if (scc->modem.speed < 4800)
1864 scc->kiss.txdelay = 36; /* 360 ms */
1865 scc->kiss.persist = 42; /* 25% persistence */ /* was 25 */
1866 scc->kiss.slottime = 16; /* 160 ms */
1867 scc->kiss.tailtime = 4; /* minimal reasonable value */
1868 scc->kiss.fulldup = 0; /* CSMA */
1869 scc->kiss.waittime = 50; /* 500 ms */
1870 scc->kiss.maxkeyup = 10; /* 10 s */
1871 scc->kiss.mintime = 3; /* 3 s */
1872 scc->kiss.idletime = 30; /* 30 s */
1873 scc->kiss.maxdefer = 120; /* 2 min */
1874 scc->kiss.softdcd = 0; /* hardware dcd */
1876 scc->kiss.txdelay = 10; /* 100 ms */
1877 scc->kiss.persist = 64; /* 25% persistence */ /* was 25 */
1878 scc->kiss.slottime = 8; /* 160 ms */
1879 scc->kiss.tailtime = 1; /* minimal reasonable value */
1880 scc->kiss.fulldup = 0; /* CSMA */
1881 scc->kiss.waittime = 50; /* 500 ms */
1882 scc->kiss.maxkeyup = 7; /* 7 s */
1883 scc->kiss.mintime = 3; /* 3 s */
1884 scc->kiss.idletime = 30; /* 30 s */
1885 scc->kiss.maxdefer = 120; /* 2 min */
1886 scc->kiss.softdcd = 0; /* hardware dcd */
1889 scc->tx_buff = NULL;
1890 skb_queue_head_init(&scc->tx_queue);
1891 scc->init = 1;
1908 scc->stat.bufsize = memcfg.bufsize;
1912 if (!arg || copy_to_user(arg, &scc->stat, sizeof(scc->stat)))
1919 kiss_cmd.param = scc_get_param(scc, kiss_cmd.command);
1928 return scc_set_param(scc, kiss_cmd.command, kiss_cmd.param);
1935 scc_start_calibrate(scc, cal.time, cal.pattern);
1959 struct scc_channel *scc = (struct scc_channel *) dev->ml_priv;
1961 scc->dev_stat.rx_errors = scc->stat.rxerrs + scc->stat.rx_over;
1962 scc->dev_stat.tx_errors = scc->stat.txerrs + scc->stat.tx_under;
1963 scc->dev_stat.rx_fifo_errors = scc->stat.rx_over;
1964 scc->dev_stat.tx_fifo_errors = scc->stat.tx_under;
1966 return &scc->dev_stat;
1997 struct scc_channel *scc = v;
2000 for (k = (v == SEQ_START_TOKEN) ? 0 : (scc - SCC_Info)+1;
2021 const struct scc_channel *scc = v;
2022 const struct scc_stat *stat = &scc->stat;
2023 const struct scc_kiss *kiss = &scc->kiss;
2036 scc->dev->name,
2037 scc->data, scc->ctrl, scc->irq, scc->clock, scc->brand,
2038 scc->enhanced, Vector_Latch, scc->special,
2039 scc->option);
2041 scc->modem.speed, scc->modem.nrz,
2042 scc->modem.clocksrc, kiss->softdcd,
2063 seq_printf(seq, "%2.2x ", scc->wreg[reg]);
2066 seq_printf(seq, "\tR %2.2x %2.2x XX ", InReg(scc->ctrl,R0), InReg(scc->ctrl,R1));
2068 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg));
2071 seq_printf(seq, "%2.2x ", InReg(scc->ctrl, reg));
2119 struct scc_channel *scc;
2148 scc = &SCC_Info[k];
2149 if (scc->ctrl)
2151 release_region(scc->ctrl, 1);
2152 release_region(scc->data, 1);
2154 if (scc->dev)
2156 unregister_netdev(scc->dev);
2157 free_netdev(scc->dev);