Lines Matching refs:s

139 static int max3100_do_parity(struct max3100_port *s, u16 c)  in max3100_do_parity()  argument
143 if (s->parity & MAX3100_PARITY_ODD) in max3100_do_parity()
148 if (s->parity & MAX3100_7BIT) in max3100_do_parity()
157 static int max3100_check_parity(struct max3100_port *s, u16 c) in max3100_check_parity() argument
159 return max3100_do_parity(s, c) == ((c >> 8) & 1); in max3100_check_parity()
162 static void max3100_calc_parity(struct max3100_port *s, u16 *c) in max3100_calc_parity() argument
164 if (s->parity & MAX3100_7BIT) in max3100_calc_parity()
169 if (s->parity & MAX3100_PARITY_ON) in max3100_calc_parity()
170 *c |= max3100_do_parity(s, *c) << 8; in max3100_calc_parity()
175 static void max3100_dowork(struct max3100_port *s) in max3100_dowork() argument
177 if (!s->force_end_work && !freezing(current) && !s->suspending) in max3100_dowork()
178 queue_work(s->workqueue, &s->work); in max3100_dowork()
183 struct max3100_port *s = from_timer(s, t, timer); in max3100_timeout() local
185 if (s->port.state) { in max3100_timeout()
186 max3100_dowork(s); in max3100_timeout()
187 mod_timer(&s->timer, jiffies + s->poll_time); in max3100_timeout()
191 static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) in max3100_sr() argument
205 status = spi_sync(s->spi, &message); in max3100_sr()
207 dev_warn(&s->spi->dev, "error while calling spi_sync\n"); in max3100_sr()
211 s->tx_empty = (*rx & MAX3100_T) > 0; in max3100_sr()
212 dev_dbg(&s->spi->dev, "%04x - %04x\n", tx, *rx); in max3100_sr()
216 static int max3100_handlerx(struct max3100_port *s, u16 rx) in max3100_handlerx() argument
221 if (rx & MAX3100_R && s->rx_enabled) { in max3100_handlerx()
222 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_handlerx()
223 ch = rx & (s->parity & MAX3100_7BIT ? 0x7f : 0xff); in max3100_handlerx()
225 s->port.icount.frame++; in max3100_handlerx()
229 if (s->parity & MAX3100_PARITY_ON) { in max3100_handlerx()
230 if (max3100_check_parity(s, rx)) { in max3100_handlerx()
231 s->port.icount.rx++; in max3100_handlerx()
234 s->port.icount.parity++; in max3100_handlerx()
239 s->port.icount.rx++; in max3100_handlerx()
243 uart_insert_char(&s->port, status, MAX3100_STATUS_OE, ch, flg); in max3100_handlerx()
248 if (s->cts != cts) { in max3100_handlerx()
249 s->cts = cts; in max3100_handlerx()
250 uart_handle_cts_change(&s->port, cts); in max3100_handlerx()
258 struct max3100_port *s = container_of(w, struct max3100_port, work); in max3100_work() local
262 struct circ_buf *xmit = &s->port.state->xmit; in max3100_work()
264 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_work()
268 spin_lock(&s->conf_lock); in max3100_work()
269 conf = s->conf; in max3100_work()
270 cconf = s->conf_commit; in max3100_work()
271 s->conf_commit = 0; in max3100_work()
272 crts = s->rts_commit; in max3100_work()
273 s->rts_commit = 0; in max3100_work()
274 spin_unlock(&s->conf_lock); in max3100_work()
276 max3100_sr(s, MAX3100_WC | conf, &rx); in max3100_work()
278 max3100_sr(s, MAX3100_WD | MAX3100_TE | in max3100_work()
279 (s->rts ? MAX3100_RTS : 0), &rx); in max3100_work()
280 rxchars += max3100_handlerx(s, rx); in max3100_work()
283 max3100_sr(s, MAX3100_RD, &rx); in max3100_work()
284 rxchars += max3100_handlerx(s, rx); in max3100_work()
288 if (s->port.x_char) { in max3100_work()
289 tx = s->port.x_char; in max3100_work()
290 s->port.icount.tx++; in max3100_work()
291 s->port.x_char = 0; in max3100_work()
293 !uart_tx_stopped(&s->port)) { in max3100_work()
295 uart_xmit_advance(&s->port, 1); in max3100_work()
298 max3100_calc_parity(s, &tx); in max3100_work()
299 tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); in max3100_work()
300 max3100_sr(s, tx, &rx); in max3100_work()
301 rxchars += max3100_handlerx(s, rx); in max3100_work()
306 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
310 uart_write_wakeup(&s->port); in max3100_work()
312 } while (!s->force_end_work && in max3100_work()
316 !uart_tx_stopped(&s->port)))); in max3100_work()
319 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
324 struct max3100_port *s = dev_id; in max3100_irq() local
326 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_irq()
328 max3100_dowork(s); in max3100_irq()
334 struct max3100_port *s = container_of(port, in max3100_enable_ms() local
338 if (s->poll_time > 0) in max3100_enable_ms()
339 mod_timer(&s->timer, jiffies); in max3100_enable_ms()
340 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_enable_ms()
345 struct max3100_port *s = container_of(port, in max3100_start_tx() local
349 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_start_tx()
351 max3100_dowork(s); in max3100_start_tx()
356 struct max3100_port *s = container_of(port, in max3100_stop_rx() local
360 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_rx()
362 s->rx_enabled = 0; in max3100_stop_rx()
363 spin_lock(&s->conf_lock); in max3100_stop_rx()
364 s->conf &= ~MAX3100_RM; in max3100_stop_rx()
365 s->conf_commit = 1; in max3100_stop_rx()
366 spin_unlock(&s->conf_lock); in max3100_stop_rx()
367 max3100_dowork(s); in max3100_stop_rx()
372 struct max3100_port *s = container_of(port, in max3100_tx_empty() local
376 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_tx_empty()
379 max3100_dowork(s); in max3100_tx_empty()
380 return s->tx_empty; in max3100_tx_empty()
385 struct max3100_port *s = container_of(port, in max3100_get_mctrl() local
389 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_get_mctrl()
392 max3100_dowork(s); in max3100_get_mctrl()
394 return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR; in max3100_get_mctrl()
399 struct max3100_port *s = container_of(port, in max3100_set_mctrl() local
404 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_mctrl()
408 spin_lock(&s->conf_lock); in max3100_set_mctrl()
409 if (s->rts != rts) { in max3100_set_mctrl()
410 s->rts = rts; in max3100_set_mctrl()
411 s->rts_commit = 1; in max3100_set_mctrl()
412 max3100_dowork(s); in max3100_set_mctrl()
414 spin_unlock(&s->conf_lock); in max3100_set_mctrl()
421 struct max3100_port *s = container_of(port, in max3100_set_termios() local
428 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_termios()
434 param_new = s->conf & MAX3100_BAUD; in max3100_set_termios()
437 if (s->crystal) in max3100_set_termios()
438 baud = s->baud; in max3100_set_termios()
443 param_new = 14 + s->crystal; in max3100_set_termios()
446 param_new = 13 + s->crystal; in max3100_set_termios()
449 param_new = 12 + s->crystal; in max3100_set_termios()
452 param_new = 11 + s->crystal; in max3100_set_termios()
455 param_new = 10 + s->crystal; in max3100_set_termios()
458 param_new = 9 + s->crystal; in max3100_set_termios()
461 param_new = 8 + s->crystal; in max3100_set_termios()
464 param_new = 1 + s->crystal; in max3100_set_termios()
467 param_new = 0 + s->crystal; in max3100_set_termios()
470 if (s->crystal) in max3100_set_termios()
473 baud = s->baud; in max3100_set_termios()
476 baud = s->baud; in max3100_set_termios()
479 s->baud = baud; in max3100_set_termios()
516 s->port.ignore_status_mask = 0; in max3100_set_termios()
518 s->port.ignore_status_mask |= in max3100_set_termios()
522 if (s->poll_time > 0) in max3100_set_termios()
523 del_timer_sync(&s->timer); in max3100_set_termios()
527 spin_lock(&s->conf_lock); in max3100_set_termios()
528 s->conf = (s->conf & ~param_mask) | (param_new & param_mask); in max3100_set_termios()
529 s->conf_commit = 1; in max3100_set_termios()
530 s->parity = parity; in max3100_set_termios()
531 spin_unlock(&s->conf_lock); in max3100_set_termios()
532 max3100_dowork(s); in max3100_set_termios()
534 if (UART_ENABLE_MS(&s->port, termios->c_cflag)) in max3100_set_termios()
535 max3100_enable_ms(&s->port); in max3100_set_termios()
540 struct max3100_port *s = container_of(port, in max3100_shutdown() local
544 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_shutdown()
546 if (s->suspending) in max3100_shutdown()
549 s->force_end_work = 1; in max3100_shutdown()
551 if (s->poll_time > 0) in max3100_shutdown()
552 del_timer_sync(&s->timer); in max3100_shutdown()
554 if (s->workqueue) { in max3100_shutdown()
555 destroy_workqueue(s->workqueue); in max3100_shutdown()
556 s->workqueue = NULL; in max3100_shutdown()
558 if (s->irq) in max3100_shutdown()
559 free_irq(s->irq, s); in max3100_shutdown()
562 if (s->max3100_hw_suspend) in max3100_shutdown()
563 s->max3100_hw_suspend(1); in max3100_shutdown()
568 max3100_sr(s, tx, &rx); in max3100_shutdown()
574 struct max3100_port *s = container_of(port, in max3100_startup() local
579 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_startup()
581 s->conf = MAX3100_RM; in max3100_startup()
582 s->baud = s->crystal ? 230400 : 115200; in max3100_startup()
583 s->rx_enabled = 1; in max3100_startup()
585 if (s->suspending) in max3100_startup()
588 s->force_end_work = 0; in max3100_startup()
589 s->parity = 0; in max3100_startup()
590 s->rts = 0; in max3100_startup()
592 sprintf(b, "max3100-%d", s->minor); in max3100_startup()
593 s->workqueue = create_freezable_workqueue(b); in max3100_startup()
594 if (!s->workqueue) { in max3100_startup()
595 dev_warn(&s->spi->dev, "cannot create workqueue\n"); in max3100_startup()
598 INIT_WORK(&s->work, max3100_work); in max3100_startup()
600 if (request_irq(s->irq, max3100_irq, in max3100_startup()
601 IRQF_TRIGGER_FALLING, "max3100", s) < 0) { in max3100_startup()
602 dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); in max3100_startup()
603 s->irq = 0; in max3100_startup()
604 destroy_workqueue(s->workqueue); in max3100_startup()
605 s->workqueue = NULL; in max3100_startup()
609 if (s->loopback) { in max3100_startup()
612 max3100_sr(s, tx, &rx); in max3100_startup()
615 if (s->max3100_hw_suspend) in max3100_startup()
616 s->max3100_hw_suspend(0); in max3100_startup()
617 s->conf_commit = 1; in max3100_startup()
618 max3100_dowork(s); in max3100_startup()
622 max3100_enable_ms(&s->port); in max3100_startup()
629 struct max3100_port *s = container_of(port, in max3100_type() local
633 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_type()
635 return s->port.type == PORT_MAX3100 ? "MAX3100" : NULL; in max3100_type()
640 struct max3100_port *s = container_of(port, in max3100_release_port() local
644 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_release_port()
649 struct max3100_port *s = container_of(port, in max3100_config_port() local
653 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_config_port()
656 s->port.type = PORT_MAX3100; in max3100_config_port()
662 struct max3100_port *s = container_of(port, in max3100_verify_port() local
667 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_verify_port()
676 struct max3100_port *s = container_of(port, in max3100_stop_tx() local
680 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_tx()
685 struct max3100_port *s = container_of(port, in max3100_request_port() local
689 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_request_port()
695 struct max3100_port *s = container_of(port, in max3100_break_ctl() local
699 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_break_ctl()
807 struct max3100_port *s = spi_get_drvdata(spi); in max3100_remove() local
814 if (max3100s[i] == s) { in max3100_remove()
840 struct max3100_port *s = dev_get_drvdata(dev); in max3100_suspend() local
842 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_suspend()
844 disable_irq(s->irq); in max3100_suspend()
846 s->suspending = 1; in max3100_suspend()
847 uart_suspend_port(&max3100_uart_driver, &s->port); in max3100_suspend()
849 if (s->max3100_hw_suspend) in max3100_suspend()
850 s->max3100_hw_suspend(1); in max3100_suspend()
856 max3100_sr(s, tx, &rx); in max3100_suspend()
863 struct max3100_port *s = dev_get_drvdata(dev); in max3100_resume() local
865 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_resume()
867 if (s->max3100_hw_suspend) in max3100_resume()
868 s->max3100_hw_suspend(0); in max3100_resume()
869 uart_resume_port(&max3100_uart_driver, &s->port); in max3100_resume()
870 s->suspending = 0; in max3100_resume()
872 enable_irq(s->irq); in max3100_resume()
874 s->conf_commit = 1; in max3100_resume()
875 if (s->workqueue) in max3100_resume()
876 max3100_dowork(s); in max3100_resume()