• Home
  • Raw
  • Download

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 ? TIOCM_CTS : 0); 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()
297 s->port.icount.tx++; in max3100_work()
300 max3100_calc_parity(s, &tx); in max3100_work()
301 tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); in max3100_work()
302 max3100_sr(s, tx, &rx); in max3100_work()
303 rxchars += max3100_handlerx(s, rx); in max3100_work()
308 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
312 uart_write_wakeup(&s->port); in max3100_work()
314 } while (!s->force_end_work && in max3100_work()
318 !uart_tx_stopped(&s->port)))); in max3100_work()
321 tty_flip_buffer_push(&s->port.state->port); in max3100_work()
326 struct max3100_port *s = dev_id; in max3100_irq() local
328 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_irq()
330 max3100_dowork(s); in max3100_irq()
336 struct max3100_port *s = container_of(port, in max3100_enable_ms() local
340 if (s->poll_time > 0) in max3100_enable_ms()
341 mod_timer(&s->timer, jiffies); in max3100_enable_ms()
342 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_enable_ms()
347 struct max3100_port *s = container_of(port, in max3100_start_tx() local
351 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_start_tx()
353 max3100_dowork(s); in max3100_start_tx()
358 struct max3100_port *s = container_of(port, in max3100_stop_rx() local
362 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_rx()
364 s->rx_enabled = 0; in max3100_stop_rx()
365 spin_lock(&s->conf_lock); in max3100_stop_rx()
366 s->conf &= ~MAX3100_RM; in max3100_stop_rx()
367 s->conf_commit = 1; in max3100_stop_rx()
368 spin_unlock(&s->conf_lock); in max3100_stop_rx()
369 max3100_dowork(s); in max3100_stop_rx()
374 struct max3100_port *s = container_of(port, in max3100_tx_empty() local
378 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_tx_empty()
381 max3100_dowork(s); in max3100_tx_empty()
382 return s->tx_empty; in max3100_tx_empty()
387 struct max3100_port *s = container_of(port, in max3100_get_mctrl() local
391 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_get_mctrl()
394 max3100_dowork(s); in max3100_get_mctrl()
396 return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR; in max3100_get_mctrl()
401 struct max3100_port *s = container_of(port, in max3100_set_mctrl() local
406 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_mctrl()
410 spin_lock(&s->conf_lock); in max3100_set_mctrl()
411 if (s->rts != rts) { in max3100_set_mctrl()
412 s->rts = rts; in max3100_set_mctrl()
413 s->rts_commit = 1; in max3100_set_mctrl()
414 max3100_dowork(s); in max3100_set_mctrl()
416 spin_unlock(&s->conf_lock); in max3100_set_mctrl()
423 struct max3100_port *s = container_of(port, in max3100_set_termios() local
430 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_set_termios()
436 param_new = s->conf & MAX3100_BAUD; in max3100_set_termios()
439 if (s->crystal) in max3100_set_termios()
440 baud = s->baud; in max3100_set_termios()
445 param_new = 14 + s->crystal; in max3100_set_termios()
448 param_new = 13 + s->crystal; in max3100_set_termios()
451 param_new = 12 + s->crystal; in max3100_set_termios()
454 param_new = 11 + s->crystal; in max3100_set_termios()
457 param_new = 10 + s->crystal; in max3100_set_termios()
460 param_new = 9 + s->crystal; in max3100_set_termios()
463 param_new = 8 + s->crystal; in max3100_set_termios()
466 param_new = 1 + s->crystal; in max3100_set_termios()
469 param_new = 0 + s->crystal; in max3100_set_termios()
472 if (s->crystal) in max3100_set_termios()
475 baud = s->baud; in max3100_set_termios()
478 baud = s->baud; in max3100_set_termios()
481 s->baud = baud; in max3100_set_termios()
518 s->port.ignore_status_mask = 0; in max3100_set_termios()
520 s->port.ignore_status_mask |= in max3100_set_termios()
525 s->port.state->port.low_latency = 1; in max3100_set_termios()
527 if (s->poll_time > 0) in max3100_set_termios()
528 del_timer_sync(&s->timer); in max3100_set_termios()
532 spin_lock(&s->conf_lock); in max3100_set_termios()
533 s->conf = (s->conf & ~param_mask) | (param_new & param_mask); in max3100_set_termios()
534 s->conf_commit = 1; in max3100_set_termios()
535 s->parity = parity; in max3100_set_termios()
536 spin_unlock(&s->conf_lock); in max3100_set_termios()
537 max3100_dowork(s); in max3100_set_termios()
539 if (UART_ENABLE_MS(&s->port, termios->c_cflag)) in max3100_set_termios()
540 max3100_enable_ms(&s->port); in max3100_set_termios()
545 struct max3100_port *s = container_of(port, in max3100_shutdown() local
549 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_shutdown()
551 if (s->suspending) in max3100_shutdown()
554 s->force_end_work = 1; in max3100_shutdown()
556 if (s->poll_time > 0) in max3100_shutdown()
557 del_timer_sync(&s->timer); in max3100_shutdown()
559 if (s->workqueue) { in max3100_shutdown()
560 flush_workqueue(s->workqueue); in max3100_shutdown()
561 destroy_workqueue(s->workqueue); in max3100_shutdown()
562 s->workqueue = NULL; in max3100_shutdown()
564 if (s->irq) in max3100_shutdown()
565 free_irq(s->irq, s); in max3100_shutdown()
568 if (s->max3100_hw_suspend) in max3100_shutdown()
569 s->max3100_hw_suspend(1); in max3100_shutdown()
574 max3100_sr(s, tx, &rx); in max3100_shutdown()
580 struct max3100_port *s = container_of(port, in max3100_startup() local
585 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_startup()
587 s->conf = MAX3100_RM; in max3100_startup()
588 s->baud = s->crystal ? 230400 : 115200; in max3100_startup()
589 s->rx_enabled = 1; in max3100_startup()
591 if (s->suspending) in max3100_startup()
594 s->force_end_work = 0; in max3100_startup()
595 s->parity = 0; in max3100_startup()
596 s->rts = 0; in max3100_startup()
598 sprintf(b, "max3100-%d", s->minor); in max3100_startup()
599 s->workqueue = create_freezable_workqueue(b); in max3100_startup()
600 if (!s->workqueue) { in max3100_startup()
601 dev_warn(&s->spi->dev, "cannot create workqueue\n"); in max3100_startup()
604 INIT_WORK(&s->work, max3100_work); in max3100_startup()
606 if (request_irq(s->irq, max3100_irq, in max3100_startup()
607 IRQF_TRIGGER_FALLING, "max3100", s) < 0) { in max3100_startup()
608 dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); in max3100_startup()
609 s->irq = 0; in max3100_startup()
610 destroy_workqueue(s->workqueue); in max3100_startup()
611 s->workqueue = NULL; in max3100_startup()
615 if (s->loopback) { in max3100_startup()
618 max3100_sr(s, tx, &rx); in max3100_startup()
621 if (s->max3100_hw_suspend) in max3100_startup()
622 s->max3100_hw_suspend(0); in max3100_startup()
623 s->conf_commit = 1; in max3100_startup()
624 max3100_dowork(s); in max3100_startup()
628 max3100_enable_ms(&s->port); in max3100_startup()
635 struct max3100_port *s = container_of(port, in max3100_type() local
639 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_type()
641 return s->port.type == PORT_MAX3100 ? "MAX3100" : NULL; in max3100_type()
646 struct max3100_port *s = container_of(port, in max3100_release_port() local
650 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_release_port()
655 struct max3100_port *s = container_of(port, in max3100_config_port() local
659 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_config_port()
662 s->port.type = PORT_MAX3100; in max3100_config_port()
668 struct max3100_port *s = container_of(port, in max3100_verify_port() local
673 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_verify_port()
682 struct max3100_port *s = container_of(port, in max3100_stop_tx() local
686 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_stop_tx()
691 struct max3100_port *s = container_of(port, in max3100_request_port() local
695 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_request_port()
701 struct max3100_port *s = container_of(port, in max3100_break_ctl() local
705 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_break_ctl()
813 struct max3100_port *s = spi_get_drvdata(spi); in max3100_remove() local
820 if (max3100s[i] == s) { in max3100_remove()
847 struct max3100_port *s = dev_get_drvdata(dev); in max3100_suspend() local
849 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_suspend()
851 disable_irq(s->irq); in max3100_suspend()
853 s->suspending = 1; in max3100_suspend()
854 uart_suspend_port(&max3100_uart_driver, &s->port); in max3100_suspend()
856 if (s->max3100_hw_suspend) in max3100_suspend()
857 s->max3100_hw_suspend(1); in max3100_suspend()
863 max3100_sr(s, tx, &rx); in max3100_suspend()
870 struct max3100_port *s = dev_get_drvdata(dev); in max3100_resume() local
872 dev_dbg(&s->spi->dev, "%s\n", __func__); in max3100_resume()
874 if (s->max3100_hw_suspend) in max3100_resume()
875 s->max3100_hw_suspend(0); in max3100_resume()
876 uart_resume_port(&max3100_uart_driver, &s->port); in max3100_resume()
877 s->suspending = 0; in max3100_resume()
879 enable_irq(s->irq); in max3100_resume()
881 s->conf_commit = 1; in max3100_resume()
882 if (s->workqueue) in max3100_resume()
883 max3100_dowork(s); in max3100_resume()