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 uart_port_lock_irqsave(&sport->port, &flags); in sa1100_timeout()
120 uart_port_unlock_irqrestore(&sport->port, 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()
191 sport->port.icount.rx++; in sa1100_rx_chars()
201 sport->port.icount.parity++; in sa1100_rx_chars()
203 sport->port.icount.frame++; in sa1100_rx_chars()
205 sport->port.icount.overrun++; in sa1100_rx_chars()
207 status &= sport->port.read_status_mask; in sa1100_rx_chars()
214 sport->port.sysrq = 0; in sa1100_rx_chars()
217 if (uart_handle_sysrq_char(&sport->port, ch)) in sa1100_rx_chars()
220 uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg); in sa1100_rx_chars()
227 tty_flip_buffer_push(&sport->port.state->port); in sa1100_rx_chars()
240 uart_port_tx(&sport->port, ch, in sa1100_tx_chars()
250 uart_port_lock(&sport->port); in sa1100_int()
252 status &= SM_TO_UTSR0(sport->port.read_status_mask) | ~UTSR0_TFS; in sa1100_int()
266 sport->port.icount.brk++; in sa1100_int()
269 uart_handle_break(&sport->port); in sa1100_int()
276 status &= SM_TO_UTSR0(sport->port.read_status_mask) | in sa1100_int()
279 uart_port_unlock(&sport->port); in sa1100_int()
301 mctrl_gpio_get(sport->gpios, &ret); in sa1100_get_mctrl()
311 mctrl_gpio_set(sport->gpios, mctrl); in sa1100_set_mctrl()
324 uart_port_lock_irqsave(&sport->port, &flags); in sa1100_break_ctl()
326 if (break_state == -1) in sa1100_break_ctl()
331 uart_port_unlock_irqrestore(&sport->port, flags); in sa1100_break_ctl()
343 retval = request_irq(sport->port.irq, sa1100_int, 0, in sa1100_startup()
344 "sa11x0-uart", sport); in sa1100_startup()
351 UART_PUT_UTSR0(sport, -1); in sa1100_startup()
357 uart_port_lock_irq(&sport->port); in sa1100_startup()
358 sa1100_enable_ms(&sport->port); in sa1100_startup()
359 uart_port_unlock_irq(&sport->port); in sa1100_startup()
372 del_timer_sync(&sport->timer); in sa1100_shutdown()
377 free_irq(sport->port.irq, sport); in sa1100_shutdown()
393 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; in sa1100_set_termios()
398 while ((termios->c_cflag & CSIZE) != CS7 && in sa1100_set_termios()
399 (termios->c_cflag & CSIZE) != CS8) { in sa1100_set_termios()
400 termios->c_cflag &= ~CSIZE; in sa1100_set_termios()
401 termios->c_cflag |= old_csize; in sa1100_set_termios()
405 if ((termios->c_cflag & CSIZE) == CS8) in sa1100_set_termios()
410 if (termios->c_cflag & CSTOPB) in sa1100_set_termios()
412 if (termios->c_cflag & PARENB) { in sa1100_set_termios()
414 if (!(termios->c_cflag & PARODD)) in sa1100_set_termios()
421 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in sa1100_set_termios()
424 del_timer_sync(&sport->timer); in sa1100_set_termios()
426 uart_port_lock_irqsave(&sport->port, &flags); in sa1100_set_termios()
428 sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS); in sa1100_set_termios()
429 sport->port.read_status_mask |= UTSR1_TO_SM(UTSR1_ROR); in sa1100_set_termios()
430 if (termios->c_iflag & INPCK) in sa1100_set_termios()
431 sport->port.read_status_mask |= in sa1100_set_termios()
433 if (termios->c_iflag & (BRKINT | PARMRK)) in sa1100_set_termios()
434 sport->port.read_status_mask |= in sa1100_set_termios()
440 sport->port.ignore_status_mask = 0; in sa1100_set_termios()
441 if (termios->c_iflag & IGNPAR) in sa1100_set_termios()
442 sport->port.ignore_status_mask |= in sa1100_set_termios()
444 if (termios->c_iflag & IGNBRK) { in sa1100_set_termios()
445 sport->port.ignore_status_mask |= in sa1100_set_termios()
451 if (termios->c_iflag & IGNPAR) in sa1100_set_termios()
452 sport->port.ignore_status_mask |= in sa1100_set_termios()
457 * Update the per-port timeout. in sa1100_set_termios()
459 uart_update_timeout(port, termios->c_cflag, baud); in sa1100_set_termios()
477 quot -= 1; in sa1100_set_termios()
481 UART_PUT_UTSR0(sport, -1); in sa1100_set_termios()
485 if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) in sa1100_set_termios()
486 sa1100_enable_ms(&sport->port); in sa1100_set_termios()
488 uart_port_unlock_irqrestore(&sport->port, flags); in sa1100_set_termios()
496 return sport->port.type == PORT_SA1100 ? "SA1100" : NULL; in sa1100_type()
507 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); in sa1100_release_port()
518 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, in sa1100_request_port()
519 "sa11x0-uart") != NULL ? 0 : -EBUSY; in sa1100_request_port()
531 sa1100_request_port(&sport->port) == 0) in sa1100_config_port()
532 sport->port.type = PORT_SA1100; in sa1100_config_port()
547 if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100) in sa1100_verify_port()
548 ret = -EINVAL; in sa1100_verify_port()
549 if (sport->port.irq != ser->irq) in sa1100_verify_port()
550 ret = -EINVAL; in sa1100_verify_port()
551 if (ser->io_type != SERIAL_IO_MEM) in sa1100_verify_port()
552 ret = -EINVAL; in sa1100_verify_port()
553 if (sport->port.uartclk / 16 != ser->baud_base) in sa1100_verify_port()
554 ret = -EINVAL; in sa1100_verify_port()
555 if ((void *)sport->port.mapbase != ser->iomem_base) in sa1100_verify_port()
556 ret = -EINVAL; in sa1100_verify_port()
557 if (sport->port.iobase != ser->port) in sa1100_verify_port()
558 ret = -EINVAL; in sa1100_verify_port()
559 if (ser->hub6 != 0) in sa1100_verify_port()
560 ret = -EINVAL; in sa1100_verify_port()
625 if (fns->get_mctrl) in sa1100_register_uart_fns()
626 sa1100_pops.get_mctrl = fns->get_mctrl; in sa1100_register_uart_fns()
627 if (fns->set_mctrl) in sa1100_register_uart_fns()
628 sa1100_pops.set_mctrl = fns->set_mctrl; in sa1100_register_uart_fns()
630 sa1100_pops.pm = fns->pm; in sa1100_register_uart_fns()
632 * FIXME: fns->set_wake is unused - this should be called from in sa1100_register_uart_fns()
689 struct sa1100_port *sport = &sa1100_ports[co->index]; in sa1100_console_write()
699 uart_console_write(&sport->port, s, count, sa1100_console_putchar); in sa1100_console_write()
743 *baud = sport->port.uartclk / (16 * (quot + 1)); in sa1100_console_get_options()
761 if (co->index == -1 || co->index >= NR_PORTS) in sa1100_console_setup()
762 co->index = 0; in sa1100_console_setup()
763 sport = &sa1100_ports[co->index]; in sa1100_console_setup()
770 return uart_set_options(&sport->port, co, baud, parity, bits, flow); in sa1100_console_setup()
780 .index = -1,
812 uart_suspend_port(&sa1100_reg, &sport->port); in sa1100_serial_suspend()
822 uart_resume_port(&sa1100_reg, &sport->port); in sa1100_serial_resume()
829 sport->port.dev = &dev->dev; in sa1100_serial_add_one_port()
830 sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SA1100_CONSOLE); in sa1100_serial_add_one_port()
835 sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0); in sa1100_serial_add_one_port()
836 if (IS_ERR(sport->gpios)) { in sa1100_serial_add_one_port()
837 int err = PTR_ERR(sport->gpios); in sa1100_serial_add_one_port()
839 dev_err(sport->port.dev, "failed to get mctrl gpios: %d\n", in sa1100_serial_add_one_port()
842 if (err == -EPROBE_DEFER) in sa1100_serial_add_one_port()
845 sport->gpios = NULL; in sa1100_serial_add_one_port()
850 return uart_add_one_port(&sa1100_reg, &sport->port); in sa1100_serial_add_one_port()
860 return -EINVAL; in sa1100_serial_probe()
863 if (sa1100_ports[i].port.mapbase == res->start) in sa1100_serial_probe()
866 return -ENODEV; in sa1100_serial_probe()
878 uart_remove_one_port(&sa1100_reg, &sport->port); in sa1100_serial_remove()
887 .name = "sa11x0-uart",
921 MODULE_ALIAS("platform:sa11x0-uart");