Lines Matching refs:sport

38 static inline void pic32_wait_deplete_txbuf(struct pic32_sport *sport)  in pic32_wait_deplete_txbuf()  argument
41 while (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_TRMT)) in pic32_wait_deplete_txbuf()
45 static inline int pic32_enable_clock(struct pic32_sport *sport) in pic32_enable_clock() argument
47 int ret = clk_prepare_enable(sport->clk); in pic32_enable_clock()
52 sport->ref_clk++; in pic32_enable_clock()
56 static inline void pic32_disable_clock(struct pic32_sport *sport) in pic32_disable_clock() argument
58 sport->ref_clk--; in pic32_disable_clock()
59 clk_disable_unprepare(sport->clk); in pic32_disable_clock()
65 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_tx_empty() local
66 u32 val = pic32_uart_readl(sport, PIC32_UART_STA); in pic32_uart_tx_empty()
74 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_set_mctrl() local
78 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_mctrl()
81 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_mctrl()
86 static unsigned int get_cts_state(struct pic32_sport *sport) in get_cts_state() argument
89 if (gpio_is_valid(sport->cts_gpio)) in get_cts_state()
90 return !gpio_get_value(sport->cts_gpio); in get_cts_state()
98 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_get_mctrl() local
101 if (!sport->hw_flow_ctrl) in pic32_uart_get_mctrl()
103 else if (get_cts_state(sport)) in pic32_uart_get_mctrl()
118 static inline void pic32_uart_irqtxen(struct pic32_sport *sport, u8 en) in pic32_uart_irqtxen() argument
120 if (en && !tx_irq_enabled(sport)) { in pic32_uart_irqtxen()
121 enable_irq(sport->irq_tx); in pic32_uart_irqtxen()
122 tx_irq_enabled(sport) = 1; in pic32_uart_irqtxen()
123 } else if (!en && tx_irq_enabled(sport)) { in pic32_uart_irqtxen()
128 disable_irq_nosync(sport->irq_tx); in pic32_uart_irqtxen()
129 tx_irq_enabled(sport) = 0; in pic32_uart_irqtxen()
136 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_stop_tx() local
138 if (!(pic32_uart_readl(sport, PIC32_UART_MODE) & PIC32_UART_MODE_ON)) in pic32_uart_stop_tx()
141 if (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_UTXEN)) in pic32_uart_stop_tx()
145 pic32_wait_deplete_txbuf(sport); in pic32_uart_stop_tx()
147 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_stop_tx()
149 pic32_uart_irqtxen(sport, 0); in pic32_uart_stop_tx()
155 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_start_tx() local
157 pic32_uart_irqtxen(sport, 1); in pic32_uart_start_tx()
158 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_start_tx()
165 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_stop_rx() local
168 disable_irq(sport->irq_rx); in pic32_uart_stop_rx()
171 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_stop_rx()
178 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_break_ctl() local
184 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_break_ctl()
187 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_break_ctl()
202 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_do_rx() local
221 sta_reg = pic32_uart_readl(sport, PIC32_UART_STA); in pic32_uart_do_rx()
225 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_do_rx()
237 c = pic32_uart_readl(sport, PIC32_UART_RX); in pic32_uart_do_rx()
279 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_do_tx() local
284 pic32_uart_writel(sport, PIC32_UART_TX, port->x_char); in pic32_uart_do_tx()
308 pic32_uart_readl(sport, PIC32_UART_STA))) { in pic32_uart_do_tx()
311 pic32_uart_writel(sport, PIC32_UART_TX, c); in pic32_uart_do_tx()
330 pic32_uart_irqtxen(sport, 0); in pic32_uart_do_tx()
366 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_en_and_unmask() local
368 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_STA), in pic32_uart_en_and_unmask()
370 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_en_and_unmask()
377 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_dsbl_and_mask() local
380 pic32_wait_deplete_txbuf(sport); in pic32_uart_dsbl_and_mask()
382 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_dsbl_and_mask()
384 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_dsbl_and_mask()
391 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_startup() local
398 ret = pic32_enable_clock(sport); in pic32_uart_startup()
405 pic32_uart_writel(sport, PIC32_UART_MODE, 0); in pic32_uart_startup()
406 pic32_uart_writel(sport, PIC32_UART_STA, 0); in pic32_uart_startup()
412 pic32_uart_writel(sport, PIC32_UART_BRG, dflt_baud); in pic32_uart_startup()
422 tx_irq_enabled(sport) = 0; in pic32_uart_startup()
424 sport->irq_fault_name = kasprintf(GFP_KERNEL, "%s%d-fault", in pic32_uart_startup()
426 sport->idx); in pic32_uart_startup()
427 if (!sport->irq_fault_name) { in pic32_uart_startup()
432 irq_set_status_flags(sport->irq_fault, IRQ_NOAUTOEN); in pic32_uart_startup()
433 ret = request_irq(sport->irq_fault, pic32_uart_fault_interrupt, in pic32_uart_startup()
434 sport->irqflags_fault, sport->irq_fault_name, port); in pic32_uart_startup()
437 __func__, sport->irq_fault, ret, in pic32_uart_startup()
442 sport->irq_rx_name = kasprintf(GFP_KERNEL, "%s%d-rx", in pic32_uart_startup()
444 sport->idx); in pic32_uart_startup()
445 if (!sport->irq_rx_name) { in pic32_uart_startup()
450 irq_set_status_flags(sport->irq_rx, IRQ_NOAUTOEN); in pic32_uart_startup()
451 ret = request_irq(sport->irq_rx, pic32_uart_rx_interrupt, in pic32_uart_startup()
452 sport->irqflags_rx, sport->irq_rx_name, port); in pic32_uart_startup()
455 __func__, sport->irq_rx, ret, in pic32_uart_startup()
460 sport->irq_tx_name = kasprintf(GFP_KERNEL, "%s%d-tx", in pic32_uart_startup()
462 sport->idx); in pic32_uart_startup()
463 if (!sport->irq_tx_name) { in pic32_uart_startup()
468 irq_set_status_flags(sport->irq_tx, IRQ_NOAUTOEN); in pic32_uart_startup()
469 ret = request_irq(sport->irq_tx, pic32_uart_tx_interrupt, in pic32_uart_startup()
470 sport->irqflags_tx, sport->irq_tx_name, port); in pic32_uart_startup()
473 __func__, sport->irq_tx, ret, in pic32_uart_startup()
481 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_startup()
485 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_STA), in pic32_uart_startup()
491 enable_irq(sport->irq_rx); in pic32_uart_startup()
496 kfree(sport->irq_tx_name); in pic32_uart_startup()
497 free_irq(sport->irq_tx, port); in pic32_uart_startup()
499 kfree(sport->irq_rx_name); in pic32_uart_startup()
500 free_irq(sport->irq_rx, port); in pic32_uart_startup()
502 kfree(sport->irq_fault_name); in pic32_uart_startup()
503 free_irq(sport->irq_fault, port); in pic32_uart_startup()
511 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_shutdown() local
518 pic32_disable_clock(sport); in pic32_uart_shutdown()
521 free_irq(sport->irq_fault, port); in pic32_uart_shutdown()
522 free_irq(sport->irq_tx, port); in pic32_uart_shutdown()
523 free_irq(sport->irq_rx, port); in pic32_uart_shutdown()
531 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_set_termios() local
543 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
546 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
552 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
554 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
557 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
559 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
563 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
568 if ((new->c_cflag & CRTSCTS) && sport->hw_flow_ctrl) { in pic32_uart_set_termios()
570 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), in pic32_uart_set_termios()
572 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
574 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
578 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
580 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
582 pic32_uart_writel(sport, PIC32_CLR(PIC32_UART_MODE), in pic32_uart_set_termios()
595 pic32_uart_writel(sport, PIC32_UART_BRG, quot); in pic32_uart_set_termios()
696 struct pic32_sport *sport = to_pic32_sport(port); in pic32_console_putchar() local
698 if (!(pic32_uart_readl(sport, PIC32_UART_MODE) & PIC32_UART_MODE_ON)) in pic32_console_putchar()
701 if (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_UTXEN)) in pic32_console_putchar()
705 pic32_wait_deplete_txbuf(sport); in pic32_console_putchar()
707 pic32_uart_writel(sport, PIC32_UART_TX, ch & 0xff); in pic32_console_putchar()
714 struct pic32_sport *sport = pic32_sports[co->index]; in pic32_console_write() local
715 struct uart_port *port = pic32_get_port(sport); in pic32_console_write()
726 struct pic32_sport *sport; in pic32_console_setup() local
737 sport = pic32_sports[co->index]; in pic32_console_setup()
738 if (!sport) in pic32_console_setup()
740 port = pic32_get_port(sport); in pic32_console_setup()
742 ret = pic32_enable_clock(sport); in pic32_console_setup()
799 struct pic32_sport *sport; in pic32_uart_probe() local
813 sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); in pic32_uart_probe()
814 if (!sport) in pic32_uart_probe()
817 sport->idx = uart_idx; in pic32_uart_probe()
818 sport->irq_fault = irq_of_parse_and_map(np, 0); in pic32_uart_probe()
819 sport->irqflags_fault = IRQF_NO_THREAD; in pic32_uart_probe()
820 sport->irq_rx = irq_of_parse_and_map(np, 1); in pic32_uart_probe()
821 sport->irqflags_rx = IRQF_NO_THREAD; in pic32_uart_probe()
822 sport->irq_tx = irq_of_parse_and_map(np, 2); in pic32_uart_probe()
823 sport->irqflags_tx = IRQF_NO_THREAD; in pic32_uart_probe()
824 sport->clk = devm_clk_get(&pdev->dev, NULL); in pic32_uart_probe()
825 sport->cts_gpio = -EINVAL; in pic32_uart_probe()
826 sport->dev = &pdev->dev; in pic32_uart_probe()
831 sport->hw_flow_ctrl = false; in pic32_uart_probe()
832 sport->cts_gpio = of_get_named_gpio(np, "cts-gpios", 0); in pic32_uart_probe()
833 if (gpio_is_valid(sport->cts_gpio)) { in pic32_uart_probe()
834 sport->hw_flow_ctrl = true; in pic32_uart_probe()
836 ret = devm_gpio_request(sport->dev, in pic32_uart_probe()
837 sport->cts_gpio, "CTS"); in pic32_uart_probe()
844 ret = gpio_direction_input(sport->cts_gpio); in pic32_uart_probe()
851 pic32_sports[uart_idx] = sport; in pic32_uart_probe()
852 port = &sport->port; in pic32_uart_probe()
860 port->uartclk = clk_get_rate(sport->clk); in pic32_uart_probe()
875 pic32_disable_clock(sport); in pic32_uart_probe()
893 struct pic32_sport *sport = to_pic32_sport(port); in pic32_uart_remove() local
896 pic32_disable_clock(sport); in pic32_uart_remove()
898 pic32_sports[sport->idx] = NULL; in pic32_uart_remove()