Lines Matching refs:bc
158 static inline void baycom_int_freq(struct baycom_state *bc)
165 bc->debug_vals.cur_intcnt++;
166 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
167 bc->debug_vals.last_jiffies = cur_jiffies;
168 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
169 bc->debug_vals.cur_intcnt = 0;
170 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr;
171 bc->debug_vals.cur_pllcorr = 0;
209 static __inline__ void ser12_rx(struct net_device *dev, struct baycom_state *bc, struct timeval *tv, unsigned char curs)
212 int bdus8 = bc->baud_us >> 3;
213 int bdus4 = bc->baud_us >> 2;
214 int bdus2 = bc->baud_us >> 1;
216 timediff = 1000000 + tv->tv_usec - bc->modem.ser12.pll_time;
220 timediff -= bc->baud_us;
221 bc->modem.ser12.pll_time += bc->baud_us;
222 bc->modem.ser12.dcd_time--;
224 if (bc->modem.shreg & 1) {
225 hdlcdrv_putbits(&bc->hdrv, (bc->modem.shreg >> 1) ^ 0xffff);
226 bc->modem.shreg = 0x10000;
229 bc->modem.shreg >>= 1;
231 if (bc->modem.ser12.dcd_time <= 0) {
232 if (!bc->opt_dcd)
233 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 +
234 bc->modem.ser12.dcd_sum1 +
235 bc->modem.ser12.dcd_sum2) < 0);
236 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1;
237 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0;
238 bc->modem.ser12.dcd_sum0 = 2; /* slight bias */
239 bc->modem.ser12.dcd_time += 120;
241 if (bc->modem.ser12.last_rxbit != curs) {
242 bc->modem.ser12.last_rxbit = curs;
243 bc->modem.shreg |= 0x10000;
246 bc->modem.ser12.pll_time += bdus8;
248 bc->modem.ser12.pll_time += 1000000 - bdus8;
251 bc->modem.ser12.dcd_sum0 += 4;
253 bc->modem.ser12.dcd_sum0--;
255 bc->debug_vals.cur_pllcorr = timediff;
258 while (bc->modem.ser12.pll_time >= 1000000)
259 bc->modem.ser12.pll_time -= 1000000;
267 struct baycom_state *bc = netdev_priv(dev);
272 if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC)
281 if ((msr & 8) && bc->opt_dcd)
282 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80));
300 baycom_int_freq(bc);
306 if (bc->modem.ptt)
307 outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr));
315 if ((msr & 8) && bc->opt_dcd)
316 hdlcdrv_setdcd(&bc->hdrv, !((msr ^ bc->opt_dcd) & 0x80));
321 ser12_rx(dev, bc, &tv, msr & 0x10); /* CTS */
322 if (bc->modem.ptt && txcount) {
323 if (bc->modem.ser12.txshreg <= 1) {
324 bc->modem.ser12.txshreg = 0x10000 | hdlcdrv_getbits(&bc->hdrv);
325 if (!hdlcdrv_ptt(&bc->hdrv)) {
327 bc->modem.ptt = 0;
331 bc->modem.ser12.tx_bit = !(bc->modem.ser12.tx_bit ^ (bc->modem.ser12.txshreg & 1));
332 bc->modem.ser12.txshreg >>= 1;
336 if (!bc->modem.ptt && txcount) {
337 hdlcdrv_arbitrate(dev, &bc->hdrv);
338 if (hdlcdrv_ptt(&bc->hdrv)) {
339 ser12_set_divisor(dev, bc->baud_uartdiv);
340 bc->modem.ser12.txshreg = 1;
341 bc->modem.ptt = 1;
344 hdlcdrv_transmitter(dev, &bc->hdrv);
345 hdlcdrv_receiver(dev, &bc->hdrv);
393 struct baycom_state *bc = netdev_priv(dev);
396 if (!dev || !bc)
405 if (bc->baud < 300 || bc->baud > 4800) {
415 memset(&bc->modem, 0, sizeof(bc->modem));
416 bc->hdrv.par.bitrate = bc->baud;
417 bc->baud_us = 1000000/bc->baud;
418 bc->baud_uartdiv = (115200/8)/bc->baud;
449 hdlcdrv_setdcd(&bc->hdrv, 0);
451 bc_drvname, dev->base_addr, dev->irq, bc->baud, uart_str[u]);
459 struct baycom_state *bc = netdev_priv(dev);
461 if (!dev || !bc)
497 static int baycom_setmode(struct baycom_state *bc, const char *modestr)
504 bc->baud = baud*100;
507 bc->opt_dcd = 0;
509 bc->opt_dcd = -1;
511 bc->opt_dcd = 1;
520 struct baycom_state *bc;
526 bc = netdev_priv(dev);
527 BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC);
536 sprintf(hi->data.modename, "ser%u", bc->baud / 100);
537 if (bc->opt_dcd <= 0)
538 strcat(hi->data.modename, (!bc->opt_dcd) ? "*" : "+");
547 return baycom_setmode(bc, hi->data.modename);
568 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed;
569 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt;
570 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr;
617 struct baycom_state *bc;
633 bc = netdev_priv(dev);
634 if (set_hw && baycom_setmode(bc, mode[i]))
636 bc->baud = baud[i];