• Home
  • Raw
  • Download

Lines Matching full:s

142 static int max3100_do_parity(struct max3100_port *s, u16 c)  in max3100_do_parity()  argument
146 if (s->parity & MAX3100_PARITY_ODD) in max3100_do_parity()
151 if (s->parity & MAX3100_7BIT) in max3100_do_parity()
160 static int max3100_check_parity(struct max3100_port *s, u16 c) in max3100_check_parity() argument
162 return max3100_do_parity(s, c) == ((c >> 8) & 1); in max3100_check_parity()
165 static void max3100_calc_parity(struct max3100_port *s, u16 *c) in max3100_calc_parity() argument
167 if (s->parity & MAX3100_7BIT) in max3100_calc_parity()
172 if (s->parity & MAX3100_PARITY_ON) in max3100_calc_parity()
173 *c |= max3100_do_parity(s, *c) << 8; in max3100_calc_parity()
178 static void max3100_dowork(struct max3100_port *s) in max3100_dowork() argument
180 if (!s->force_end_work && !freezing(current) && !s->suspending) in max3100_dowork()
181 queue_work(s->workqueue, &s->work); in max3100_dowork()
186 struct max3100_port *s = from_timer(s, t, timer); in max3100_timeout() local
188 if (s->port.state) { in max3100_timeout()
189 max3100_dowork(s); in max3100_timeout()
190 mod_timer(&s->timer, jiffies + s->poll_time); in max3100_timeout()
194 static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) in max3100_sr() argument
208 status = spi_sync(s->spi, &message); in max3100_sr()
210 dev_warn(&s->spi->dev, "error while calling spi_sync\n"); in max3100_sr()
214 s->tx_empty = (*rx & MAX3100_T) > 0; in max3100_sr()
215 dev_dbg(&s->spi->dev, "%04x - %04x\n", tx, *rx); in max3100_sr()
219 static int max3100_handlerx_unlocked(struct max3100_port *s, u16 rx) in max3100_handlerx_unlocked() argument
225 if (rx & MAX3100_R && s->rx_enabled) { in max3100_handlerx_unlocked()
226 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_handlerx_unlocked()
227 ch = rx & (s->parity & MAX3100_7BIT ? 0x7f : 0xff); in max3100_handlerx_unlocked()
229 s->port.icount.frame++; in max3100_handlerx_unlocked()
233 if (s->parity & MAX3100_PARITY_ON) { in max3100_handlerx_unlocked()
234 if (max3100_check_parity(s, rx)) { in max3100_handlerx_unlocked()
235 s->port.icount.rx++; in max3100_handlerx_unlocked()
238 s->port.icount.parity++; in max3100_handlerx_unlocked()
243 s->port.icount.rx++; in max3100_handlerx_unlocked()
247 uart_insert_char(&s->port, status, MAX3100_STATUS_OE, ch, flg); in max3100_handlerx_unlocked()
252 if (s->cts != cts) { in max3100_handlerx_unlocked()
253 s->cts = cts; in max3100_handlerx_unlocked()
254 uart_handle_cts_change(&s->port, cts); in max3100_handlerx_unlocked()
260 static int max3100_handlerx(struct max3100_port *s, u16 rx) in max3100_handlerx() argument
265 uart_port_lock_irqsave(&s->port, &flags); in max3100_handlerx()
266 ret = max3100_handlerx_unlocked(s, rx); in max3100_handlerx()
267 uart_port_unlock_irqrestore(&s->port, flags); in max3100_handlerx()
273 struct max3100_port *s = container_of(w, struct max3100_port, work); in max3100_work() local
277 struct circ_buf *xmit = &s->port.state->xmit; in max3100_work()
279 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_work()
283 spin_lock(&s->conf_lock); in max3100_work()
284 conf = s->conf; in max3100_work()
285 cconf = s->conf_commit; in max3100_work()
286 s->conf_commit = 0; in max3100_work()
287 crts = s->rts_commit; in max3100_work()
288 s->rts_commit = 0; in max3100_work()
289 spin_unlock(&s->conf_lock); in max3100_work()
291 max3100_sr(s, MAX3100_WC | conf, &rx); in max3100_work()
293 max3100_sr(s, MAX3100_WD | MAX3100_TE | in max3100_work()
294 (s->rts ? MAX3100_RTS : 0), &rx); in max3100_work()
295 rxchars += max3100_handlerx(s, rx); in max3100_work()
298 max3100_sr(s, MAX3100_RD, &rx); in max3100_work()
299 rxchars += max3100_handlerx(s, rx); in max3100_work()
303 if (s->port.x_char) { in max3100_work()
304 tx = s->port.x_char; in max3100_work()
305 s->port.icount.tx++; in max3100_work()
306 s->port.x_char = 0; in max3100_work()
308 !uart_tx_stopped(&s->port)) { in max3100_work()
310 uart_xmit_advance(&s->port, 1); in max3100_work()
313 max3100_calc_parity(s, &tx); in max3100_work()
314 tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); in max3100_work()
315 max3100_sr(s, tx, &rx); in max3100_work()
316 rxchars += max3100_handlerx(s, rx); in max3100_work()
321 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
325 uart_write_wakeup(&s->port); in max3100_work()
327 } while (!s->force_end_work && in max3100_work()
331 !uart_tx_stopped(&s->port)))); in max3100_work()
334 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
339 struct max3100_port *s = dev_id; in max3100_irq() local
341 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_irq()
343 max3100_dowork(s); in max3100_irq()
349 struct max3100_port *s = container_of(port, in max3100_enable_ms() local
353 if (s->poll_time > 0) in max3100_enable_ms()
354 mod_timer(&s->timer, jiffies); in max3100_enable_ms()
355 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_enable_ms()
360 struct max3100_port *s = container_of(port, in max3100_start_tx() local
364 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_start_tx()
366 max3100_dowork(s); in max3100_start_tx()
371 struct max3100_port *s = container_of(port, in max3100_stop_rx() local
375 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_rx()
377 s->rx_enabled = 0; in max3100_stop_rx()
378 spin_lock(&s->conf_lock); in max3100_stop_rx()
379 s->conf &= ~MAX3100_RM; in max3100_stop_rx()
380 s->conf_commit = 1; in max3100_stop_rx()
381 spin_unlock(&s->conf_lock); in max3100_stop_rx()
382 max3100_dowork(s); in max3100_stop_rx()
387 struct max3100_port *s = container_of(port, in max3100_tx_empty() local
391 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_tx_empty()
394 max3100_dowork(s); in max3100_tx_empty()
395 return s->tx_empty; in max3100_tx_empty()
400 struct max3100_port *s = container_of(port, in max3100_get_mctrl() local
404 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_get_mctrl()
407 max3100_dowork(s); in max3100_get_mctrl()
409 return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR; in max3100_get_mctrl()
414 struct max3100_port *s = container_of(port, in max3100_set_mctrl() local
419 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_mctrl()
423 spin_lock(&s->conf_lock); in max3100_set_mctrl()
424 if (s->rts != rts) { in max3100_set_mctrl()
425 s->rts = rts; in max3100_set_mctrl()
426 s->rts_commit = 1; in max3100_set_mctrl()
427 max3100_dowork(s); in max3100_set_mctrl()
429 spin_unlock(&s->conf_lock); in max3100_set_mctrl()
436 struct max3100_port *s = container_of(port, in max3100_set_termios() local
443 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_termios()
449 param_new = s->conf & MAX3100_BAUD; in max3100_set_termios()
452 if (s->crystal) in max3100_set_termios()
453 baud = s->baud; in max3100_set_termios()
458 param_new = 14 + s->crystal; in max3100_set_termios()
461 param_new = 13 + s->crystal; in max3100_set_termios()
464 param_new = 12 + s->crystal; in max3100_set_termios()
467 param_new = 11 + s->crystal; in max3100_set_termios()
470 param_new = 10 + s->crystal; in max3100_set_termios()
473 param_new = 9 + s->crystal; in max3100_set_termios()
476 param_new = 8 + s->crystal; in max3100_set_termios()
479 param_new = 1 + s->crystal; in max3100_set_termios()
482 param_new = 0 + s->crystal; in max3100_set_termios()
485 if (s->crystal) in max3100_set_termios()
488 baud = s->baud; in max3100_set_termios()
491 baud = s->baud; in max3100_set_termios()
494 s->baud = baud; in max3100_set_termios()
531 s->port.ignore_status_mask = 0; in max3100_set_termios()
533 s->port.ignore_status_mask |= in max3100_set_termios()
537 if (s->poll_time > 0) in max3100_set_termios()
538 del_timer_sync(&s->timer); in max3100_set_termios()
542 spin_lock(&s->conf_lock); in max3100_set_termios()
543 s->conf = (s->conf & ~param_mask) | (param_new & param_mask); in max3100_set_termios()
544 s->conf_commit = 1; in max3100_set_termios()
545 s->parity = parity; in max3100_set_termios()
546 spin_unlock(&s->conf_lock); in max3100_set_termios()
547 max3100_dowork(s); in max3100_set_termios()
549 if (UART_ENABLE_MS(&s->port, termios->c_cflag)) in max3100_set_termios()
550 max3100_enable_ms(&s->port); in max3100_set_termios()
555 struct max3100_port *s = container_of(port, in max3100_shutdown() local
559 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_shutdown()
561 if (s->suspending) in max3100_shutdown()
564 s->force_end_work = 1; in max3100_shutdown()
566 if (s->poll_time > 0) in max3100_shutdown()
567 del_timer_sync(&s->timer); in max3100_shutdown()
569 if (s->workqueue) { in max3100_shutdown()
570 destroy_workqueue(s->workqueue); in max3100_shutdown()
571 s->workqueue = NULL; in max3100_shutdown()
573 if (s->irq) in max3100_shutdown()
574 free_irq(s->irq, s); in max3100_shutdown()
577 if (s->max3100_hw_suspend) in max3100_shutdown()
578 s->max3100_hw_suspend(1); in max3100_shutdown()
583 max3100_sr(s, tx, &rx); in max3100_shutdown()
589 struct max3100_port *s = container_of(port, in max3100_startup() local
594 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_startup()
596 s->conf = MAX3100_RM; in max3100_startup()
597 s->baud = s->crystal ? 230400 : 115200; in max3100_startup()
598 s->rx_enabled = 1; in max3100_startup()
600 if (s->suspending) in max3100_startup()
603 s->force_end_work = 0; in max3100_startup()
604 s->parity = 0; in max3100_startup()
605 s->rts = 0; in max3100_startup()
607 sprintf(b, "max3100-%d", s->minor); in max3100_startup()
608 s->workqueue = create_freezable_workqueue(b); in max3100_startup()
609 if (!s->workqueue) { in max3100_startup()
610 dev_warn(&s->spi->dev, "cannot create workqueue\n"); in max3100_startup()
613 INIT_WORK(&s->work, max3100_work); in max3100_startup()
615 if (request_irq(s->irq, max3100_irq, in max3100_startup()
616 IRQF_TRIGGER_FALLING, "max3100", s) < 0) { in max3100_startup()
617 dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); in max3100_startup()
618 s->irq = 0; in max3100_startup()
619 destroy_workqueue(s->workqueue); in max3100_startup()
620 s->workqueue = NULL; in max3100_startup()
624 if (s->loopback) { in max3100_startup()
627 max3100_sr(s, tx, &rx); in max3100_startup()
630 if (s->max3100_hw_suspend) in max3100_startup()
631 s->max3100_hw_suspend(0); in max3100_startup()
632 s->conf_commit = 1; in max3100_startup()
633 max3100_dowork(s); in max3100_startup()
637 max3100_enable_ms(&s->port); in max3100_startup()
644 struct max3100_port *s = container_of(port, in max3100_type() local
648 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_type()
650 return s->port.type == PORT_MAX3100 ? "MAX3100" : NULL; in max3100_type()
655 struct max3100_port *s = container_of(port, in max3100_release_port() local
659 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_release_port()
664 struct max3100_port *s = container_of(port, in max3100_config_port() local
668 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_config_port()
671 s->port.type = PORT_MAX3100; in max3100_config_port()
677 struct max3100_port *s = container_of(port, in max3100_verify_port() local
682 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_verify_port()
691 struct max3100_port *s = container_of(port, in max3100_stop_tx() local
695 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_tx()
700 struct max3100_port *s = container_of(port, in max3100_request_port() local
704 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_request_port()
710 struct max3100_port *s = container_of(port, in max3100_break_ctl() local
714 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_break_ctl()
795 dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i); in max3100_probe()
823 struct max3100_port *s = spi_get_drvdata(spi); in max3100_remove() local
830 if (max3100s[i] == s) { in max3100_remove()
831 dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i); in max3100_remove()
857 struct max3100_port *s = dev_get_drvdata(dev); in max3100_suspend() local
859 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_suspend()
861 disable_irq(s->irq); in max3100_suspend()
863 s->suspending = 1; in max3100_suspend()
864 uart_suspend_port(&max3100_uart_driver, &s->port); in max3100_suspend()
866 if (s->max3100_hw_suspend) in max3100_suspend()
867 s->max3100_hw_suspend(1); in max3100_suspend()
873 max3100_sr(s, tx, &rx); in max3100_suspend()
880 struct max3100_port *s = dev_get_drvdata(dev); in max3100_resume() local
882 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_resume()
884 if (s->max3100_hw_suspend) in max3100_resume()
885 s->max3100_hw_suspend(0); in max3100_resume()
886 uart_resume_port(&max3100_uart_driver, &s->port); in max3100_resume()
887 s->suspending = 0; in max3100_resume()
889 enable_irq(s->irq); in max3100_resume()
891 s->conf_commit = 1; in max3100_resume()
892 if (s->workqueue) in max3100_resume()
893 max3100_dowork(s); in max3100_resume()