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
222 if (rx & MAX3100_R && s->rx_enabled) { in max3100_handlerx()
223 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_handlerx()
224 ch = rx & (s->parity & MAX3100_7BIT ? 0x7f : 0xff); in max3100_handlerx()
226 s->port.icount.frame++; in max3100_handlerx()
230 if (s->parity & MAX3100_PARITY_ON) { in max3100_handlerx()
231 if (max3100_check_parity(s, rx)) { in max3100_handlerx()
232 s->port.icount.rx++; in max3100_handlerx()
235 s->port.icount.parity++; in max3100_handlerx()
240 s->port.icount.rx++; in max3100_handlerx()
244 uart_insert_char(&s->port, status, MAX3100_STATUS_OE, ch, flg); in max3100_handlerx()
249 if (s->cts != cts) { in max3100_handlerx()
250 s->cts = cts; in max3100_handlerx()
251 uart_handle_cts_change(&s->port, cts); in max3100_handlerx()
259 struct max3100_port *s = container_of(w, struct max3100_port, work); in max3100_work() local
263 struct circ_buf *xmit = &s->port.state->xmit; in max3100_work()
265 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_work()
269 spin_lock(&s->conf_lock); in max3100_work()
270 conf = s->conf; in max3100_work()
271 cconf = s->conf_commit; in max3100_work()
272 s->conf_commit = 0; in max3100_work()
273 crts = s->rts_commit; in max3100_work()
274 s->rts_commit = 0; in max3100_work()
275 spin_unlock(&s->conf_lock); in max3100_work()
277 max3100_sr(s, MAX3100_WC | conf, &rx); in max3100_work()
279 max3100_sr(s, MAX3100_WD | MAX3100_TE | in max3100_work()
280 (s->rts ? MAX3100_RTS : 0), &rx); in max3100_work()
281 rxchars += max3100_handlerx(s, rx); in max3100_work()
284 max3100_sr(s, MAX3100_RD, &rx); in max3100_work()
285 rxchars += max3100_handlerx(s, rx); in max3100_work()
289 if (s->port.x_char) { in max3100_work()
290 tx = s->port.x_char; in max3100_work()
291 s->port.icount.tx++; in max3100_work()
292 s->port.x_char = 0; in max3100_work()
294 !uart_tx_stopped(&s->port)) { in max3100_work()
296 uart_xmit_advance(&s->port, 1); in max3100_work()
299 max3100_calc_parity(s, &tx); in max3100_work()
300 tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); in max3100_work()
301 max3100_sr(s, tx, &rx); in max3100_work()
302 rxchars += max3100_handlerx(s, rx); in max3100_work()
307 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
311 uart_write_wakeup(&s->port); in max3100_work()
313 } while (!s->force_end_work && in max3100_work()
317 !uart_tx_stopped(&s->port)))); in max3100_work()
320 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
325 struct max3100_port *s = dev_id; in max3100_irq() local
327 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_irq()
329 max3100_dowork(s); in max3100_irq()
335 struct max3100_port *s = container_of(port, in max3100_enable_ms() local
339 if (s->poll_time > 0) in max3100_enable_ms()
340 mod_timer(&s->timer, jiffies); in max3100_enable_ms()
341 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_enable_ms()
346 struct max3100_port *s = container_of(port, in max3100_start_tx() local
350 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_start_tx()
352 max3100_dowork(s); in max3100_start_tx()
357 struct max3100_port *s = container_of(port, in max3100_stop_rx() local
361 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_rx()
363 s->rx_enabled = 0; in max3100_stop_rx()
364 spin_lock(&s->conf_lock); in max3100_stop_rx()
365 s->conf &= ~MAX3100_RM; in max3100_stop_rx()
366 s->conf_commit = 1; in max3100_stop_rx()
367 spin_unlock(&s->conf_lock); in max3100_stop_rx()
368 max3100_dowork(s); in max3100_stop_rx()
373 struct max3100_port *s = container_of(port, in max3100_tx_empty() local
377 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_tx_empty()
380 max3100_dowork(s); in max3100_tx_empty()
381 return s->tx_empty; in max3100_tx_empty()
386 struct max3100_port *s = container_of(port, in max3100_get_mctrl() local
390 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_get_mctrl()
393 max3100_dowork(s); in max3100_get_mctrl()
395 return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR; in max3100_get_mctrl()
400 struct max3100_port *s = container_of(port, in max3100_set_mctrl() local
405 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_mctrl()
409 spin_lock(&s->conf_lock); in max3100_set_mctrl()
410 if (s->rts != rts) { in max3100_set_mctrl()
411 s->rts = rts; in max3100_set_mctrl()
412 s->rts_commit = 1; in max3100_set_mctrl()
413 max3100_dowork(s); in max3100_set_mctrl()
415 spin_unlock(&s->conf_lock); in max3100_set_mctrl()
422 struct max3100_port *s = container_of(port, in max3100_set_termios() local
429 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_termios()
435 param_new = s->conf & MAX3100_BAUD; in max3100_set_termios()
438 if (s->crystal) in max3100_set_termios()
439 baud = s->baud; in max3100_set_termios()
444 param_new = 14 + s->crystal; in max3100_set_termios()
447 param_new = 13 + s->crystal; in max3100_set_termios()
450 param_new = 12 + s->crystal; in max3100_set_termios()
453 param_new = 11 + s->crystal; in max3100_set_termios()
456 param_new = 10 + s->crystal; in max3100_set_termios()
459 param_new = 9 + s->crystal; in max3100_set_termios()
462 param_new = 8 + s->crystal; in max3100_set_termios()
465 param_new = 1 + s->crystal; in max3100_set_termios()
468 param_new = 0 + s->crystal; in max3100_set_termios()
471 if (s->crystal) in max3100_set_termios()
474 baud = s->baud; in max3100_set_termios()
477 baud = s->baud; in max3100_set_termios()
480 s->baud = baud; in max3100_set_termios()
517 s->port.ignore_status_mask = 0; in max3100_set_termios()
519 s->port.ignore_status_mask |= in max3100_set_termios()
523 if (s->poll_time > 0) in max3100_set_termios()
524 del_timer_sync(&s->timer); in max3100_set_termios()
528 spin_lock(&s->conf_lock); in max3100_set_termios()
529 s->conf = (s->conf & ~param_mask) | (param_new & param_mask); in max3100_set_termios()
530 s->conf_commit = 1; in max3100_set_termios()
531 s->parity = parity; in max3100_set_termios()
532 spin_unlock(&s->conf_lock); in max3100_set_termios()
533 max3100_dowork(s); in max3100_set_termios()
535 if (UART_ENABLE_MS(&s->port, termios->c_cflag)) in max3100_set_termios()
536 max3100_enable_ms(&s->port); in max3100_set_termios()
541 struct max3100_port *s = container_of(port, in max3100_shutdown() local
545 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_shutdown()
547 if (s->suspending) in max3100_shutdown()
550 s->force_end_work = 1; in max3100_shutdown()
552 if (s->poll_time > 0) in max3100_shutdown()
553 del_timer_sync(&s->timer); in max3100_shutdown()
555 if (s->workqueue) { in max3100_shutdown()
556 destroy_workqueue(s->workqueue); in max3100_shutdown()
557 s->workqueue = NULL; in max3100_shutdown()
559 if (s->irq) in max3100_shutdown()
560 free_irq(s->irq, s); in max3100_shutdown()
563 if (s->max3100_hw_suspend) in max3100_shutdown()
564 s->max3100_hw_suspend(1); in max3100_shutdown()
569 max3100_sr(s, tx, &rx); in max3100_shutdown()
575 struct max3100_port *s = container_of(port, in max3100_startup() local
580 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_startup()
582 s->conf = MAX3100_RM; in max3100_startup()
583 s->baud = s->crystal ? 230400 : 115200; in max3100_startup()
584 s->rx_enabled = 1; in max3100_startup()
586 if (s->suspending) in max3100_startup()
589 s->force_end_work = 0; in max3100_startup()
590 s->parity = 0; in max3100_startup()
591 s->rts = 0; in max3100_startup()
593 sprintf(b, "max3100-%d", s->minor); in max3100_startup()
594 s->workqueue = create_freezable_workqueue(b); in max3100_startup()
595 if (!s->workqueue) { in max3100_startup()
596 dev_warn(&s->spi->dev, "cannot create workqueue\n"); in max3100_startup()
599 INIT_WORK(&s->work, max3100_work); in max3100_startup()
601 if (request_irq(s->irq, max3100_irq, in max3100_startup()
602 IRQF_TRIGGER_FALLING, "max3100", s) < 0) { in max3100_startup()
603 dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); in max3100_startup()
604 s->irq = 0; in max3100_startup()
605 destroy_workqueue(s->workqueue); in max3100_startup()
606 s->workqueue = NULL; in max3100_startup()
610 if (s->loopback) { in max3100_startup()
613 max3100_sr(s, tx, &rx); in max3100_startup()
616 if (s->max3100_hw_suspend) in max3100_startup()
617 s->max3100_hw_suspend(0); in max3100_startup()
618 s->conf_commit = 1; in max3100_startup()
619 max3100_dowork(s); in max3100_startup()
623 max3100_enable_ms(&s->port); in max3100_startup()
630 struct max3100_port *s = container_of(port, in max3100_type() local
634 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_type()
636 return s->port.type == PORT_MAX3100 ? "MAX3100" : NULL; in max3100_type()
641 struct max3100_port *s = container_of(port, in max3100_release_port() local
645 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_release_port()
650 struct max3100_port *s = container_of(port, in max3100_config_port() local
654 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_config_port()
657 s->port.type = PORT_MAX3100; in max3100_config_port()
663 struct max3100_port *s = container_of(port, in max3100_verify_port() local
668 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_verify_port()
677 struct max3100_port *s = container_of(port, in max3100_stop_tx() local
681 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_tx()
686 struct max3100_port *s = container_of(port, in max3100_request_port() local
690 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_request_port()
696 struct max3100_port *s = container_of(port, in max3100_break_ctl() local
700 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_break_ctl()
808 struct max3100_port *s = spi_get_drvdata(spi); in max3100_remove() local
815 if (max3100s[i] == s) { in max3100_remove()
841 struct max3100_port *s = dev_get_drvdata(dev); in max3100_suspend() local
843 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_suspend()
845 disable_irq(s->irq); in max3100_suspend()
847 s->suspending = 1; in max3100_suspend()
848 uart_suspend_port(&max3100_uart_driver, &s->port); in max3100_suspend()
850 if (s->max3100_hw_suspend) in max3100_suspend()
851 s->max3100_hw_suspend(1); in max3100_suspend()
857 max3100_sr(s, tx, &rx); in max3100_suspend()
864 struct max3100_port *s = dev_get_drvdata(dev); in max3100_resume() local
866 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_resume()
868 if (s->max3100_hw_suspend) in max3100_resume()
869 s->max3100_hw_suspend(0); in max3100_resume()
870 uart_resume_port(&max3100_uart_driver, &s->port); in max3100_resume()
871 s->suspending = 0; in max3100_resume()
873 enable_irq(s->irq); in max3100_resume()
875 s->conf_commit = 1; in max3100_resume()
876 if (s->workqueue) in max3100_resume()
877 max3100_dowork(s); in max3100_resume()