Lines Matching +full:rng +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0+
15 #include <linux/platform_data/sa11x0-serial.h>
29 /* We've been assigned a range on the "Low-density serial ports" major */
45 #define UART_GET_UTCR0(sport) __raw_readl((sport)->port.membase + UTCR0)
46 #define UART_GET_UTCR1(sport) __raw_readl((sport)->port.membase + UTCR1)
47 #define UART_GET_UTCR2(sport) __raw_readl((sport)->port.membase + UTCR2)
48 #define UART_GET_UTCR3(sport) __raw_readl((sport)->port.membase + UTCR3)
49 #define UART_GET_UTSR0(sport) __raw_readl((sport)->port.membase + UTSR0)
50 #define UART_GET_UTSR1(sport) __raw_readl((sport)->port.membase + UTSR1)
51 #define UART_GET_CHAR(sport) __raw_readl((sport)->port.membase + UTDR)
53 #define UART_PUT_UTCR0(sport,v) __raw_writel((v),(sport)->port.membase + UTCR0)
54 #define UART_PUT_UTCR1(sport,v) __raw_writel((v),(sport)->port.membase + UTCR1)
55 #define UART_PUT_UTCR2(sport,v) __raw_writel((v),(sport)->port.membase + UTCR2)
56 #define UART_PUT_UTCR3(sport,v) __raw_writel((v),(sport)->port.membase + UTCR3)
57 #define UART_PUT_UTSR0(sport,v) __raw_writel((v),(sport)->port.membase + UTSR0)
58 #define UART_PUT_UTSR1(sport,v) __raw_writel((v),(sport)->port.membase + UTSR1)
59 #define UART_PUT_CHAR(sport,v) __raw_writel((v),(sport)->port.membase + UTDR)
78 struct mctrl_gpios *gpios; member
88 status = sport->port.ops->get_mctrl(&sport->port); in sa1100_mctrl_check()
89 changed = status ^ sport->old_status; in sa1100_mctrl_check()
94 sport->old_status = status; in sa1100_mctrl_check()
97 sport->port.icount.rng++; in sa1100_mctrl_check()
99 sport->port.icount.dsr++; in sa1100_mctrl_check()
101 uart_handle_dcd_change(&sport->port, status & TIOCM_CAR); in sa1100_mctrl_check()
103 uart_handle_cts_change(&sport->port, status & TIOCM_CTS); in sa1100_mctrl_check()
105 wake_up_interruptible(&sport->port.state->port.delta_msr_wait); in sa1100_mctrl_check()
109 * This is our per-port timeout handler, for checking the
117 if (sport->port.state) { in sa1100_timeout()
118 spin_lock_irqsave(&sport->port.lock, flags); in sa1100_timeout()
120 spin_unlock_irqrestore(&sport->port.lock, flags); in sa1100_timeout()
122 mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT); in sa1100_timeout()
137 sport->port.read_status_mask &= ~UTSR0_TO_SM(UTSR0_TFS); in sa1100_stop_tx()
150 sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS); in sa1100_start_tx()
175 mod_timer(&sport->timer, jiffies); in sa1100_enable_ms()
177 mctrl_gpio_enable_ms(sport->gpios); in sa1100_enable_ms()
190 sport->port.icount.rx++; in sa1100_rx_chars()
200 sport->port.icount.parity++; in sa1100_rx_chars()
202 sport->port.icount.frame++; in sa1100_rx_chars()
204 sport->port.icount.overrun++; in sa1100_rx_chars()
206 status &= sport->port.read_status_mask; in sa1100_rx_chars()
213 sport->port.sysrq = 0; in sa1100_rx_chars()
216 if (uart_handle_sysrq_char(&sport->port, ch)) in sa1100_rx_chars()
219 uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg); in sa1100_rx_chars()
226 tty_flip_buffer_push(&sport->port.state->port); in sa1100_rx_chars()
231 struct circ_buf *xmit = &sport->port.state->xmit; in sa1100_tx_chars()
233 if (sport->port.x_char) { in sa1100_tx_chars()
234 UART_PUT_CHAR(sport, sport->port.x_char); in sa1100_tx_chars()
235 sport->port.icount.tx++; in sa1100_tx_chars()
236 sport->port.x_char = 0; in sa1100_tx_chars()
246 if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { in sa1100_tx_chars()
247 sa1100_stop_tx(&sport->port); in sa1100_tx_chars()
256 UART_PUT_CHAR(sport, xmit->buf[xmit->tail]); in sa1100_tx_chars()
257 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in sa1100_tx_chars()
258 sport->port.icount.tx++; in sa1100_tx_chars()
264 uart_write_wakeup(&sport->port); in sa1100_tx_chars()
267 sa1100_stop_tx(&sport->port); in sa1100_tx_chars()
275 spin_lock(&sport->port.lock); in sa1100_int()
277 status &= SM_TO_UTSR0(sport->port.read_status_mask) | ~UTSR0_TFS; in sa1100_int()
291 sport->port.icount.brk++; in sa1100_int()
294 uart_handle_break(&sport->port); in sa1100_int()
301 status &= SM_TO_UTSR0(sport->port.read_status_mask) | in sa1100_int()
304 spin_unlock(&sport->port.lock); in sa1100_int()
326 mctrl_gpio_get(sport->gpios, &ret); in sa1100_get_mctrl()
336 mctrl_gpio_set(sport->gpios, mctrl); in sa1100_set_mctrl()
349 spin_lock_irqsave(&sport->port.lock, flags); in sa1100_break_ctl()
351 if (break_state == -1) in sa1100_break_ctl()
356 spin_unlock_irqrestore(&sport->port.lock, flags); in sa1100_break_ctl()
368 retval = request_irq(sport->port.irq, sa1100_int, 0, in sa1100_startup()
369 "sa11x0-uart", sport); in sa1100_startup()
376 UART_PUT_UTSR0(sport, -1); in sa1100_startup()
382 spin_lock_irq(&sport->port.lock); in sa1100_startup()
383 sa1100_enable_ms(&sport->port); in sa1100_startup()
384 spin_unlock_irq(&sport->port.lock); in sa1100_startup()
397 del_timer_sync(&sport->timer); in sa1100_shutdown()
402 free_irq(sport->port.irq, sport); in sa1100_shutdown()
418 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; in sa1100_set_termios()
423 while ((termios->c_cflag & CSIZE) != CS7 && in sa1100_set_termios()
424 (termios->c_cflag & CSIZE) != CS8) { in sa1100_set_termios()
425 termios->c_cflag &= ~CSIZE; in sa1100_set_termios()
426 termios->c_cflag |= old_csize; in sa1100_set_termios()
430 if ((termios->c_cflag & CSIZE) == CS8) in sa1100_set_termios()
435 if (termios->c_cflag & CSTOPB) in sa1100_set_termios()
437 if (termios->c_cflag & PARENB) { in sa1100_set_termios()
439 if (!(termios->c_cflag & PARODD)) in sa1100_set_termios()
446 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in sa1100_set_termios()
449 del_timer_sync(&sport->timer); in sa1100_set_termios()
451 spin_lock_irqsave(&sport->port.lock, flags); in sa1100_set_termios()
453 sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS); in sa1100_set_termios()
454 sport->port.read_status_mask |= UTSR1_TO_SM(UTSR1_ROR); in sa1100_set_termios()
455 if (termios->c_iflag & INPCK) in sa1100_set_termios()
456 sport->port.read_status_mask |= in sa1100_set_termios()
458 if (termios->c_iflag & (BRKINT | PARMRK)) in sa1100_set_termios()
459 sport->port.read_status_mask |= in sa1100_set_termios()
465 sport->port.ignore_status_mask = 0; in sa1100_set_termios()
466 if (termios->c_iflag & IGNPAR) in sa1100_set_termios()
467 sport->port.ignore_status_mask |= in sa1100_set_termios()
469 if (termios->c_iflag & IGNBRK) { in sa1100_set_termios()
470 sport->port.ignore_status_mask |= in sa1100_set_termios()
476 if (termios->c_iflag & IGNPAR) in sa1100_set_termios()
477 sport->port.ignore_status_mask |= in sa1100_set_termios()
482 * Update the per-port timeout. in sa1100_set_termios()
484 uart_update_timeout(port, termios->c_cflag, baud); in sa1100_set_termios()
502 quot -= 1; in sa1100_set_termios()
506 UART_PUT_UTSR0(sport, -1); in sa1100_set_termios()
510 if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) in sa1100_set_termios()
511 sa1100_enable_ms(&sport->port); in sa1100_set_termios()
513 spin_unlock_irqrestore(&sport->port.lock, flags); in sa1100_set_termios()
521 return sport->port.type == PORT_SA1100 ? "SA1100" : NULL; in sa1100_type()
532 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); in sa1100_release_port()
543 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, in sa1100_request_port()
544 "sa11x0-uart") != NULL ? 0 : -EBUSY; in sa1100_request_port()
556 sa1100_request_port(&sport->port) == 0) in sa1100_config_port()
557 sport->port.type = PORT_SA1100; in sa1100_config_port()
572 if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100) in sa1100_verify_port()
573 ret = -EINVAL; in sa1100_verify_port()
574 if (sport->port.irq != ser->irq) in sa1100_verify_port()
575 ret = -EINVAL; in sa1100_verify_port()
576 if (ser->io_type != SERIAL_IO_MEM) in sa1100_verify_port()
577 ret = -EINVAL; in sa1100_verify_port()
578 if (sport->port.uartclk / 16 != ser->baud_base) in sa1100_verify_port()
579 ret = -EINVAL; in sa1100_verify_port()
580 if ((void *)sport->port.mapbase != ser->iomem_base) in sa1100_verify_port()
581 ret = -EINVAL; in sa1100_verify_port()
582 if (sport->port.iobase != ser->port) in sa1100_verify_port()
583 ret = -EINVAL; in sa1100_verify_port()
584 if (ser->hub6 != 0) in sa1100_verify_port()
585 ret = -EINVAL; in sa1100_verify_port()
650 if (fns->get_mctrl) in sa1100_register_uart_fns()
651 sa1100_pops.get_mctrl = fns->get_mctrl; in sa1100_register_uart_fns()
652 if (fns->set_mctrl) in sa1100_register_uart_fns()
653 sa1100_pops.set_mctrl = fns->set_mctrl; in sa1100_register_uart_fns()
655 sa1100_pops.pm = fns->pm; in sa1100_register_uart_fns()
657 * FIXME: fns->set_wake is unused - this should be called from in sa1100_register_uart_fns()
714 struct sa1100_port *sport = &sa1100_ports[co->index]; in sa1100_console_write()
724 uart_console_write(&sport->port, s, count, sa1100_console_putchar); in sa1100_console_write()
768 *baud = sport->port.uartclk / (16 * (quot + 1)); in sa1100_console_get_options()
786 if (co->index == -1 || co->index >= NR_PORTS) in sa1100_console_setup()
787 co->index = 0; in sa1100_console_setup()
788 sport = &sa1100_ports[co->index]; in sa1100_console_setup()
795 return uart_set_options(&sport->port, co, baud, parity, bits, flow); in sa1100_console_setup()
805 .index = -1,
837 uart_suspend_port(&sa1100_reg, &sport->port); in sa1100_serial_suspend()
847 uart_resume_port(&sa1100_reg, &sport->port); in sa1100_serial_resume()
854 sport->port.dev = &dev->dev; in sa1100_serial_add_one_port()
855 sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SA1100_CONSOLE); in sa1100_serial_add_one_port()
860 sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0); in sa1100_serial_add_one_port()
861 if (IS_ERR(sport->gpios)) { in sa1100_serial_add_one_port()
862 int err = PTR_ERR(sport->gpios); in sa1100_serial_add_one_port()
864 dev_err(sport->port.dev, "failed to get mctrl gpios: %d\n", in sa1100_serial_add_one_port()
867 if (err == -EPROBE_DEFER) in sa1100_serial_add_one_port()
870 sport->gpios = NULL; in sa1100_serial_add_one_port()
875 return uart_add_one_port(&sa1100_reg, &sport->port); in sa1100_serial_add_one_port()
885 return -EINVAL; in sa1100_serial_probe()
888 if (sa1100_ports[i].port.mapbase == res->start) in sa1100_serial_probe()
891 return -ENODEV; in sa1100_serial_probe()
903 uart_remove_one_port(&sa1100_reg, &sport->port); in sa1100_serial_remove()
914 .name = "sa11x0-uart",
948 MODULE_ALIAS("platform:sa11x0-uart");