Lines Matching refs:port
78 struct uart_port port; member
84 static u32 altera_uart_readl(struct uart_port *port, int reg) in altera_uart_readl() argument
86 return readl(port->membase + (reg << port->regshift)); in altera_uart_readl()
89 static void altera_uart_writel(struct uart_port *port, u32 dat, int reg) in altera_uart_writel() argument
91 writel(dat, port->membase + (reg << port->regshift)); in altera_uart_writel()
94 static unsigned int altera_uart_tx_empty(struct uart_port *port) in altera_uart_tx_empty() argument
96 return (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_empty()
100 static unsigned int altera_uart_get_mctrl(struct uart_port *port) in altera_uart_get_mctrl() argument
102 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_get_mctrl()
105 sigs = (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_get_mctrl()
120 if (!pp->port.irq) in altera_uart_update_ctrl_reg()
123 altera_uart_writel(&pp->port, imr, ALTERA_UART_CONTROL_REG); in altera_uart_update_ctrl_reg()
126 static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs) in altera_uart_set_mctrl() argument
128 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_set_mctrl()
138 static void altera_uart_start_tx(struct uart_port *port) in altera_uart_start_tx() argument
140 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_start_tx()
146 static void altera_uart_stop_tx(struct uart_port *port) in altera_uart_stop_tx() argument
148 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_tx()
154 static void altera_uart_stop_rx(struct uart_port *port) in altera_uart_stop_rx() argument
156 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_rx()
162 static void altera_uart_break_ctl(struct uart_port *port, int break_state) in altera_uart_break_ctl() argument
164 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_break_ctl()
167 spin_lock_irqsave(&port->lock, flags); in altera_uart_break_ctl()
173 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_break_ctl()
176 static void altera_uart_set_termios(struct uart_port *port, in altera_uart_set_termios() argument
183 baud = uart_get_baud_rate(port, termios, old, 0, 4000000); in altera_uart_set_termios()
184 baudclk = port->uartclk / baud; in altera_uart_set_termios()
190 spin_lock_irqsave(&port->lock, flags); in altera_uart_set_termios()
191 uart_update_timeout(port, termios->c_cflag, baud); in altera_uart_set_termios()
192 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_set_termios()
193 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_set_termios()
202 static void altera_uart_rx_chars(struct uart_port *port) in altera_uart_rx_chars() argument
207 while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) & in altera_uart_rx_chars()
209 ch = altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_rx_chars()
211 port->icount.rx++; in altera_uart_rx_chars()
214 altera_uart_writel(port, status, in altera_uart_rx_chars()
218 port->icount.brk++; in altera_uart_rx_chars()
219 if (uart_handle_break(port)) in altera_uart_rx_chars()
222 port->icount.parity++; in altera_uart_rx_chars()
224 port->icount.overrun++; in altera_uart_rx_chars()
226 port->icount.frame++; in altera_uart_rx_chars()
229 status &= port->read_status_mask; in altera_uart_rx_chars()
239 if (uart_handle_sysrq_char(port, ch)) in altera_uart_rx_chars()
241 uart_insert_char(port, status, ALTERA_UART_STATUS_ROE_MSK, ch, in altera_uart_rx_chars()
245 tty_flip_buffer_push(&port->state->port); in altera_uart_rx_chars()
248 static void altera_uart_tx_chars(struct uart_port *port) in altera_uart_tx_chars() argument
252 uart_port_tx(port, ch, in altera_uart_tx_chars()
253 altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_chars()
255 altera_uart_writel(port, ch, ALTERA_UART_TXDATA_REG)); in altera_uart_tx_chars()
260 struct uart_port *port = data; in altera_uart_interrupt() local
261 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_interrupt()
265 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
267 spin_lock_irqsave(&port->lock, flags); in altera_uart_interrupt()
269 altera_uart_rx_chars(port); in altera_uart_interrupt()
271 altera_uart_tx_chars(port); in altera_uart_interrupt()
272 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_interrupt()
280 struct uart_port *port = &pp->port; in altera_uart_timer() local
282 altera_uart_interrupt(0, port); in altera_uart_timer()
283 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
286 static void altera_uart_config_port(struct uart_port *port, int flags) in altera_uart_config_port() argument
288 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
291 altera_uart_writel(port, 0, ALTERA_UART_CONTROL_REG); in altera_uart_config_port()
293 altera_uart_writel(port, 0, ALTERA_UART_STATUS_REG); in altera_uart_config_port()
296 static int altera_uart_startup(struct uart_port *port) in altera_uart_startup() argument
298 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_startup()
301 if (!port->irq) { in altera_uart_startup()
303 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
307 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
308 DRV_NAME, port); in altera_uart_startup()
311 "interrupt vector=%d\n", port->line, port->irq); in altera_uart_startup()
316 spin_lock_irqsave(&port->lock, flags); in altera_uart_startup()
322 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_startup()
327 static void altera_uart_shutdown(struct uart_port *port) in altera_uart_shutdown() argument
329 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_shutdown()
332 spin_lock_irqsave(&port->lock, flags); in altera_uart_shutdown()
338 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_shutdown()
340 if (port->irq) in altera_uart_shutdown()
341 free_irq(port->irq, port); in altera_uart_shutdown()
346 static const char *altera_uart_type(struct uart_port *port) in altera_uart_type() argument
348 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
351 static int altera_uart_request_port(struct uart_port *port) in altera_uart_request_port() argument
357 static void altera_uart_release_port(struct uart_port *port) in altera_uart_release_port() argument
362 static int altera_uart_verify_port(struct uart_port *port, in altera_uart_verify_port() argument
371 static int altera_uart_poll_get_char(struct uart_port *port) in altera_uart_poll_get_char() argument
373 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_get_char()
377 return altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_poll_get_char()
380 static void altera_uart_poll_put_char(struct uart_port *port, unsigned char c) in altera_uart_poll_put_char() argument
382 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_put_char()
386 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_poll_put_char()
419 static void altera_uart_console_putc(struct uart_port *port, unsigned char c) in altera_uart_console_putc() argument
421 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_console_putc()
425 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_console_putc()
431 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write() local
433 uart_console_write(port, s, count, altera_uart_console_putc); in altera_uart_console_write()
438 struct uart_port *port; in altera_uart_console_setup() local
446 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
447 if (!port->membase) in altera_uart_console_setup()
453 return uart_set_options(port, co, baud, parity, bits, flow); in altera_uart_console_setup()
483 uart_console_write(&dev->port, s, count, altera_uart_console_putc); in altera_uart_earlycon_write()
489 struct uart_port *port = &dev->port; in altera_uart_earlycon_setup() local
491 if (!port->membase) in altera_uart_earlycon_setup()
495 altera_uart_writel(port, ALTERA_UART_CONTROL_RRDY_MSK, in altera_uart_earlycon_setup()
499 unsigned int baudclk = port->uartclk / dev->baud; in altera_uart_earlycon_setup()
501 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_earlycon_setup()
532 struct uart_port *port; in altera_uart_probe() local
540 if (altera_uart_ports[i].port.mapbase == 0) in altera_uart_probe()
547 port = &altera_uart_ports[i].port; in altera_uart_probe()
551 port->mapbase = res_mem->start; in altera_uart_probe()
553 port->mapbase = platp->mapbase; in altera_uart_probe()
561 port->irq = ret; in altera_uart_probe()
563 port->irq = platp->irq; in altera_uart_probe()
567 port->uartclk = platp->uartclk; in altera_uart_probe()
570 &port->uartclk); in altera_uart_probe()
575 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
576 if (!port->membase) in altera_uart_probe()
580 port->regshift = platp->bus_shift; in altera_uart_probe()
582 port->regshift = 0; in altera_uart_probe()
584 port->line = i; in altera_uart_probe()
585 port->type = PORT_ALTERA_UART; in altera_uart_probe()
586 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
587 port->ops = &altera_uart_ops; in altera_uart_probe()
588 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
589 port->dev = &pdev->dev; in altera_uart_probe()
591 platform_set_drvdata(pdev, port); in altera_uart_probe()
593 uart_add_one_port(&altera_uart_driver, port); in altera_uart_probe()
600 struct uart_port *port = platform_get_drvdata(pdev); in altera_uart_remove() local
602 if (port) { in altera_uart_remove()
603 uart_remove_one_port(&altera_uart_driver, port); in altera_uart_remove()
604 port->mapbase = 0; in altera_uart_remove()
605 iounmap(port->membase); in altera_uart_remove()