Lines Matching refs:bc

155 static void inline baycom_int_freq(struct baycom_state *bc)  in baycom_int_freq()  argument
162 bc->debug_vals.cur_intcnt++; in baycom_int_freq()
163 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { in baycom_int_freq()
164 bc->debug_vals.last_jiffies = cur_jiffies; in baycom_int_freq()
165 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; in baycom_int_freq()
166 bc->debug_vals.cur_intcnt = 0; in baycom_int_freq()
167 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr; in baycom_int_freq()
168 bc->debug_vals.cur_pllcorr = 0; in baycom_int_freq()
227 static __inline__ void ser12_rx(struct net_device *dev, struct baycom_state *bc, struct timeval *tv… in ser12_rx() argument
230 int bdus8 = bc->baud_us >> 3; in ser12_rx()
231 int bdus4 = bc->baud_us >> 2; in ser12_rx()
232 int bdus2 = bc->baud_us >> 1; in ser12_rx()
234 timediff = 1000000 + tv->tv_usec - bc->modem.ser12.pll_time; in ser12_rx()
238 timediff -= bc->baud_us; in ser12_rx()
239 bc->modem.ser12.pll_time += bc->baud_us; in ser12_rx()
240 bc->modem.ser12.dcd_time--; in ser12_rx()
242 if (bc->modem.shreg & 1) { in ser12_rx()
243 hdlcdrv_putbits(&bc->hdrv, (bc->modem.shreg >> 1) ^ 0xffff); in ser12_rx()
244 bc->modem.shreg = 0x10000; in ser12_rx()
247 bc->modem.shreg >>= 1; in ser12_rx()
249 if (bc->modem.ser12.dcd_time <= 0) { in ser12_rx()
250 if (!bc->opt_dcd) in ser12_rx()
251 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
252 bc->modem.ser12.dcd_sum1 + in ser12_rx()
253 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
254 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
255 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
256 bc->modem.ser12.dcd_sum0 = 2; /* slight bias */ in ser12_rx()
257 bc->modem.ser12.dcd_time += 120; in ser12_rx()
259 if (bc->modem.ser12.last_rxbit != curs) { in ser12_rx()
260 bc->modem.ser12.last_rxbit = curs; in ser12_rx()
261 bc->modem.shreg |= 0x10000; in ser12_rx()
264 bc->modem.ser12.pll_time += bdus8; in ser12_rx()
266 bc->modem.ser12.pll_time += 1000000 - bdus8; in ser12_rx()
269 bc->modem.ser12.dcd_sum0 += 4; in ser12_rx()
271 bc->modem.ser12.dcd_sum0--; in ser12_rx()
273 bc->debug_vals.cur_pllcorr = timediff; in ser12_rx()
276 while (bc->modem.ser12.pll_time >= 1000000) in ser12_rx()
277 bc->modem.ser12.pll_time -= 1000000; in ser12_rx()
285 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_interrupt() local
290 if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC) in ser12_interrupt()
299 if ((msr & 8) && bc->opt_dcd) in ser12_interrupt()
300 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80)); in ser12_interrupt()
318 baycom_int_freq(bc); in ser12_interrupt()
324 if (bc->modem.ptt) in ser12_interrupt()
325 outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr)); in ser12_interrupt()
333 if ((msr & 8) && bc->opt_dcd) in ser12_interrupt()
334 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80)); in ser12_interrupt()
339 ser12_rx(dev, bc, &tv, msr & 0x10); /* CTS */ in ser12_interrupt()
340 if (bc->modem.ptt && txcount) { in ser12_interrupt()
341 if (bc->modem.ser12.txshreg <= 1) { in ser12_interrupt()
342 bc->modem.ser12.txshreg = 0x10000 | hdlcdrv_getbits(&bc->hdrv); in ser12_interrupt()
343 if (!hdlcdrv_ptt(&bc->hdrv)) { in ser12_interrupt()
345 bc->modem.ptt = 0; in ser12_interrupt()
349 bc->modem.ser12.tx_bit = !(bc->modem.ser12.tx_bit ^ (bc->modem.ser12.txshreg & 1)); in ser12_interrupt()
350 bc->modem.ser12.txshreg >>= 1; in ser12_interrupt()
354 if (!bc->modem.ptt && txcount) { in ser12_interrupt()
355 hdlcdrv_arbitrate(dev, &bc->hdrv); in ser12_interrupt()
356 if (hdlcdrv_ptt(&bc->hdrv)) { in ser12_interrupt()
357 ser12_set_divisor(dev, bc->baud_uartdiv); in ser12_interrupt()
358 bc->modem.ser12.txshreg = 1; in ser12_interrupt()
359 bc->modem.ptt = 1; in ser12_interrupt()
362 hdlcdrv_transmitter(dev, &bc->hdrv); in ser12_interrupt()
363 hdlcdrv_receiver(dev, &bc->hdrv); in ser12_interrupt()
410 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_open() local
413 if (!dev || !bc) in ser12_open()
418 if (bc->baud < 300 || bc->baud > 4800) in ser12_open()
425 memset(&bc->modem, 0, sizeof(bc->modem)); in ser12_open()
426 bc->hdrv.par.bitrate = bc->baud; in ser12_open()
427 bc->baud_us = 1000000/bc->baud; in ser12_open()
428 bc->baud_uartdiv = (115200/8)/bc->baud; in ser12_open()
459 hdlcdrv_setdcd(&bc->hdrv, 0); in ser12_open()
461 bc_drvname, dev->base_addr, dev->irq, bc->baud, uart_str[u]); in ser12_open()
470 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_close() local
472 if (!dev || !bc) in ser12_close()
509 static int baycom_setmode(struct baycom_state *bc, const char *modestr) in baycom_setmode() argument
516 bc->baud = baud*100; in baycom_setmode()
519 bc->opt_dcd = 0; in baycom_setmode()
521 bc->opt_dcd = -1; in baycom_setmode()
523 bc->opt_dcd = 1; in baycom_setmode()
532 struct baycom_state *bc; in baycom_ioctl() local
541 bc = (struct baycom_state *)dev->priv; in baycom_ioctl()
552 sprintf(hi->data.modename, "ser%u", bc->baud / 100); in baycom_ioctl()
553 if (bc->opt_dcd <= 0) in baycom_ioctl()
554 strcat(hi->data.modename, (!bc->opt_dcd) ? "*" : "+"); in baycom_ioctl()
563 return baycom_setmode(bc, hi->data.modename); in baycom_ioctl()
584 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed; in baycom_ioctl()
585 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt; in baycom_ioctl()
586 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr; in baycom_ioctl()
626 struct baycom_state *bc; in init_baycomserfdx() local
644 bc = (struct baycom_state *)dev->priv; in init_baycomserfdx()
645 if (set_hw && baycom_setmode(bc, mode[i])) in init_baycomserfdx()
647 bc->baud = baud[i]; in init_baycomserfdx()
665 struct baycom_state *bc = (struct baycom_state *)dev->priv; in cleanup_baycomserfdx() local
667 if (bc) { in cleanup_baycomserfdx()
668 if (bc->hdrv.magic != HDLCDRV_MAGIC) in cleanup_baycomserfdx()