Lines Matching refs:sport

45 #define UART_GET_UTCR0(sport)	__raw_readl((sport)->port.membase + UTCR0)  argument
46 #define UART_GET_UTCR1(sport) __raw_readl((sport)->port.membase + UTCR1) argument
47 #define UART_GET_UTCR2(sport) __raw_readl((sport)->port.membase + UTCR2) argument
48 #define UART_GET_UTCR3(sport) __raw_readl((sport)->port.membase + UTCR3) argument
49 #define UART_GET_UTSR0(sport) __raw_readl((sport)->port.membase + UTSR0) argument
50 #define UART_GET_UTSR1(sport) __raw_readl((sport)->port.membase + UTSR1) argument
51 #define UART_GET_CHAR(sport) __raw_readl((sport)->port.membase + UTDR) argument
53 #define UART_PUT_UTCR0(sport,v) __raw_writel((v),(sport)->port.membase + UTCR0) argument
54 #define UART_PUT_UTCR1(sport,v) __raw_writel((v),(sport)->port.membase + UTCR1) argument
55 #define UART_PUT_UTCR2(sport,v) __raw_writel((v),(sport)->port.membase + UTCR2) argument
56 #define UART_PUT_UTCR3(sport,v) __raw_writel((v),(sport)->port.membase + UTCR3) argument
57 #define UART_PUT_UTSR0(sport,v) __raw_writel((v),(sport)->port.membase + UTSR0) argument
58 #define UART_PUT_UTSR1(sport,v) __raw_writel((v),(sport)->port.membase + UTSR1) argument
59 #define UART_PUT_CHAR(sport,v) __raw_writel((v),(sport)->port.membase + UTDR) argument
84 static void sa1100_mctrl_check(struct sa1100_port *sport) in sa1100_mctrl_check() argument
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()
114 struct sa1100_port *sport = from_timer(sport, t, timer); in sa1100_timeout() local
117 if (sport->port.state) { in sa1100_timeout()
118 uart_port_lock_irqsave(&sport->port, &flags); in sa1100_timeout()
119 sa1100_mctrl_check(sport); 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()
131 struct sa1100_port *sport = in sa1100_stop_tx() local
135 utcr3 = UART_GET_UTCR3(sport); in sa1100_stop_tx()
136 UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_TIE); in sa1100_stop_tx()
137 sport->port.read_status_mask &= ~UTSR0_TO_SM(UTSR0_TFS); in sa1100_stop_tx()
145 struct sa1100_port *sport = in sa1100_start_tx() local
149 utcr3 = UART_GET_UTCR3(sport); in sa1100_start_tx()
150 sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS); in sa1100_start_tx()
151 UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE); in sa1100_start_tx()
159 struct sa1100_port *sport = in sa1100_stop_rx() local
163 utcr3 = UART_GET_UTCR3(sport); in sa1100_stop_rx()
164 UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_RIE); in sa1100_stop_rx()
172 struct sa1100_port *sport = in sa1100_enable_ms() local
175 mod_timer(&sport->timer, jiffies); in sa1100_enable_ms()
177 mctrl_gpio_enable_ms(sport->gpios); in sa1100_enable_ms()
181 sa1100_rx_chars(struct sa1100_port *sport) in sa1100_rx_chars() argument
186 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | in sa1100_rx_chars()
187 UTSR0_TO_SM(UART_GET_UTSR0(sport)); in sa1100_rx_chars()
189 ch = UART_GET_CHAR(sport); in sa1100_rx_chars()
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()
223 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | in sa1100_rx_chars()
224 UTSR0_TO_SM(UART_GET_UTSR0(sport)); in sa1100_rx_chars()
227 tty_flip_buffer_push(&sport->port.state->port); in sa1100_rx_chars()
230 static void sa1100_tx_chars(struct sa1100_port *sport) in sa1100_tx_chars() argument
238 sa1100_mctrl_check(sport); in sa1100_tx_chars()
240 uart_port_tx(&sport->port, ch, in sa1100_tx_chars()
241 UART_GET_UTSR1(sport) & UTSR1_TNF, in sa1100_tx_chars()
242 UART_PUT_CHAR(sport, ch)); in sa1100_tx_chars()
247 struct sa1100_port *sport = dev_id; in sa1100_int() local
250 uart_port_lock(&sport->port); in sa1100_int()
251 status = UART_GET_UTSR0(sport); in sa1100_int()
252 status &= SM_TO_UTSR0(sport->port.read_status_mask) | ~UTSR0_TFS; in sa1100_int()
257 UART_PUT_UTSR0(sport, UTSR0_RID); in sa1100_int()
258 sa1100_rx_chars(sport); in sa1100_int()
263 UART_PUT_UTSR0(sport, status & (UTSR0_RBB | UTSR0_REB)); in sa1100_int()
266 sport->port.icount.brk++; in sa1100_int()
269 uart_handle_break(&sport->port); in sa1100_int()
272 sa1100_tx_chars(sport); in sa1100_int()
275 status = UART_GET_UTSR0(sport); 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()
289 struct sa1100_port *sport = in sa1100_tx_empty() local
292 return UART_GET_UTSR1(sport) & UTSR1_TBY ? 0 : TIOCSER_TEMT; in sa1100_tx_empty()
297 struct sa1100_port *sport = in sa1100_get_mctrl() local
301 mctrl_gpio_get(sport->gpios, &ret); in sa1100_get_mctrl()
308 struct sa1100_port *sport = in sa1100_set_mctrl() local
311 mctrl_gpio_set(sport->gpios, mctrl); in sa1100_set_mctrl()
319 struct sa1100_port *sport = in sa1100_break_ctl() local
324 uart_port_lock_irqsave(&sport->port, &flags); in sa1100_break_ctl()
325 utcr3 = UART_GET_UTCR3(sport); in sa1100_break_ctl()
330 UART_PUT_UTCR3(sport, utcr3); in sa1100_break_ctl()
331 uart_port_unlock_irqrestore(&sport->port, flags); in sa1100_break_ctl()
336 struct sa1100_port *sport = in sa1100_startup() local
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()
352 UART_PUT_UTCR3(sport, UTCR3_RXE | UTCR3_TXE | UTCR3_RIE); 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()
366 struct sa1100_port *sport = in sa1100_shutdown() local
372 del_timer_sync(&sport->timer); in sa1100_shutdown()
377 free_irq(sport->port.irq, sport); in sa1100_shutdown()
382 UART_PUT_UTCR3(sport, 0); in sa1100_shutdown()
389 struct sa1100_port *sport = in sa1100_set_termios() local
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()
431 sport->port.read_status_mask |= 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()
442 sport->port.ignore_status_mask |= in sa1100_set_termios()
445 sport->port.ignore_status_mask |= in sa1100_set_termios()
452 sport->port.ignore_status_mask |= in sa1100_set_termios()
464 old_utcr3 = UART_GET_UTCR3(sport); in sa1100_set_termios()
465 UART_PUT_UTCR3(sport, old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)); in sa1100_set_termios()
467 while (UART_GET_UTSR1(sport) & UTSR1_TBY) in sa1100_set_termios()
471 UART_PUT_UTCR3(sport, 0); in sa1100_set_termios()
474 UART_PUT_UTCR0(sport, utcr0); in sa1100_set_termios()
478 UART_PUT_UTCR1(sport, ((quot & 0xf00) >> 8)); in sa1100_set_termios()
479 UART_PUT_UTCR2(sport, (quot & 0xff)); in sa1100_set_termios()
481 UART_PUT_UTSR0(sport, -1); in sa1100_set_termios()
483 UART_PUT_UTCR3(sport, old_utcr3); 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()
493 struct sa1100_port *sport = in sa1100_type() local
496 return sport->port.type == PORT_SA1100 ? "SA1100" : NULL; in sa1100_type()
504 struct sa1100_port *sport = in sa1100_release_port() local
507 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); in sa1100_release_port()
515 struct sa1100_port *sport = in sa1100_request_port() local
518 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, in sa1100_request_port()
527 struct sa1100_port *sport = in sa1100_config_port() local
531 sa1100_request_port(&sport->port) == 0) in sa1100_config_port()
532 sport->port.type = PORT_SA1100; in sa1100_config_port()
543 struct sa1100_port *sport = in sa1100_verify_port() local
549 if (sport->port.irq != ser->irq) in sa1100_verify_port()
553 if (sport->port.uartclk / 16 != ser->baud_base) in sa1100_verify_port()
555 if ((void *)sport->port.mapbase != ser->iomem_base) in sa1100_verify_port()
557 if (sport->port.iobase != ser->port) in sa1100_verify_port()
675 struct sa1100_port *sport = in sa1100_console_putchar() local
678 while (!(UART_GET_UTSR1(sport) & UTSR1_TNF)) in sa1100_console_putchar()
680 UART_PUT_CHAR(sport, ch); in sa1100_console_putchar()
689 struct sa1100_port *sport = &sa1100_ports[co->index]; in sa1100_console_write() local
695 old_utcr3 = UART_GET_UTCR3(sport); in sa1100_console_write()
696 UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) | in sa1100_console_write()
699 uart_console_write(&sport->port, s, count, sa1100_console_putchar); in sa1100_console_write()
706 status = UART_GET_UTSR1(sport); in sa1100_console_write()
708 UART_PUT_UTCR3(sport, old_utcr3); in sa1100_console_write()
716 sa1100_console_get_options(struct sa1100_port *sport, int *baud, in sa1100_console_get_options() argument
721 utcr3 = UART_GET_UTCR3(sport) & (UTCR3_RXE | UTCR3_TXE); in sa1100_console_get_options()
726 utcr0 = UART_GET_UTCR0(sport); in sa1100_console_get_options()
741 quot = UART_GET_UTCR2(sport) | UART_GET_UTCR1(sport) << 8; in sa1100_console_get_options()
743 *baud = sport->port.uartclk / (16 * (quot + 1)); in sa1100_console_get_options()
750 struct sa1100_port *sport; in sa1100_console_setup() local
763 sport = &sa1100_ports[co->index]; in sa1100_console_setup()
768 sa1100_console_get_options(sport, &baud, &parity, &bits); in sa1100_console_setup()
770 return uart_set_options(&sport->port, co, baud, parity, bits, flow); in sa1100_console_setup()
809 struct sa1100_port *sport = platform_get_drvdata(dev); in sa1100_serial_suspend() local
811 if (sport) in sa1100_serial_suspend()
812 uart_suspend_port(&sa1100_reg, &sport->port); in sa1100_serial_suspend()
819 struct sa1100_port *sport = platform_get_drvdata(dev); in sa1100_serial_resume() local
821 if (sport) in sa1100_serial_resume()
822 uart_resume_port(&sa1100_reg, &sport->port); in sa1100_serial_resume()
827 static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev) in sa1100_serial_add_one_port() argument
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()
845 sport->gpios = NULL; in sa1100_serial_add_one_port()
848 platform_set_drvdata(dev, sport); in sa1100_serial_add_one_port()
850 return uart_add_one_port(&sa1100_reg, &sport->port); in sa1100_serial_add_one_port()
875 struct sa1100_port *sport = platform_get_drvdata(pdev); in sa1100_serial_remove() local
877 if (sport) in sa1100_serial_remove()
878 uart_remove_one_port(&sa1100_reg, &sport->port); in sa1100_serial_remove()