Lines Matching refs:s
144 static int max3100_do_parity(struct max3100_port *s, u16 c) in max3100_do_parity() argument
148 if (s->parity & MAX3100_PARITY_ODD) in max3100_do_parity()
153 if (s->parity & MAX3100_7BIT) in max3100_do_parity()
162 static int max3100_check_parity(struct max3100_port *s, u16 c) in max3100_check_parity() argument
164 return max3100_do_parity(s, c) == ((c >> 8) & 1); in max3100_check_parity()
167 static void max3100_calc_parity(struct max3100_port *s, u16 *c) in max3100_calc_parity() argument
169 if (s->parity & MAX3100_7BIT) in max3100_calc_parity()
174 if (s->parity & MAX3100_PARITY_ON) in max3100_calc_parity()
175 *c |= max3100_do_parity(s, *c) << 8; in max3100_calc_parity()
180 static void max3100_dowork(struct max3100_port *s) in max3100_dowork() argument
182 if (!s->force_end_work && !freezing(current) && !s->suspending) in max3100_dowork()
183 queue_work(s->workqueue, &s->work); in max3100_dowork()
188 struct max3100_port *s = (struct max3100_port *)data; in max3100_timeout() local
190 if (s->port.state) { in max3100_timeout()
191 max3100_dowork(s); in max3100_timeout()
192 mod_timer(&s->timer, jiffies + s->poll_time); in max3100_timeout()
196 static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) in max3100_sr() argument
210 status = spi_sync(s->spi, &message); in max3100_sr()
212 dev_warn(&s->spi->dev, "error while calling spi_sync\n"); in max3100_sr()
216 s->tx_empty = (*rx & MAX3100_T) > 0; in max3100_sr()
217 dev_dbg(&s->spi->dev, "%04x - %04x\n", tx, *rx); in max3100_sr()
221 static int max3100_handlerx(struct max3100_port *s, u16 rx) in max3100_handlerx() argument
226 if (rx & MAX3100_R && s->rx_enabled) { in max3100_handlerx()
227 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_handlerx()
228 ch = rx & (s->parity & MAX3100_7BIT ? 0x7f : 0xff); in max3100_handlerx()
230 s->port.icount.frame++; in max3100_handlerx()
234 if (s->parity & MAX3100_PARITY_ON) { in max3100_handlerx()
235 if (max3100_check_parity(s, rx)) { in max3100_handlerx()
236 s->port.icount.rx++; in max3100_handlerx()
239 s->port.icount.parity++; in max3100_handlerx()
244 s->port.icount.rx++; in max3100_handlerx()
248 uart_insert_char(&s->port, status, MAX3100_STATUS_OE, ch, flg); in max3100_handlerx()
253 if (s->cts != cts) { in max3100_handlerx()
254 s->cts = cts; in max3100_handlerx()
255 uart_handle_cts_change(&s->port, cts ? TIOCM_CTS : 0); in max3100_handlerx()
263 struct max3100_port *s = container_of(w, struct max3100_port, work); in max3100_work() local
267 struct circ_buf *xmit = &s->port.state->xmit; in max3100_work()
269 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_work()
273 spin_lock(&s->conf_lock); in max3100_work()
274 conf = s->conf; in max3100_work()
275 cconf = s->conf_commit; in max3100_work()
276 s->conf_commit = 0; in max3100_work()
277 rts = s->rts; in max3100_work()
278 crts = s->rts_commit; in max3100_work()
279 s->rts_commit = 0; in max3100_work()
280 spin_unlock(&s->conf_lock); in max3100_work()
282 max3100_sr(s, MAX3100_WC | conf, &rx); in max3100_work()
284 max3100_sr(s, MAX3100_WD | MAX3100_TE | in max3100_work()
285 (s->rts ? MAX3100_RTS : 0), &rx); in max3100_work()
286 rxchars += max3100_handlerx(s, rx); in max3100_work()
289 max3100_sr(s, MAX3100_RD, &rx); in max3100_work()
290 rxchars += max3100_handlerx(s, rx); in max3100_work()
294 if (s->port.x_char) { in max3100_work()
295 tx = s->port.x_char; in max3100_work()
296 s->port.icount.tx++; in max3100_work()
297 s->port.x_char = 0; in max3100_work()
299 !uart_tx_stopped(&s->port)) { in max3100_work()
303 s->port.icount.tx++; in max3100_work()
306 max3100_calc_parity(s, &tx); in max3100_work()
307 tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); in max3100_work()
308 max3100_sr(s, tx, &rx); in max3100_work()
309 rxchars += max3100_handlerx(s, rx); in max3100_work()
314 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
318 uart_write_wakeup(&s->port); in max3100_work()
320 } while (!s->force_end_work && in max3100_work()
324 !uart_tx_stopped(&s->port)))); in max3100_work()
327 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
332 struct max3100_port *s = dev_id; in max3100_irq() local
334 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_irq()
336 max3100_dowork(s); in max3100_irq()
342 struct max3100_port *s = container_of(port, in max3100_enable_ms() local
346 if (s->poll_time > 0) in max3100_enable_ms()
347 mod_timer(&s->timer, jiffies); in max3100_enable_ms()
348 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_enable_ms()
353 struct max3100_port *s = container_of(port, in max3100_start_tx() local
357 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_start_tx()
359 max3100_dowork(s); in max3100_start_tx()
364 struct max3100_port *s = container_of(port, in max3100_stop_rx() local
368 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_rx()
370 s->rx_enabled = 0; in max3100_stop_rx()
371 spin_lock(&s->conf_lock); in max3100_stop_rx()
372 s->conf &= ~MAX3100_RM; in max3100_stop_rx()
373 s->conf_commit = 1; in max3100_stop_rx()
374 spin_unlock(&s->conf_lock); in max3100_stop_rx()
375 max3100_dowork(s); in max3100_stop_rx()
380 struct max3100_port *s = container_of(port, in max3100_tx_empty() local
384 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_tx_empty()
387 max3100_dowork(s); in max3100_tx_empty()
388 return s->tx_empty; in max3100_tx_empty()
393 struct max3100_port *s = container_of(port, in max3100_get_mctrl() local
397 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_get_mctrl()
400 max3100_dowork(s); in max3100_get_mctrl()
402 return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR; in max3100_get_mctrl()
407 struct max3100_port *s = container_of(port, in max3100_set_mctrl() local
412 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_mctrl()
416 spin_lock(&s->conf_lock); in max3100_set_mctrl()
417 if (s->rts != rts) { in max3100_set_mctrl()
418 s->rts = rts; in max3100_set_mctrl()
419 s->rts_commit = 1; in max3100_set_mctrl()
420 max3100_dowork(s); in max3100_set_mctrl()
422 spin_unlock(&s->conf_lock); in max3100_set_mctrl()
429 struct max3100_port *s = container_of(port, in max3100_set_termios() local
436 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_termios()
443 param_new = s->conf & MAX3100_BAUD; in max3100_set_termios()
446 if (s->crystal) in max3100_set_termios()
447 baud = s->baud; in max3100_set_termios()
452 param_new = 14 + s->crystal; in max3100_set_termios()
455 param_new = 13 + s->crystal; in max3100_set_termios()
458 param_new = 12 + s->crystal; in max3100_set_termios()
461 param_new = 11 + s->crystal; in max3100_set_termios()
464 param_new = 10 + s->crystal; in max3100_set_termios()
467 param_new = 9 + s->crystal; in max3100_set_termios()
470 param_new = 8 + s->crystal; in max3100_set_termios()
473 param_new = 1 + s->crystal; in max3100_set_termios()
476 param_new = 0 + s->crystal; in max3100_set_termios()
479 if (s->crystal) in max3100_set_termios()
482 baud = s->baud; in max3100_set_termios()
485 baud = s->baud; in max3100_set_termios()
488 s->baud = baud; in max3100_set_termios()
525 s->port.ignore_status_mask = 0; in max3100_set_termios()
527 s->port.ignore_status_mask |= in max3100_set_termios()
532 s->port.state->port.low_latency = 1; in max3100_set_termios()
534 if (s->poll_time > 0) in max3100_set_termios()
535 del_timer_sync(&s->timer); in max3100_set_termios()
539 spin_lock(&s->conf_lock); in max3100_set_termios()
540 s->conf = (s->conf & ~param_mask) | (param_new & param_mask); in max3100_set_termios()
541 s->conf_commit = 1; in max3100_set_termios()
542 s->parity = parity; in max3100_set_termios()
543 spin_unlock(&s->conf_lock); in max3100_set_termios()
544 max3100_dowork(s); in max3100_set_termios()
546 if (UART_ENABLE_MS(&s->port, termios->c_cflag)) in max3100_set_termios()
547 max3100_enable_ms(&s->port); in max3100_set_termios()
552 struct max3100_port *s = container_of(port, in max3100_shutdown() local
556 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_shutdown()
558 if (s->suspending) in max3100_shutdown()
561 s->force_end_work = 1; in max3100_shutdown()
563 if (s->poll_time > 0) in max3100_shutdown()
564 del_timer_sync(&s->timer); in max3100_shutdown()
566 if (s->workqueue) { in max3100_shutdown()
567 flush_workqueue(s->workqueue); in max3100_shutdown()
568 destroy_workqueue(s->workqueue); in max3100_shutdown()
569 s->workqueue = NULL; in max3100_shutdown()
571 if (s->irq) in max3100_shutdown()
572 free_irq(s->irq, s); in max3100_shutdown()
575 if (s->max3100_hw_suspend) in max3100_shutdown()
576 s->max3100_hw_suspend(1); in max3100_shutdown()
581 max3100_sr(s, tx, &rx); in max3100_shutdown()
587 struct max3100_port *s = container_of(port, in max3100_startup() local
592 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_startup()
594 s->conf = MAX3100_RM; in max3100_startup()
595 s->baud = s->crystal ? 230400 : 115200; in max3100_startup()
596 s->rx_enabled = 1; in max3100_startup()
598 if (s->suspending) in max3100_startup()
601 s->force_end_work = 0; in max3100_startup()
602 s->parity = 0; in max3100_startup()
603 s->rts = 0; in max3100_startup()
605 sprintf(b, "max3100-%d", s->minor); in max3100_startup()
606 s->workqueue = create_freezable_workqueue(b); in max3100_startup()
607 if (!s->workqueue) { in max3100_startup()
608 dev_warn(&s->spi->dev, "cannot create workqueue\n"); in max3100_startup()
611 INIT_WORK(&s->work, max3100_work); in max3100_startup()
613 if (request_irq(s->irq, max3100_irq, in max3100_startup()
614 IRQF_TRIGGER_FALLING, "max3100", s) < 0) { in max3100_startup()
615 dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); in max3100_startup()
616 s->irq = 0; in max3100_startup()
617 destroy_workqueue(s->workqueue); in max3100_startup()
618 s->workqueue = NULL; in max3100_startup()
622 if (s->loopback) { in max3100_startup()
625 max3100_sr(s, tx, &rx); in max3100_startup()
628 if (s->max3100_hw_suspend) in max3100_startup()
629 s->max3100_hw_suspend(0); in max3100_startup()
630 s->conf_commit = 1; in max3100_startup()
631 max3100_dowork(s); in max3100_startup()
635 max3100_enable_ms(&s->port); in max3100_startup()
642 struct max3100_port *s = container_of(port, in max3100_type() local
646 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_type()
648 return s->port.type == PORT_MAX3100 ? "MAX3100" : NULL; in max3100_type()
653 struct max3100_port *s = container_of(port, in max3100_release_port() local
657 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_release_port()
662 struct max3100_port *s = container_of(port, in max3100_config_port() local
666 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_config_port()
669 s->port.type = PORT_MAX3100; in max3100_config_port()
675 struct max3100_port *s = container_of(port, in max3100_verify_port() local
680 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_verify_port()
689 struct max3100_port *s = container_of(port, in max3100_stop_tx() local
693 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_tx()
698 struct max3100_port *s = container_of(port, in max3100_request_port() local
702 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_request_port()
708 struct max3100_port *s = container_of(port, in max3100_break_ctl() local
712 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_break_ctl()
822 struct max3100_port *s = spi_get_drvdata(spi); in max3100_remove() local
829 if (max3100s[i] == s) { in max3100_remove()
856 struct max3100_port *s = dev_get_drvdata(dev); in max3100_suspend() local
858 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_suspend()
860 disable_irq(s->irq); in max3100_suspend()
862 s->suspending = 1; in max3100_suspend()
863 uart_suspend_port(&max3100_uart_driver, &s->port); in max3100_suspend()
865 if (s->max3100_hw_suspend) in max3100_suspend()
866 s->max3100_hw_suspend(1); in max3100_suspend()
872 max3100_sr(s, tx, &rx); in max3100_suspend()
879 struct max3100_port *s = dev_get_drvdata(dev); in max3100_resume() local
881 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_resume()
883 if (s->max3100_hw_suspend) in max3100_resume()
884 s->max3100_hw_suspend(0); in max3100_resume()
885 uart_resume_port(&max3100_uart_driver, &s->port); in max3100_resume()
886 s->suspending = 0; in max3100_resume()
888 enable_irq(s->irq); in max3100_resume()
890 s->conf_commit = 1; in max3100_resume()
891 if (s->workqueue) in max3100_resume()
892 max3100_dowork(s); in max3100_resume()