diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2018-03-02 05:07:19 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-09 13:21:01 -0500 |
commit | 27c844261b87f85f23784e78170883092428e5a1 (patch) | |
tree | f16b1893baa3aa97bcc69ef51d70ea41ddc899d5 | |
parent | afa6b1ccfad5e72918b79461a97fe21d1c2292da (diff) |
serial: imx: add wrappers for writel and readl
This prepares implementing shadow copies for the control registers and
additionally provides a good place to hook in debug code to trace
register usage.
Most of this patch was done using pattern substitution:
perl -p -i -e '
s/\breadl(?:_relaxed)?\((?:sport->port\.|port->)membase \+/imx_uart_readl(sport,/;
s/\bwritel(?:_relaxed)?\(([^,]*), (sport->port\.|port->)membase \+/imx_uart_writel(sport, $1,/;
' drivers/tty/serial/imx.c
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/imx.c | 383 |
1 files changed, 199 insertions, 184 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index dc33b82cd887..659a949bed8a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -273,6 +273,16 @@ static const struct of_device_id imx_uart_dt_ids[] = { | |||
273 | }; | 273 | }; |
274 | MODULE_DEVICE_TABLE(of, imx_uart_dt_ids); | 274 | MODULE_DEVICE_TABLE(of, imx_uart_dt_ids); |
275 | 275 | ||
276 | static void imx_uart_writel(struct imx_port *sport, u32 val, u32 offset) | ||
277 | { | ||
278 | writel(val, sport->port.membase + offset); | ||
279 | } | ||
280 | |||
281 | static u32 imx_uart_readl(struct imx_port *sport, u32 offset) | ||
282 | { | ||
283 | return readl(sport->port.membase + offset); | ||
284 | } | ||
285 | |||
276 | static inline unsigned uts_reg(struct imx_port *sport) | 286 | static inline unsigned uts_reg(struct imx_port *sport) |
277 | { | 287 | { |
278 | return sport->devdata->uts_reg; | 288 | return sport->devdata->uts_reg; |
@@ -301,22 +311,22 @@ static inline int is_imx6q_uart(struct imx_port *sport) | |||
301 | * Save and restore functions for UCR1, UCR2 and UCR3 registers | 311 | * Save and restore functions for UCR1, UCR2 and UCR3 registers |
302 | */ | 312 | */ |
303 | #if defined(CONFIG_SERIAL_IMX_CONSOLE) | 313 | #if defined(CONFIG_SERIAL_IMX_CONSOLE) |
304 | static void imx_port_ucrs_save(struct uart_port *port, | 314 | static void imx_port_ucrs_save(struct imx_port *sport, |
305 | struct imx_port_ucrs *ucr) | 315 | struct imx_port_ucrs *ucr) |
306 | { | 316 | { |
307 | /* save control registers */ | 317 | /* save control registers */ |
308 | ucr->ucr1 = readl(port->membase + UCR1); | 318 | ucr->ucr1 = imx_uart_readl(sport, UCR1); |
309 | ucr->ucr2 = readl(port->membase + UCR2); | 319 | ucr->ucr2 = imx_uart_readl(sport, UCR2); |
310 | ucr->ucr3 = readl(port->membase + UCR3); | 320 | ucr->ucr3 = imx_uart_readl(sport, UCR3); |
311 | } | 321 | } |
312 | 322 | ||
313 | static void imx_port_ucrs_restore(struct uart_port *port, | 323 | static void imx_port_ucrs_restore(struct imx_port *sport, |
314 | struct imx_port_ucrs *ucr) | 324 | struct imx_port_ucrs *ucr) |
315 | { | 325 | { |
316 | /* restore control registers */ | 326 | /* restore control registers */ |
317 | writel(ucr->ucr1, port->membase + UCR1); | 327 | imx_uart_writel(sport, ucr->ucr1, UCR1); |
318 | writel(ucr->ucr2, port->membase + UCR2); | 328 | imx_uart_writel(sport, ucr->ucr2, UCR2); |
319 | writel(ucr->ucr3, port->membase + UCR3); | 329 | imx_uart_writel(sport, ucr->ucr3, UCR3); |
320 | } | 330 | } |
321 | #endif | 331 | #endif |
322 | 332 | ||
@@ -355,23 +365,23 @@ static void imx_stop_tx(struct uart_port *port) | |||
355 | if (sport->dma_is_enabled && sport->dma_is_txing) | 365 | if (sport->dma_is_enabled && sport->dma_is_txing) |
356 | return; | 366 | return; |
357 | 367 | ||
358 | temp = readl(port->membase + UCR1); | 368 | temp = imx_uart_readl(sport, UCR1); |
359 | writel(temp & ~UCR1_TXMPTYEN, port->membase + UCR1); | 369 | imx_uart_writel(sport, temp & ~UCR1_TXMPTYEN, UCR1); |
360 | 370 | ||
361 | /* in rs485 mode disable transmitter if shifter is empty */ | 371 | /* in rs485 mode disable transmitter if shifter is empty */ |
362 | if (port->rs485.flags & SER_RS485_ENABLED && | 372 | if (port->rs485.flags & SER_RS485_ENABLED && |
363 | readl(port->membase + USR2) & USR2_TXDC) { | 373 | imx_uart_readl(sport, USR2) & USR2_TXDC) { |
364 | temp = readl(port->membase + UCR2); | 374 | temp = imx_uart_readl(sport, UCR2); |
365 | if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) | 375 | if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) |
366 | imx_port_rts_active(sport, &temp); | 376 | imx_port_rts_active(sport, &temp); |
367 | else | 377 | else |
368 | imx_port_rts_inactive(sport, &temp); | 378 | imx_port_rts_inactive(sport, &temp); |
369 | temp |= UCR2_RXEN; | 379 | temp |= UCR2_RXEN; |
370 | writel(temp, port->membase + UCR2); | 380 | imx_uart_writel(sport, temp, UCR2); |
371 | 381 | ||
372 | temp = readl(port->membase + UCR4); | 382 | temp = imx_uart_readl(sport, UCR4); |
373 | temp &= ~UCR4_TCEN; | 383 | temp &= ~UCR4_TCEN; |
374 | writel(temp, port->membase + UCR4); | 384 | imx_uart_writel(sport, temp, UCR4); |
375 | } | 385 | } |
376 | } | 386 | } |
377 | 387 | ||
@@ -390,12 +400,12 @@ static void imx_stop_rx(struct uart_port *port) | |||
390 | } | 400 | } |
391 | } | 401 | } |
392 | 402 | ||
393 | temp = readl(sport->port.membase + UCR2); | 403 | temp = imx_uart_readl(sport, UCR2); |
394 | writel(temp & ~UCR2_RXEN, sport->port.membase + UCR2); | 404 | imx_uart_writel(sport, temp & ~UCR2_RXEN, UCR2); |
395 | 405 | ||
396 | /* disable the `Receiver Ready Interrrupt` */ | 406 | /* disable the `Receiver Ready Interrrupt` */ |
397 | temp = readl(sport->port.membase + UCR1); | 407 | temp = imx_uart_readl(sport, UCR1); |
398 | writel(temp & ~UCR1_RRDYEN, sport->port.membase + UCR1); | 408 | imx_uart_writel(sport, temp & ~UCR1_RRDYEN, UCR1); |
399 | } | 409 | } |
400 | 410 | ||
401 | /* called with port.lock taken and irqs off */ | 411 | /* called with port.lock taken and irqs off */ |
@@ -418,7 +428,7 @@ static inline void imx_transmit_buffer(struct imx_port *sport) | |||
418 | 428 | ||
419 | if (sport->port.x_char) { | 429 | if (sport->port.x_char) { |
420 | /* Send next char */ | 430 | /* Send next char */ |
421 | writel(sport->port.x_char, sport->port.membase + URTX0); | 431 | imx_uart_writel(sport, sport->port.x_char, URTX0); |
422 | sport->port.icount.tx++; | 432 | sport->port.icount.tx++; |
423 | sport->port.x_char = 0; | 433 | sport->port.x_char = 0; |
424 | return; | 434 | return; |
@@ -434,13 +444,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport) | |||
434 | * We've just sent a X-char Ensure the TX DMA is enabled | 444 | * We've just sent a X-char Ensure the TX DMA is enabled |
435 | * and the TX IRQ is disabled. | 445 | * and the TX IRQ is disabled. |
436 | **/ | 446 | **/ |
437 | temp = readl(sport->port.membase + UCR1); | 447 | temp = imx_uart_readl(sport, UCR1); |
438 | temp &= ~UCR1_TXMPTYEN; | 448 | temp &= ~UCR1_TXMPTYEN; |
439 | if (sport->dma_is_txing) { | 449 | if (sport->dma_is_txing) { |
440 | temp |= UCR1_TXDMAEN; | 450 | temp |= UCR1_TXDMAEN; |
441 | writel(temp, sport->port.membase + UCR1); | 451 | imx_uart_writel(sport, temp, UCR1); |
442 | } else { | 452 | } else { |
443 | writel(temp, sport->port.membase + UCR1); | 453 | imx_uart_writel(sport, temp, UCR1); |
444 | imx_dma_tx(sport); | 454 | imx_dma_tx(sport); |
445 | } | 455 | } |
446 | } | 456 | } |
@@ -449,10 +459,10 @@ static inline void imx_transmit_buffer(struct imx_port *sport) | |||
449 | return; | 459 | return; |
450 | 460 | ||
451 | while (!uart_circ_empty(xmit) && | 461 | while (!uart_circ_empty(xmit) && |
452 | !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { | 462 | !(imx_uart_readl(sport, uts_reg(sport)) & UTS_TXFULL)) { |
453 | /* send xmit->buf[xmit->tail] | 463 | /* send xmit->buf[xmit->tail] |
454 | * out the port here */ | 464 | * out the port here */ |
455 | writel(xmit->buf[xmit->tail], sport->port.membase + URTX0); | 465 | imx_uart_writel(sport, xmit->buf[xmit->tail], URTX0); |
456 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 466 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
457 | sport->port.icount.tx++; | 467 | sport->port.icount.tx++; |
458 | } | 468 | } |
@@ -476,9 +486,9 @@ static void dma_tx_callback(void *data) | |||
476 | 486 | ||
477 | dma_unmap_sg(sport->port.dev, sgl, sport->dma_tx_nents, DMA_TO_DEVICE); | 487 | dma_unmap_sg(sport->port.dev, sgl, sport->dma_tx_nents, DMA_TO_DEVICE); |
478 | 488 | ||
479 | temp = readl(sport->port.membase + UCR1); | 489 | temp = imx_uart_readl(sport, UCR1); |
480 | temp &= ~UCR1_TXDMAEN; | 490 | temp &= ~UCR1_TXDMAEN; |
481 | writel(temp, sport->port.membase + UCR1); | 491 | imx_uart_writel(sport, temp, UCR1); |
482 | 492 | ||
483 | /* update the stat */ | 493 | /* update the stat */ |
484 | xmit->tail = (xmit->tail + sport->tx_bytes) & (UART_XMIT_SIZE - 1); | 494 | xmit->tail = (xmit->tail + sport->tx_bytes) & (UART_XMIT_SIZE - 1); |
@@ -543,9 +553,9 @@ static void imx_dma_tx(struct imx_port *sport) | |||
543 | dev_dbg(dev, "TX: prepare to send %lu bytes by DMA.\n", | 553 | dev_dbg(dev, "TX: prepare to send %lu bytes by DMA.\n", |
544 | uart_circ_chars_pending(xmit)); | 554 | uart_circ_chars_pending(xmit)); |
545 | 555 | ||
546 | temp = readl(sport->port.membase + UCR1); | 556 | temp = imx_uart_readl(sport, UCR1); |
547 | temp |= UCR1_TXDMAEN; | 557 | temp |= UCR1_TXDMAEN; |
548 | writel(temp, sport->port.membase + UCR1); | 558 | imx_uart_writel(sport, temp, UCR1); |
549 | 559 | ||
550 | /* fire it */ | 560 | /* fire it */ |
551 | sport->dma_is_txing = 1; | 561 | sport->dma_is_txing = 1; |
@@ -561,34 +571,34 @@ static void imx_start_tx(struct uart_port *port) | |||
561 | unsigned long temp; | 571 | unsigned long temp; |
562 | 572 | ||
563 | if (port->rs485.flags & SER_RS485_ENABLED) { | 573 | if (port->rs485.flags & SER_RS485_ENABLED) { |
564 | temp = readl(port->membase + UCR2); | 574 | temp = imx_uart_readl(sport, UCR2); |
565 | if (port->rs485.flags & SER_RS485_RTS_ON_SEND) | 575 | if (port->rs485.flags & SER_RS485_RTS_ON_SEND) |
566 | imx_port_rts_active(sport, &temp); | 576 | imx_port_rts_active(sport, &temp); |
567 | else | 577 | else |
568 | imx_port_rts_inactive(sport, &temp); | 578 | imx_port_rts_inactive(sport, &temp); |
569 | if (!(port->rs485.flags & SER_RS485_RX_DURING_TX)) | 579 | if (!(port->rs485.flags & SER_RS485_RX_DURING_TX)) |
570 | temp &= ~UCR2_RXEN; | 580 | temp &= ~UCR2_RXEN; |
571 | writel(temp, port->membase + UCR2); | 581 | imx_uart_writel(sport, temp, UCR2); |
572 | 582 | ||
573 | /* enable transmitter and shifter empty irq */ | 583 | /* enable transmitter and shifter empty irq */ |
574 | temp = readl(port->membase + UCR4); | 584 | temp = imx_uart_readl(sport, UCR4); |
575 | temp |= UCR4_TCEN; | 585 | temp |= UCR4_TCEN; |
576 | writel(temp, port->membase + UCR4); | 586 | imx_uart_writel(sport, temp, UCR4); |
577 | } | 587 | } |
578 | 588 | ||
579 | if (!sport->dma_is_enabled) { | 589 | if (!sport->dma_is_enabled) { |
580 | temp = readl(sport->port.membase + UCR1); | 590 | temp = imx_uart_readl(sport, UCR1); |
581 | writel(temp | UCR1_TXMPTYEN, sport->port.membase + UCR1); | 591 | imx_uart_writel(sport, temp | UCR1_TXMPTYEN, UCR1); |
582 | } | 592 | } |
583 | 593 | ||
584 | if (sport->dma_is_enabled) { | 594 | if (sport->dma_is_enabled) { |
585 | if (sport->port.x_char) { | 595 | if (sport->port.x_char) { |
586 | /* We have X-char to send, so enable TX IRQ and | 596 | /* We have X-char to send, so enable TX IRQ and |
587 | * disable TX DMA to let TX interrupt to send X-char */ | 597 | * disable TX DMA to let TX interrupt to send X-char */ |
588 | temp = readl(sport->port.membase + UCR1); | 598 | temp = imx_uart_readl(sport, UCR1); |
589 | temp &= ~UCR1_TXDMAEN; | 599 | temp &= ~UCR1_TXDMAEN; |
590 | temp |= UCR1_TXMPTYEN; | 600 | temp |= UCR1_TXMPTYEN; |
591 | writel(temp, sport->port.membase + UCR1); | 601 | imx_uart_writel(sport, temp, UCR1); |
592 | return; | 602 | return; |
593 | } | 603 | } |
594 | 604 | ||
@@ -607,8 +617,8 @@ static irqreturn_t imx_rtsint(int irq, void *dev_id) | |||
607 | 617 | ||
608 | spin_lock_irqsave(&sport->port.lock, flags); | 618 | spin_lock_irqsave(&sport->port.lock, flags); |
609 | 619 | ||
610 | writel(USR1_RTSD, sport->port.membase + USR1); | 620 | imx_uart_writel(sport, USR1_RTSD, USR1); |
611 | val = readl(sport->port.membase + USR1) & USR1_RTSS; | 621 | val = imx_uart_readl(sport, USR1) & USR1_RTSS; |
612 | uart_handle_cts_change(&sport->port, !!val); | 622 | uart_handle_cts_change(&sport->port, !!val); |
613 | wake_up_interruptible(&sport->port.state->port.delta_msr_wait); | 623 | wake_up_interruptible(&sport->port.state->port.delta_msr_wait); |
614 | 624 | ||
@@ -636,15 +646,15 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) | |||
636 | 646 | ||
637 | spin_lock_irqsave(&sport->port.lock, flags); | 647 | spin_lock_irqsave(&sport->port.lock, flags); |
638 | 648 | ||
639 | while (readl(sport->port.membase + USR2) & USR2_RDR) { | 649 | while (imx_uart_readl(sport, USR2) & USR2_RDR) { |
640 | flg = TTY_NORMAL; | 650 | flg = TTY_NORMAL; |
641 | sport->port.icount.rx++; | 651 | sport->port.icount.rx++; |
642 | 652 | ||
643 | rx = readl(sport->port.membase + URXD0); | 653 | rx = imx_uart_readl(sport, URXD0); |
644 | 654 | ||
645 | temp = readl(sport->port.membase + USR2); | 655 | temp = imx_uart_readl(sport, USR2); |
646 | if (temp & USR2_BRCD) { | 656 | if (temp & USR2_BRCD) { |
647 | writel(USR2_BRCD, sport->port.membase + USR2); | 657 | imx_uart_writel(sport, USR2_BRCD, USR2); |
648 | if (uart_handle_break(&sport->port)) | 658 | if (uart_handle_break(&sport->port)) |
649 | continue; | 659 | continue; |
650 | } | 660 | } |
@@ -705,8 +715,8 @@ static void clear_rx_errors(struct imx_port *sport); | |||
705 | static unsigned int imx_get_hwmctrl(struct imx_port *sport) | 715 | static unsigned int imx_get_hwmctrl(struct imx_port *sport) |
706 | { | 716 | { |
707 | unsigned int tmp = TIOCM_DSR; | 717 | unsigned int tmp = TIOCM_DSR; |
708 | unsigned usr1 = readl(sport->port.membase + USR1); | 718 | unsigned usr1 = imx_uart_readl(sport, USR1); |
709 | unsigned usr2 = readl(sport->port.membase + USR2); | 719 | unsigned usr2 = imx_uart_readl(sport, USR2); |
710 | 720 | ||
711 | if (usr1 & USR1_RTSS) | 721 | if (usr1 & USR1_RTSS) |
712 | tmp |= TIOCM_CTS; | 722 | tmp |= TIOCM_CTS; |
@@ -716,7 +726,7 @@ static unsigned int imx_get_hwmctrl(struct imx_port *sport) | |||
716 | tmp |= TIOCM_CAR; | 726 | tmp |= TIOCM_CAR; |
717 | 727 | ||
718 | if (sport->dte_mode) | 728 | if (sport->dte_mode) |
719 | if (!(readl(sport->port.membase + USR2) & USR2_RIIN)) | 729 | if (!(imx_uart_readl(sport, USR2) & USR2_RIIN)) |
720 | tmp |= TIOCM_RI; | 730 | tmp |= TIOCM_RI; |
721 | 731 | ||
722 | return tmp; | 732 | return tmp; |
@@ -755,12 +765,12 @@ static irqreturn_t imx_int(int irq, void *dev_id) | |||
755 | unsigned int usr1, usr2, ucr1, ucr2, ucr3, ucr4; | 765 | unsigned int usr1, usr2, ucr1, ucr2, ucr3, ucr4; |
756 | irqreturn_t ret = IRQ_NONE; | 766 | irqreturn_t ret = IRQ_NONE; |
757 | 767 | ||
758 | usr1 = readl(sport->port.membase + USR1); | 768 | usr1 = imx_uart_readl(sport, USR1); |
759 | usr2 = readl(sport->port.membase + USR2); | 769 | usr2 = imx_uart_readl(sport, USR2); |
760 | ucr1 = readl(sport->port.membase + UCR1); | 770 | ucr1 = imx_uart_readl(sport, UCR1); |
761 | ucr2 = readl(sport->port.membase + UCR2); | 771 | ucr2 = imx_uart_readl(sport, UCR2); |
762 | ucr3 = readl(sport->port.membase + UCR3); | 772 | ucr3 = imx_uart_readl(sport, UCR3); |
763 | ucr4 = readl(sport->port.membase + UCR4); | 773 | ucr4 = imx_uart_readl(sport, UCR4); |
764 | 774 | ||
765 | /* | 775 | /* |
766 | * Even if a condition is true that can trigger an irq only handle it if | 776 | * Even if a condition is true that can trigger an irq only handle it if |
@@ -800,7 +810,7 @@ static irqreturn_t imx_int(int irq, void *dev_id) | |||
800 | if (usr1 & USR1_DTRD) { | 810 | if (usr1 & USR1_DTRD) { |
801 | unsigned long flags; | 811 | unsigned long flags; |
802 | 812 | ||
803 | writel(USR1_DTRD, sport->port.membase + USR1); | 813 | imx_uart_writel(sport, USR1_DTRD, USR1); |
804 | 814 | ||
805 | spin_lock_irqsave(&sport->port.lock, flags); | 815 | spin_lock_irqsave(&sport->port.lock, flags); |
806 | imx_mctrl_check(sport); | 816 | imx_mctrl_check(sport); |
@@ -815,13 +825,13 @@ static irqreturn_t imx_int(int irq, void *dev_id) | |||
815 | } | 825 | } |
816 | 826 | ||
817 | if (usr1 & USR1_AWAKE) { | 827 | if (usr1 & USR1_AWAKE) { |
818 | writel(USR1_AWAKE, sport->port.membase + USR1); | 828 | imx_uart_writel(sport, USR1_AWAKE, USR1); |
819 | ret = IRQ_HANDLED; | 829 | ret = IRQ_HANDLED; |
820 | } | 830 | } |
821 | 831 | ||
822 | if (usr2 & USR2_ORE) { | 832 | if (usr2 & USR2_ORE) { |
823 | sport->port.icount.overrun++; | 833 | sport->port.icount.overrun++; |
824 | writel(USR2_ORE, sport->port.membase + USR2); | 834 | imx_uart_writel(sport, USR2_ORE, USR2); |
825 | ret = IRQ_HANDLED; | 835 | ret = IRQ_HANDLED; |
826 | } | 836 | } |
827 | 837 | ||
@@ -836,7 +846,7 @@ static unsigned int imx_tx_empty(struct uart_port *port) | |||
836 | struct imx_port *sport = (struct imx_port *)port; | 846 | struct imx_port *sport = (struct imx_port *)port; |
837 | unsigned int ret; | 847 | unsigned int ret; |
838 | 848 | ||
839 | ret = (readl(sport->port.membase + USR2) & USR2_TXDC) ? TIOCSER_TEMT : 0; | 849 | ret = (imx_uart_readl(sport, USR2) & USR2_TXDC) ? TIOCSER_TEMT : 0; |
840 | 850 | ||
841 | /* If the TX DMA is working, return 0. */ | 851 | /* If the TX DMA is working, return 0. */ |
842 | if (sport->dma_is_enabled && sport->dma_is_txing) | 852 | if (sport->dma_is_enabled && sport->dma_is_txing) |
@@ -863,22 +873,22 @@ static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl) | |||
863 | unsigned long temp; | 873 | unsigned long temp; |
864 | 874 | ||
865 | if (!(port->rs485.flags & SER_RS485_ENABLED)) { | 875 | if (!(port->rs485.flags & SER_RS485_ENABLED)) { |
866 | temp = readl(sport->port.membase + UCR2); | 876 | temp = imx_uart_readl(sport, UCR2); |
867 | temp &= ~(UCR2_CTS | UCR2_CTSC); | 877 | temp &= ~(UCR2_CTS | UCR2_CTSC); |
868 | if (mctrl & TIOCM_RTS) | 878 | if (mctrl & TIOCM_RTS) |
869 | temp |= UCR2_CTS | UCR2_CTSC; | 879 | temp |= UCR2_CTS | UCR2_CTSC; |
870 | writel(temp, sport->port.membase + UCR2); | 880 | imx_uart_writel(sport, temp, UCR2); |
871 | } | 881 | } |
872 | 882 | ||
873 | temp = readl(sport->port.membase + UCR3) & ~UCR3_DSR; | 883 | temp = imx_uart_readl(sport, UCR3) & ~UCR3_DSR; |
874 | if (!(mctrl & TIOCM_DTR)) | 884 | if (!(mctrl & TIOCM_DTR)) |
875 | temp |= UCR3_DSR; | 885 | temp |= UCR3_DSR; |
876 | writel(temp, sport->port.membase + UCR3); | 886 | imx_uart_writel(sport, temp, UCR3); |
877 | 887 | ||
878 | temp = readl(sport->port.membase + uts_reg(sport)) & ~UTS_LOOP; | 888 | temp = imx_uart_readl(sport, uts_reg(sport)) & ~UTS_LOOP; |
879 | if (mctrl & TIOCM_LOOP) | 889 | if (mctrl & TIOCM_LOOP) |
880 | temp |= UTS_LOOP; | 890 | temp |= UTS_LOOP; |
881 | writel(temp, sport->port.membase + uts_reg(sport)); | 891 | imx_uart_writel(sport, temp, uts_reg(sport)); |
882 | 892 | ||
883 | mctrl_gpio_set(sport->gpios, mctrl); | 893 | mctrl_gpio_set(sport->gpios, mctrl); |
884 | } | 894 | } |
@@ -893,12 +903,12 @@ static void imx_break_ctl(struct uart_port *port, int break_state) | |||
893 | 903 | ||
894 | spin_lock_irqsave(&sport->port.lock, flags); | 904 | spin_lock_irqsave(&sport->port.lock, flags); |
895 | 905 | ||
896 | temp = readl(sport->port.membase + UCR1) & ~UCR1_SNDBRK; | 906 | temp = imx_uart_readl(sport, UCR1) & ~UCR1_SNDBRK; |
897 | 907 | ||
898 | if (break_state != 0) | 908 | if (break_state != 0) |
899 | temp |= UCR1_SNDBRK; | 909 | temp |= UCR1_SNDBRK; |
900 | 910 | ||
901 | writel(temp, sport->port.membase + UCR1); | 911 | imx_uart_writel(sport, temp, UCR1); |
902 | 912 | ||
903 | spin_unlock_irqrestore(&sport->port.lock, flags); | 913 | spin_unlock_irqrestore(&sport->port.lock, flags); |
904 | } | 914 | } |
@@ -1050,12 +1060,12 @@ static void clear_rx_errors(struct imx_port *sport) | |||
1050 | struct tty_port *port = &sport->port.state->port; | 1060 | struct tty_port *port = &sport->port.state->port; |
1051 | unsigned int status_usr1, status_usr2; | 1061 | unsigned int status_usr1, status_usr2; |
1052 | 1062 | ||
1053 | status_usr1 = readl(sport->port.membase + USR1); | 1063 | status_usr1 = imx_uart_readl(sport, USR1); |
1054 | status_usr2 = readl(sport->port.membase + USR2); | 1064 | status_usr2 = imx_uart_readl(sport, USR2); |
1055 | 1065 | ||
1056 | if (status_usr2 & USR2_BRCD) { | 1066 | if (status_usr2 & USR2_BRCD) { |
1057 | sport->port.icount.brk++; | 1067 | sport->port.icount.brk++; |
1058 | writel(USR2_BRCD, sport->port.membase + USR2); | 1068 | imx_uart_writel(sport, USR2_BRCD, USR2); |
1059 | uart_handle_break(&sport->port); | 1069 | uart_handle_break(&sport->port); |
1060 | if (tty_insert_flip_char(port, 0, TTY_BREAK) == 0) | 1070 | if (tty_insert_flip_char(port, 0, TTY_BREAK) == 0) |
1061 | sport->port.icount.buf_overrun++; | 1071 | sport->port.icount.buf_overrun++; |
@@ -1064,16 +1074,16 @@ static void clear_rx_errors(struct imx_port *sport) | |||
1064 | dev_err(sport->port.dev, "DMA transaction error.\n"); | 1074 | dev_err(sport->port.dev, "DMA transaction error.\n"); |
1065 | if (status_usr1 & USR1_FRAMERR) { | 1075 | if (status_usr1 & USR1_FRAMERR) { |
1066 | sport->port.icount.frame++; | 1076 | sport->port.icount.frame++; |
1067 | writel(USR1_FRAMERR, sport->port.membase + USR1); | 1077 | imx_uart_writel(sport, USR1_FRAMERR, USR1); |
1068 | } else if (status_usr1 & USR1_PARITYERR) { | 1078 | } else if (status_usr1 & USR1_PARITYERR) { |
1069 | sport->port.icount.parity++; | 1079 | sport->port.icount.parity++; |
1070 | writel(USR1_PARITYERR, sport->port.membase + USR1); | 1080 | imx_uart_writel(sport, USR1_PARITYERR, USR1); |
1071 | } | 1081 | } |
1072 | } | 1082 | } |
1073 | 1083 | ||
1074 | if (status_usr2 & USR2_ORE) { | 1084 | if (status_usr2 & USR2_ORE) { |
1075 | sport->port.icount.overrun++; | 1085 | sport->port.icount.overrun++; |
1076 | writel(USR2_ORE, sport->port.membase + USR2); | 1086 | imx_uart_writel(sport, USR2_ORE, USR2); |
1077 | } | 1087 | } |
1078 | 1088 | ||
1079 | } | 1089 | } |
@@ -1089,9 +1099,9 @@ static void imx_setup_ufcr(struct imx_port *sport, | |||
1089 | unsigned int val; | 1099 | unsigned int val; |
1090 | 1100 | ||
1091 | /* set receiver / transmitter trigger level */ | 1101 | /* set receiver / transmitter trigger level */ |
1092 | val = readl(sport->port.membase + UFCR) & (UFCR_RFDIV | UFCR_DCEDTE); | 1102 | val = imx_uart_readl(sport, UFCR) & (UFCR_RFDIV | UFCR_DCEDTE); |
1093 | val |= txwl << UFCR_TXTL_SHF | rxwl; | 1103 | val |= txwl << UFCR_TXTL_SHF | rxwl; |
1094 | writel(val, sport->port.membase + UFCR); | 1104 | imx_uart_writel(sport, val, UFCR); |
1095 | } | 1105 | } |
1096 | 1106 | ||
1097 | static void imx_uart_dma_exit(struct imx_port *sport) | 1107 | static void imx_uart_dma_exit(struct imx_port *sport) |
@@ -1173,9 +1183,9 @@ static void imx_enable_dma(struct imx_port *sport) | |||
1173 | unsigned long temp; | 1183 | unsigned long temp; |
1174 | 1184 | ||
1175 | /* set UCR1 */ | 1185 | /* set UCR1 */ |
1176 | temp = readl(sport->port.membase + UCR1); | 1186 | temp = imx_uart_readl(sport, UCR1); |
1177 | temp |= UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN; | 1187 | temp |= UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN; |
1178 | writel(temp, sport->port.membase + UCR1); | 1188 | imx_uart_writel(sport, temp, UCR1); |
1179 | 1189 | ||
1180 | imx_setup_ufcr(sport, TXTL_DMA, RXTL_DMA); | 1190 | imx_setup_ufcr(sport, TXTL_DMA, RXTL_DMA); |
1181 | 1191 | ||
@@ -1187,14 +1197,14 @@ static void imx_disable_dma(struct imx_port *sport) | |||
1187 | unsigned long temp; | 1197 | unsigned long temp; |
1188 | 1198 | ||
1189 | /* clear UCR1 */ | 1199 | /* clear UCR1 */ |
1190 | temp = readl(sport->port.membase + UCR1); | 1200 | temp = imx_uart_readl(sport, UCR1); |
1191 | temp &= ~(UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN); | 1201 | temp &= ~(UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN); |
1192 | writel(temp, sport->port.membase + UCR1); | 1202 | imx_uart_writel(sport, temp, UCR1); |
1193 | 1203 | ||
1194 | /* clear UCR2 */ | 1204 | /* clear UCR2 */ |
1195 | temp = readl(sport->port.membase + UCR2); | 1205 | temp = imx_uart_readl(sport, UCR2); |
1196 | temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN); | 1206 | temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN); |
1197 | writel(temp, sport->port.membase + UCR2); | 1207 | imx_uart_writel(sport, temp, UCR2); |
1198 | 1208 | ||
1199 | imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT); | 1209 | imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT); |
1200 | 1210 | ||
@@ -1225,13 +1235,13 @@ static int imx_startup(struct uart_port *port) | |||
1225 | /* disable the DREN bit (Data Ready interrupt enable) before | 1235 | /* disable the DREN bit (Data Ready interrupt enable) before |
1226 | * requesting IRQs | 1236 | * requesting IRQs |
1227 | */ | 1237 | */ |
1228 | temp = readl(sport->port.membase + UCR4); | 1238 | temp = imx_uart_readl(sport, UCR4); |
1229 | 1239 | ||
1230 | /* set the trigger level for CTS */ | 1240 | /* set the trigger level for CTS */ |
1231 | temp &= ~(UCR4_CTSTL_MASK << UCR4_CTSTL_SHF); | 1241 | temp &= ~(UCR4_CTSTL_MASK << UCR4_CTSTL_SHF); |
1232 | temp |= CTSTL << UCR4_CTSTL_SHF; | 1242 | temp |= CTSTL << UCR4_CTSTL_SHF; |
1233 | 1243 | ||
1234 | writel(temp & ~UCR4_DREN, sport->port.membase + UCR4); | 1244 | imx_uart_writel(sport, temp & ~UCR4_DREN, UCR4); |
1235 | 1245 | ||
1236 | /* Can we enable the DMA support? */ | 1246 | /* Can we enable the DMA support? */ |
1237 | if (!uart_console(port) && imx_uart_dma_init(sport) == 0) | 1247 | if (!uart_console(port) && imx_uart_dma_init(sport) == 0) |
@@ -1241,37 +1251,37 @@ static int imx_startup(struct uart_port *port) | |||
1241 | /* Reset fifo's and state machines */ | 1251 | /* Reset fifo's and state machines */ |
1242 | i = 100; | 1252 | i = 100; |
1243 | 1253 | ||
1244 | temp = readl(sport->port.membase + UCR2); | 1254 | temp = imx_uart_readl(sport, UCR2); |
1245 | temp &= ~UCR2_SRST; | 1255 | temp &= ~UCR2_SRST; |
1246 | writel(temp, sport->port.membase + UCR2); | 1256 | imx_uart_writel(sport, temp, UCR2); |
1247 | 1257 | ||
1248 | while (!(readl(sport->port.membase + UCR2) & UCR2_SRST) && (--i > 0)) | 1258 | while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) |
1249 | udelay(1); | 1259 | udelay(1); |
1250 | 1260 | ||
1251 | /* | 1261 | /* |
1252 | * Finally, clear and enable interrupts | 1262 | * Finally, clear and enable interrupts |
1253 | */ | 1263 | */ |
1254 | writel(USR1_RTSD | USR1_DTRD, sport->port.membase + USR1); | 1264 | imx_uart_writel(sport, USR1_RTSD | USR1_DTRD, USR1); |
1255 | writel(USR2_ORE, sport->port.membase + USR2); | 1265 | imx_uart_writel(sport, USR2_ORE, USR2); |
1256 | 1266 | ||
1257 | if (dma_is_inited) | 1267 | if (dma_is_inited) |
1258 | imx_enable_dma(sport); | 1268 | imx_enable_dma(sport); |
1259 | 1269 | ||
1260 | temp = readl(sport->port.membase + UCR1) & ~UCR1_RRDYEN; | 1270 | temp = imx_uart_readl(sport, UCR1) & ~UCR1_RRDYEN; |
1261 | if (!sport->dma_is_enabled) | 1271 | if (!sport->dma_is_enabled) |
1262 | temp |= UCR1_RRDYEN; | 1272 | temp |= UCR1_RRDYEN; |
1263 | temp |= UCR1_UARTEN; | 1273 | temp |= UCR1_UARTEN; |
1264 | if (sport->have_rtscts) | 1274 | if (sport->have_rtscts) |
1265 | temp |= UCR1_RTSDEN; | 1275 | temp |= UCR1_RTSDEN; |
1266 | 1276 | ||
1267 | writel(temp, sport->port.membase + UCR1); | 1277 | imx_uart_writel(sport, temp, UCR1); |
1268 | 1278 | ||
1269 | temp = readl(sport->port.membase + UCR4) & ~UCR4_OREN; | 1279 | temp = imx_uart_readl(sport, UCR4) & ~UCR4_OREN; |
1270 | if (!sport->dma_is_enabled) | 1280 | if (!sport->dma_is_enabled) |
1271 | temp |= UCR4_OREN; | 1281 | temp |= UCR4_OREN; |
1272 | writel(temp, sport->port.membase + UCR4); | 1282 | imx_uart_writel(sport, temp, UCR4); |
1273 | 1283 | ||
1274 | temp = readl(sport->port.membase + UCR2) & ~UCR2_ATEN; | 1284 | temp = imx_uart_readl(sport, UCR2) & ~UCR2_ATEN; |
1275 | temp |= (UCR2_RXEN | UCR2_TXEN); | 1285 | temp |= (UCR2_RXEN | UCR2_TXEN); |
1276 | if (!sport->have_rtscts) | 1286 | if (!sport->have_rtscts) |
1277 | temp |= UCR2_IRTS; | 1287 | temp |= UCR2_IRTS; |
@@ -1281,10 +1291,10 @@ static int imx_startup(struct uart_port *port) | |||
1281 | */ | 1291 | */ |
1282 | if (!is_imx1_uart(sport)) | 1292 | if (!is_imx1_uart(sport)) |
1283 | temp &= ~UCR2_RTSEN; | 1293 | temp &= ~UCR2_RTSEN; |
1284 | writel(temp, sport->port.membase + UCR2); | 1294 | imx_uart_writel(sport, temp, UCR2); |
1285 | 1295 | ||
1286 | if (!is_imx1_uart(sport)) { | 1296 | if (!is_imx1_uart(sport)) { |
1287 | temp = readl(sport->port.membase + UCR3); | 1297 | temp = imx_uart_readl(sport, UCR3); |
1288 | 1298 | ||
1289 | temp |= UCR3_DTRDEN | UCR3_RI | UCR3_DCD; | 1299 | temp |= UCR3_DTRDEN | UCR3_RI | UCR3_DCD; |
1290 | 1300 | ||
@@ -1292,7 +1302,7 @@ static int imx_startup(struct uart_port *port) | |||
1292 | /* disable broken interrupts */ | 1302 | /* disable broken interrupts */ |
1293 | temp &= ~(UCR3_RI | UCR3_DCD); | 1303 | temp &= ~(UCR3_RI | UCR3_DCD); |
1294 | 1304 | ||
1295 | writel(temp, sport->port.membase + UCR3); | 1305 | imx_uart_writel(sport, temp, UCR3); |
1296 | } | 1306 | } |
1297 | 1307 | ||
1298 | /* | 1308 | /* |
@@ -1336,9 +1346,9 @@ static void imx_shutdown(struct uart_port *port) | |||
1336 | mctrl_gpio_disable_ms(sport->gpios); | 1346 | mctrl_gpio_disable_ms(sport->gpios); |
1337 | 1347 | ||
1338 | spin_lock_irqsave(&sport->port.lock, flags); | 1348 | spin_lock_irqsave(&sport->port.lock, flags); |
1339 | temp = readl(sport->port.membase + UCR2); | 1349 | temp = imx_uart_readl(sport, UCR2); |
1340 | temp &= ~(UCR2_TXEN); | 1350 | temp &= ~(UCR2_TXEN); |
1341 | writel(temp, sport->port.membase + UCR2); | 1351 | imx_uart_writel(sport, temp, UCR2); |
1342 | spin_unlock_irqrestore(&sport->port.lock, flags); | 1352 | spin_unlock_irqrestore(&sport->port.lock, flags); |
1343 | 1353 | ||
1344 | /* | 1354 | /* |
@@ -1351,10 +1361,10 @@ static void imx_shutdown(struct uart_port *port) | |||
1351 | */ | 1361 | */ |
1352 | 1362 | ||
1353 | spin_lock_irqsave(&sport->port.lock, flags); | 1363 | spin_lock_irqsave(&sport->port.lock, flags); |
1354 | temp = readl(sport->port.membase + UCR1); | 1364 | temp = imx_uart_readl(sport, UCR1); |
1355 | temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); | 1365 | temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); |
1356 | 1366 | ||
1357 | writel(temp, sport->port.membase + UCR1); | 1367 | imx_uart_writel(sport, temp, UCR1); |
1358 | spin_unlock_irqrestore(&sport->port.lock, flags); | 1368 | spin_unlock_irqrestore(&sport->port.lock, flags); |
1359 | 1369 | ||
1360 | clk_disable_unprepare(sport->clk_per); | 1370 | clk_disable_unprepare(sport->clk_per); |
@@ -1377,9 +1387,9 @@ static void imx_flush_buffer(struct uart_port *port) | |||
1377 | if (sport->dma_is_txing) { | 1387 | if (sport->dma_is_txing) { |
1378 | dma_unmap_sg(sport->port.dev, sgl, sport->dma_tx_nents, | 1388 | dma_unmap_sg(sport->port.dev, sgl, sport->dma_tx_nents, |
1379 | DMA_TO_DEVICE); | 1389 | DMA_TO_DEVICE); |
1380 | temp = readl(sport->port.membase + UCR1); | 1390 | temp = imx_uart_readl(sport, UCR1); |
1381 | temp &= ~UCR1_TXDMAEN; | 1391 | temp &= ~UCR1_TXDMAEN; |
1382 | writel(temp, sport->port.membase + UCR1); | 1392 | imx_uart_writel(sport, temp, UCR1); |
1383 | sport->dma_is_txing = 0; | 1393 | sport->dma_is_txing = 0; |
1384 | } | 1394 | } |
1385 | 1395 | ||
@@ -1394,21 +1404,21 @@ static void imx_flush_buffer(struct uart_port *port) | |||
1394 | * UTXD. UBRC is read only, so only save/restore the other three | 1404 | * UTXD. UBRC is read only, so only save/restore the other three |
1395 | * registers. | 1405 | * registers. |
1396 | */ | 1406 | */ |
1397 | ubir = readl(sport->port.membase + UBIR); | 1407 | ubir = imx_uart_readl(sport, UBIR); |
1398 | ubmr = readl(sport->port.membase + UBMR); | 1408 | ubmr = imx_uart_readl(sport, UBMR); |
1399 | uts = readl(sport->port.membase + IMX21_UTS); | 1409 | uts = imx_uart_readl(sport, IMX21_UTS); |
1400 | 1410 | ||
1401 | temp = readl(sport->port.membase + UCR2); | 1411 | temp = imx_uart_readl(sport, UCR2); |
1402 | temp &= ~UCR2_SRST; | 1412 | temp &= ~UCR2_SRST; |
1403 | writel(temp, sport->port.membase + UCR2); | 1413 | imx_uart_writel(sport, temp, UCR2); |
1404 | 1414 | ||
1405 | while (!(readl(sport->port.membase + UCR2) & UCR2_SRST) && (--i > 0)) | 1415 | while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) |
1406 | udelay(1); | 1416 | udelay(1); |
1407 | 1417 | ||
1408 | /* Restore the registers */ | 1418 | /* Restore the registers */ |
1409 | writel(ubir, sport->port.membase + UBIR); | 1419 | imx_uart_writel(sport, ubir, UBIR); |
1410 | writel(ubmr, sport->port.membase + UBMR); | 1420 | imx_uart_writel(sport, ubmr, UBMR); |
1411 | writel(uts, sport->port.membase + IMX21_UTS); | 1421 | imx_uart_writel(sport, uts, IMX21_UTS); |
1412 | } | 1422 | } |
1413 | 1423 | ||
1414 | static void | 1424 | static void |
@@ -1520,17 +1530,17 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1520 | /* | 1530 | /* |
1521 | * disable interrupts and drain transmitter | 1531 | * disable interrupts and drain transmitter |
1522 | */ | 1532 | */ |
1523 | old_ucr1 = readl(sport->port.membase + UCR1); | 1533 | old_ucr1 = imx_uart_readl(sport, UCR1); |
1524 | writel(old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN), | 1534 | imx_uart_writel(sport, |
1525 | sport->port.membase + UCR1); | 1535 | old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN), |
1536 | UCR1); | ||
1526 | 1537 | ||
1527 | while (!(readl(sport->port.membase + USR2) & USR2_TXDC)) | 1538 | while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)) |
1528 | barrier(); | 1539 | barrier(); |
1529 | 1540 | ||
1530 | /* then, disable everything */ | 1541 | /* then, disable everything */ |
1531 | old_ucr2 = readl(sport->port.membase + UCR2); | 1542 | old_ucr2 = imx_uart_readl(sport, UCR2); |
1532 | writel(old_ucr2 & ~(UCR2_TXEN | UCR2_RXEN), | 1543 | imx_uart_writel(sport, old_ucr2 & ~(UCR2_TXEN | UCR2_RXEN), UCR2); |
1533 | sport->port.membase + UCR2); | ||
1534 | old_ucr2 &= (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN); | 1544 | old_ucr2 &= (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN); |
1535 | 1545 | ||
1536 | /* custom-baudrate handling */ | 1546 | /* custom-baudrate handling */ |
@@ -1556,21 +1566,21 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1556 | num -= 1; | 1566 | num -= 1; |
1557 | denom -= 1; | 1567 | denom -= 1; |
1558 | 1568 | ||
1559 | ufcr = readl(sport->port.membase + UFCR); | 1569 | ufcr = imx_uart_readl(sport, UFCR); |
1560 | ufcr = (ufcr & (~UFCR_RFDIV)) | UFCR_RFDIV_REG(div); | 1570 | ufcr = (ufcr & (~UFCR_RFDIV)) | UFCR_RFDIV_REG(div); |
1561 | writel(ufcr, sport->port.membase + UFCR); | 1571 | imx_uart_writel(sport, ufcr, UFCR); |
1562 | 1572 | ||
1563 | writel(num, sport->port.membase + UBIR); | 1573 | imx_uart_writel(sport, num, UBIR); |
1564 | writel(denom, sport->port.membase + UBMR); | 1574 | imx_uart_writel(sport, denom, UBMR); |
1565 | 1575 | ||
1566 | if (!is_imx1_uart(sport)) | 1576 | if (!is_imx1_uart(sport)) |
1567 | writel(sport->port.uartclk / div / 1000, | 1577 | imx_uart_writel(sport, sport->port.uartclk / div / 1000, |
1568 | sport->port.membase + IMX21_ONEMS); | 1578 | IMX21_ONEMS); |
1569 | 1579 | ||
1570 | writel(old_ucr1, sport->port.membase + UCR1); | 1580 | imx_uart_writel(sport, old_ucr1, UCR1); |
1571 | 1581 | ||
1572 | /* set the parity, stop bits and data size */ | 1582 | /* set the parity, stop bits and data size */ |
1573 | writel(ucr2 | old_ucr2, sport->port.membase + UCR2); | 1583 | imx_uart_writel(sport, ucr2 | old_ucr2, UCR2); |
1574 | 1584 | ||
1575 | if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) | 1585 | if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) |
1576 | imx_enable_ms(&sport->port); | 1586 | imx_enable_ms(&sport->port); |
@@ -1644,16 +1654,16 @@ static int imx_poll_init(struct uart_port *port) | |||
1644 | 1654 | ||
1645 | spin_lock_irqsave(&sport->port.lock, flags); | 1655 | spin_lock_irqsave(&sport->port.lock, flags); |
1646 | 1656 | ||
1647 | temp = readl(sport->port.membase + UCR1); | 1657 | temp = imx_uart_readl(sport, UCR1); |
1648 | if (is_imx1_uart(sport)) | 1658 | if (is_imx1_uart(sport)) |
1649 | temp |= IMX1_UCR1_UARTCLKEN; | 1659 | temp |= IMX1_UCR1_UARTCLKEN; |
1650 | temp |= UCR1_UARTEN | UCR1_RRDYEN; | 1660 | temp |= UCR1_UARTEN | UCR1_RRDYEN; |
1651 | temp &= ~(UCR1_TXMPTYEN | UCR1_RTSDEN); | 1661 | temp &= ~(UCR1_TXMPTYEN | UCR1_RTSDEN); |
1652 | writel(temp, sport->port.membase + UCR1); | 1662 | imx_uart_writel(sport, temp, UCR1); |
1653 | 1663 | ||
1654 | temp = readl(sport->port.membase + UCR2); | 1664 | temp = imx_uart_readl(sport, UCR2); |
1655 | temp |= UCR2_RXEN; | 1665 | temp |= UCR2_RXEN; |
1656 | writel(temp, sport->port.membase + UCR2); | 1666 | imx_uart_writel(sport, temp, UCR2); |
1657 | 1667 | ||
1658 | spin_unlock_irqrestore(&sport->port.lock, flags); | 1668 | spin_unlock_irqrestore(&sport->port.lock, flags); |
1659 | 1669 | ||
@@ -1662,27 +1672,29 @@ static int imx_poll_init(struct uart_port *port) | |||
1662 | 1672 | ||
1663 | static int imx_poll_get_char(struct uart_port *port) | 1673 | static int imx_poll_get_char(struct uart_port *port) |
1664 | { | 1674 | { |
1665 | if (!(readl_relaxed(port->membase + USR2) & USR2_RDR)) | 1675 | struct imx_port *sport = (struct imx_port *)port; |
1676 | if (!(imx_uart_readl(sport, USR2) & USR2_RDR)) | ||
1666 | return NO_POLL_CHAR; | 1677 | return NO_POLL_CHAR; |
1667 | 1678 | ||
1668 | return readl_relaxed(port->membase + URXD0) & URXD_RX_DATA; | 1679 | return imx_uart_readl(sport, URXD0) & URXD_RX_DATA; |
1669 | } | 1680 | } |
1670 | 1681 | ||
1671 | static void imx_poll_put_char(struct uart_port *port, unsigned char c) | 1682 | static void imx_poll_put_char(struct uart_port *port, unsigned char c) |
1672 | { | 1683 | { |
1684 | struct imx_port *sport = (struct imx_port *)port; | ||
1673 | unsigned int status; | 1685 | unsigned int status; |
1674 | 1686 | ||
1675 | /* drain */ | 1687 | /* drain */ |
1676 | do { | 1688 | do { |
1677 | status = readl_relaxed(port->membase + USR1); | 1689 | status = imx_uart_readl(sport, USR1); |
1678 | } while (~status & USR1_TRDY); | 1690 | } while (~status & USR1_TRDY); |
1679 | 1691 | ||
1680 | /* write */ | 1692 | /* write */ |
1681 | writel_relaxed(c, port->membase + URTX0); | 1693 | imx_uart_writel(sport, c, URTX0); |
1682 | 1694 | ||
1683 | /* flush */ | 1695 | /* flush */ |
1684 | do { | 1696 | do { |
1685 | status = readl_relaxed(port->membase + USR2); | 1697 | status = imx_uart_readl(sport, USR2); |
1686 | } while (~status & USR2_TXDC); | 1698 | } while (~status & USR2_TXDC); |
1687 | } | 1699 | } |
1688 | #endif | 1700 | #endif |
@@ -1704,20 +1716,20 @@ static int imx_rs485_config(struct uart_port *port, | |||
1704 | 1716 | ||
1705 | if (rs485conf->flags & SER_RS485_ENABLED) { | 1717 | if (rs485conf->flags & SER_RS485_ENABLED) { |
1706 | /* disable transmitter */ | 1718 | /* disable transmitter */ |
1707 | temp = readl(sport->port.membase + UCR2); | 1719 | temp = imx_uart_readl(sport, UCR2); |
1708 | if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) | 1720 | if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) |
1709 | imx_port_rts_active(sport, &temp); | 1721 | imx_port_rts_active(sport, &temp); |
1710 | else | 1722 | else |
1711 | imx_port_rts_inactive(sport, &temp); | 1723 | imx_port_rts_inactive(sport, &temp); |
1712 | writel(temp, sport->port.membase + UCR2); | 1724 | imx_uart_writel(sport, temp, UCR2); |
1713 | } | 1725 | } |
1714 | 1726 | ||
1715 | /* Make sure Rx is enabled in case Tx is active with Rx disabled */ | 1727 | /* Make sure Rx is enabled in case Tx is active with Rx disabled */ |
1716 | if (!(rs485conf->flags & SER_RS485_ENABLED) || | 1728 | if (!(rs485conf->flags & SER_RS485_ENABLED) || |
1717 | rs485conf->flags & SER_RS485_RX_DURING_TX) { | 1729 | rs485conf->flags & SER_RS485_RX_DURING_TX) { |
1718 | temp = readl(sport->port.membase + UCR2); | 1730 | temp = imx_uart_readl(sport, UCR2); |
1719 | temp |= UCR2_RXEN; | 1731 | temp |= UCR2_RXEN; |
1720 | writel(temp, sport->port.membase + UCR2); | 1732 | imx_uart_writel(sport, temp, UCR2); |
1721 | } | 1733 | } |
1722 | 1734 | ||
1723 | port->rs485 = *rs485conf; | 1735 | port->rs485 = *rs485conf; |
@@ -1755,10 +1767,10 @@ static void imx_console_putchar(struct uart_port *port, int ch) | |||
1755 | { | 1767 | { |
1756 | struct imx_port *sport = (struct imx_port *)port; | 1768 | struct imx_port *sport = (struct imx_port *)port; |
1757 | 1769 | ||
1758 | while (readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL) | 1770 | while (imx_uart_readl(sport, uts_reg(sport)) & UTS_TXFULL) |
1759 | barrier(); | 1771 | barrier(); |
1760 | 1772 | ||
1761 | writel(ch, sport->port.membase + URTX0); | 1773 | imx_uart_writel(sport, ch, URTX0); |
1762 | } | 1774 | } |
1763 | 1775 | ||
1764 | /* | 1776 | /* |
@@ -1793,7 +1805,7 @@ imx_console_write(struct console *co, const char *s, unsigned int count) | |||
1793 | /* | 1805 | /* |
1794 | * First, save UCR1/2/3 and then disable interrupts | 1806 | * First, save UCR1/2/3 and then disable interrupts |
1795 | */ | 1807 | */ |
1796 | imx_port_ucrs_save(&sport->port, &old_ucr); | 1808 | imx_port_ucrs_save(sport, &old_ucr); |
1797 | ucr1 = old_ucr.ucr1; | 1809 | ucr1 = old_ucr.ucr1; |
1798 | 1810 | ||
1799 | if (is_imx1_uart(sport)) | 1811 | if (is_imx1_uart(sport)) |
@@ -1801,9 +1813,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count) | |||
1801 | ucr1 |= UCR1_UARTEN; | 1813 | ucr1 |= UCR1_UARTEN; |
1802 | ucr1 &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); | 1814 | ucr1 &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); |
1803 | 1815 | ||
1804 | writel(ucr1, sport->port.membase + UCR1); | 1816 | imx_uart_writel(sport, ucr1, UCR1); |
1805 | 1817 | ||
1806 | writel(old_ucr.ucr2 | UCR2_TXEN, sport->port.membase + UCR2); | 1818 | imx_uart_writel(sport, old_ucr.ucr2 | UCR2_TXEN, UCR2); |
1807 | 1819 | ||
1808 | uart_console_write(&sport->port, s, count, imx_console_putchar); | 1820 | uart_console_write(&sport->port, s, count, imx_console_putchar); |
1809 | 1821 | ||
@@ -1811,9 +1823,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count) | |||
1811 | * Finally, wait for transmitter to become empty | 1823 | * Finally, wait for transmitter to become empty |
1812 | * and restore UCR1/2/3 | 1824 | * and restore UCR1/2/3 |
1813 | */ | 1825 | */ |
1814 | while (!(readl(sport->port.membase + USR2) & USR2_TXDC)); | 1826 | while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)); |
1815 | 1827 | ||
1816 | imx_port_ucrs_restore(&sport->port, &old_ucr); | 1828 | imx_port_ucrs_restore(sport, &old_ucr); |
1817 | 1829 | ||
1818 | if (locked) | 1830 | if (locked) |
1819 | spin_unlock_irqrestore(&sport->port.lock, flags); | 1831 | spin_unlock_irqrestore(&sport->port.lock, flags); |
@@ -1831,13 +1843,13 @@ imx_console_get_options(struct imx_port *sport, int *baud, | |||
1831 | int *parity, int *bits) | 1843 | int *parity, int *bits) |
1832 | { | 1844 | { |
1833 | 1845 | ||
1834 | if (readl(sport->port.membase + UCR1) & UCR1_UARTEN) { | 1846 | if (imx_uart_readl(sport, UCR1) & UCR1_UARTEN) { |
1835 | /* ok, the port was enabled */ | 1847 | /* ok, the port was enabled */ |
1836 | unsigned int ucr2, ubir, ubmr, uartclk; | 1848 | unsigned int ucr2, ubir, ubmr, uartclk; |
1837 | unsigned int baud_raw; | 1849 | unsigned int baud_raw; |
1838 | unsigned int ucfr_rfdiv; | 1850 | unsigned int ucfr_rfdiv; |
1839 | 1851 | ||
1840 | ucr2 = readl(sport->port.membase + UCR2); | 1852 | ucr2 = imx_uart_readl(sport, UCR2); |
1841 | 1853 | ||
1842 | *parity = 'n'; | 1854 | *parity = 'n'; |
1843 | if (ucr2 & UCR2_PREN) { | 1855 | if (ucr2 & UCR2_PREN) { |
@@ -1852,10 +1864,10 @@ imx_console_get_options(struct imx_port *sport, int *baud, | |||
1852 | else | 1864 | else |
1853 | *bits = 7; | 1865 | *bits = 7; |
1854 | 1866 | ||
1855 | ubir = readl(sport->port.membase + UBIR) & 0xffff; | 1867 | ubir = imx_uart_readl(sport, UBIR) & 0xffff; |
1856 | ubmr = readl(sport->port.membase + UBMR) & 0xffff; | 1868 | ubmr = imx_uart_readl(sport, UBMR) & 0xffff; |
1857 | 1869 | ||
1858 | ucfr_rfdiv = (readl(sport->port.membase + UFCR) & UFCR_RFDIV) >> 7; | 1870 | ucfr_rfdiv = (imx_uart_readl(sport, UFCR) & UFCR_RFDIV) >> 7; |
1859 | if (ucfr_rfdiv == 6) | 1871 | if (ucfr_rfdiv == 6) |
1860 | ucfr_rfdiv = 7; | 1872 | ucfr_rfdiv = 7; |
1861 | else | 1873 | else |
@@ -1950,10 +1962,12 @@ static struct console imx_console = { | |||
1950 | #ifdef CONFIG_OF | 1962 | #ifdef CONFIG_OF |
1951 | static void imx_console_early_putchar(struct uart_port *port, int ch) | 1963 | static void imx_console_early_putchar(struct uart_port *port, int ch) |
1952 | { | 1964 | { |
1953 | while (readl_relaxed(port->membase + IMX21_UTS) & UTS_TXFULL) | 1965 | struct imx_port *sport = (struct imx_port *)port; |
1966 | |||
1967 | while (imx_uart_readl(sport, IMX21_UTS) & UTS_TXFULL) | ||
1954 | cpu_relax(); | 1968 | cpu_relax(); |
1955 | 1969 | ||
1956 | writel_relaxed(ch, port->membase + URTX0); | 1970 | imx_uart_writel(sport, ch, URTX0); |
1957 | } | 1971 | } |
1958 | 1972 | ||
1959 | static void imx_console_early_write(struct console *con, const char *s, | 1973 | static void imx_console_early_write(struct console *con, const char *s, |
@@ -2131,10 +2145,10 @@ static int serial_imx_probe(struct platform_device *pdev) | |||
2131 | imx_rs485_config(&sport->port, &sport->port.rs485); | 2145 | imx_rs485_config(&sport->port, &sport->port.rs485); |
2132 | 2146 | ||
2133 | /* Disable interrupts before requesting them */ | 2147 | /* Disable interrupts before requesting them */ |
2134 | reg = readl_relaxed(sport->port.membase + UCR1); | 2148 | reg = imx_uart_readl(sport, UCR1); |
2135 | reg &= ~(UCR1_ADEN | UCR1_TRDYEN | UCR1_IDEN | UCR1_RRDYEN | | 2149 | reg &= ~(UCR1_ADEN | UCR1_TRDYEN | UCR1_IDEN | UCR1_RRDYEN | |
2136 | UCR1_TXMPTYEN | UCR1_RTSDEN); | 2150 | UCR1_TXMPTYEN | UCR1_RTSDEN); |
2137 | writel_relaxed(reg, sport->port.membase + UCR1); | 2151 | imx_uart_writel(sport, reg, UCR1); |
2138 | 2152 | ||
2139 | if (!is_imx1_uart(sport) && sport->dte_mode) { | 2153 | if (!is_imx1_uart(sport) && sport->dte_mode) { |
2140 | /* | 2154 | /* |
@@ -2143,28 +2157,29 @@ static int serial_imx_probe(struct platform_device *pdev) | |||
2143 | * and DCD (when they are outputs) or enables the respective | 2157 | * and DCD (when they are outputs) or enables the respective |
2144 | * irqs. So set this bit early, i.e. before requesting irqs. | 2158 | * irqs. So set this bit early, i.e. before requesting irqs. |
2145 | */ | 2159 | */ |
2146 | reg = readl(sport->port.membase + UFCR); | 2160 | reg = imx_uart_readl(sport, UFCR); |
2147 | if (!(reg & UFCR_DCEDTE)) | 2161 | if (!(reg & UFCR_DCEDTE)) |
2148 | writel(reg | UFCR_DCEDTE, sport->port.membase + UFCR); | 2162 | imx_uart_writel(sport, reg | UFCR_DCEDTE, UFCR); |
2149 | 2163 | ||
2150 | /* | 2164 | /* |
2151 | * Disable UCR3_RI and UCR3_DCD irqs. They are also not | 2165 | * Disable UCR3_RI and UCR3_DCD irqs. They are also not |
2152 | * enabled later because they cannot be cleared | 2166 | * enabled later because they cannot be cleared |
2153 | * (confirmed on i.MX25) which makes them unusable. | 2167 | * (confirmed on i.MX25) which makes them unusable. |
2154 | */ | 2168 | */ |
2155 | writel(IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP | UCR3_DSR, | 2169 | imx_uart_writel(sport, |
2156 | sport->port.membase + UCR3); | 2170 | IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP | UCR3_DSR, |
2171 | UCR3); | ||
2157 | 2172 | ||
2158 | } else { | 2173 | } else { |
2159 | unsigned long ucr3 = UCR3_DSR; | 2174 | unsigned long ucr3 = UCR3_DSR; |
2160 | 2175 | ||
2161 | reg = readl(sport->port.membase + UFCR); | 2176 | reg = imx_uart_readl(sport, UFCR); |
2162 | if (reg & UFCR_DCEDTE) | 2177 | if (reg & UFCR_DCEDTE) |
2163 | writel(reg & ~UFCR_DCEDTE, sport->port.membase + UFCR); | 2178 | imx_uart_writel(sport, reg & ~UFCR_DCEDTE, UFCR); |
2164 | 2179 | ||
2165 | if (!is_imx1_uart(sport)) | 2180 | if (!is_imx1_uart(sport)) |
2166 | ucr3 |= IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP; | 2181 | ucr3 |= IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP; |
2167 | writel(ucr3, sport->port.membase + UCR3); | 2182 | imx_uart_writel(sport, ucr3, UCR3); |
2168 | } | 2183 | } |
2169 | 2184 | ||
2170 | clk_disable_unprepare(sport->clk_ipg); | 2185 | clk_disable_unprepare(sport->clk_ipg); |
@@ -2217,32 +2232,32 @@ static void serial_imx_restore_context(struct imx_port *sport) | |||
2217 | if (!sport->context_saved) | 2232 | if (!sport->context_saved) |
2218 | return; | 2233 | return; |
2219 | 2234 | ||
2220 | writel(sport->saved_reg[4], sport->port.membase + UFCR); | 2235 | imx_uart_writel(sport, sport->saved_reg[4], UFCR); |
2221 | writel(sport->saved_reg[5], sport->port.membase + UESC); | 2236 | imx_uart_writel(sport, sport->saved_reg[5], UESC); |
2222 | writel(sport->saved_reg[6], sport->port.membase + UTIM); | 2237 | imx_uart_writel(sport, sport->saved_reg[6], UTIM); |
2223 | writel(sport->saved_reg[7], sport->port.membase + UBIR); | 2238 | imx_uart_writel(sport, sport->saved_reg[7], UBIR); |
2224 | writel(sport->saved_reg[8], sport->port.membase + UBMR); | 2239 | imx_uart_writel(sport, sport->saved_reg[8], UBMR); |
2225 | writel(sport->saved_reg[9], sport->port.membase + IMX21_UTS); | 2240 | imx_uart_writel(sport, sport->saved_reg[9], IMX21_UTS); |
2226 | writel(sport->saved_reg[0], sport->port.membase + UCR1); | 2241 | imx_uart_writel(sport, sport->saved_reg[0], UCR1); |
2227 | writel(sport->saved_reg[1] | UCR2_SRST, sport->port.membase + UCR2); | 2242 | imx_uart_writel(sport, sport->saved_reg[1] | UCR2_SRST, UCR2); |
2228 | writel(sport->saved_reg[2], sport->port.membase + UCR3); | 2243 | imx_uart_writel(sport, sport->saved_reg[2], UCR3); |
2229 | writel(sport->saved_reg[3], sport->port.membase + UCR4); | 2244 | imx_uart_writel(sport, sport->saved_reg[3], UCR4); |
2230 | sport->context_saved = false; | 2245 | sport->context_saved = false; |
2231 | } | 2246 | } |
2232 | 2247 | ||
2233 | static void serial_imx_save_context(struct imx_port *sport) | 2248 | static void serial_imx_save_context(struct imx_port *sport) |
2234 | { | 2249 | { |
2235 | /* Save necessary regs */ | 2250 | /* Save necessary regs */ |
2236 | sport->saved_reg[0] = readl(sport->port.membase + UCR1); | 2251 | sport->saved_reg[0] = imx_uart_readl(sport, UCR1); |
2237 | sport->saved_reg[1] = readl(sport->port.membase + UCR2); | 2252 | sport->saved_reg[1] = imx_uart_readl(sport, UCR2); |
2238 | sport->saved_reg[2] = readl(sport->port.membase + UCR3); | 2253 | sport->saved_reg[2] = imx_uart_readl(sport, UCR3); |
2239 | sport->saved_reg[3] = readl(sport->port.membase + UCR4); | 2254 | sport->saved_reg[3] = imx_uart_readl(sport, UCR4); |
2240 | sport->saved_reg[4] = readl(sport->port.membase + UFCR); | 2255 | sport->saved_reg[4] = imx_uart_readl(sport, UFCR); |
2241 | sport->saved_reg[5] = readl(sport->port.membase + UESC); | 2256 | sport->saved_reg[5] = imx_uart_readl(sport, UESC); |
2242 | sport->saved_reg[6] = readl(sport->port.membase + UTIM); | 2257 | sport->saved_reg[6] = imx_uart_readl(sport, UTIM); |
2243 | sport->saved_reg[7] = readl(sport->port.membase + UBIR); | 2258 | sport->saved_reg[7] = imx_uart_readl(sport, UBIR); |
2244 | sport->saved_reg[8] = readl(sport->port.membase + UBMR); | 2259 | sport->saved_reg[8] = imx_uart_readl(sport, UBMR); |
2245 | sport->saved_reg[9] = readl(sport->port.membase + IMX21_UTS); | 2260 | sport->saved_reg[9] = imx_uart_readl(sport, IMX21_UTS); |
2246 | sport->context_saved = true; | 2261 | sport->context_saved = true; |
2247 | } | 2262 | } |
2248 | 2263 | ||
@@ -2250,22 +2265,22 @@ static void serial_imx_enable_wakeup(struct imx_port *sport, bool on) | |||
2250 | { | 2265 | { |
2251 | unsigned int val; | 2266 | unsigned int val; |
2252 | 2267 | ||
2253 | val = readl(sport->port.membase + UCR3); | 2268 | val = imx_uart_readl(sport, UCR3); |
2254 | if (on) { | 2269 | if (on) { |
2255 | writel(USR1_AWAKE, sport->port.membase + USR1); | 2270 | imx_uart_writel(sport, USR1_AWAKE, USR1); |
2256 | val |= UCR3_AWAKEN; | 2271 | val |= UCR3_AWAKEN; |
2257 | } | 2272 | } |
2258 | else | 2273 | else |
2259 | val &= ~UCR3_AWAKEN; | 2274 | val &= ~UCR3_AWAKEN; |
2260 | writel(val, sport->port.membase + UCR3); | 2275 | imx_uart_writel(sport, val, UCR3); |
2261 | 2276 | ||
2262 | if (sport->have_rtscts) { | 2277 | if (sport->have_rtscts) { |
2263 | val = readl(sport->port.membase + UCR1); | 2278 | val = imx_uart_readl(sport, UCR1); |
2264 | if (on) | 2279 | if (on) |
2265 | val |= UCR1_RTSDEN; | 2280 | val |= UCR1_RTSDEN; |
2266 | else | 2281 | else |
2267 | val &= ~UCR1_RTSDEN; | 2282 | val &= ~UCR1_RTSDEN; |
2268 | writel(val, sport->port.membase + UCR1); | 2283 | imx_uart_writel(sport, val, UCR1); |
2269 | } | 2284 | } |
2270 | } | 2285 | } |
2271 | 2286 | ||