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, struct circ_buf *xmit) in transmit_chars_putchar() argument
45 long status = sun4v_con_putchar(xmit->buf[xmit->tail]); in transmit_chars_putchar()
50 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in transmit_chars_putchar()
51 port->icount.tx++; in transmit_chars_putchar()
55 static void transmit_chars_write(struct uart_port *port, struct circ_buf *xmit) in transmit_chars_write() argument
58 unsigned long ra = __pa(xmit->buf + xmit->tail); in transmit_chars_write()
61 len = CIRC_CNT_TO_END(xmit->head, xmit->tail, in transmit_chars_write()
66 xmit->tail = (xmit->tail + sent) & (UART_XMIT_SIZE - 1); in transmit_chars_write()
67 port->icount.tx += sent; in transmit_chars_write()
71 static int receive_chars_getchar(struct uart_port *port) in receive_chars_getchar() argument
76 while (limit-- > 0) { in receive_chars_getchar()
84 if (uart_handle_break(port)) in receive_chars_getchar()
86 saw_console_brk = 1; in receive_chars_getchar()
91 hung_up = 1; in receive_chars_getchar()
92 uart_handle_dcd_change(port, 0); in receive_chars_getchar()
95 uart_handle_dcd_change(port, 1); in receive_chars_getchar()
98 if (port->state == NULL) { in receive_chars_getchar()
99 uart_handle_sysrq_char(port, c); in receive_chars_getchar()
103 port->icount.rx++; in receive_chars_getchar()
105 if (uart_handle_sysrq_char(port, c)) in receive_chars_getchar()
108 tty_insert_flip_char(&port->state->port, c, TTY_NORMAL); in receive_chars_getchar()
114 static int receive_chars_read(struct uart_port *port) in receive_chars_read() argument
119 while (limit-- > 0) { in receive_chars_read()
131 if (uart_handle_break(port)) in receive_chars_read()
133 saw_console_brk = 1; in receive_chars_read()
135 bytes_read = 1; in receive_chars_read()
137 hung_up = 1; in receive_chars_read()
138 uart_handle_dcd_change(port, 0); in receive_chars_read()
148 uart_handle_dcd_change(port, 1); in receive_chars_read()
151 if (port->sysrq != 0 && *con_read_page) { in receive_chars_read()
153 uart_handle_sysrq_char(port, con_read_page[i]); in receive_chars_read()
157 if (port->state == NULL) in receive_chars_read()
160 port->icount.rx += bytes_read; in receive_chars_read()
162 tty_insert_flip_string(&port->state->port, con_read_page, in receive_chars_read()
170 void (*transmit_chars)(struct uart_port *port, struct circ_buf *xmit);
171 int (*receive_chars)(struct uart_port *port);
186 static struct tty_port *receive_chars(struct uart_port *port) in receive_chars() argument
190 if (port->state != NULL) /* Unopened serial console */ in receive_chars()
191 tport = &port->state->port; in receive_chars()
193 if (sunhv_ops->receive_chars(port)) in receive_chars()
199 static void transmit_chars(struct uart_port *port) in transmit_chars() argument
203 if (!port->state) in transmit_chars()
206 xmit = &port->state->xmit; in transmit_chars()
207 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) in transmit_chars()
210 sunhv_ops->transmit_chars(port, xmit); in transmit_chars()
213 uart_write_wakeup(port); in transmit_chars()
218 struct uart_port *port = dev_id; in sunhv_interrupt() local
222 spin_lock_irqsave(&port->lock, flags); in sunhv_interrupt()
223 tport = receive_chars(port); in sunhv_interrupt()
224 transmit_chars(port); in sunhv_interrupt()
225 spin_unlock_irqrestore(&port->lock, flags); in sunhv_interrupt()
233 /* port->lock is not held. */
234 static unsigned int sunhv_tx_empty(struct uart_port *port) in sunhv_tx_empty() argument
237 * is non-empty or there is an x_char pending, our caller in sunhv_tx_empty()
243 /* port->lock held by caller. */
244 static void sunhv_set_mctrl(struct uart_port *port, unsigned int mctrl) in sunhv_set_mctrl() argument
249 /* port->lock is held by caller and interrupts are disabled. */
250 static unsigned int sunhv_get_mctrl(struct uart_port *port) in sunhv_get_mctrl() argument
255 /* port->lock held by caller. */
256 static void sunhv_stop_tx(struct uart_port *port) in sunhv_stop_tx() argument
261 /* port->lock held by caller. */
262 static void sunhv_start_tx(struct uart_port *port) in sunhv_start_tx() argument
264 transmit_chars(port); in sunhv_start_tx()
267 /* port->lock is not held. */
268 static void sunhv_send_xchar(struct uart_port *port, char ch) in sunhv_send_xchar() argument
276 spin_lock_irqsave(&port->lock, flags); in sunhv_send_xchar()
278 while (limit-- > 0) { in sunhv_send_xchar()
282 udelay(1); in sunhv_send_xchar()
285 spin_unlock_irqrestore(&port->lock, flags); in sunhv_send_xchar()
288 /* port->lock held by caller. */
289 static void sunhv_stop_rx(struct uart_port *port) in sunhv_stop_rx() argument
293 /* port->lock is not held. */
294 static void sunhv_break_ctl(struct uart_port *port, int break_state) in sunhv_break_ctl() argument
300 spin_lock_irqsave(&port->lock, flags); in sunhv_break_ctl()
302 while (limit-- > 0) { in sunhv_break_ctl()
306 udelay(1); in sunhv_break_ctl()
309 spin_unlock_irqrestore(&port->lock, flags); in sunhv_break_ctl()
313 /* port->lock is not held. */
314 static int sunhv_startup(struct uart_port *port) in sunhv_startup() argument
319 /* port->lock is not held. */
320 static void sunhv_shutdown(struct uart_port *port) in sunhv_shutdown() argument
324 /* port->lock is not held. */
325 static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios, in sunhv_set_termios() argument
328 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); in sunhv_set_termios()
329 unsigned int quot = uart_get_divisor(port, baud); in sunhv_set_termios()
333 spin_lock_irqsave(&port->lock, flags); in sunhv_set_termios()
335 iflag = termios->c_iflag; in sunhv_set_termios()
336 cflag = termios->c_cflag; in sunhv_set_termios()
338 port->ignore_status_mask = 0; in sunhv_set_termios()
340 port->ignore_status_mask |= IGNORE_BREAK; in sunhv_set_termios()
342 port->ignore_status_mask |= IGNORE_ALL; in sunhv_set_termios()
345 uart_update_timeout(port, cflag, in sunhv_set_termios()
346 (port->uartclk / (16 * quot))); in sunhv_set_termios()
348 spin_unlock_irqrestore(&port->lock, flags); in sunhv_set_termios()
351 static const char *sunhv_type(struct uart_port *port) in sunhv_type() argument
356 static void sunhv_release_port(struct uart_port *port) in sunhv_release_port() argument
360 static int sunhv_request_port(struct uart_port *port) in sunhv_request_port() argument
365 static void sunhv_config_port(struct uart_port *port, int flags) in sunhv_config_port() argument
369 static int sunhv_verify_port(struct uart_port *port, struct serial_struct *ser) in sunhv_verify_port() argument
371 return -EINVAL; in sunhv_verify_port()
405 irq_force_affinity(sunhv_port->irq, cpumask_of(cpu)); in sunhv_migrate_hvcons_irq()
420 while (n--) { in fill_con_write_page()
425 left--; in fill_con_write_page()
426 } else if (left < 1) in fill_con_write_page()
429 left--; in fill_con_write_page()
431 *page_bytes = p - con_write_page; in fill_con_write_page()
432 return s - orig_s; in fill_con_write_page()
437 struct uart_port *port = sunhv_port; in sunhv_console_write_paged() local
439 int locked = 1; in sunhv_console_write_paged()
441 if (port->sysrq || oops_in_progress) in sunhv_console_write_paged()
442 locked = spin_trylock_irqsave(&port->lock, flags); in sunhv_console_write_paged()
444 spin_lock_irqsave(&port->lock, flags); in sunhv_console_write_paged()
452 n -= cpy; in sunhv_console_write_paged()
458 while (limit--) { in sunhv_console_write_paged()
465 udelay(1); in sunhv_console_write_paged()
469 page_bytes -= written; in sunhv_console_write_paged()
475 spin_unlock_irqrestore(&port->lock, flags); in sunhv_console_write_paged()
478 static inline void sunhv_console_putchar(struct uart_port *port, char c) in sunhv_console_putchar() argument
482 while (limit-- > 0) { in sunhv_console_putchar()
486 udelay(1); in sunhv_console_putchar()
492 struct uart_port *port = sunhv_port; in sunhv_console_write_bychar() local
494 int i, locked = 1; in sunhv_console_write_bychar()
496 if (port->sysrq || oops_in_progress) in sunhv_console_write_bychar()
497 locked = spin_trylock_irqsave(&port->lock, flags); in sunhv_console_write_bychar()
499 spin_lock_irqsave(&port->lock, flags); in sunhv_console_write_bychar()
503 sunhv_console_putchar(port, '\r'); in sunhv_console_write_bychar()
504 sunhv_console_putchar(port, *s++); in sunhv_console_write_bychar()
508 spin_unlock_irqrestore(&port->lock, flags); in sunhv_console_write_bychar()
516 .index = -1,
522 struct uart_port *port; in hv_probe() local
526 if (op->archdata.irqs[0] == 0xffffffff) in hv_probe()
527 return -ENODEV; in hv_probe()
529 port = kzalloc(sizeof(struct uart_port), GFP_KERNEL); in hv_probe()
530 if (unlikely(!port)) in hv_probe()
531 return -ENOMEM; in hv_probe()
533 minor = 1; in hv_probe()
534 if (sun4v_hvapi_register(HV_GRP_CORE, 1, &minor) == 0 && in hv_probe()
535 minor >= 1) { in hv_probe()
536 err = -ENOMEM; in hv_probe()
549 sunhv_port = port; in hv_probe()
551 port->has_sysrq = 1; in hv_probe()
552 port->line = 0; in hv_probe()
553 port->ops = &sunhv_pops; in hv_probe()
554 port->type = PORT_SUNHV; in hv_probe()
555 port->uartclk = ( 29491200 / 16 ); /* arbitrary */ in hv_probe()
557 port->membase = (unsigned char __iomem *) __pa(port); in hv_probe()
559 port->irq = op->archdata.irqs[0]; in hv_probe()
561 port->dev = &op->dev; in hv_probe()
563 err = sunserial_register_minors(&sunhv_reg, 1); in hv_probe()
567 sunserial_console_match(&sunhv_console, op->dev.of_node, in hv_probe()
568 &sunhv_reg, port->line, false); in hv_probe()
570 err = uart_add_one_port(&sunhv_reg, port); in hv_probe()
574 err = request_irq(port->irq, sunhv_interrupt, 0, "hvcons", port); in hv_probe()
578 platform_set_drvdata(op, port); in hv_probe()
583 uart_remove_one_port(&sunhv_reg, port); in hv_probe()
586 sunserial_unregister_minors(&sunhv_reg, 1); in hv_probe()
595 kfree(port); in hv_probe()
602 struct uart_port *port = platform_get_drvdata(dev); in hv_remove() local
604 free_irq(port->irq, port); in hv_remove()
606 uart_remove_one_port(&sunhv_reg, port); in hv_remove()
608 sunserial_unregister_minors(&sunhv_reg, 1); in hv_remove()
611 kfree(port); in hv_remove()
624 .compatible = "SUNW,sun4v-console",
641 return -ENODEV; in sunhv_init()