Lines Matching full:port
82 struct uart_port port; member
88 static u32 altera_uart_readl(struct uart_port *port, int reg) in altera_uart_readl() argument
90 return readl(port->membase + (reg << port->regshift)); in altera_uart_readl()
93 static void altera_uart_writel(struct uart_port *port, u32 dat, int reg) in altera_uart_writel() argument
95 writel(dat, port->membase + (reg << port->regshift)); in altera_uart_writel()
98 static unsigned int altera_uart_tx_empty(struct uart_port *port) in altera_uart_tx_empty() argument
100 return (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_empty()
104 static unsigned int altera_uart_get_mctrl(struct uart_port *port) in altera_uart_get_mctrl() argument
106 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_get_mctrl()
109 sigs = (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_get_mctrl()
116 static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs) in altera_uart_set_mctrl() argument
118 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_set_mctrl()
125 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_set_mctrl()
128 static void altera_uart_start_tx(struct uart_port *port) in altera_uart_start_tx() argument
130 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_start_tx()
133 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_start_tx()
136 static void altera_uart_stop_tx(struct uart_port *port) in altera_uart_stop_tx() argument
138 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_tx()
141 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_stop_tx()
144 static void altera_uart_stop_rx(struct uart_port *port) in altera_uart_stop_rx() argument
146 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_rx()
149 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_stop_rx()
152 static void altera_uart_break_ctl(struct uart_port *port, int break_state) in altera_uart_break_ctl() argument
154 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_break_ctl()
157 spin_lock_irqsave(&port->lock, flags); in altera_uart_break_ctl()
162 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_break_ctl()
163 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_break_ctl()
166 static void altera_uart_enable_ms(struct uart_port *port) in altera_uart_enable_ms() argument
170 static void altera_uart_set_termios(struct uart_port *port, in altera_uart_set_termios() argument
177 baud = uart_get_baud_rate(port, termios, old, 0, 4000000); in altera_uart_set_termios()
178 baudclk = port->uartclk / baud; in altera_uart_set_termios()
184 spin_lock_irqsave(&port->lock, flags); in altera_uart_set_termios()
185 uart_update_timeout(port, termios->c_cflag, baud); in altera_uart_set_termios()
186 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_set_termios()
187 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_set_termios()
192 struct uart_port *port = &pp->port; in altera_uart_rx_chars() local
196 while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) & in altera_uart_rx_chars()
198 ch = altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_rx_chars()
200 port->icount.rx++; in altera_uart_rx_chars()
203 altera_uart_writel(port, status, in altera_uart_rx_chars()
207 port->icount.brk++; in altera_uart_rx_chars()
208 if (uart_handle_break(port)) in altera_uart_rx_chars()
211 port->icount.parity++; in altera_uart_rx_chars()
213 port->icount.overrun++; in altera_uart_rx_chars()
215 port->icount.frame++; in altera_uart_rx_chars()
218 status &= port->read_status_mask; in altera_uart_rx_chars()
228 if (uart_handle_sysrq_char(port, ch)) in altera_uart_rx_chars()
230 uart_insert_char(port, status, ALTERA_UART_STATUS_ROE_MSK, ch, in altera_uart_rx_chars()
234 tty_flip_buffer_push(port->state->port.tty); in altera_uart_rx_chars()
239 struct uart_port *port = &pp->port; in altera_uart_tx_chars() local
240 struct circ_buf *xmit = &port->state->xmit; in altera_uart_tx_chars()
242 if (port->x_char) { in altera_uart_tx_chars()
244 altera_uart_writel(port, port->x_char, ALTERA_UART_TXDATA_REG); in altera_uart_tx_chars()
245 port->x_char = 0; in altera_uart_tx_chars()
246 port->icount.tx++; in altera_uart_tx_chars()
250 while (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_chars()
254 altera_uart_writel(port, xmit->buf[xmit->tail], in altera_uart_tx_chars()
257 port->icount.tx++; in altera_uart_tx_chars()
261 uart_write_wakeup(port); in altera_uart_tx_chars()
265 altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); in altera_uart_tx_chars()
271 struct uart_port *port = data; in altera_uart_interrupt() local
272 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_interrupt()
275 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
277 spin_lock(&port->lock); in altera_uart_interrupt()
282 spin_unlock(&port->lock); in altera_uart_interrupt()
289 struct uart_port *port = (void *)data; in altera_uart_timer() local
290 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_timer()
292 altera_uart_interrupt(0, port); in altera_uart_timer()
293 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
296 static void altera_uart_config_port(struct uart_port *port, int flags) in altera_uart_config_port() argument
298 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
301 altera_uart_writel(port, 0, ALTERA_UART_CONTROL_REG); in altera_uart_config_port()
303 altera_uart_writel(port, 0, ALTERA_UART_STATUS_REG); in altera_uart_config_port()
306 static int altera_uart_startup(struct uart_port *port) in altera_uart_startup() argument
308 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_startup()
312 if (!port->irq) { in altera_uart_startup()
313 setup_timer(&pp->tmr, altera_uart_timer, (unsigned long)port); in altera_uart_startup()
314 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
318 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
319 DRV_NAME, port); in altera_uart_startup()
322 "interrupt vector=%d\n", port->line, port->irq); in altera_uart_startup()
326 spin_lock_irqsave(&port->lock, flags); in altera_uart_startup()
330 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); in altera_uart_startup()
332 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_startup()
337 static void altera_uart_shutdown(struct uart_port *port) in altera_uart_shutdown() argument
339 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_shutdown()
342 spin_lock_irqsave(&port->lock, flags); in altera_uart_shutdown()
346 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); in altera_uart_shutdown()
348 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_shutdown()
350 if (port->irq) in altera_uart_shutdown()
351 free_irq(port->irq, port); in altera_uart_shutdown()
356 static const char *altera_uart_type(struct uart_port *port) in altera_uart_type() argument
358 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
361 static int altera_uart_request_port(struct uart_port *port) in altera_uart_request_port() argument
367 static void altera_uart_release_port(struct uart_port *port) in altera_uart_release_port() argument
372 static int altera_uart_verify_port(struct uart_port *port, in altera_uart_verify_port() argument
408 struct uart_port *port; in early_altera_uart_setup() local
412 port = &altera_uart_ports[i].port; in early_altera_uart_setup()
414 port->line = i; in early_altera_uart_setup()
415 port->type = PORT_ALTERA_UART; in early_altera_uart_setup()
416 port->mapbase = platp[i].mapbase; in early_altera_uart_setup()
417 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in early_altera_uart_setup()
418 port->iotype = SERIAL_IO_MEM; in early_altera_uart_setup()
419 port->irq = platp[i].irq; in early_altera_uart_setup()
420 port->uartclk = platp[i].uartclk; in early_altera_uart_setup()
421 port->flags = UPF_BOOT_AUTOCONF; in early_altera_uart_setup()
422 port->ops = &altera_uart_ops; in early_altera_uart_setup()
423 port->private_data = platp; in early_altera_uart_setup()
429 static void altera_uart_console_putc(struct uart_port *port, const char c) in altera_uart_console_putc() argument
431 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_console_putc()
435 writel(c, port->membase + ALTERA_UART_TXDATA_REG); in altera_uart_console_putc()
441 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write() local
444 altera_uart_console_putc(port, *s); in altera_uart_console_write()
446 altera_uart_console_putc(port, '\r'); in altera_uart_console_write()
452 struct uart_port *port; in altera_uart_console_setup() local
460 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
461 if (!port->membase) in altera_uart_console_setup()
467 return uart_set_options(port, co, baud, parity, bits, flow); in altera_uart_console_setup()
513 struct uart_port *port) in altera_uart_get_of_uartclk() argument
522 port->uartclk = be32_to_cpup(clk); in altera_uart_get_of_uartclk()
528 struct uart_port *port) in altera_uart_get_of_uartclk() argument
537 struct uart_port *port; in altera_uart_probe() local
546 if (altera_uart_ports[i].port.mapbase == 0) in altera_uart_probe()
553 port = &altera_uart_ports[i].port; in altera_uart_probe()
557 port->mapbase = res_mem->start; in altera_uart_probe()
559 port->mapbase = platp->mapbase; in altera_uart_probe()
565 port->irq = res_irq->start; in altera_uart_probe()
567 port->irq = platp->irq; in altera_uart_probe()
571 port->uartclk = platp->uartclk; in altera_uart_probe()
573 ret = altera_uart_get_of_uartclk(pdev, port); in altera_uart_probe()
578 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
579 if (!port->membase) in altera_uart_probe()
583 port->regshift = platp->bus_shift; in altera_uart_probe()
585 port->regshift = 0; in altera_uart_probe()
587 port->line = i; in altera_uart_probe()
588 port->type = PORT_ALTERA_UART; in altera_uart_probe()
589 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
590 port->ops = &altera_uart_ops; in altera_uart_probe()
591 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
593 dev_set_drvdata(&pdev->dev, port); in altera_uart_probe()
595 uart_add_one_port(&altera_uart_driver, port); in altera_uart_probe()
602 struct uart_port *port = dev_get_drvdata(&pdev->dev); in altera_uart_remove() local
604 if (port) { in altera_uart_remove()
605 uart_remove_one_port(&altera_uart_driver, port); in altera_uart_remove()
607 port->mapbase = 0; in altera_uart_remove()