• Home
  • Raw
  • Download

Lines Matching +full:up +full:-

1 // SPDX-License-Identifier: GPL-2.0
12 * rocketport_infinity_express-linux-1.20.tar.gz
13 * Copyright (C) 2004-2011 Comtrol, Inc.
44 #define ALL_PORTS_MASK (BIT(PORTS_PER_ASIC) - 1)
206 *ports = id->driver_data >> 8; in rp2_decode_cap()
207 *smpte = id->driver_data & 0xff; in rp2_decode_cap()
215 int ret = -ENOSPC; in rp2_alloc_ports()
233 static void rp2_rmw(struct rp2_uart_port *up, int reg, in rp2_rmw() argument
236 u32 tmp = readl(up->base + reg); in rp2_rmw()
239 writel(tmp, up->base + reg); in rp2_rmw()
242 static void rp2_rmw_clr(struct rp2_uart_port *up, int reg, u32 val) in rp2_rmw_clr() argument
244 rp2_rmw(up, reg, val, 0); in rp2_rmw_clr()
247 static void rp2_rmw_set(struct rp2_uart_port *up, int reg, u32 val) in rp2_rmw_set() argument
249 rp2_rmw(up, reg, 0, val); in rp2_rmw_set()
252 static void rp2_mask_ch_irq(struct rp2_uart_port *up, int ch_num, in rp2_mask_ch_irq() argument
257 spin_lock_irqsave(&up->card->card_lock, flags); in rp2_mask_ch_irq()
259 irq_mask = readl(up->asic_base + RP2_CH_IRQ_MASK); in rp2_mask_ch_irq()
264 writel(irq_mask, up->asic_base + RP2_CH_IRQ_MASK); in rp2_mask_ch_irq()
266 spin_unlock_irqrestore(&up->card->card_lock, flags); in rp2_mask_ch_irq()
271 struct rp2_uart_port *up = port_to_up(port); in rp2_uart_tx_empty() local
279 spin_lock_irqsave(&up->port.lock, flags); in rp2_uart_tx_empty()
280 tx_fifo_bytes = readw(up->base + RP2_TX_FIFO_COUNT); in rp2_uart_tx_empty()
281 spin_unlock_irqrestore(&up->port.lock, flags); in rp2_uart_tx_empty()
288 struct rp2_uart_port *up = port_to_up(port); in rp2_uart_get_mctrl() local
291 status = readl(up->base + RP2_CHAN_STAT); in rp2_uart_get_mctrl()
326 spin_lock_irqsave(&port->lock, flags); in rp2_uart_break_ctl()
329 spin_unlock_irqrestore(&port->lock, flags); in rp2_uart_break_ctl()
337 static void __rp2_uart_set_termios(struct rp2_uart_port *up, in __rp2_uart_set_termios() argument
342 /* baud rate divisor (calculated elsewhere). 0 = divide-by-1 */ in __rp2_uart_set_termios()
343 writew(baud_div - 1, up->base + RP2_BAUD); in __rp2_uart_set_termios()
346 rp2_rmw(up, RP2_UART_CTL, in __rp2_uart_set_termios()
355 rp2_rmw(up, RP2_TXRX_CTL, in __rp2_uart_set_termios()
368 up->ucode + RP2_TX_SWFLOW); in __rp2_uart_set_termios()
370 up->ucode + RP2_RX_SWFLOW); in __rp2_uart_set_termios()
377 struct rp2_uart_port *up = port_to_up(port); in rp2_uart_set_termios() local
381 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in rp2_uart_set_termios()
387 spin_lock_irqsave(&port->lock, flags); in rp2_uart_set_termios()
390 port->ignore_status_mask = (new->c_cflag & CREAD) ? 0 : RP2_DUMMY_READ; in rp2_uart_set_termios()
392 __rp2_uart_set_termios(up, new->c_cflag, new->c_iflag, baud_div); in rp2_uart_set_termios()
393 uart_update_timeout(port, new->c_cflag, baud); in rp2_uart_set_termios()
395 spin_unlock_irqrestore(&port->lock, flags); in rp2_uart_set_termios()
398 static void rp2_rx_chars(struct rp2_uart_port *up) in rp2_rx_chars() argument
400 u16 bytes = readw(up->base + RP2_RX_FIFO_COUNT); in rp2_rx_chars()
401 struct tty_port *port = &up->port.state->port; in rp2_rx_chars()
403 for (; bytes != 0; bytes--) { in rp2_rx_chars()
404 u32 byte = readw(up->base + RP2_DATA_BYTE) | RP2_DUMMY_READ; in rp2_rx_chars()
408 if (!uart_handle_sysrq_char(&up->port, ch)) in rp2_rx_chars()
409 uart_insert_char(&up->port, byte, 0, ch, in rp2_rx_chars()
420 uart_insert_char(&up->port, byte, in rp2_rx_chars()
423 up->port.icount.rx++; in rp2_rx_chars()
426 spin_unlock(&up->port.lock); in rp2_rx_chars()
428 spin_lock(&up->port.lock); in rp2_rx_chars()
431 static void rp2_tx_chars(struct rp2_uart_port *up) in rp2_tx_chars() argument
433 u16 max_tx = FIFO_SIZE - readw(up->base + RP2_TX_FIFO_COUNT); in rp2_tx_chars()
434 struct circ_buf *xmit = &up->port.state->xmit; in rp2_tx_chars()
436 if (uart_tx_stopped(&up->port)) { in rp2_tx_chars()
437 rp2_uart_stop_tx(&up->port); in rp2_tx_chars()
441 for (; max_tx != 0; max_tx--) { in rp2_tx_chars()
442 if (up->port.x_char) { in rp2_tx_chars()
443 writeb(up->port.x_char, up->base + RP2_DATA_BYTE); in rp2_tx_chars()
444 up->port.x_char = 0; in rp2_tx_chars()
445 up->port.icount.tx++; in rp2_tx_chars()
449 rp2_uart_stop_tx(&up->port); in rp2_tx_chars()
452 writeb(xmit->buf[xmit->tail], up->base + RP2_DATA_BYTE); in rp2_tx_chars()
453 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in rp2_tx_chars()
454 up->port.icount.tx++; in rp2_tx_chars()
458 uart_write_wakeup(&up->port); in rp2_tx_chars()
461 static void rp2_ch_interrupt(struct rp2_uart_port *up) in rp2_ch_interrupt() argument
465 spin_lock(&up->port.lock); in rp2_ch_interrupt()
468 * The IRQ status bits are clear-on-write. Other status bits in in rp2_ch_interrupt()
471 status = readl(up->base + RP2_CHAN_STAT); in rp2_ch_interrupt()
472 writel(status, up->base + RP2_CHAN_STAT); in rp2_ch_interrupt()
475 rp2_rx_chars(up); in rp2_ch_interrupt()
477 rp2_tx_chars(up); in rp2_ch_interrupt()
479 wake_up_interruptible(&up->port.state->port.delta_msr_wait); in rp2_ch_interrupt()
481 spin_unlock(&up->port.lock); in rp2_ch_interrupt()
486 void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); in rp2_asic_interrupt()
492 rp2_ch_interrupt(&card->ports[ch]); in rp2_asic_interrupt()
504 if (card->n_ports >= PORTS_PER_ASIC) in rp2_uart_interrupt()
510 static inline void rp2_flush_fifos(struct rp2_uart_port *up) in rp2_flush_fifos() argument
512 rp2_rmw_set(up, RP2_UART_CTL, in rp2_flush_fifos()
514 readl(up->base + RP2_UART_CTL); in rp2_flush_fifos()
516 rp2_rmw_clr(up, RP2_UART_CTL, in rp2_flush_fifos()
522 struct rp2_uart_port *up = port_to_up(port); in rp2_uart_startup() local
524 rp2_flush_fifos(up); in rp2_uart_startup()
525 rp2_rmw(up, RP2_TXRX_CTL, RP2_TXRX_CTL_MSRIRQ_m, RP2_TXRX_CTL_RXIRQ_m); in rp2_uart_startup()
526 rp2_rmw(up, RP2_TXRX_CTL, RP2_TXRX_CTL_RX_TRIG_m, in rp2_uart_startup()
528 rp2_rmw(up, RP2_CHAN_STAT, 0, 0); in rp2_uart_startup()
529 rp2_mask_ch_irq(up, up->idx, 1); in rp2_uart_startup()
536 struct rp2_uart_port *up = port_to_up(port); in rp2_uart_shutdown() local
541 spin_lock_irqsave(&port->lock, flags); in rp2_uart_shutdown()
542 rp2_mask_ch_irq(up, up->idx, 0); in rp2_uart_shutdown()
543 rp2_rmw(up, RP2_CHAN_STAT, 0, 0); in rp2_uart_shutdown()
544 spin_unlock_irqrestore(&port->lock, flags); in rp2_uart_shutdown()
549 return (port->type == PORT_RP2) ? "RocketPort 2 UART" : NULL; in rp2_uart_type()
566 port->type = PORT_RP2; in rp2_uart_config_port()
572 if (ser->type != PORT_UNKNOWN && ser->type != PORT_RP2) in rp2_uart_verify_port()
573 return -EINVAL; in rp2_uart_verify_port()
599 void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); in rp2_reset_asic()
619 writel(4, card->bar0 + RP2_FPGA_CTL0); in rp2_init_card()
620 writel(0, card->bar0 + RP2_FPGA_CTL1); in rp2_init_card()
623 if (card->n_ports >= PORTS_PER_ASIC) in rp2_init_card()
626 writel(RP2_IRQ_MASK_EN_m, card->bar0 + RP2_IRQ_MASK); in rp2_init_card()
629 static void rp2_init_port(struct rp2_uart_port *up, const struct firmware *fw) in rp2_init_port() argument
633 writel(RP2_UART_CTL_RESET_CH_m, up->base + RP2_UART_CTL); in rp2_init_port()
634 readl(up->base + RP2_UART_CTL); in rp2_init_port()
637 writel(0, up->base + RP2_TXRX_CTL); in rp2_init_port()
638 writel(0, up->base + RP2_UART_CTL); in rp2_init_port()
639 readl(up->base + RP2_UART_CTL); in rp2_init_port()
642 rp2_flush_fifos(up); in rp2_init_port()
644 for (i = 0; i < min_t(int, fw->size, RP2_UCODE_BYTES); i++) in rp2_init_port()
645 writeb(fw->data[i], up->ucode + i); in rp2_init_port()
647 __rp2_uart_set_termios(up, CS8 | CREAD | CLOCAL, 0, DEFAULT_BAUD_DIV); in rp2_init_port()
648 rp2_uart_set_mctrl(&up->port, 0); in rp2_init_port()
650 writeb(RP2_RX_FIFO_ena, up->ucode + RP2_RX_FIFO); in rp2_init_port()
651 rp2_rmw(up, RP2_UART_CTL, RP2_UART_CTL_MODE_m, in rp2_init_port()
653 rp2_rmw_set(up, RP2_TXRX_CTL, in rp2_init_port()
661 for (i = 0; i < card->initialized_ports; i++) in rp2_remove_ports()
662 uart_remove_one_port(&rp2_uart_driver, &card->ports[i].port); in rp2_remove_ports()
663 card->initialized_ports = 0; in rp2_remove_ports()
671 phys_base = pci_resource_start(card->pdev, 1); in rp2_load_firmware()
673 for (i = 0; i < card->n_ports; i++) { in rp2_load_firmware()
674 struct rp2_uart_port *rp = &card->ports[i]; in rp2_load_firmware()
678 rp->asic_base = card->bar1; in rp2_load_firmware()
679 rp->base = card->bar1 + RP2_PORT_BASE + j*RP2_PORT_SPACING; in rp2_load_firmware()
680 rp->ucode = card->bar1 + RP2_UCODE_BASE + j*RP2_UCODE_SPACING; in rp2_load_firmware()
681 rp->card = card; in rp2_load_firmware()
682 rp->idx = j; in rp2_load_firmware()
684 p = &rp->port; in rp2_load_firmware()
685 p->line = card->minor_start + i; in rp2_load_firmware()
686 p->dev = &card->pdev->dev; in rp2_load_firmware()
687 p->type = PORT_RP2; in rp2_load_firmware()
688 p->iotype = UPIO_MEM32; in rp2_load_firmware()
689 p->uartclk = UART_CLOCK; in rp2_load_firmware()
690 p->regshift = 2; in rp2_load_firmware()
691 p->fifosize = FIFO_SIZE; in rp2_load_firmware()
692 p->ops = &rp2_uart_ops; in rp2_load_firmware()
693 p->irq = card->pdev->irq; in rp2_load_firmware()
694 p->membase = rp->base; in rp2_load_firmware()
695 p->mapbase = phys_base + RP2_PORT_BASE + j*RP2_PORT_SPACING; in rp2_load_firmware()
698 rp->asic_base += RP2_ASIC_SPACING; in rp2_load_firmware()
699 rp->base += RP2_ASIC_SPACING; in rp2_load_firmware()
700 rp->ucode += RP2_ASIC_SPACING; in rp2_load_firmware()
701 p->mapbase += RP2_ASIC_SPACING; in rp2_load_firmware()
707 dev_err(&card->pdev->dev, in rp2_load_firmware()
712 card->initialized_ports++; in rp2_load_firmware()
727 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); in rp2_probe()
729 return -ENOMEM; in rp2_probe()
731 spin_lock_init(&card->card_lock); in rp2_probe()
742 card->bar0 = bars[0]; in rp2_probe()
743 card->bar1 = bars[1]; in rp2_probe()
744 card->pdev = pdev; in rp2_probe()
746 rp2_decode_cap(id, &card->n_ports, &card->smpte); in rp2_probe()
747 dev_info(&pdev->dev, "found new card with %d ports\n", card->n_ports); in rp2_probe()
749 card->minor_start = rp2_alloc_ports(card->n_ports); in rp2_probe()
750 if (card->minor_start < 0) { in rp2_probe()
751 dev_err(&pdev->dev, in rp2_probe()
753 return -EINVAL; in rp2_probe()
758 ports = devm_kcalloc(&pdev->dev, card->n_ports, sizeof(*ports), in rp2_probe()
761 return -ENOMEM; in rp2_probe()
762 card->ports = ports; in rp2_probe()
764 rc = request_firmware(&fw, RP2_FW_NAME, &pdev->dev); in rp2_probe()
766 dev_err(&pdev->dev, "cannot find '%s' firmware image\n", in rp2_probe()
777 rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt, in rp2_probe()