71 #include <linux/module.h>
72 #include <linux/kernel.h>
73 #include <linux/types.h>
74 #include <linux/fcntl.h>
78 #include <linux/string.h>
81 #include <linux/errno.h>
82 #include <linux/netdevice.h>
83 #include <linux/hdlcdrv.h>
85 #include <linux/parport.h>
86 #include <linux/bitops.h>
89 #include <asm/uaccess.h>
98 #define BAYCOM_OPTIONS_SOFTDCD 1
102 static const char bc_drvname[] =
"baycom_par";
103 static const char bc_drvinfo[] =
KERN_INFO "baycom_par: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
104 "baycom_par: version 0.9\n";
114 #define PAR96_BURSTBITS 16
115 #define PAR96_BURST 4
117 #define PAR96_TXBIT 1
118 #define PAR96_ACK 0x40
119 #define PAR96_RXBIT 0x20
120 #define PAR96_DCD 0x10
121 #define PAR97_POWER 0xf8
162 unsigned long cur_jiffies =
jiffies;
182 #define PAR96_DESCRAM_TAP1 0x20000
183 #define PAR96_DESCRAM_TAP2 0x01000
184 #define PAR96_DESCRAM_TAP3 0x00001
186 #define PAR96_DESCRAM_TAPSH1 17
187 #define PAR96_DESCRAM_TAPSH2 12
188 #define PAR96_DESCRAM_TAPSH3 0
190 #define PAR96_SCRAM_TAP1 0x20000
191 #define PAR96_SCRAM_TAPN 0x00021
198 unsigned int data = hdlcdrv_getbits(&bc->
hdrv);
201 for(i = 0; i < PAR96_BURSTBITS; i++, data >>= 1) {
203 bc->
modem.par96.scram = ((bc->
modem.par96.scram << 1) |
204 (bc->
modem.par96.scram & 1));
206 bc->
modem.par96.scram ^= 1;
208 bc->
modem.par96.scram ^=
212 pp->
ops->write_data(pp, val);
222 unsigned int data,
mask, mask2, descx;
229 bc->
modem.par96.descram = (bc->
modem.par96.descram << 1);
231 bc->
modem.par96.descram |= 1;
232 descx = bc->
modem.par96.descram ^
233 (bc->
modem.par96.descram >> 1);
243 hdlcdrv_putbits(&bc->
hdrv, data);
248 bc->
modem.par96.dcd_shreg = (bc->
modem.par96.dcd_shreg >> 16)
251 for(mask = 0x1fe00, mask2 = 0xfc00, i = 0;
253 if ((bc->
modem.par96.dcd_shreg & mask) == mask2)
256 for(mask = 0x1fe00, mask2 = 0x1fe00, i = 0;
257 i < PAR96_BURSTBITS; i++, mask <<= 1, mask2 <<= 1)
258 if (((bc->
modem.par96.dcd_shreg & mask) == mask2) &&
259 (bc->
modem.par96.dcd_count >= 0))
262 if (bc->
modem.par96.dcd_count >= 0)
263 bc->
modem.par96.dcd_count -= 2;
264 hdlcdrv_setdcd(&bc->
hdrv, bc->
modem.par96.dcd_count > 0);
272 static void par96_interrupt(
void *
dev_id)
281 if (hdlcdrv_ptt(&bc->
hdrv))
285 if (--bc->
modem.arb_divider <= 0) {
286 bc->
modem.arb_divider = 6;
299 static void par96_wakeup(
void *
handle)
334 bc->
hdrv.par.bitrate = 9600;
349 pp->
ops->data_forward(pp);
350 bc->
hdrv.par.bitrate = 9600;
352 pp->
ops->enable_irq(pp);
360 static int par96_close(
struct net_device *dev)
369 pp->
ops->disable_irq(pp);
390 .drvname = bc_drvname,
391 .drvinfo = bc_drvinfo,
393 .close = par96_close,
399 static int baycom_setmode(
struct baycom_state *bc,
const char *modestr)
401 if (!
strncmp(modestr,
"picpar", 6))
403 else if (!
strncmp(modestr,
"par96", 5))
421 bc = netdev_priv(dev);
461 bi.data.dbg.debug1 = bc->
hdrv.ptt_keyed;
493 static int __init init_baycompar(
void)
516 ifname, iobase[i], 0, 0);
520 bc = netdev_priv(dev);
521 if (set_hw && baycom_setmode(bc, mode[i]))
524 baycom_device[
i] =
dev;
532 static void __exit cleanup_baycompar(
void)
556 static int __init baycom_par_setup(
char *
str)
558 static unsigned nr_dev;
561 if (nr_dev >= NR_PORTS)
567 iobase[nr_dev] = ints[1];
572 __setup(
"baycom_par=", baycom_par_setup);