Lines Matching +full:modem +full:- +full:init

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * baycom_par.c -- baycom par96 and picpar radio modem driver.
7 * Copyright (C) 1996-2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
15 * par96: This is a modem for 9600 baud FSK compatible to the G3RUH standard.
16 * The modem does all the filtering and regenerates the receiver clock.
20 * modem connects to the parallel port, hence the name. The modem
22 * polynomial to the PC. This modem is no longer available (at least
23 * from Baycom) and has been replaced by the PICPAR modem (see below).
25 * cq-DL :-).
27 * picpar: This is a redesign of the par96 modem by Henning Rech, DF9IC. The
28 * modem is protocol compatible to par96, but uses only three low
42 * 0.3 26.04.1997 init code/data tagged
46 * removed some pre-2.2 kernel compatibility cruft
63 #include <linux/init.h>
75 /* --------------------------------------------------------------------- */
80 * modem options; bit mask
84 /* --------------------------------------------------------------------- */
87 static const char bc_drvinfo[] = KERN_INFO "baycom_par: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
90 /* --------------------------------------------------------------------- */
96 /* --------------------------------------------------------------------- */
107 /* ---------------------------------------------------------------------- */
128 } modem; member
141 /* --------------------------------------------------------------------- */
150 bc->debug_vals.cur_intcnt++; in baycom_int_freq()
151 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) { in baycom_int_freq()
152 bc->debug_vals.last_jiffies = cur_jiffies; in baycom_int_freq()
153 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; in baycom_int_freq()
154 bc->debug_vals.cur_intcnt = 0; in baycom_int_freq()
155 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr; in baycom_int_freq()
156 bc->debug_vals.cur_pllcorr = 0; in baycom_int_freq()
161 /* --------------------------------------------------------------------- */
177 /* --------------------------------------------------------------------- */
182 unsigned int data = hdlcdrv_getbits(&bc->hdrv); in par96_tx()
183 struct parport *pp = bc->pdev->port; in par96_tx()
187 bc->modem.par96.scram = ((bc->modem.par96.scram << 1) | in par96_tx()
188 (bc->modem.par96.scram & 1)); in par96_tx()
190 bc->modem.par96.scram ^= 1; in par96_tx()
191 if (bc->modem.par96.scram & (PAR96_SCRAM_TAP1 << 1)) in par96_tx()
192 bc->modem.par96.scram ^= in par96_tx()
194 if (bc->modem.par96.scram & (PAR96_SCRAM_TAP1 << 2)) in par96_tx()
196 pp->ops->write_data(pp, val); in par96_tx()
197 pp->ops->write_data(pp, val | PAR96_BURST); in par96_tx()
201 /* --------------------------------------------------------------------- */
207 struct parport *pp = bc->pdev->port; in par96_rx()
213 bc->modem.par96.descram = (bc->modem.par96.descram << 1); in par96_rx()
214 if (pp->ops->read_status(pp) & PAR96_RXBIT) in par96_rx()
215 bc->modem.par96.descram |= 1; in par96_rx()
216 descx = bc->modem.par96.descram ^ in par96_rx()
217 (bc->modem.par96.descram >> 1); in par96_rx()
219 pp->ops->write_data(pp, PAR97_POWER | PAR96_PTT); in par96_rx()
225 pp->ops->write_data(pp, PAR97_POWER | PAR96_PTT | PAR96_BURST); in par96_rx()
227 hdlcdrv_putbits(&bc->hdrv, data); in par96_rx()
231 if (bc->options & BAYCOM_OPTIONS_SOFTDCD) { in par96_rx()
232 bc->modem.par96.dcd_shreg = (bc->modem.par96.dcd_shreg >> 16) in par96_rx()
237 if ((bc->modem.par96.dcd_shreg & mask) == mask2) in par96_rx()
238 bc->modem.par96.dcd_count = HDLCDRV_MAXFLEN+4; in par96_rx()
242 if (((bc->modem.par96.dcd_shreg & mask) == mask2) && in par96_rx()
243 (bc->modem.par96.dcd_count >= 0)) in par96_rx()
244 bc->modem.par96.dcd_count -= HDLCDRV_MAXFLEN-10; in par96_rx()
246 if (bc->modem.par96.dcd_count >= 0) in par96_rx()
247 bc->modem.par96.dcd_count -= 2; in par96_rx()
248 hdlcdrv_setdcd(&bc->hdrv, bc->modem.par96.dcd_count > 0); in par96_rx()
250 hdlcdrv_setdcd(&bc->hdrv, !!(pp->ops->read_status(pp) & PAR96_DCD)); in par96_rx()
254 /* --------------------------------------------------------------------- */
265 if (hdlcdrv_ptt(&bc->hdrv)) in par96_interrupt()
269 if (--bc->modem.arb_divider <= 0) { in par96_interrupt()
270 bc->modem.arb_divider = 6; in par96_interrupt()
272 hdlcdrv_arbitrate(dev, &bc->hdrv); in par96_interrupt()
276 hdlcdrv_transmitter(dev, &bc->hdrv); in par96_interrupt()
277 hdlcdrv_receiver(dev, &bc->hdrv); in par96_interrupt()
281 /* --------------------------------------------------------------------- */
288 printk(KERN_DEBUG "baycom_par: %s: why am I being woken up?\n", dev->name); in par96_wakeup()
289 if (!parport_claim(bc->pdev)) in par96_wakeup()
290 printk(KERN_DEBUG "baycom_par: %s: I'm broken.\n", dev->name); in par96_wakeup()
293 /* --------------------------------------------------------------------- */
303 return -ENXIO; in par96_open()
304 pp = parport_find_base(dev->base_addr); in par96_open()
306 printk(KERN_ERR "baycom_par: parport at 0x%lx unknown\n", dev->base_addr); in par96_open()
307 return -ENXIO; in par96_open()
309 if (pp->irq < 0) { in par96_open()
310 printk(KERN_ERR "baycom_par: parport at 0x%lx has no irq\n", pp->base); in par96_open()
312 return -ENXIO; in par96_open()
314 if ((~pp->modes) & (PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT)) { in par96_open()
315 printk(KERN_ERR "baycom_par: parport at 0x%lx cannot be used\n", pp->base); in par96_open()
317 return -ENXIO; in par96_open()
319 memset(&bc->modem, 0, sizeof(bc->modem)); in par96_open()
320 bc->hdrv.par.bitrate = 9600; in par96_open()
333 return -ENODEV; in par96_open()
335 bc->pdev = parport_register_dev_model(pp, dev->name, &par_cb, i); in par96_open()
337 if (!bc->pdev) { in par96_open()
338 printk(KERN_ERR "baycom_par: cannot register parport at 0x%lx\n", dev->base_addr); in par96_open()
339 return -ENXIO; in par96_open()
341 if (parport_claim(bc->pdev)) { in par96_open()
342 printk(KERN_ERR "baycom_par: parport at 0x%lx busy\n", pp->base); in par96_open()
343 parport_unregister_device(bc->pdev); in par96_open()
344 return -EBUSY; in par96_open()
346 pp = bc->pdev->port; in par96_open()
347 dev->irq = pp->irq; in par96_open()
348 pp->ops->data_forward(pp); in par96_open()
349 bc->hdrv.par.bitrate = 9600; in par96_open()
350 pp->ops->write_data(pp, PAR96_PTT | PAR97_POWER); /* switch off PTT */ in par96_open()
351 pp->ops->enable_irq(pp); in par96_open()
353 bc_drvname, dev->base_addr, dev->irq, bc->options); in par96_open()
357 /* --------------------------------------------------------------------- */
365 return -EINVAL; in par96_close()
366 pp = bc->pdev->port; in par96_close()
368 pp->ops->disable_irq(pp); in par96_close()
370 pp->ops->write_data(pp, PAR96_PTT | PAR97_POWER); in par96_close()
371 parport_release(bc->pdev); in par96_close()
372 parport_unregister_device(bc->pdev); in par96_close()
374 bc_drvname, dev->base_addr, dev->irq); in par96_close()
378 /* --------------------------------------------------------------------- */
386 /* --------------------------------------------------------------------- */
396 /* --------------------------------------------------------------------- */
401 bc->options = 0; in baycom_setmode()
403 bc->options = BAYCOM_OPTIONS_SOFTDCD; in baycom_setmode()
405 bc->options = !!strchr(modestr, '*'); in baycom_setmode()
409 /* --------------------------------------------------------------------- */
418 return -EINVAL; in baycom_ioctl()
421 BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); in baycom_ioctl()
424 return -ENOIOCTLCMD; in baycom_ioctl()
425 switch (hi->cmd) { in baycom_ioctl()
430 strcpy(hi->data.modename, bc->options ? "par96" : "picpar"); in baycom_ioctl()
431 if (copy_to_user(ifr->ifr_data, hi, sizeof(struct hdlcdrv_ioctl))) in baycom_ioctl()
432 return -EFAULT; in baycom_ioctl()
437 return -EACCES; in baycom_ioctl()
438 hi->data.modename[sizeof(hi->data.modename)-1] = '\0'; in baycom_ioctl()
439 return baycom_setmode(bc, hi->data.modename); in baycom_ioctl()
442 strcpy(hi->data.modename, "par96,picpar"); in baycom_ioctl()
443 if (copy_to_user(ifr->ifr_data, hi, sizeof(struct hdlcdrv_ioctl))) in baycom_ioctl()
444 return -EFAULT; in baycom_ioctl()
452 if (copy_from_user(&bi, ifr->ifr_data, sizeof(bi))) in baycom_ioctl()
453 return -EFAULT; in baycom_ioctl()
456 return -ENOIOCTLCMD; in baycom_ioctl()
460 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed; in baycom_ioctl()
461 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt; in baycom_ioctl()
462 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr; in baycom_ioctl()
467 if (copy_to_user(ifr->ifr_data, &bi, sizeof(bi))) in baycom_ioctl()
468 return -EFAULT; in baycom_ioctl()
473 /* --------------------------------------------------------------------- */
487 MODULE_DESCRIPTION("Baycom par96 and picpar amateur radio modem driver");
490 /* --------------------------------------------------------------------- */
494 struct device_driver *drv = par_dev->dev.driver; in baycom_par_probe()
495 int len = strlen(drv->name); in baycom_par_probe()
497 if (strncmp(par_dev->name, drv->name, len)) in baycom_par_probe()
498 return -ENODEV; in baycom_par_probe()
550 return -ENXIO; in init_baycompar()
571 /* --------------------------------------------------------------------- */
599 /* --------------------------------------------------------------------- */