Lines Matching +full:lgm +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/clk.h>
111 struct clk *freqclk;
113 struct clk *clk; member
144 u32 fstat = __raw_readl(port->membase + LTQ_ASC_FSTAT); in lqasc_tx_ready()
156 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_start_tx()
159 writeb(ch, port->membase + LTQ_ASC_TBUF)); in lqasc_start_tx()
160 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_start_tx()
167 __raw_writel(ASCWHBSTATE_CLRREN, port->membase + LTQ_ASC_WHBSTATE); in lqasc_stop_rx()
173 struct tty_port *tport = &port->state->port; in lqasc_rx_chars()
176 fifocnt = __raw_readl(port->membase + LTQ_ASC_FSTAT) & in lqasc_rx_chars()
178 while (fifocnt--) { in lqasc_rx_chars()
180 ch = readb(port->membase + LTQ_ASC_RBUF); in lqasc_rx_chars()
181 rsr = (__raw_readl(port->membase + LTQ_ASC_STATE) in lqasc_rx_chars()
184 port->icount.rx++; in lqasc_rx_chars()
192 port->icount.parity++; in lqasc_rx_chars()
194 port->membase + LTQ_ASC_WHBSTATE); in lqasc_rx_chars()
196 port->icount.frame++; in lqasc_rx_chars()
198 port->membase + LTQ_ASC_WHBSTATE); in lqasc_rx_chars()
201 port->icount.overrun++; in lqasc_rx_chars()
203 port->membase + LTQ_ASC_WHBSTATE); in lqasc_rx_chars()
206 rsr &= port->read_status_mask; in lqasc_rx_chars()
214 if ((rsr & port->ignore_status_mask) == 0) in lqasc_rx_chars()
239 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_tx_int()
240 __raw_writel(ASC_IRNCR_TIR, port->membase + LTQ_ASC_IRNCR); in lqasc_tx_int()
241 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_tx_int()
253 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_err_int()
254 __raw_writel(ASC_IRNCR_EIR, port->membase + LTQ_ASC_IRNCR); in lqasc_err_int()
257 ASCWHBSTATE_CLRROE, port->membase + LTQ_ASC_WHBSTATE); in lqasc_err_int()
258 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_err_int()
269 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_rx_int()
270 __raw_writel(ASC_IRNCR_RIR, port->membase + LTQ_ASC_IRNCR); in lqasc_rx_int()
272 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_rx_int()
283 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_irq()
284 stat = readl(port->membase + LTQ_ASC_IRNCR); in lqasc_irq()
285 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_irq()
305 status = __raw_readl(port->membase + LTQ_ASC_FSTAT) & in lqasc_tx_empty()
333 if (!IS_ERR(ltq_port->clk)) in lqasc_startup()
334 clk_prepare_enable(ltq_port->clk); in lqasc_startup()
335 port->uartclk = clk_get_rate(ltq_port->freqclk); in lqasc_startup()
337 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_startup()
339 port->membase + LTQ_ASC_CLC); in lqasc_startup()
341 __raw_writel(0, port->membase + LTQ_ASC_PISEL); in lqasc_startup()
345 port->membase + LTQ_ASC_TXFCON); in lqasc_startup()
349 port->membase + LTQ_ASC_RXFCON); in lqasc_startup()
355 ASCCON_ROEN, port->membase + LTQ_ASC_CON); in lqasc_startup()
357 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_startup()
359 retval = ltq_port->soc->request_irq(port); in lqasc_startup()
364 port->membase + LTQ_ASC_IRNREN); in lqasc_startup()
374 ltq_port->soc->free_irq(port); in lqasc_shutdown()
376 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_shutdown()
377 __raw_writel(0, port->membase + LTQ_ASC_CON); in lqasc_shutdown()
379 port->membase + LTQ_ASC_RXFCON); in lqasc_shutdown()
381 port->membase + LTQ_ASC_TXFCON); in lqasc_shutdown()
382 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_shutdown()
383 if (!IS_ERR(ltq_port->clk)) in lqasc_shutdown()
384 clk_disable_unprepare(ltq_port->clk); in lqasc_shutdown()
399 cflag = new->c_cflag; in lqasc_set_termios()
400 iflag = new->c_iflag; in lqasc_set_termios()
410 new->c_cflag &= ~ CSIZE; in lqasc_set_termios()
411 new->c_cflag |= CS8; in lqasc_set_termios()
428 port->read_status_mask = ASCSTATE_ROE; in lqasc_set_termios()
430 port->read_status_mask |= ASCSTATE_FE | ASCSTATE_PE; in lqasc_set_termios()
432 port->ignore_status_mask = 0; in lqasc_set_termios()
434 port->ignore_status_mask |= ASCSTATE_FE | ASCSTATE_PE; in lqasc_set_termios()
442 port->ignore_status_mask |= ASCSTATE_ROE; in lqasc_set_termios()
446 port->ignore_status_mask |= UART_DUMMY_UER_RX; in lqasc_set_termios()
448 /* set error signals - framing, parity and overrun, enable receiver */ in lqasc_set_termios()
451 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_set_termios()
454 asc_update_bits(0, con, port->membase + LTQ_ASC_CON); in lqasc_set_termios()
456 /* Set baud rate - take a divider of 2 into account */ in lqasc_set_termios()
457 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in lqasc_set_termios()
459 divisor = divisor / 2 - 1; in lqasc_set_termios()
462 asc_update_bits(ASCCON_R, 0, port->membase + LTQ_ASC_CON); in lqasc_set_termios()
465 asc_update_bits(ASCCON_FDE, 0, port->membase + LTQ_ASC_CON); in lqasc_set_termios()
468 asc_update_bits(ASCCON_BRS, 0, port->membase + LTQ_ASC_CON); in lqasc_set_termios()
471 __raw_writel(divisor, port->membase + LTQ_ASC_BG); in lqasc_set_termios()
474 asc_update_bits(0, ASCCON_R, port->membase + LTQ_ASC_CON); in lqasc_set_termios()
477 __raw_writel(ASCWHBSTATE_SETREN, port->membase + LTQ_ASC_WHBSTATE); in lqasc_set_termios()
479 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_set_termios()
491 if (port->type == PORT_LTQ_ASC) in lqasc_type()
500 struct platform_device *pdev = to_platform_device(port->dev); in lqasc_release_port()
502 if (port->flags & UPF_IOREMAP) { in lqasc_release_port()
503 devm_iounmap(&pdev->dev, port->membase); in lqasc_release_port()
504 port->membase = NULL; in lqasc_release_port()
511 struct platform_device *pdev = to_platform_device(port->dev); in lqasc_request_port()
517 dev_err(&pdev->dev, "cannot obtain I/O memory region"); in lqasc_request_port()
518 return -ENODEV; in lqasc_request_port()
522 res = devm_request_mem_region(&pdev->dev, res->start, in lqasc_request_port()
523 size, dev_name(&pdev->dev)); in lqasc_request_port()
525 dev_err(&pdev->dev, "cannot request I/O memory region"); in lqasc_request_port()
526 return -EBUSY; in lqasc_request_port()
529 if (port->flags & UPF_IOREMAP) { in lqasc_request_port()
530 port->membase = devm_ioremap(&pdev->dev, in lqasc_request_port()
531 port->mapbase, size); in lqasc_request_port()
532 if (port->membase == NULL) in lqasc_request_port()
533 return -ENOMEM; in lqasc_request_port()
542 port->type = PORT_LTQ_ASC; in lqasc_config_port()
552 if (ser->type != PORT_UNKNOWN && ser->type != PORT_LTQ_ASC) in lqasc_verify_port()
553 ret = -EINVAL; in lqasc_verify_port()
554 if (ser->irq < 0 || ser->irq >= NR_IRQS) in lqasc_verify_port()
555 ret = -EINVAL; in lqasc_verify_port()
556 if (ser->baud_base < 9600) in lqasc_verify_port()
557 ret = -EINVAL; in lqasc_verify_port()
583 if (!port->membase) in lqasc_console_putchar()
589 writeb(ch, port->membase + LTQ_ASC_TBUF); in lqasc_console_putchar()
604 if (co->index >= MAXPORTS) in lqasc_console_write()
607 ltq_port = lqasc_port[co->index]; in lqasc_console_write()
611 spin_lock_irqsave(&ltq_port->lock, flags); in lqasc_console_write()
612 lqasc_serial_port_write(&ltq_port->port, s, count); in lqasc_console_write()
613 spin_unlock_irqrestore(&ltq_port->lock, flags); in lqasc_console_write()
626 if (co->index >= MAXPORTS) in lqasc_console_setup()
627 return -ENODEV; in lqasc_console_setup()
629 ltq_port = lqasc_port[co->index]; in lqasc_console_setup()
631 return -ENODEV; in lqasc_console_setup()
633 port = &ltq_port->port; in lqasc_console_setup()
635 if (!IS_ERR(ltq_port->clk)) in lqasc_console_setup()
636 clk_prepare_enable(ltq_port->clk); in lqasc_console_setup()
638 port->uartclk = clk_get_rate(ltq_port->freqclk); in lqasc_console_setup()
651 .index = -1,
667 struct earlycon_device *dev = co->data; in lqasc_serial_early_console_write()
669 lqasc_serial_port_write(&dev->port, s, count); in lqasc_serial_early_console_write()
676 if (!device->port.membase) in lqasc_serial_early_console_setup()
677 return -ENODEV; in lqasc_serial_early_console_setup()
679 device->con->write = lqasc_serial_early_console_write; in lqasc_serial_early_console_setup()
683 OF_EARLYCON_DECLARE(lantiq, "intel,lgm-asc", lqasc_serial_early_console_setup);
705 struct uart_port *port = &ltq_port->port; in fetch_irq_lantiq()
712 ltq_port->tx_irq = irq; in fetch_irq_lantiq()
716 ltq_port->rx_irq = irq; in fetch_irq_lantiq()
720 ltq_port->err_irq = irq; in fetch_irq_lantiq()
722 port->irq = ltq_port->tx_irq; in fetch_irq_lantiq()
732 retval = request_irq(ltq_port->tx_irq, lqasc_tx_int, in request_irq_lantiq()
735 dev_err(port->dev, "failed to request asc_tx\n"); in request_irq_lantiq()
739 retval = request_irq(ltq_port->rx_irq, lqasc_rx_int, in request_irq_lantiq()
742 dev_err(port->dev, "failed to request asc_rx\n"); in request_irq_lantiq()
746 retval = request_irq(ltq_port->err_irq, lqasc_err_int, in request_irq_lantiq()
749 dev_err(port->dev, "failed to request asc_err\n"); in request_irq_lantiq()
755 free_irq(ltq_port->rx_irq, port); in request_irq_lantiq()
757 free_irq(ltq_port->tx_irq, port); in request_irq_lantiq()
765 free_irq(ltq_port->tx_irq, port); in free_irq_lantiq()
766 free_irq(ltq_port->rx_irq, port); in free_irq_lantiq()
767 free_irq(ltq_port->err_irq, port); in free_irq_lantiq()
772 struct uart_port *port = &ltq_port->port; in fetch_irq_intel()
780 ltq_port->common_irq = ret; in fetch_irq_intel()
781 port->irq = ret; in fetch_irq_intel()
791 retval = request_irq(ltq_port->common_irq, lqasc_irq, 0, in request_irq_intel()
794 dev_err(port->dev, "failed to request asc_irq\n"); in request_irq_intel()
803 free_irq(ltq_port->common_irq, port); in free_irq_intel()
808 struct device_node *node = pdev->dev.of_node; in lqasc_probe()
817 dev_err(&pdev->dev, in lqasc_probe()
819 return -ENODEV; in lqasc_probe()
822 ltq_port = devm_kzalloc(&pdev->dev, sizeof(struct ltq_uart_port), in lqasc_probe()
825 return -ENOMEM; in lqasc_probe()
827 port = &ltq_port->port; in lqasc_probe()
829 ltq_port->soc = of_device_get_match_data(&pdev->dev); in lqasc_probe()
830 ret = ltq_port->soc->fetch_irq(&pdev->dev, ltq_port); in lqasc_probe()
838 if (mmres->start == CPHYSADDR(LTQ_EARLY_ASC)) in lqasc_probe()
843 dev_err(&pdev->dev, "failed to get alias id, errno %d\n", in lqasc_probe()
850 dev_err(&pdev->dev, "port %d already allocated\n", line); in lqasc_probe()
851 return -EBUSY; in lqasc_probe()
854 port->iotype = SERIAL_IO_MEM; in lqasc_probe()
855 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; in lqasc_probe()
856 port->ops = &lqasc_pops; in lqasc_probe()
857 port->fifosize = 16; in lqasc_probe()
858 port->type = PORT_LTQ_ASC; in lqasc_probe()
859 port->line = line; in lqasc_probe()
860 port->dev = &pdev->dev; in lqasc_probe()
861 /* unused, just to be backward-compatible */ in lqasc_probe()
862 port->mapbase = mmres->start; in lqasc_probe()
865 ltq_port->freqclk = clk_get_fpi(); in lqasc_probe()
867 ltq_port->freqclk = devm_clk_get(&pdev->dev, "freq"); in lqasc_probe()
870 if (IS_ERR(ltq_port->freqclk)) { in lqasc_probe()
871 pr_err("failed to get fpi clk\n"); in lqasc_probe()
872 return -ENOENT; in lqasc_probe()
877 ltq_port->clk = clk_get(&pdev->dev, NULL); in lqasc_probe()
879 ltq_port->clk = devm_clk_get(&pdev->dev, "asc"); in lqasc_probe()
881 spin_lock_init(&ltq_port->lock); in lqasc_probe()
911 { .compatible = "intel,lgm-asc", .data = &soc_data_intel },