Lines Matching refs:bc
145 static inline void baycom_int_freq(struct baycom_state *bc) in baycom_int_freq() argument
152 bc->debug_vals.cur_intcnt++; in baycom_int_freq()
153 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) { in baycom_int_freq()
154 bc->debug_vals.last_jiffies = cur_jiffies; in baycom_int_freq()
155 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; in baycom_int_freq()
156 bc->debug_vals.cur_intcnt = 0; in baycom_int_freq()
157 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr; in baycom_int_freq()
158 bc->debug_vals.cur_pllcorr = 0; in baycom_int_freq()
191 static __inline__ void ser12_rx(struct net_device *dev, struct baycom_state *bc, struct timespec64 … in ser12_rx() argument
194 int bdus8 = bc->baud_us >> 3; in ser12_rx()
195 int bdus4 = bc->baud_us >> 2; in ser12_rx()
196 int bdus2 = bc->baud_us >> 1; in ser12_rx()
199 bc->modem.ser12.pll_time; in ser12_rx()
203 timediff -= bc->baud_us; in ser12_rx()
204 bc->modem.ser12.pll_time += bc->baud_us; in ser12_rx()
205 bc->modem.ser12.dcd_time--; in ser12_rx()
207 if (bc->modem.shreg & 1) { in ser12_rx()
208 hdlcdrv_putbits(&bc->hdrv, (bc->modem.shreg >> 1) ^ 0xffff); in ser12_rx()
209 bc->modem.shreg = 0x10000; in ser12_rx()
212 bc->modem.shreg >>= 1; in ser12_rx()
214 if (bc->modem.ser12.dcd_time <= 0) { in ser12_rx()
215 if (!bc->opt_dcd) in ser12_rx()
216 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
217 bc->modem.ser12.dcd_sum1 + in ser12_rx()
218 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
219 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
220 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
221 bc->modem.ser12.dcd_sum0 = 2; /* slight bias */ in ser12_rx()
222 bc->modem.ser12.dcd_time += 120; in ser12_rx()
224 if (bc->modem.ser12.last_rxbit != curs) { in ser12_rx()
225 bc->modem.ser12.last_rxbit = curs; in ser12_rx()
226 bc->modem.shreg |= 0x10000; in ser12_rx()
229 bc->modem.ser12.pll_time += bdus8; in ser12_rx()
231 bc->modem.ser12.pll_time += 1000000 - bdus8; in ser12_rx()
234 bc->modem.ser12.dcd_sum0 += 4; in ser12_rx()
236 bc->modem.ser12.dcd_sum0--; in ser12_rx()
238 bc->debug_vals.cur_pllcorr = timediff; in ser12_rx()
241 while (bc->modem.ser12.pll_time >= 1000000) in ser12_rx()
242 bc->modem.ser12.pll_time -= 1000000; in ser12_rx()
250 struct baycom_state *bc = netdev_priv(dev); in ser12_interrupt() local
255 if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC) in ser12_interrupt()
264 if ((msr & 8) && bc->opt_dcd) in ser12_interrupt()
265 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80)); in ser12_interrupt()
283 baycom_int_freq(bc); in ser12_interrupt()
289 if (bc->modem.ptt) in ser12_interrupt()
290 outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr)); in ser12_interrupt()
298 if ((msr & 8) && bc->opt_dcd) in ser12_interrupt()
299 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80)); in ser12_interrupt()
304 ser12_rx(dev, bc, &ts, msr & 0x10); /* CTS */ in ser12_interrupt()
305 if (bc->modem.ptt && txcount) { in ser12_interrupt()
306 if (bc->modem.ser12.txshreg <= 1) { in ser12_interrupt()
307 bc->modem.ser12.txshreg = 0x10000 | hdlcdrv_getbits(&bc->hdrv); in ser12_interrupt()
308 if (!hdlcdrv_ptt(&bc->hdrv)) { in ser12_interrupt()
310 bc->modem.ptt = 0; in ser12_interrupt()
314 bc->modem.ser12.tx_bit = !(bc->modem.ser12.tx_bit ^ (bc->modem.ser12.txshreg & 1)); in ser12_interrupt()
315 bc->modem.ser12.txshreg >>= 1; in ser12_interrupt()
319 if (!bc->modem.ptt && txcount) { in ser12_interrupt()
320 hdlcdrv_arbitrate(dev, &bc->hdrv); in ser12_interrupt()
321 if (hdlcdrv_ptt(&bc->hdrv)) { in ser12_interrupt()
322 ser12_set_divisor(dev, bc->baud_uartdiv); in ser12_interrupt()
323 bc->modem.ser12.txshreg = 1; in ser12_interrupt()
324 bc->modem.ptt = 1; in ser12_interrupt()
327 hdlcdrv_transmitter(dev, &bc->hdrv); in ser12_interrupt()
328 hdlcdrv_receiver(dev, &bc->hdrv); in ser12_interrupt()
376 struct baycom_state *bc = netdev_priv(dev); in ser12_open() local
379 if (!dev || !bc) in ser12_open()
388 if (bc->baud < 300 || bc->baud > 4800) { in ser12_open()
398 memset(&bc->modem, 0, sizeof(bc->modem)); in ser12_open()
399 bc->hdrv.par.bitrate = bc->baud; in ser12_open()
400 bc->baud_us = 1000000/bc->baud; in ser12_open()
401 bc->baud_uartdiv = (115200/8)/bc->baud; in ser12_open()
432 hdlcdrv_setdcd(&bc->hdrv, 0); in ser12_open()
434 bc_drvname, dev->base_addr, dev->irq, bc->baud, uart_str[u]); in ser12_open()
442 struct baycom_state *bc = netdev_priv(dev); in ser12_close() local
444 if (!dev || !bc) in ser12_close()
480 static int baycom_setmode(struct baycom_state *bc, const char *modestr) in baycom_setmode() argument
487 bc->baud = baud*100; in baycom_setmode()
490 bc->opt_dcd = 0; in baycom_setmode()
492 bc->opt_dcd = -1; in baycom_setmode()
494 bc->opt_dcd = 1; in baycom_setmode()
503 struct baycom_state *bc; in baycom_ioctl() local
509 bc = netdev_priv(dev); in baycom_ioctl()
510 BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); in baycom_ioctl()
519 sprintf(hi->data.modename, "ser%u", bc->baud / 100); in baycom_ioctl()
520 if (bc->opt_dcd <= 0) in baycom_ioctl()
521 strcat(hi->data.modename, (!bc->opt_dcd) ? "*" : "+"); in baycom_ioctl()
530 return baycom_setmode(bc, hi->data.modename); in baycom_ioctl()
551 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed; in baycom_ioctl()
552 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt; in baycom_ioctl()
553 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr; in baycom_ioctl()
600 struct baycom_state *bc; in init_baycomserfdx() local
616 bc = netdev_priv(dev); in init_baycomserfdx()
617 if (set_hw && baycom_setmode(bc, mode[i])) in init_baycomserfdx()
619 bc->baud = baud[i]; in init_baycomserfdx()