Lines Matching +full:port +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
31 #define CON_BREAK ((long)-1)
32 #define CON_HUP ((long)-2)
42 static void transmit_chars_putchar(struct uart_port *port, in transmit_chars_putchar() argument
47 while (kfifo_peek(&tport->xmit_fifo, &ch)) { in transmit_chars_putchar()
53 uart_xmit_advance(port, 1); in transmit_chars_putchar()
57 static void transmit_chars_write(struct uart_port *port, struct tty_port *tport) in transmit_chars_write() argument
59 while (!kfifo_is_empty(&tport->xmit_fifo)) { in transmit_chars_write()
63 len = kfifo_out_linear_ptr(&tport->xmit_fifo, &tail, in transmit_chars_write()
70 uart_xmit_advance(port, sent); in transmit_chars_write()
74 static int receive_chars_getchar(struct uart_port *port) in receive_chars_getchar() argument
79 while (limit-- > 0) { in receive_chars_getchar()
87 if (uart_handle_break(port)) in receive_chars_getchar()
89 saw_console_brk = 1; in receive_chars_getchar()
94 hung_up = 1; in receive_chars_getchar()
95 uart_handle_dcd_change(port, false); in receive_chars_getchar()
98 uart_handle_dcd_change(port, true); in receive_chars_getchar()
101 if (port->state == NULL) { in receive_chars_getchar()
102 uart_handle_sysrq_char(port, c); in receive_chars_getchar()
106 port->icount.rx++; in receive_chars_getchar()
108 if (uart_handle_sysrq_char(port, c)) in receive_chars_getchar()
111 tty_insert_flip_char(&port->state->port, c, TTY_NORMAL); in receive_chars_getchar()
117 static int receive_chars_read(struct uart_port *port) in receive_chars_read() argument
122 while (limit-- > 0) { in receive_chars_read()
134 if (uart_handle_break(port)) in receive_chars_read()
136 saw_console_brk = 1; in receive_chars_read()
138 bytes_read = 1; in receive_chars_read()
140 hung_up = 1; in receive_chars_read()
141 uart_handle_dcd_change(port, false); in receive_chars_read()
151 uart_handle_dcd_change(port, true); in receive_chars_read()
154 if (port->sysrq != 0 && *con_read_page) { in receive_chars_read()
156 uart_handle_sysrq_char(port, con_read_page[i]); in receive_chars_read()
160 if (port->state == NULL) in receive_chars_read()
163 port->icount.rx += bytes_read; in receive_chars_read()
165 tty_insert_flip_string(&port->state->port, con_read_page, in receive_chars_read()
173 void (*transmit_chars)(struct uart_port *port, struct tty_port *tport);
174 int (*receive_chars)(struct uart_port *port);
189 static struct tty_port *receive_chars(struct uart_port *port) in receive_chars() argument
193 if (port->state != NULL) /* Unopened serial console */ in receive_chars()
194 tport = &port->state->port; in receive_chars()
196 if (sunhv_ops->receive_chars(port)) in receive_chars()
202 static void transmit_chars(struct uart_port *port) in transmit_chars() argument
206 if (!port->state) in transmit_chars()
209 tport = &port->state->port; in transmit_chars()
210 if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) in transmit_chars()
213 sunhv_ops->transmit_chars(port, tport); in transmit_chars()
215 if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS) in transmit_chars()
216 uart_write_wakeup(port); in transmit_chars()
221 struct uart_port *port = dev_id; in sunhv_interrupt() local
225 uart_port_lock_irqsave(port, &flags); in sunhv_interrupt()
226 tport = receive_chars(port); in sunhv_interrupt()
227 transmit_chars(port); in sunhv_interrupt()
228 uart_port_unlock_irqrestore(port, flags); in sunhv_interrupt()
236 /* port->lock is not held. */
237 static unsigned int sunhv_tx_empty(struct uart_port *port) in sunhv_tx_empty() argument
240 * is non-empty or there is an x_char pending, our caller in sunhv_tx_empty()
246 /* port->lock held by caller. */
247 static void sunhv_set_mctrl(struct uart_port *port, unsigned int mctrl) in sunhv_set_mctrl() argument
252 /* port->lock is held by caller and interrupts are disabled. */
253 static unsigned int sunhv_get_mctrl(struct uart_port *port) in sunhv_get_mctrl() argument
258 /* port->lock held by caller. */
259 static void sunhv_stop_tx(struct uart_port *port) in sunhv_stop_tx() argument
264 /* port->lock held by caller. */
265 static void sunhv_start_tx(struct uart_port *port) in sunhv_start_tx() argument
267 transmit_chars(port); in sunhv_start_tx()
270 /* port->lock is not held. */
271 static void sunhv_send_xchar(struct uart_port *port, char ch) in sunhv_send_xchar() argument
279 uart_port_lock_irqsave(port, &flags); in sunhv_send_xchar()
281 while (limit-- > 0) { in sunhv_send_xchar()
285 udelay(1); in sunhv_send_xchar()
288 uart_port_unlock_irqrestore(port, flags); in sunhv_send_xchar()
291 /* port->lock held by caller. */
292 static void sunhv_stop_rx(struct uart_port *port) in sunhv_stop_rx() argument
296 /* port->lock is not held. */
297 static void sunhv_break_ctl(struct uart_port *port, int break_state) in sunhv_break_ctl() argument
303 uart_port_lock_irqsave(port, &flags); in sunhv_break_ctl()
305 while (limit-- > 0) { in sunhv_break_ctl()
309 udelay(1); in sunhv_break_ctl()
312 uart_port_unlock_irqrestore(port, flags); in sunhv_break_ctl()
316 /* port->lock is not held. */
317 static int sunhv_startup(struct uart_port *port) in sunhv_startup() argument
322 /* port->lock is not held. */
323 static void sunhv_shutdown(struct uart_port *port) in sunhv_shutdown() argument
327 /* port->lock is not held. */
328 static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios, in sunhv_set_termios() argument
331 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); in sunhv_set_termios()
332 unsigned int quot = uart_get_divisor(port, baud); in sunhv_set_termios()
336 uart_port_lock_irqsave(port, &flags); in sunhv_set_termios()
338 iflag = termios->c_iflag; in sunhv_set_termios()
339 cflag = termios->c_cflag; in sunhv_set_termios()
341 port->ignore_status_mask = 0; in sunhv_set_termios()
343 port->ignore_status_mask |= IGNORE_BREAK; in sunhv_set_termios()
345 port->ignore_status_mask |= IGNORE_ALL; in sunhv_set_termios()
348 uart_update_timeout(port, cflag, in sunhv_set_termios()
349 (port->uartclk / (16 * quot))); in sunhv_set_termios()
351 uart_port_unlock_irqrestore(port, flags); in sunhv_set_termios()
354 static const char *sunhv_type(struct uart_port *port) in sunhv_type() argument
359 static void sunhv_release_port(struct uart_port *port) in sunhv_release_port() argument
363 static int sunhv_request_port(struct uart_port *port) in sunhv_request_port() argument
368 static void sunhv_config_port(struct uart_port *port, int flags) in sunhv_config_port() argument
372 static int sunhv_verify_port(struct uart_port *port, struct serial_struct *ser) in sunhv_verify_port() argument
374 return -EINVAL; in sunhv_verify_port()
408 irq_force_affinity(sunhv_port->irq, cpumask_of(cpu)); in sunhv_migrate_hvcons_irq()
423 while (n--) { in fill_con_write_page()
428 left--; in fill_con_write_page()
429 } else if (left < 1) in fill_con_write_page()
432 left--; in fill_con_write_page()
434 *page_bytes = p - con_write_page; in fill_con_write_page()
435 return s - orig_s; in fill_con_write_page()
440 struct uart_port *port = sunhv_port; in sunhv_console_write_paged() local
442 int locked = 1; in sunhv_console_write_paged()
444 if (port->sysrq || oops_in_progress) in sunhv_console_write_paged()
445 locked = uart_port_trylock_irqsave(port, &flags); in sunhv_console_write_paged()
447 uart_port_lock_irqsave(port, &flags); in sunhv_console_write_paged()
455 n -= cpy; in sunhv_console_write_paged()
461 while (limit--) { in sunhv_console_write_paged()
468 udelay(1); in sunhv_console_write_paged()
472 page_bytes -= written; in sunhv_console_write_paged()
478 uart_port_unlock_irqrestore(port, flags); in sunhv_console_write_paged()
481 static inline void sunhv_console_putchar(struct uart_port *port, char c) in sunhv_console_putchar() argument
485 while (limit-- > 0) { in sunhv_console_putchar()
489 udelay(1); in sunhv_console_putchar()
495 struct uart_port *port = sunhv_port; in sunhv_console_write_bychar() local
497 int i, locked = 1; in sunhv_console_write_bychar()
499 if (port->sysrq || oops_in_progress) in sunhv_console_write_bychar()
500 locked = uart_port_trylock_irqsave(port, &flags); in sunhv_console_write_bychar()
502 uart_port_lock_irqsave(port, &flags); in sunhv_console_write_bychar()
506 sunhv_console_putchar(port, '\r'); in sunhv_console_write_bychar()
507 sunhv_console_putchar(port, *s++); in sunhv_console_write_bychar()
511 uart_port_unlock_irqrestore(port, flags); in sunhv_console_write_bychar()
519 .index = -1,
525 struct uart_port *port; in hv_probe() local
529 if (op->archdata.irqs[0] == 0xffffffff) in hv_probe()
530 return -ENODEV; in hv_probe()
532 port = kzalloc(sizeof(struct uart_port), GFP_KERNEL); in hv_probe()
533 if (unlikely(!port)) in hv_probe()
534 return -ENOMEM; in hv_probe()
536 minor = 1; in hv_probe()
537 if (sun4v_hvapi_register(HV_GRP_CORE, 1, &minor) == 0 && in hv_probe()
538 minor >= 1) { in hv_probe()
539 err = -ENOMEM; in hv_probe()
552 sunhv_port = port; in hv_probe()
554 port->has_sysrq = 1; in hv_probe()
555 port->line = 0; in hv_probe()
556 port->ops = &sunhv_pops; in hv_probe()
557 port->type = PORT_SUNHV; in hv_probe()
558 port->uartclk = ( 29491200 / 16 ); /* arbitrary */ in hv_probe()
560 port->membase = (unsigned char __iomem *) __pa(port); in hv_probe()
562 port->irq = op->archdata.irqs[0]; in hv_probe()
564 port->dev = &op->dev; in hv_probe()
566 err = sunserial_register_minors(&sunhv_reg, 1); in hv_probe()
570 sunserial_console_match(&sunhv_console, op->dev.of_node, in hv_probe()
571 &sunhv_reg, port->line, false); in hv_probe()
573 err = uart_add_one_port(&sunhv_reg, port); in hv_probe()
577 err = request_irq(port->irq, sunhv_interrupt, 0, "hvcons", port); in hv_probe()
581 platform_set_drvdata(op, port); in hv_probe()
586 uart_remove_one_port(&sunhv_reg, port); in hv_probe()
589 sunserial_unregister_minors(&sunhv_reg, 1); in hv_probe()
598 kfree(port); in hv_probe()
605 struct uart_port *port = platform_get_drvdata(dev); in hv_remove() local
607 free_irq(port->irq, port); in hv_remove()
609 uart_remove_one_port(&sunhv_reg, port); in hv_remove()
611 sunserial_unregister_minors(&sunhv_reg, 1); in hv_remove()
614 kfree(port); in hv_remove()
625 .compatible = "SUNW,sun4v-console",
642 return -ENODEV; in sunhv_init()