Lines Matching refs:port
103 static inline u32 uart_in32(u32 offset, struct uart_port *port) in uart_in32() argument
105 struct uartlite_data *pdata = port->private_data; in uart_in32()
107 return pdata->reg_ops->in(port->membase + offset); in uart_in32()
110 static inline void uart_out32(u32 val, u32 offset, struct uart_port *port) in uart_out32() argument
112 struct uartlite_data *pdata = port->private_data; in uart_out32()
114 pdata->reg_ops->out(val, port->membase + offset); in uart_out32()
123 static int ulite_receive(struct uart_port *port, int stat) in ulite_receive() argument
125 struct tty_port *tport = &port->state->port; in ulite_receive()
135 port->icount.rx++; in ulite_receive()
136 ch = uart_in32(ULITE_RX, port); in ulite_receive()
139 port->icount.parity++; in ulite_receive()
143 port->icount.overrun++; in ulite_receive()
146 port->icount.frame++; in ulite_receive()
150 if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY) in ulite_receive()
153 stat &= port->read_status_mask; in ulite_receive()
159 stat &= ~port->ignore_status_mask; in ulite_receive()
173 static int ulite_transmit(struct uart_port *port, int stat) in ulite_transmit() argument
175 struct circ_buf *xmit = &port->state->xmit; in ulite_transmit()
180 if (port->x_char) { in ulite_transmit()
181 uart_out32(port->x_char, ULITE_TX, port); in ulite_transmit()
182 port->x_char = 0; in ulite_transmit()
183 port->icount.tx++; in ulite_transmit()
187 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) in ulite_transmit()
190 uart_out32(xmit->buf[xmit->tail], ULITE_TX, port); in ulite_transmit()
192 port->icount.tx++; in ulite_transmit()
196 uart_write_wakeup(port); in ulite_transmit()
203 struct uart_port *port = dev_id; in ulite_isr() local
208 spin_lock_irqsave(&port->lock, flags); in ulite_isr()
209 stat = uart_in32(ULITE_STATUS, port); in ulite_isr()
210 busy = ulite_receive(port, stat); in ulite_isr()
211 busy |= ulite_transmit(port, stat); in ulite_isr()
212 spin_unlock_irqrestore(&port->lock, flags); in ulite_isr()
218 tty_flip_buffer_push(&port->state->port); in ulite_isr()
225 static unsigned int ulite_tx_empty(struct uart_port *port) in ulite_tx_empty() argument
230 spin_lock_irqsave(&port->lock, flags); in ulite_tx_empty()
231 ret = uart_in32(ULITE_STATUS, port); in ulite_tx_empty()
232 spin_unlock_irqrestore(&port->lock, flags); in ulite_tx_empty()
237 static unsigned int ulite_get_mctrl(struct uart_port *port) in ulite_get_mctrl() argument
242 static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl) in ulite_set_mctrl() argument
247 static void ulite_stop_tx(struct uart_port *port) in ulite_stop_tx() argument
252 static void ulite_start_tx(struct uart_port *port) in ulite_start_tx() argument
254 ulite_transmit(port, uart_in32(ULITE_STATUS, port)); in ulite_start_tx()
257 static void ulite_stop_rx(struct uart_port *port) in ulite_stop_rx() argument
260 port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY in ulite_stop_rx()
264 static void ulite_break_ctl(struct uart_port *port, int ctl) in ulite_break_ctl() argument
269 static int ulite_startup(struct uart_port *port) in ulite_startup() argument
271 struct uartlite_data *pdata = port->private_data; in ulite_startup()
276 dev_err(port->dev, "Failed to enable clock\n"); in ulite_startup()
280 ret = request_irq(port->irq, ulite_isr, IRQF_SHARED | IRQF_TRIGGER_RISING, in ulite_startup()
281 "uartlite", port); in ulite_startup()
286 ULITE_CONTROL, port); in ulite_startup()
287 uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port); in ulite_startup()
292 static void ulite_shutdown(struct uart_port *port) in ulite_shutdown() argument
294 struct uartlite_data *pdata = port->private_data; in ulite_shutdown()
296 uart_out32(0, ULITE_CONTROL, port); in ulite_shutdown()
297 uart_in32(ULITE_CONTROL, port); /* dummy */ in ulite_shutdown()
298 free_irq(port->irq, port); in ulite_shutdown()
302 static void ulite_set_termios(struct uart_port *port, struct ktermios *termios, in ulite_set_termios() argument
308 spin_lock_irqsave(&port->lock, flags); in ulite_set_termios()
310 port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN in ulite_set_termios()
314 port->read_status_mask |= in ulite_set_termios()
317 port->ignore_status_mask = 0; in ulite_set_termios()
319 port->ignore_status_mask |= ULITE_STATUS_PARITY in ulite_set_termios()
324 port->ignore_status_mask |= in ulite_set_termios()
329 baud = uart_get_baud_rate(port, termios, old, 0, 460800); in ulite_set_termios()
330 uart_update_timeout(port, termios->c_cflag, baud); in ulite_set_termios()
332 spin_unlock_irqrestore(&port->lock, flags); in ulite_set_termios()
335 static const char *ulite_type(struct uart_port *port) in ulite_type() argument
337 return port->type == PORT_UARTLITE ? "uartlite" : NULL; in ulite_type()
340 static void ulite_release_port(struct uart_port *port) in ulite_release_port() argument
342 release_mem_region(port->mapbase, ULITE_REGION); in ulite_release_port()
343 iounmap(port->membase); in ulite_release_port()
344 port->membase = NULL; in ulite_release_port()
347 static int ulite_request_port(struct uart_port *port) in ulite_request_port() argument
349 struct uartlite_data *pdata = port->private_data; in ulite_request_port()
353 port, (unsigned long long) port->mapbase); in ulite_request_port()
355 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) { in ulite_request_port()
356 dev_err(port->dev, "Memory region busy\n"); in ulite_request_port()
360 port->membase = ioremap(port->mapbase, ULITE_REGION); in ulite_request_port()
361 if (!port->membase) { in ulite_request_port()
362 dev_err(port->dev, "Unable to map registers\n"); in ulite_request_port()
363 release_mem_region(port->mapbase, ULITE_REGION); in ulite_request_port()
368 ret = uart_in32(ULITE_CONTROL, port); in ulite_request_port()
369 uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port); in ulite_request_port()
370 ret = uart_in32(ULITE_STATUS, port); in ulite_request_port()
378 static void ulite_config_port(struct uart_port *port, int flags) in ulite_config_port() argument
380 if (!ulite_request_port(port)) in ulite_config_port()
381 port->type = PORT_UARTLITE; in ulite_config_port()
384 static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser) in ulite_verify_port() argument
390 static void ulite_pm(struct uart_port *port, unsigned int state, in ulite_pm() argument
393 struct uartlite_data *pdata = port->private_data; in ulite_pm()
402 static int ulite_get_poll_char(struct uart_port *port) in ulite_get_poll_char() argument
404 if (!(uart_in32(ULITE_STATUS, port) & ULITE_STATUS_RXVALID)) in ulite_get_poll_char()
407 return uart_in32(ULITE_RX, port); in ulite_get_poll_char()
410 static void ulite_put_poll_char(struct uart_port *port, unsigned char ch) in ulite_put_poll_char() argument
412 while (uart_in32(ULITE_STATUS, port) & ULITE_STATUS_TXFULL) in ulite_put_poll_char()
416 uart_out32(ch, ULITE_TX, port); in ulite_put_poll_char()
448 static void ulite_console_wait_tx(struct uart_port *port) in ulite_console_wait_tx() argument
459 val = uart_in32(ULITE_STATUS, port); in ulite_console_wait_tx()
463 dev_warn(port->dev, in ulite_console_wait_tx()
471 static void ulite_console_putchar(struct uart_port *port, int ch) in ulite_console_putchar() argument
473 ulite_console_wait_tx(port); in ulite_console_putchar()
474 uart_out32(ch, ULITE_TX, port); in ulite_console_putchar()
480 struct uart_port *port = console_port; in ulite_console_write() local
486 locked = spin_trylock_irqsave(&port->lock, flags); in ulite_console_write()
488 spin_lock_irqsave(&port->lock, flags); in ulite_console_write()
491 ier = uart_in32(ULITE_STATUS, port) & ULITE_STATUS_IE; in ulite_console_write()
492 uart_out32(0, ULITE_CONTROL, port); in ulite_console_write()
494 uart_console_write(port, s, count, ulite_console_putchar); in ulite_console_write()
496 ulite_console_wait_tx(port); in ulite_console_write()
500 uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port); in ulite_console_write()
503 spin_unlock_irqrestore(&port->lock, flags); in ulite_console_write()
508 struct uart_port *port = NULL; in ulite_console_setup() local
515 port = ulite_ports + co->index; in ulite_console_setup()
518 if (!port || !port->mapbase) { in ulite_console_setup()
523 console_port = port; in ulite_console_setup()
526 if (!port->membase) { in ulite_console_setup()
527 if (ulite_request_port(port)) in ulite_console_setup()
534 return uart_set_options(port, co, baud, parity, bits, flow); in ulite_console_setup()
549 static void early_uartlite_putc(struct uart_port *port, int c) in early_uartlite_putc() argument
561 while (--retries && (readl(port->membase + 8) & (1 << 3))) in early_uartlite_putc()
567 writel(c & 0xff, port->membase + 4); in early_uartlite_putc()
574 uart_console_write(&device->port, s, n, early_uartlite_putc); in early_uartlite_write()
580 if (!device->port.membase) in early_uartlite_setup()
621 struct uart_port *port; in ulite_assign() local
641 port = &ulite_ports[id]; in ulite_assign()
643 spin_lock_init(&port->lock); in ulite_assign()
644 port->fifosize = 16; in ulite_assign()
645 port->regshift = 2; in ulite_assign()
646 port->iotype = UPIO_MEM; in ulite_assign()
647 port->iobase = 1; /* mark port in use */ in ulite_assign()
648 port->mapbase = base; in ulite_assign()
649 port->membase = NULL; in ulite_assign()
650 port->ops = &ulite_ops; in ulite_assign()
651 port->irq = irq; in ulite_assign()
652 port->flags = UPF_BOOT_AUTOCONF; in ulite_assign()
653 port->dev = dev; in ulite_assign()
654 port->type = PORT_UNKNOWN; in ulite_assign()
655 port->line = id; in ulite_assign()
656 port->private_data = pdata; in ulite_assign()
658 dev_set_drvdata(dev, port); in ulite_assign()
661 rc = uart_add_one_port(&ulite_uart_driver, port); in ulite_assign()
664 port->mapbase = 0; in ulite_assign()
678 struct uart_port *port = dev_get_drvdata(dev); in ulite_release() local
681 if (port) { in ulite_release()
682 rc = uart_remove_one_port(&ulite_uart_driver, port); in ulite_release()
684 port->mapbase = 0; in ulite_release()
698 struct uart_port *port = dev_get_drvdata(dev); in ulite_suspend() local
700 if (port) in ulite_suspend()
701 uart_suspend_port(&ulite_uart_driver, port); in ulite_suspend()
714 struct uart_port *port = dev_get_drvdata(dev); in ulite_resume() local
716 if (port) in ulite_resume()
717 uart_resume_port(&ulite_uart_driver, port); in ulite_resume()
800 struct uart_port *port = dev_get_drvdata(&pdev->dev); in ulite_remove() local
801 struct uartlite_data *pdata = port->private_data; in ulite_remove()