Lines Matching refs:sport

79 static inline void pic32_uart_writel(struct pic32_sport *sport,  in pic32_uart_writel()  argument
82 __raw_writel(val, sport->port.membase + reg); in pic32_uart_writel()
85 static inline u32 pic32_uart_readl(struct pic32_sport *sport, u32 reg) in pic32_uart_readl() argument
87 return __raw_readl(sport->port.membase + reg); in pic32_uart_readl()
129 static inline void pic32_wait_deplete_txbuf(struct pic32_sport *sport) in pic32_wait_deplete_txbuf() argument
132 while (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_TRMT)) in pic32_wait_deplete_txbuf()
139 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_tx_empty() local
140 u32 val = pic32_uart_readl(sport, PIC32_UART_STA); in pic32_uart_tx_empty()
148 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_set_mctrl() local
152 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_mctrl()
155 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_mctrl()
162 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_get_mctrl() local
166 if (!sport->cts_gpiod) in pic32_uart_get_mctrl()
168 else if (gpiod_get_value(sport->cts_gpiod)) in pic32_uart_get_mctrl()
183 static inline void pic32_uart_irqtxen(struct pic32_sport *sport, u8 en) in pic32_uart_irqtxen() argument
185 if (en && !sport->enable_tx_irq) { in pic32_uart_irqtxen()
186 enable_irq(sport->irq_tx); in pic32_uart_irqtxen()
187 sport->enable_tx_irq = true; in pic32_uart_irqtxen()
188 } else if (!en && sport->enable_tx_irq) { in pic32_uart_irqtxen()
193 disable_irq_nosync(sport->irq_tx); in pic32_uart_irqtxen()
194 sport->enable_tx_irq = false; in pic32_uart_irqtxen()
201 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_stop_tx() local
203 if (!(pic32_uart_readl(sport, PIC32_UART_MODE) & PIC32_UART_MODE_ON)) in pic32_uart_stop_tx()
206 if (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_UTXEN)) in pic32_uart_stop_tx()
210 pic32_wait_deplete_txbuf(sport); in pic32_uart_stop_tx()
212 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_stop_tx()
214 pic32_uart_irqtxen(sport, 0); in pic32_uart_stop_tx()
220 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_start_tx() local
222 pic32_uart_irqtxen(sport, 1); in pic32_uart_start_tx()
223 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_start_tx()
230 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_stop_rx() local
233 disable_irq(sport->irq_rx); in pic32_uart_stop_rx()
236 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_stop_rx()
243 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_break_ctl() local
249 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_break_ctl()
252 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_break_ctl()
267 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_do_rx() local
286 sta_reg = pic32_uart_readl(sport, PIC32_UART_STA); in pic32_uart_do_rx()
290 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_do_rx()
302 c = pic32_uart_readl(sport, PIC32_UART_RX); in pic32_uart_do_rx()
344 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_do_tx() local
349 pic32_uart_writel(sport, PIC32_UART_TX, port->x_char); in pic32_uart_do_tx()
373 pic32_uart_readl(sport, PIC32_UART_STA))) { in pic32_uart_do_tx()
378 pic32_uart_writel(sport, PIC32_UART_TX, c); in pic32_uart_do_tx()
393 pic32_uart_irqtxen(sport, 0); in pic32_uart_do_tx()
429 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_en_and_unmask() local
431 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_en_and_unmask()
433 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_en_and_unmask()
440 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_dsbl_and_mask() local
443 pic32_wait_deplete_txbuf(sport); in pic32_uart_dsbl_and_mask()
445 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_dsbl_and_mask()
447 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_dsbl_and_mask()
454 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_startup() local
461 ret = clk_prepare_enable(sport->clk); in pic32_uart_startup()
468 pic32_uart_writel(sport, PIC32_UART_MODE, 0); in pic32_uart_startup()
469 pic32_uart_writel(sport, PIC32_UART_STA, 0); in pic32_uart_startup()
475 pic32_uart_writel(sport, PIC32_UART_BRG, dflt_baud); in pic32_uart_startup()
485 sport->enable_tx_irq = false; in pic32_uart_startup()
487 sport->irq_fault_name = kasprintf(GFP_KERNEL, "%s%d-fault", in pic32_uart_startup()
489 sport->idx); in pic32_uart_startup()
490 if (!sport->irq_fault_name) { in pic32_uart_startup()
495 irq_set_status_flags(sport->irq_fault, IRQ_NOAUTOEN); in pic32_uart_startup()
496 ret = request_irq(sport->irq_fault, pic32_uart_fault_interrupt, in pic32_uart_startup()
497 IRQF_NO_THREAD, sport->irq_fault_name, port); in pic32_uart_startup()
500 __func__, sport->irq_fault, ret, in pic32_uart_startup()
505 sport->irq_rx_name = kasprintf(GFP_KERNEL, "%s%d-rx", in pic32_uart_startup()
507 sport->idx); in pic32_uart_startup()
508 if (!sport->irq_rx_name) { in pic32_uart_startup()
513 irq_set_status_flags(sport->irq_rx, IRQ_NOAUTOEN); in pic32_uart_startup()
514 ret = request_irq(sport->irq_rx, pic32_uart_rx_interrupt, in pic32_uart_startup()
515 IRQF_NO_THREAD, sport->irq_rx_name, port); in pic32_uart_startup()
518 __func__, sport->irq_rx, ret, in pic32_uart_startup()
523 sport->irq_tx_name = kasprintf(GFP_KERNEL, "%s%d-tx", in pic32_uart_startup()
525 sport->idx); in pic32_uart_startup()
526 if (!sport->irq_tx_name) { in pic32_uart_startup()
531 irq_set_status_flags(sport->irq_tx, IRQ_NOAUTOEN); in pic32_uart_startup()
532 ret = request_irq(sport->irq_tx, pic32_uart_tx_interrupt, in pic32_uart_startup()
533 IRQF_NO_THREAD, sport->irq_tx_name, port); in pic32_uart_startup()
536 __func__, sport->irq_tx, ret, in pic32_uart_startup()
544 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_startup()
548 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_startup()
556 enable_irq(sport->irq_rx); in pic32_uart_startup()
561 free_irq(sport->irq_tx, port); in pic32_uart_startup()
562 kfree(sport->irq_tx_name); in pic32_uart_startup()
564 free_irq(sport->irq_rx, port); in pic32_uart_startup()
565 kfree(sport->irq_rx_name); in pic32_uart_startup()
567 free_irq(sport->irq_fault, port); in pic32_uart_startup()
568 kfree(sport->irq_fault_name); in pic32_uart_startup()
570 clk_disable_unprepare(sport->clk); in pic32_uart_startup()
578 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_shutdown() local
585 clk_disable_unprepare(sport->clk); in pic32_uart_shutdown()
588 free_irq(sport->irq_fault, port); in pic32_uart_shutdown()
589 kfree(sport->irq_fault_name); in pic32_uart_shutdown()
590 free_irq(sport->irq_tx, port); in pic32_uart_shutdown()
591 kfree(sport->irq_tx_name); in pic32_uart_shutdown()
592 free_irq(sport->irq_rx, port); in pic32_uart_shutdown()
593 kfree(sport->irq_rx_name); in pic32_uart_shutdown()
601 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_set_termios() local
613 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
616 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
622 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
624 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
627 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
629 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
633 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
638 if ((new->c_cflag & CRTSCTS) && sport->cts_gpiod) { in pic32_uart_set_termios()
640 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
642 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
644 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
648 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
650 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
652 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
665 pic32_uart_writel(sport, PIC32_UART_BRG, quot); in pic32_uart_set_termios()
766 struct pic32_sport *sport = to_pic32_sport(port); in pic32_console_putchar() local
768 if (!(pic32_uart_readl(sport, PIC32_UART_MODE) & PIC32_UART_MODE_ON)) in pic32_console_putchar()
771 if (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_UTXEN)) in pic32_console_putchar()
775 pic32_wait_deplete_txbuf(sport); in pic32_console_putchar()
777 pic32_uart_writel(sport, PIC32_UART_TX, ch & 0xff); in pic32_console_putchar()
784 struct pic32_sport *sport = pic32_sports[co->index]; in pic32_console_write() local
787 uart_console_write(&sport->port, s, count, pic32_console_putchar); in pic32_console_write()
795 struct pic32_sport *sport; in pic32_console_setup() local
805 sport = pic32_sports[co->index]; in pic32_console_setup()
806 if (!sport) in pic32_console_setup()
809 ret = clk_prepare_enable(sport->clk); in pic32_console_setup()
816 return uart_set_options(&sport->port, co, baud, parity, bits, flow); in pic32_console_setup()
867 struct pic32_sport *sport; in pic32_uart_probe() local
881 sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); in pic32_uart_probe()
882 if (!sport) in pic32_uart_probe()
885 sport->idx = uart_idx; in pic32_uart_probe()
886 sport->irq_fault = irq_of_parse_and_map(np, 0); in pic32_uart_probe()
887 sport->irq_rx = irq_of_parse_and_map(np, 1); in pic32_uart_probe()
888 sport->irq_tx = irq_of_parse_and_map(np, 2); in pic32_uart_probe()
889 sport->clk = devm_clk_get(&pdev->dev, NULL); in pic32_uart_probe()
890 if (IS_ERR(sport->clk)) in pic32_uart_probe()
891 return PTR_ERR(sport->clk); in pic32_uart_probe()
892 sport->dev = &pdev->dev; in pic32_uart_probe()
897 sport->cts_gpiod = devm_gpiod_get_optional(dev, "cts", GPIOD_IN); in pic32_uart_probe()
898 if (IS_ERR(sport->cts_gpiod)) in pic32_uart_probe()
899 return dev_err_probe(dev, PTR_ERR(sport->cts_gpiod), "error requesting CTS GPIO\n"); in pic32_uart_probe()
900 gpiod_set_consumer_name(sport->cts_gpiod, "CTS"); in pic32_uart_probe()
902 pic32_sports[uart_idx] = sport; in pic32_uart_probe()
903 port = &sport->port; in pic32_uart_probe()
910 port->uartclk = clk_get_rate(sport->clk); in pic32_uart_probe()
925 clk_disable_unprepare(sport->clk); in pic32_uart_probe()
943 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_remove() local
946 clk_disable_unprepare(sport->clk); in pic32_uart_remove()
948 pic32_sports[sport->idx] = NULL; in pic32_uart_remove()